From dd8ddd3a5d2aa35d21a5e78804d7d9bf1b163946 Mon Sep 17 00:00:00 2001 From: Aquilar <20759278+Aquilar@users.noreply.github.com> Date: Mon, 23 Mar 2020 17:11:56 +0800 Subject: [PATCH 1/3] fixes smoking and similar incremental dosage systems for addiction. Signed-off-by: Aquilar <20759278+Aquilar@users.noreply.github.com> --- code/modules/reagents/chemistry/holder.dm | 26 +++++++++------------ code/modules/reagents/chemistry/reagents.dm | 17 ++++++++------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 9774021210c..b5663a7a6d5 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -299,21 +299,17 @@ if(R.addiction_stage < 5) if(prob(5)) R.addiction_stage++ - if(M.reagents.has_reagent(R.id)) - R.last_addiction_dose = world.timeofday - R.addiction_stage = 1 - else - switch(R.addiction_stage) - if(1) - update_flags |= R.addiction_act_stage1(M) - if(2) - update_flags |= R.addiction_act_stage2(M) - if(3) - update_flags |= R.addiction_act_stage3(M) - if(4) - update_flags |= R.addiction_act_stage4(M) - if(5) - update_flags |= R.addiction_act_stage5(M) + switch(R.addiction_stage) + if(1) + update_flags |= R.addiction_act_stage1(M) + if(2) + update_flags |= R.addiction_act_stage2(M) + if(3) + update_flags |= R.addiction_act_stage3(M) + if(4) + update_flags |= R.addiction_act_stage4(M) + if(5) + update_flags |= R.addiction_act_stage5(M) if(prob(20) && (world.timeofday > (R.last_addiction_dose + ADDICTION_TIME))) //Each addiction lasts 8 minutes before it can end to_chat(M, "You no longer feel reliant on [R.name]!") addiction_list.Remove(R) diff --git a/code/modules/reagents/chemistry/reagents.dm b/code/modules/reagents/chemistry/reagents.dm index 26dfa2d815f..4271b26ba17 100644 --- a/code/modules/reagents/chemistry/reagents.dm +++ b/code/modules/reagents/chemistry/reagents.dm @@ -54,15 +54,9 @@ if(method == REAGENT_INGEST) //Yes, even Xenos can get addicted to drugs. var/can_become_addicted = M.reagents.reaction_check(M, src) - if(can_become_addicted) if(is_type_in_list(src, M.reagents.addiction_list)) - to_chat(M, "You feel slightly better, but for how long?") - for(var/A in M.reagents.addiction_list) - var/datum/reagent/AD = A - if(AD && istype(AD, src)) - AD.last_addiction_dose = world.timeofday - AD.addiction_stage = 1 + to_chat(M, "You feel slightly better, but for how long?") //sate_addiction handles this now, but kept this for the feed back. return TRUE /datum/reagent/proc/reaction_obj(obj/O, volume) @@ -76,6 +70,7 @@ var/total_depletion_rate = metabolization_rate * M.metabolism_efficiency * M.digestion_ratio // Cache it handle_addiction(M, total_depletion_rate) + sate_addiction(M) holder.remove_reagent(id, total_depletion_rate) //By default it slowly disappears. return STATUS_UPDATE_NONE @@ -91,6 +86,14 @@ new_reagent.last_addiction_dose = world.timeofday M.reagents.addiction_list.Add(new_reagent) +/datum/reagent/proc/sate_addiction(mob/living/M) //reagents sate their own withdrawals + if(is_type_in_list(src, M.reagents.addiction_list)) + for(var/A in M.reagents.addiction_list) + var/datum/reagent/AD = A + if(AD && istype(AD, src)) + AD.last_addiction_dose = world.timeofday + AD.addiction_stage = 1 + /datum/reagent/proc/on_mob_death(mob/living/M) //use this to have chems have a "death-triggered" effect return From ba2decc4664630a6d07dd3d79405890fa459a2fc Mon Sep 17 00:00:00 2001 From: Aquilar <20759278+Aquilar@users.noreply.github.com> Date: Tue, 24 Mar 2020 15:57:11 +0800 Subject: [PATCH 2/3] minor update Signed-off-by: Aquilar <20759278+Aquilar@users.noreply.github.com> --- code/modules/reagents/chemistry/holder.dm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index b5663a7a6d5..efbe2ffa209 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -299,17 +299,18 @@ if(R.addiction_stage < 5) if(prob(5)) R.addiction_stage++ - switch(R.addiction_stage) - if(1) - update_flags |= R.addiction_act_stage1(M) - if(2) - update_flags |= R.addiction_act_stage2(M) - if(3) - update_flags |= R.addiction_act_stage3(M) - if(4) - update_flags |= R.addiction_act_stage4(M) - if(5) - update_flags |= R.addiction_act_stage5(M) + if(!M.reagents.has_reagent(R.id)) + switch(R.addiction_stage) + if(1) + update_flags |= R.addiction_act_stage1(M) + if(2) + update_flags |= R.addiction_act_stage2(M) + if(3) + update_flags |= R.addiction_act_stage3(M) + if(4) + update_flags |= R.addiction_act_stage4(M) + if(5) + update_flags |= R.addiction_act_stage5(M) if(prob(20) && (world.timeofday > (R.last_addiction_dose + ADDICTION_TIME))) //Each addiction lasts 8 minutes before it can end to_chat(M, "You no longer feel reliant on [R.name]!") addiction_list.Remove(R) From 87c2bd02ef9988e2a87fa5c8e73e5c2ef854b7ce Mon Sep 17 00:00:00 2001 From: Aquilar <20759278+Aquilar@users.noreply.github.com> Date: Fri, 24 Apr 2020 00:36:51 +0800 Subject: [PATCH 3/3] adds delay until addiction switch happens. Signed-off-by: Aquilar <20759278+Aquilar@users.noreply.github.com> --- code/modules/reagents/chemistry/holder.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index efbe2ffa209..ddd78b2018f 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -299,7 +299,7 @@ if(R.addiction_stage < 5) if(prob(5)) R.addiction_stage++ - if(!M.reagents.has_reagent(R.id)) + if(world.timeofday > R.last_addiction_dose) //time check so addiction act doesn't play over and over. Allows incremental dosages to work. switch(R.addiction_stage) if(1) update_flags |= R.addiction_act_stage1(M)