From fccbe18286c425927db9ef9cf4bab29fabad2a0d Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Sat, 29 Apr 2017 16:50:50 -0500 Subject: [PATCH] Status effects are actually deleted/handled when the mob is deleted --- code/datums/status_effects/status_effect.dm | 8 +++++--- code/modules/mob/living/living.dm | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/code/datums/status_effects/status_effect.dm b/code/datums/status_effects/status_effect.dm index 8b6d255f1a..51b4f8fc5f 100644 --- a/code/datums/status_effects/status_effect.dm +++ b/code/datums/status_effects/status_effect.dm @@ -8,6 +8,7 @@ var/tick_interval = 10 //How many deciseconds between ticks, approximately. Leave at 10 for every second. var/mob/living/owner //The mob affected by the status effect. var/status_type = STATUS_EFFECT_UNIQUE //How many of the effect can be on one mob, and what happens when you try to add another + var/on_remove_on_mob_delete = FALSE //if we call on_remove() when the mob is deleted var/alert_type = /obj/screen/alert/status_effect //the alert thrown by the status effect, contains name and description /datum/status_effect/New(mob/living/new_owner) @@ -21,8 +22,9 @@ STOP_PROCESSING(SSfastprocess, src) if(owner) owner.clear_alert(id) - on_remove() LAZYREMOVE(owner.status_effects, src) + on_remove() + owner = null return ..() /datum/status_effect/proc/start_ticking() @@ -52,8 +54,8 @@ /datum/status_effect/proc/on_apply() //Called whenever the buff is applied. /datum/status_effect/proc/tick() //Called every tick. -/datum/status_effect/proc/on_remove() //Called whenever the buff expires or is removed. -/datum/status_effect/proc/be_replaced() //Called instead of on_remove when a status effect is replaced by itself +/datum/status_effect/proc/on_remove() //Called whenever the buff expires or is removed; do note that at the point this is called, it is out of the owner's status_effects but owner is not yet null +/datum/status_effect/proc/be_replaced() //Called instead of on_remove when a status effect is replaced by itself or when a status effect with on_remove_on_mob_delete = FALSE has its mob deleted owner.clear_alert(id) LAZYREMOVE(owner.status_effects, src) owner = null diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index e3502e7a90..dd28a93c7d 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -29,6 +29,13 @@ med_hud_set_status() /mob/living/Destroy() + if(LAZYLEN(status_effects)) + for(var/s in status_effects) + var/datum/status_effect/S = s + if(S.on_remove_on_mob_delete) //the status effect calls on_remove when its mob is deleted + qdel(S) + else + S.be_replaced() if(ranged_ability) ranged_ability.remove_ranged_ability(src) if(buckled)