From aa9fe479e0aff121d02f9f1fc61f9162dcc75931 Mon Sep 17 00:00:00 2001 From: Luc <89928798+lewcc@users.noreply.github.com> Date: Sun, 16 Jul 2023 09:32:44 -0700 Subject: [PATCH] Adds some missing checks for suicides on revivals, prevents clings from suiciding (#21588) * Add some missing suicide checks on some revives * Adds a check to morgue trays as well * Rework defib messaging slightly --- code/datums/components/defibrillator.dm | 4 ++-- code/game/machinery/computer/aifixer.dm | 3 +++ code/game/objects/structures/morgue.dm | 2 +- code/game/verbs/suicide.dm | 5 +++++ code/modules/mob/living/carbon/brain/brain_update_status.dm | 2 +- code/modules/mob/living/carbon/human/human_update_status.dm | 2 +- code/modules/mob/living/silicon/robot/robot_update_status.dm | 2 +- code/modules/mob/living/stat_states.dm | 3 +++ 8 files changed, 17 insertions(+), 6 deletions(-) diff --git a/code/datums/components/defibrillator.dm b/code/datums/components/defibrillator.dm index eb885c825f1..31dda0d64b8 100644 --- a/code/datums/components/defibrillator.dm +++ b/code/datums/components/defibrillator.dm @@ -252,12 +252,12 @@ user.visible_message("[defib_ref] buzzes: Resuscitation failed - No brain detected within patient.") defib_success = FALSE else if(ghost) - if(!ghost.can_reenter_corpse) // DNR or AntagHUD + if(!ghost.can_reenter_corpse || target.suiciding) // DNR or AntagHUD user.visible_message("[defib_ref] buzzes: Resuscitation failed - No electrical brain activity detected.") else user.visible_message("[defib_ref] buzzes: Resuscitation failed - Patient's brain is unresponsive. Further attempts may succeed.") defib_success = FALSE - else if((signal_result & COMPONENT_BLOCK_DEFIB) || HAS_TRAIT(target, TRAIT_FAKEDEATH) || HAS_TRAIT(target, TRAIT_BADDNA)) // these are a bit more arbitrary + else if((signal_result & COMPONENT_BLOCK_DEFIB) || HAS_TRAIT(target, TRAIT_FAKEDEATH) || HAS_TRAIT(target, TRAIT_BADDNA) || target.suiciding) // these are a bit more arbitrary user.visible_message("[defib_ref] buzzes: Resuscitation failed.") defib_success = FALSE diff --git a/code/game/machinery/computer/aifixer.dm b/code/game/machinery/computer/aifixer.dm index 5da774972bb..92a73e8fed1 100644 --- a/code/game/machinery/computer/aifixer.dm +++ b/code/game/machinery/computer/aifixer.dm @@ -61,6 +61,9 @@ return switch(action) if("fix") + if(occupant.suiciding) + to_chat(usr, "Memory corruption detected in recovery partition, likely due to a sudden self-induced shutdown. AI is unrecoverable.") + return if(active) // Prevent from starting a fix while fixing. to_chat(usr, "You are already fixing this AI!") return diff --git a/code/game/objects/structures/morgue.dm b/code/game/objects/structures/morgue.dm index 0b71005e3e8..45e79ac6bfb 100644 --- a/code/game/objects/structures/morgue.dm +++ b/code/game/objects/structures/morgue.dm @@ -66,7 +66,7 @@ var/mob/dead/observer/G = M.get_ghost() - if(M.mind && !M.mind.suicided) + if(M.mind && !M.mind.suicided && !M.suiciding) if(M.client) status = REVIVABLE return diff --git a/code/game/verbs/suicide.dm b/code/game/verbs/suicide.dm index b005f037013..a587eb098b9 100644 --- a/code/game/verbs/suicide.dm +++ b/code/game/verbs/suicide.dm @@ -21,6 +21,11 @@ var/confirm = null if(!forced) + if(ischangeling(src)) + // the alternative is to allow clings to commit suicide, but then you'd probably have them + // killing themselves as soon as they're in cuffs + to_chat(src, "We refuse to take the coward's way out.") + return confirm = alert("Are you sure you want to commit suicide?", "Confirm Suicide", "Yes", "No") if(stat == DEAD || suiciding) //We check again, because alerts sleep until a choice is made diff --git a/code/modules/mob/living/carbon/brain/brain_update_status.dm b/code/modules/mob/living/carbon/brain/brain_update_status.dm index 6fec51bb07b..ec4edb77fc7 100644 --- a/code/modules/mob/living/carbon/brain/brain_update_status.dm +++ b/code/modules/mob/living/carbon/brain/brain_update_status.dm @@ -3,7 +3,7 @@ return // if(health <= min_health) if(stat == DEAD) - if(container && health > HEALTH_THRESHOLD_DEAD) + if(container && health > HEALTH_THRESHOLD_DEAD && !suiciding) update_revive() create_debug_log("revived, trigger reason: [reason]") return diff --git a/code/modules/mob/living/carbon/human/human_update_status.dm b/code/modules/mob/living/carbon/human/human_update_status.dm index 52452cbc251..26972a8ecf2 100644 --- a/code/modules/mob/living/carbon/human/human_update_status.dm +++ b/code/modules/mob/living/carbon/human/human_update_status.dm @@ -6,7 +6,7 @@ if(dna.species && dna.species.can_revive_by_healing) var/obj/item/organ/internal/brain/B = get_int_organ(/obj/item/organ/internal/brain) if(B) - if((health >= (HEALTH_THRESHOLD_DEAD + HEALTH_THRESHOLD_CRIT) * 0.5) && getBrainLoss() < 120) + if((health >= (HEALTH_THRESHOLD_DEAD + HEALTH_THRESHOLD_CRIT) * 0.5) && getBrainLoss() < 120 && !suiciding) update_revive() create_debug_log("revived from healing, trigger reason: [reason]") diff --git a/code/modules/mob/living/silicon/robot/robot_update_status.dm b/code/modules/mob/living/silicon/robot/robot_update_status.dm index f8038f07ea5..6ada3eb466a 100644 --- a/code/modules/mob/living/silicon/robot/robot_update_status.dm +++ b/code/modules/mob/living/silicon/robot/robot_update_status.dm @@ -23,7 +23,7 @@ WakeUp() create_debug_log("woke up, trigger reason: [reason]") else - if(health > 0) + if(health > 0 && !suiciding) update_revive() var/mob/dead/observer/ghost = get_ghost() if(ghost) diff --git a/code/modules/mob/living/stat_states.dm b/code/modules/mob/living/stat_states.dm index 26d5664a0f2..9b81310fa61 100644 --- a/code/modules/mob/living/stat_states.dm +++ b/code/modules/mob/living/stat_states.dm @@ -57,6 +57,9 @@ set_stat(UNCONSCIOUS) // this is done as `WakeUp` early returns if they are `stat = DEAD` WakeUp() + if(suiciding) + message_admins("[key_name(src)] was revived after having committed suicide. This is likely a bug.") + GLOB.dead_mob_list -= src GLOB.alive_mob_list |= src