diff --git a/code/controllers/subsystems/chemistry.dm b/code/controllers/subsystems/chemistry.dm index 549ac0de9b..82f6f824b3 100644 --- a/code/controllers/subsystems/chemistry.dm +++ b/code/controllers/subsystems/chemistry.dm @@ -35,6 +35,18 @@ SUBSYSTEM_DEF(chemistry) if(!chemical_reactions_by_id[reagent_id]) chemical_reactions_by_id[reagent_id] = list() chemical_reactions_by_id[reagent_id] += D + + // Init addiction probabilities + // The calcualation for the value fed into prob every tick that an addictive chemical is + // metabolized is quite complex, but it is based off values that are constant post-start up. + // We'll initialize those values into a global list here. + for(var/path in subtypesof(/datum/reagent)) + var/datum/reagent/R = new path() + if(!R.addictiveness) + continue + GLOB.addiction_probs_ += R.type + GLOB.addiction_probs_[R.type] = 100 * (1 - (Root(R.addiction_median_dose/R.metabolism, 0.5 ))) + return ..() /datum/controller/subsystem/chemistry/fire(resumed = FALSE) diff --git a/code/modules/reagents/Chemistry-Metabolism.dm b/code/modules/reagents/Chemistry-Metabolism.dm index a9286fca89..7c25bf34e0 100644 --- a/code/modules/reagents/Chemistry-Metabolism.dm +++ b/code/modules/reagents/Chemistry-Metabolism.dm @@ -57,7 +57,7 @@ var/datum/reagent/addict_reagent = (ref_reagent.parent_substance ? new ref_reagent.parent_substance : ref_reagent) if(!is_type_in_list(addict_reagent, addiction_levels)) - var/add_addiction_prob = 100 * (1 - (Root(0.5, ref_reagent.addiction_median_dose/removed))) + var/add_addiction_prob = GLOB.addiction_probs_[ref_reagent.type] if(prob(add_addiction_prob)) addiction_levels.Add(addict_reagent) addiction_levels[addict_reagent] = 10 diff --git a/code/modules/reagents/Chemistry-Reagents.dm b/code/modules/reagents/Chemistry-Reagents.dm index ea56176062..7e1ba3427a 100644 --- a/code/modules/reagents/Chemistry-Reagents.dm +++ b/code/modules/reagents/Chemistry-Reagents.dm @@ -1,3 +1,5 @@ +GLOBAL_LIST_EMPTY(addiction_probs_) + /datum/reagent var/name = "Reagent" var/description = "A non-descript chemical."