From 37c23ef4285ead55f5ae0e2effb597fc3db40fc9 Mon Sep 17 00:00:00 2001
From: Gamer025 <33846895+Gamer025@users.noreply.github.com>
Date: Thu, 7 Jan 2021 20:18:09 +0100
Subject: [PATCH] Fixes and refactors death examine code (#55907)
Examine death bodies should now display the correct text
Changed the logic so that the message tells you if the players is:
- Still in his body (`[t_He] [t_is] limp and unresponsive; there are no signs of life...`) or
- A ghost that could enter the body again (`[t_He] [t_is] limp and unresponsive; there are no signs of life and [t_his] soul has departed, but the link is not yet fully broken...`) or
- No ghost, that can reenter the body and no key (`[t_He] [t_is] limp and unresponsive; there are no signs of life and [t_his] soul has lost the will to live...`)
Also refactored the code a bit:
- Moved the death examine message generation to a proc so that you can work with returns
- Removed pushed_do_not_resuscitate since its not needed this way
---
code/modules/mob/dead/observer/observer.dm | 2 --
code/modules/mob/living/carbon/human/examine.dm | 11 +----------
.../mob/living/carbon/human/human_defines.dm | 1 -
.../mob/living/carbon/human/human_helpers.dm | 15 +++++++++++++++
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm
index 76aa6f75b3c..68d245d8cdb 100644
--- a/code/modules/mob/dead/observer/observer.dm
+++ b/code/modules/mob/dead/observer/observer.dm
@@ -22,7 +22,6 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
light_power = 2
light_on = FALSE
var/can_reenter_corpse
- var/pushed_do_not_resuscitate = FALSE
var/datum/hud/living/carbon/hud = null // hud
var/bootime = 0
var/started_as_observer //This variable is set to 1 when you enter the game as an observer.
@@ -381,7 +380,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
return
can_reenter_corpse = FALSE
- pushed_do_not_resuscitate = TRUE
// Update med huds
var/mob/living/carbon/current = mind.current
current.med_hud_set_status()
diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm
index fdd37ebab23..3b711287771 100644
--- a/code/modules/mob/living/carbon/human/examine.dm
+++ b/code/modules/mob/living/carbon/human/examine.dm
@@ -124,16 +124,7 @@
if(suiciding)
. += "[t_He] appear[p_s()] to have committed suicide... there is no hope of recovery."
- var/mob/dead/observer/ghost = get_ghost(TRUE, TRUE)
- if(getorgan(/obj/item/organ/brain))
- if(!ghost && !client) //There's no ghost with a mind matching the body's (and there's no client still in the body, if they haven't left the body once yet), the ghost has likely disconnected
- . += "[t_He] [t_is] limp and unresponsive; there are no signs of life and [t_his] soul has departed..."
- else if (!ghost.can_reenter_corpse || ghost.pushed_do_not_resuscitate) //There is a ghost with a matching mind but they pushed DNR or otherwise can't reenter
- . += "[t_He] [t_is] limp and unresponsive; there are no signs of life and [t_his] soul has lost the will to live..."
- else
- . += "[t_He] [t_is] limp and unresponsive; there are no signs of life..."
- else
- . += "[t_He] [t_is] limp and unresponsive; there are no signs of life..."
+ . += generate_death_examine_text()
if(get_bodypart(BODY_ZONE_HEAD) && !getorgan(/obj/item/organ/brain))
. += "It appears that [t_his] brain is missing..."
diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm
index 8564877820a..a72e9ce736a 100644
--- a/code/modules/mob/living/carbon/human/human_defines.dm
+++ b/code/modules/mob/living/carbon/human/human_defines.dm
@@ -77,4 +77,3 @@
///Exposure to damaging heat levels increases stacks, stacks clean over time when temperatures are lower. Stack is consumed to add a wound.
var/heat_exposure_stacks = 0
-
diff --git a/code/modules/mob/living/carbon/human/human_helpers.dm b/code/modules/mob/living/carbon/human/human_helpers.dm
index 7048ab37380..7c14e6754a6 100644
--- a/code/modules/mob/living/carbon/human/human_helpers.dm
+++ b/code/modules/mob/living/carbon/human/human_helpers.dm
@@ -220,3 +220,18 @@
/mob/living/carbon/human/get_biological_state()
return dna.species.get_biological_state()
+
+///Returns death message for mob examine text
+/mob/living/carbon/human/proc/generate_death_examine_text()
+ var/mob/dead/observer/ghost = get_ghost(TRUE, TRUE)
+ var/t_He = p_they(TRUE)
+ var/t_his = p_their()
+ var/t_is = p_are()
+ if(key || !getorgan(/obj/item/organ/brain))
+ return "[t_He] [t_is] limp and unresponsive; there are no signs of life..." //Default death message
+ //The death mob has a brain and no client/player that is assigned to the mob
+ if(!ghost?.can_reenter_corpse) //And there is no ghost that could reenter the body
+ //There is no way this mob can in any normal way get a player, so they lost the will to live
+ return "[t_He] [t_is] limp and unresponsive; there are no signs of life and [t_his] soul has lost the will to live..."
+ //This mob has a ghost linked that could still reenter the body, so the soul only departed
+ return "[t_He] [t_is] limp and unresponsive; there are no signs of life and [t_his] soul has departed, but the link is not yet fully broken..."