From 8d82546d9d78ab68d51379aca6c23bdb77a8a161 Mon Sep 17 00:00:00 2001 From: Adrer Date: Mon, 16 Sep 2024 16:39:54 +0200 Subject: [PATCH] [FIX] Mobs that were offered up to ghosts no longer get taken over by their old owners (#26650) * Grab_ghost now checks the ckey of the mind * Remove superfluous loops for getting ghosts. * Early return for MMI --------- Co-authored-by: adrermail@gmail.com --- code/datums/components/defibrillator.dm | 4 ++-- code/datums/mind.dm | 2 +- code/game/data_huds.dm | 10 ++-------- code/game/objects/items/robot/robot_parts.dm | 20 ++++++++------------ code/modules/mob/living/carbon/examine.dm | 8 +------- code/modules/mob/mob_misc_procs.dm | 3 ++- code/modules/surgery/organs/brain.dm | 9 +-------- 7 files changed, 17 insertions(+), 39 deletions(-) diff --git a/code/datums/components/defibrillator.dm b/code/datums/components/defibrillator.dm index e1c8011fe17..83884d00097 100644 --- a/code/datums/components/defibrillator.dm +++ b/code/datums/components/defibrillator.dm @@ -183,8 +183,8 @@ ) busy = TRUE - var/mob/dead/observer/ghost = target.get_ghost(TRUE) - if(ghost?.can_reenter_corpse) + var/mob/dead/observer/ghost = target.get_ghost() + if(ghost) to_chat(ghost, "Your heart is being defibrillated. Return to your body if you want to be revived! (Verbs -> Ghost -> Re-enter corpse)") window_flash(ghost.client) SEND_SOUND(ghost, sound('sound/effects/genetics.ogg')) diff --git a/code/datums/mind.dm b/code/datums/mind.dm index 70b9f3d46e6..19de1e5e2f0 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -1760,7 +1760,7 @@ /datum/mind/proc/get_ghost(even_if_they_cant_reenter) for(var/mob/dead/observer/G in GLOB.dead_mob_list) - if(G.mind == src) + if(G.mind == src && G.mind.key == G.key) if(G.can_reenter_corpse || even_if_they_cant_reenter) return G break diff --git a/code/game/data_huds.dm b/code/game/data_huds.dm index 488ee658f16..7081814e916 100644 --- a/code/game/data_huds.dm +++ b/code/game/data_huds.dm @@ -200,14 +200,8 @@ revivable_state = "flatline" else if(!mind) revivable_state = "dead" - else - var/foundghost = FALSE - for(var/mob/dead/observer/G in GLOB.player_list) - if(G.mind.current == src) - foundghost = (G.can_reenter_corpse && G.client) - break - if(foundghost || key) - revivable_state = "hassoul" + else if(get_ghost() || key) + revivable_state = "hassoul" holder.icon_state = "hud[revivable_state]" diff --git a/code/game/objects/items/robot/robot_parts.dm b/code/game/objects/items/robot/robot_parts.dm index 6cb40e0e326..1938d86a1cd 100644 --- a/code/game/objects/items/robot/robot_parts.dm +++ b/code/game/objects/items/robot/robot_parts.dm @@ -234,19 +234,15 @@ return if(!M.brainmob.key) - var/ghost_can_reenter = FALSE - if(M.brainmob.mind) - for(var/mob/dead/observer/G in GLOB.player_list) - if(G.can_reenter_corpse && G.mind == M.brainmob.mind) - ghost_can_reenter = TRUE - if(M.next_possible_ghost_ping < world.time) - G.notify_cloning("Somebody is trying to borg you! Re-enter your corpse if you want to be borged!", 'sound/voice/liveagain.ogg', src) - M.next_possible_ghost_ping = world.time + 30 SECONDS // Avoid spam - break - if(!ghost_can_reenter) - to_chat(user, "[M] is completely unresponsive; there's no point.") + var/mob/dead/observer/G = M.brainmob.get_ghost() + if(G) + if(M.next_possible_ghost_ping < world.time) + G.notify_cloning("Somebody is trying to borg you! Re-enter your corpse if you want to be borged!", 'sound/voice/liveagain.ogg', src) + M.next_possible_ghost_ping = world.time + 30 SECONDS // Avoid spam else - to_chat(user, "[M] is currently inactive. Try again later.") + to_chat(user, "[M] is completely unresponsive; there's no point.") + return + to_chat(user, "[M] is currently inactive. Try again later.") return if(M.brainmob.stat == DEAD) diff --git a/code/modules/mob/living/carbon/examine.dm b/code/modules/mob/living/carbon/examine.dm index d0a880a9022..42511b04c46 100644 --- a/code/modules/mob/living/carbon/examine.dm +++ b/code/modules/mob/living/carbon/examine.dm @@ -221,13 +221,7 @@ if(!just_sleeping) msg += "[p_they(TRUE)] [p_are()] limp and unresponsive; there are no signs of life" if(get_int_organ(/obj/item/organ/internal/brain) && !key) - var/foundghost = FALSE - if(mind) - for(var/mob/dead/observer/G in GLOB.player_list) - if(G.mind == mind && G.can_reenter_corpse) - foundghost = TRUE - break - if(!foundghost) + if(!get_ghost()) msg += " and [p_their()] soul has departed" msg += "...\n" diff --git a/code/modules/mob/mob_misc_procs.dm b/code/modules/mob/mob_misc_procs.dm index b01207220e5..049a727572a 100644 --- a/code/modules/mob/mob_misc_procs.dm +++ b/code/modules/mob/mob_misc_procs.dm @@ -175,7 +175,8 @@ theghost = pick(candidates) to_chat(M, "Your mob has been taken over by a ghost!") message_admins("[key_name_admin(theghost)] has taken control of ([key_name_admin(M)])") - M.ghostize() + var/mob/dead/observer/ghost = M.ghostize(TRUE) // Keep them respawnable + ghost.can_reenter_corpse = FALSE // but keep them out of their old body M.key = theghost.key dust_if_respawnable(theghost) else diff --git a/code/modules/surgery/organs/brain.dm b/code/modules/surgery/organs/brain.dm index 45ccd25faaf..cd29e5c36ae 100644 --- a/code/modules/surgery/organs/brain.dm +++ b/code/modules/surgery/organs/brain.dm @@ -59,14 +59,7 @@ . += "You can feel a bright spark of life in this one!" return if(brainmob?.mind) - var/foundghost = FALSE - for(var/mob/dead/observer/G in GLOB.player_list) - if(G.mind == brainmob.mind) - foundghost = TRUE - if(!G.can_reenter_corpse) - foundghost = FALSE - break - if(foundghost) + if(brainmob.get_ghost()) . += "You can feel the small spark of life still left in this one." return