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
This commit is contained in:
Gamer025
2021-01-07 16:18:09 -03:00
committed by GitHub
parent 704a7465be
commit 37c23ef428
4 changed files with 16 additions and 13 deletions
@@ -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()
@@ -124,16 +124,7 @@
if(suiciding)
. += "<span class='warning'>[t_He] appear[p_s()] to have committed suicide... there is no hope of recovery.</span>"
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
. += "<span class='deadsay'>[t_He] [t_is] limp and unresponsive; there are no signs of life and [t_his] soul has departed...</span>"
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
. += "<span class='deadsay'>[t_He] [t_is] limp and unresponsive; there are no signs of life and [t_his] soul has lost the will to live...</span>"
else
. += "<span class='deadsay'>[t_He] [t_is] limp and unresponsive; there are no signs of life...</span>"
else
. += "<span class='deadsay'>[t_He] [t_is] limp and unresponsive; there are no signs of life...</span>"
. += generate_death_examine_text()
if(get_bodypart(BODY_ZONE_HEAD) && !getorgan(/obj/item/organ/brain))
. += "<span class='deadsay'>It appears that [t_his] brain is missing...</span>"
@@ -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
@@ -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 "<span class='deadsay'>[t_He] [t_is] limp and unresponsive; there are no signs of life...</span>" //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 "<span class='deadsay'>[t_He] [t_is] limp and unresponsive; there are no signs of life and [t_his] soul has lost the will to live...</span>"
//This mob has a ghost linked that could still reenter the body, so the soul only departed
return "<span class='deadsay'>[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...</span>"