[MIRROR] Attempts to fix addictions being utterly broken and almost impossible to obtain. (#2827)

* Attempts to fix addictions being utterly broken and almost impossible to obtain. (#56302)

* Attempts to fix addictions being utterly broken and almost impossible to obtain.

Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
This commit is contained in:
SkyratBot
2021-01-22 05:06:35 +01:00
committed by GitHub
parent d12b8d8a87
commit 7efde01cae
2 changed files with 76 additions and 5 deletions
+4 -5
View File
@@ -565,7 +565,6 @@
*/
/datum/reagents/proc/metabolize(mob/living/carbon/C, can_overdose = FALSE, liverless = FALSE)
var/list/cached_reagents = reagent_list
var/list/cached_addictions = addiction_list
if(C)
expose_temperature(C.bodytemperature, 0.25)
var/need_mob_update = 0
@@ -613,18 +612,18 @@
R.overdosed = TRUE
need_mob_update += R.overdose_start(C)
log_game("[key_name(C)] has started overdosing on [R.name] at [R.volume] units.")
var/is_addicted_to = cached_addictions && is_type_in_list(R, cached_addictions)
var/is_addicted_to = addiction_list && is_type_in_list(R, addiction_list)
if(R.addiction_threshold)
if(R.volume >= R.addiction_threshold && !is_addicted_to)
var/datum/reagent/new_reagent = new R.addiction_type()
LAZYADD(cached_addictions, new_reagent)
LAZYADD(addiction_list, new_reagent)
is_addicted_to = TRUE
log_game("[key_name(C)] has become addicted to [R.name] at [R.volume] units.")
if(R.overdosed)
need_mob_update += R.overdose_process(C)
var/datum/reagent/addiction_type = new R.addiction_type()
if(is_addicted_to)
for(var/addiction in cached_addictions)
for(var/addiction in addiction_list)
var/datum/reagent/A = addiction
if(istype(addiction_type, A))
A.addiction_stage = -15 // you're satisfied for a good while.
@@ -633,7 +632,7 @@
if(can_overdose)
if(addiction_tick == 6)
addiction_tick = 1
for(var/addiction in cached_addictions)
for(var/addiction in addiction_list)
var/datum/reagent/R = addiction
if(!C)
break
+72
View File
@@ -17,6 +17,8 @@
return ..()
/datum/unit_test/on_mob_end_metabolize/Run()
SSmobs.pause()
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
var/obj/item/reagent_containers/pill/pill = allocate(/obj/item/reagent_containers/pill)
var/datum/reagent/drug/methamphetamine/meth = /datum/reagent/drug/methamphetamine
@@ -34,3 +36,73 @@
TEST_ASSERT(!user.reagents.has_reagent(meth), "User still has meth in their system when it should've finished metabolizing")
TEST_ASSERT(!user.has_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine), "User still has movespeed modifier despite not containing any more meth")
/datum/unit_test/on_mob_end_metabolize/Destroy()
SSmobs.ignite()
return ..()
/datum/unit_test/addictions/Run()
SSmobs.pause()
var/mob/living/carbon/human/pill_user = allocate(/mob/living/carbon/human)
var/mob/living/carbon/human/syringe_user = allocate(/mob/living/carbon/human)
var/mob/living/carbon/human/pill_syringe_user = allocate(/mob/living/carbon/human)
var/obj/item/reagent_containers/pill/pill = allocate(/obj/item/reagent_containers/pill)
var/obj/item/reagent_containers/pill/pill_two = allocate(/obj/item/reagent_containers/pill)
var/obj/item/reagent_containers/syringe/syringe = allocate(/obj/item/reagent_containers/syringe)
var/datum/reagent/drug/methamphetamine/meth = allocate(/datum/reagent/drug/methamphetamine)
// Let's start with stomach metabolism
pill.reagents.add_reagent(meth.type, meth.addiction_threshold)
pill.attack(pill_user, pill_user)
// Set the metabolism efficiency to 1.0 so it transfers all reagents to the body in one go.
var/obj/item/organ/stomach/pill_belly = pill_user.getorganslot(ORGAN_SLOT_STOMACH)
pill_belly.metabolism_efficiency = 1
pill_user.Life()
TEST_ASSERT(pill_user.reagents.addiction_list && is_type_in_list(meth, pill_user.reagents.addiction_list), "User is not addicted to meth after ingesting the addiction threshold")
// Then injected metabolism
syringe.volume = meth.addiction_threshold
syringe.amount_per_transfer_from_this = meth.addiction_threshold
syringe.reagents.add_reagent(meth.type, meth.addiction_threshold)
syringe.mode = SYRINGE_INJECT
syringe_user.a_intent = INTENT_HARM
syringe.afterattack(syringe_user, syringe_user, TRUE)
syringe_user.Life()
TEST_ASSERT(syringe_user.reagents.addiction_list && is_type_in_list(meth, syringe_user.reagents.addiction_list), "User is not addicted to meth after injecting the addiction threshold")
// One half syringe
syringe.reagents.remove_all()
syringe.volume = meth.addiction_threshold
syringe.amount_per_transfer_from_this = meth.addiction_threshold
syringe.reagents.add_reagent(meth.type, (meth.addiction_threshold * 0.5) + 1)
// One half pill
pill_two.reagents.add_reagent(meth.type, (meth.addiction_threshold * 0.5) + 1)
pill_two.attack(pill_syringe_user, pill_syringe_user)
pill_syringe_user.a_intent = INTENT_HARM
syringe.mode = SYRINGE_INJECT
syringe.afterattack(pill_syringe_user, pill_syringe_user, TRUE)
// Set the metabolism efficiency to 1.0 so it transfers all reagents to the body in one go.
pill_belly = pill_syringe_user.getorganslot(ORGAN_SLOT_STOMACH)
pill_belly.metabolism_efficiency = 1
pill_syringe_user.Life()
TEST_ASSERT(pill_syringe_user.reagents.addiction_list && is_type_in_list(meth, pill_syringe_user.reagents.addiction_list), "User is not addicted to meth after injecting and ingesting half the addiction threshold each")
/datum/unit_test/addictions/Destroy()
SSmobs.ignite()
return ..()