From 48324f59c650afc2a73dfe3cb7bf85b3a47d5614 Mon Sep 17 00:00:00 2001 From: NightRed Date: Tue, 29 Sep 2020 21:26:29 -0500 Subject: [PATCH] Fixes up addictions reporting on scanners, and admin full heal (#54056) --- code/game/machinery/medical_kiosk.dm | 5 +-- code/game/objects/items/devices/scanners.dm | 8 +++-- code/modules/antagonists/gang/gang.dm | 3 +- code/modules/mob/living/carbon/carbon.dm | 7 +--- code/modules/mob/living/life.dm | 40 +++++++++++++++++++++ 5 files changed, 51 insertions(+), 12 deletions(-) diff --git a/code/game/machinery/medical_kiosk.dm b/code/game/machinery/medical_kiosk.dm index 013b031b68b..1cc623a1cc8 100644 --- a/code/game/machinery/medical_kiosk.dm +++ b/code/game/machinery/medical_kiosk.dm @@ -243,8 +243,9 @@ chemical_list += list(list("name" = bit.name, "volume" = round(bit.volume, 0.01))) if(bit.overdosed) overdose_list += list(list("name" = bit.name)) - if(altPatient.reagents.addiction_list.len) - for(var/datum/reagent/R in altPatient.reagents.addiction_list) + var/list/addictions = altPatient.get_addiction_list() + if(addictions.len) + for(var/datum/reagent/R in addictions) addict_list += list(list("name" = R.name)) if (altPatient.hallucinating()) hallucination_status = "Subject appears to be hallucinating. Suggested treatments: bedrest, mannitol or psicodine." diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm index 5d34eb41ffd..e8ac7ad45b9 100644 --- a/code/game/objects/items/devices/scanners.dm +++ b/code/game/objects/items/devices/scanners.dm @@ -429,10 +429,12 @@ GENE SCANNER render_list += "[round(bit.volume, 0.001)] units of [bit.name][bit.overdosed ? " - OVERDOSING" : "."]\n" else render_list += "Subject contains no reagents in their stomach.\n" - if(M.reagents.addiction_list.len) + + var/list/addictions = M.get_addiction_list() + if(addictions.len) render_list += "Subject is addicted to the following reagents:\n" - for(var/datum/reagent/R in M.reagents.addiction_list) - render_list += "[R.name]\n" + for(var/datum/reagent/reagent in addictions) + render_list += "[reagent.name]\n" else render_list += "Subject is not addicted to any reagents.\n" diff --git a/code/modules/antagonists/gang/gang.dm b/code/modules/antagonists/gang/gang.dm index 2c734270bd5..c60a5a0ffac 100644 --- a/code/modules/antagonists/gang/gang.dm +++ b/code/modules/antagonists/gang/gang.dm @@ -423,7 +423,8 @@ if(ishuman(M)) var/mob/living/carbon/human/H = M people_on_station++ - for(var/R in H.reagents.addiction_list) + var/list/addictions = H.get_addiction_list() + for(var/R in addictions) if(istype(R, /datum/reagent/drug/methamphetamine)) people_on_crack++ if(0.25*people_on_station > people_on_crack) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 89419e88441..d239ee6459b 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -859,10 +859,6 @@ update_mobility() /mob/living/carbon/fully_heal(admin_revive = FALSE) - if(reagents) - reagents.clear_reagents() - for(var/addi in reagents.addiction_list) - reagents.remove_addiction(addi) for(var/O in internal_organs) var/obj/item/organ/organ = O organ.setOrganDamage(0) @@ -881,8 +877,7 @@ for(var/obj/item/restraints/R in contents) //actually remove cuffs from inventory qdel(R) update_handcuffed() - if(reagents) - reagents.addiction_list = list() + clear_addictions() cure_all_traumas(TRAUMA_RESILIENCE_MAGIC) ..() diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index 7b8db83a969..79e6b0067d2 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -168,6 +168,46 @@ /mob/living/proc/get_reagent_amount(reagent) return reagents.get_reagent_amount(reagent) +/** + * Get a list of all chems the mob has that they are addicted to. + * + * This creates a ist of all chems the mob has within its body that it is addicted to. + * Returns list of reagents + */ +/mob/living/proc/get_addiction_list() + var/list/addictions = list() + var/obj/item/organ/stomach/belly = getorganslot(ORGAN_SLOT_STOMACH) + if(reagents.addiction_list.len) + for(var/datum/reagent/reagent in reagents.addiction_list) + addictions += reagent + if(belly?.reagents.addiction_list.len) + for(var/bile in belly.reagents.addiction_list) + addictions += bile + return addictions + +/** + * Removes an addiction from the mob + * + * This will remove addiction to the passeed in chem from the mob + * vars: + * * addiction (reagent) the reagent to remove + */ +/mob/living/proc/remove_addiction(addiction) + reagents.remove_addiction(addiction) + var/obj/item/organ/stomach/belly = getorganslot(ORGAN_SLOT_STOMACH) + if(belly) + belly.reagents.remove_addiction(addiction) + +/** + * Removes all addictions from the mob + * + * This will remove all addictions from the mob + */ +/mob/living/proc/clear_addictions() + var/list/addictions = get_addiction_list() + for(var/reagent in addictions) + remove_addiction(reagent) + //this updates all special effects: knockdown, druggy, stuttering, etc.. /mob/living/proc/handle_status_effects()