diff --git a/code/modules/surgery/organs/organ_internal.dm b/code/modules/surgery/organs/organ_internal.dm index 895309b0523..842b43808c1 100644 --- a/code/modules/surgery/organs/organ_internal.dm +++ b/code/modules/surgery/organs/organ_internal.dm @@ -60,6 +60,16 @@ //Special is for instant replacement like autosurgeons /obj/item/organ/proc/Remove(mob/living/carbon/M, special = FALSE) + //Stop any reagent metabolizing on organ destruction + if(reagents && iscarbon(owner)) + var/mob/living/carbon/body = owner + for(var/chem in reagents.reagent_list) + var/datum/reagent/reagent = chem + if(reagent.metabolizing) + reagent.metabolizing = FALSE + reagent.on_mob_end_metabolize(body) + reagent.on_mob_delete(body) //It was removed from the body + owner = null if(M) M.internal_organs -= src diff --git a/code/modules/unit_tests/stomach.dm b/code/modules/unit_tests/stomach.dm index e7f5458da7f..677629c0daa 100644 --- a/code/modules/unit_tests/stomach.dm +++ b/code/modules/unit_tests/stomach.dm @@ -2,6 +2,8 @@ var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human) var/obj/item/reagent_containers/food/snacks/hotdog/fooditem = allocate(/obj/item/reagent_containers/food/snacks/hotdog) var/obj/item/organ/stomach/belly = human.getorganslot(ORGAN_SLOT_STOMACH) + var/obj/item/reagent_containers/pill/pill = allocate(/obj/item/reagent_containers/pill) + var/datum/reagent/drug/methamphetamine/meth = /datum/reagent/drug/methamphetamine TEST_ASSERT_EQUAL(human.has_reagent(/datum/reagent/consumable/ketchup), FALSE, "Human somehow has ketchup before eating") @@ -10,9 +12,19 @@ TEST_ASSERT(human.has_reagent(/datum/reagent/consumable/ketchup), "Human doesn't have ketchup after eating") TEST_ASSERT(belly.reagents.has_reagent(/datum/reagent/consumable/ketchup), "Stomach doesn't have ketchup after eating") - qdel(belly) + //Give them meth and let it kick in + pill.reagents.add_reagent(meth, initial(meth.metabolization_rate) * 1.9) + pill.attack(human, human) + human.Life() + + TEST_ASSERT(belly.reagents.has_reagent(/datum/reagent/consumable/ketchup), "Stomach doesn't have ketchup after eating") + TEST_ASSERT(human.has_reagent(meth), "Human does not have meth in their system after consuming it") + TEST_ASSERT(human.has_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine), "Human consumed meth, but did not gain movespeed modifier") + + belly.Remove(human) TEST_ASSERT_EQUAL(human.has_reagent(/datum/reagent/consumable/ketchup), FALSE, "Human still has ketchup after removal of stomach") + TEST_ASSERT(!human.has_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine), "Human still has movespeed modifier despite not containing any more meth") fooditem.attack(human, human)