From 0e85aa3220f69669490f38bb63bce99bbff0b943 Mon Sep 17 00:00:00 2001 From: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Date: Mon, 10 Jul 2023 03:37:25 -0500 Subject: [PATCH] Lets you enter fakedeath when dead (#76666) ## About The Pull Request Fixes #76665 `fakedeath` early returned if the mob was dead, I guess it assumed if you were dead dead you wouldn't want to become fake dead as well I removed that because it's definitely a valid use case, in my eyes, that you would be able to apply the fakedeath traits to a mob who is dead, for the event they are revived at some point (to still appear dead) ## Why It's Good For The Game Lings rely on this ## Changelog :cl: Melbert fix: Fix ling revival for full-dead lings /:cl: --- code/datums/diseases/advance/symptoms/heal.dm | 3 +- .../changeling/powers/defib_grasp.dm | 1 - .../changeling/powers/fakedeath.dm | 38 +++++++++++++------ code/modules/mob/living/status_procs.dm | 10 ++--- .../chemistry/reagents/toxin_reagents.dm | 5 ++- 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/code/datums/diseases/advance/symptoms/heal.dm b/code/datums/diseases/advance/symptoms/heal.dm index 890494eae4b..916154d5139 100644 --- a/code/datums/diseases/advance/symptoms/heal.dm +++ b/code/datums/diseases/advance/symptoms/heal.dm @@ -384,10 +384,11 @@ /datum/symptom/heal/coma/proc/coma(mob/living/M) + if(QDELETED(M) || M.stat == DEAD) + return M.fakedeath("regenerative_coma", !deathgasp) addtimer(CALLBACK(src, PROC_REF(uncoma), M), 300) - /datum/symptom/heal/coma/proc/uncoma(mob/living/M) if(QDELETED(M) || !active_coma) return diff --git a/code/modules/antagonists/changeling/powers/defib_grasp.dm b/code/modules/antagonists/changeling/powers/defib_grasp.dm index c99774df536..20ff3049c8f 100644 --- a/code/modules/antagonists/changeling/powers/defib_grasp.dm +++ b/code/modules/antagonists/changeling/powers/defib_grasp.dm @@ -33,7 +33,6 @@ else changeling.fully_heal(heal_flags) - changeling.cure_fakedeath(CHANGELING_TRAIT) // rips us out of revival stasis (if we're in it) changeling.buckled?.unbuckle_mob(changeling) // get us off of stasis beds please changeling.set_resting(FALSE) changeling.adjust_jitter(20 SECONDS) diff --git a/code/modules/antagonists/changeling/powers/fakedeath.dm b/code/modules/antagonists/changeling/powers/fakedeath.dm index c6fa466cdb1..a4b6b54de3d 100644 --- a/code/modules/antagonists/changeling/powers/fakedeath.dm +++ b/code/modules/antagonists/changeling/powers/fakedeath.dm @@ -9,7 +9,7 @@ ignores_fakedeath = TRUE /// How long it takes for revival to ready upon entering stasis. - /// The changelin can opt to stay in fakedeath for longer, though. + /// The changeling can opt to stay in fakedeath for longer, though. var/fakedeath_duration = 40 SECONDS /// If TRUE, we're ready to revive and can click the button to heal. var/revive_ready = FALSE @@ -21,9 +21,11 @@ INVOKE_ASYNC(src, PROC_REF(revive), user) disable_revive(user) // this should be already called via signal, but just incase something wacky happens + else if(enable_fakedeath(user)) + to_chat(user, span_changeling("We begin our stasis, preparing energy to arise once more.")) + else - to_chat(user, span_notice("We begin our stasis, preparing energy to arise once more.")) - enable_fakedeath(user) + stack_trace("Changeling revive failed to enter fakedeath when it should have been in a valid state to.") return TRUE @@ -34,17 +36,21 @@ changeling.fakedeath(CHANGELING_TRAIT) addtimer(CALLBACK(src, PROC_REF(ready_to_regenerate), changeling), fakedeath_duration, TIMER_UNIQUE) + // Basically, these let the ling exit stasis without giving away their ling-y-ness if revived through other means RegisterSignal(changeling, SIGNAL_REMOVETRAIT(TRAIT_DEATHCOMA), PROC_REF(fakedeath_reset)) + RegisterSignal(changeling, COMSIG_MOB_STATCHANGE, PROC_REF(on_stat_change)) + return TRUE /// Sets [revive_ready] to FALSE and updates the button icons. +/// Can be called mid-revival if the process is being cancelled /datum/action/changeling/fakedeath/proc/disable_revive(mob/living/changeling) - if(!revive_ready) - return + if(revive_ready) + chemical_cost = 15 + revive_ready = FALSE + build_all_button_icons(UPDATE_BUTTON_NAME|UPDATE_BUTTON_ICON) - chemical_cost = 15 - revive_ready = FALSE - build_all_button_icons(UPDATE_BUTTON_NAME|UPDATE_BUTTON_ICON) UnregisterSignal(changeling, SIGNAL_REMOVETRAIT(TRAIT_DEATHCOMA)) + UnregisterSignal(changeling, COMSIG_MOB_STATCHANGE) /// Sets [revive_ready] to TRUE and updates the button icons. /datum/action/changeling/fakedeath/proc/enable_revive(mob/living/changeling) @@ -56,7 +62,7 @@ build_all_button_icons(UPDATE_BUTTON_NAME|UPDATE_BUTTON_ICON) /// Signal proc to stop the revival process if the changeling exits their stasis early. -/datum/action/changeling/fakedeath/proc/fakedeath_reset(datum/source) +/datum/action/changeling/fakedeath/proc/fakedeath_reset(mob/living/source) SIGNAL_HANDLER if(HAS_TRAIT_FROM(source, TRAIT_DEATHCOMA, CHANGELING_TRAIT)) @@ -64,6 +70,16 @@ disable_revive(source) +/// Signal proc to exit fakedeath early if we're revived from being previously dead +/datum/action/changeling/fakedeath/proc/on_stat_change(mob/living/source, new_stat, old_stat) + SIGNAL_HANDLER + + if(old_stat != DEAD) + return + + source.cure_fakedeath(CHANGELING_TRAIT) + to_chat(source, span_changeling("We exit our stasis early.")) + /datum/action/changeling/fakedeath/proc/revive(mob/living/carbon/user) if(!istype(user)) return @@ -75,7 +91,7 @@ var/flags_to_heal = (HEAL_DAMAGE|HEAL_BODY|HEAL_STATUS|HEAL_CC_STATUS) // but leave out limbs so we can do it specially user.revive(flags_to_heal & ~HEAL_LIMBS) - to_chat(user, span_notice("We have revived ourselves.")) + to_chat(user, span_changeling("We have revived ourselves.")) var/static/list/dont_regenerate = list(BODY_ZONE_HEAD) // headless changelings are funny if(!length(user.get_missing_limbs() - dont_regenerate)) @@ -101,7 +117,7 @@ if(!HAS_TRAIT_FROM(user, TRAIT_DEATHCOMA, CHANGELING_TRAIT)) return - to_chat(user, span_notice("We are ready to revive.")) + to_chat(user, span_changeling("We are ready to revive.")) enable_revive(user) /datum/action/changeling/fakedeath/can_sting(mob/living/user) diff --git a/code/modules/mob/living/status_procs.dm b/code/modules/mob/living/status_procs.dm index 16f0d3d2daa..ee77b5ab634 100644 --- a/code/modules/mob/living/status_procs.dm +++ b/code/modules/mob/living/status_procs.dm @@ -517,12 +517,12 @@ /// Induces fake death on a living mob. /mob/living/proc/fakedeath(source, silent = FALSE) - if(stat == DEAD) - return - if(!silent) - emote("deathgasp") + if(stat != DEAD) + if(!silent) + emote("deathgasp") + tod = station_time_timestamp() + add_traits(list(TRAIT_FAKEDEATH, TRAIT_DEATHCOMA), source) - tod = station_time_timestamp() ///Unignores all slowdowns that lack the IGNORE_NOSLOW flag. /mob/living/proc/unignore_slowdown(source) diff --git a/code/modules/reagents/chemistry/reagents/toxin_reagents.dm b/code/modules/reagents/chemistry/reagents/toxin_reagents.dm index 76e97b5e0b0..f7fc8dcf83a 100644 --- a/code/modules/reagents/chemistry/reagents/toxin_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/toxin_reagents.dm @@ -247,7 +247,7 @@ /datum/reagent/toxin/zombiepowder/on_mob_metabolize(mob/living/holder_mob) . = ..() holder_mob.adjustOxyLoss(0.5*REM, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) - if(data?["method"] & INGEST) + if((data?["method"] & INGEST) && holder_mob.stat != DEAD) holder_mob.fakedeath(type) /datum/reagent/toxin/zombiepowder/on_mob_end_metabolize(mob/living/holder_mob) @@ -274,7 +274,8 @@ if(5 to 8) affected_mob.adjustStaminaLoss(40 * REM * seconds_per_tick, 0) if(9 to INFINITY) - affected_mob.fakedeath(type) + if(affected_mob.stat != DEAD) + affected_mob.fakedeath(type) ..() return TRUE