diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 5ed83d99f36..3c9b1d1ec2d 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -459,6 +459,13 @@ #define COMSIG_LIVING_FIRE_TICK "living_fire_tick" //sent from living mobs when they are ahealed #define COMSIG_LIVING_AHEAL "living_aheal" +//sent from mobs when they exit their body as a ghost +#define COMSIG_LIVING_GHOSTIZED "ghostized" +//sent from mobs when they re-enter their body as a ghost +#define COMSIG_LIVING_REENTERED_BODY "reentered_body" +//sent from a mob when they set themselves to DNR +#define COMSIG_LIVING_SET_DNR "set_dnr" + //ALL OF THESE DO NOT TAKE INTO ACCOUNT WHETHER AMOUNT IS 0 OR LOWER AND ARE SENT REGARDLESS! // none of these are called as of right now, as there is nothing listening for them. diff --git a/code/game/objects/structures/morgue.dm b/code/game/objects/structures/morgue.dm index 612c4014510..2ba9225189a 100644 --- a/code/game/objects/structures/morgue.dm +++ b/code/game/objects/structures/morgue.dm @@ -43,16 +43,33 @@ update_icon(update_state()) set_light(1, LIGHTING_MINIMUM_POWER) -/obj/structure/morgue/proc/update_state() - . = UPDATE_OVERLAYS +/obj/structure/morgue/proc/get_revivable(closing) + var/mob/living/M = locate() in contents + var/obj/structure/closet/body_bag/B = locate() in contents + if(!M) + M = locate() in B + + if(!M) + return + + if(closing) + RegisterSignal(M, COMSIG_LIVING_GHOSTIZED, PROC_REF(update_state)) + RegisterSignal(M, COMSIG_LIVING_REENTERED_BODY, PROC_REF(update_state)) + RegisterSignal(M, COMSIG_LIVING_SET_DNR, PROC_REF(update_state)) + else + UnregisterSignal(M, COMSIG_LIVING_GHOSTIZED) + UnregisterSignal(M, COMSIG_LIVING_REENTERED_BODY) + UnregisterSignal(M, COMSIG_LIVING_SET_DNR) + +/obj/structure/morgue/proc/update_state() if(connected) status = EXTENDED_TRAY - return + return update_icon(UPDATE_OVERLAYS) if(!length(contents)) status = EMPTY_MORGUE - return + return update_icon(UPDATE_OVERLAYS) var/mob/living/M = locate() in contents var/obj/structure/closet/body_bag/B = locate() in contents @@ -62,20 +79,21 @@ if(!M) status = NOT_BODY - return + return update_icon(UPDATE_OVERLAYS) var/mob/dead/observer/G = M.get_ghost() if(M.mind && !M.mind.suicided && !M.suiciding) if(M.client) status = REVIVABLE - return + return update_icon(UPDATE_OVERLAYS) if(G && G.client) //There is a ghost and it is connected to the server status = GHOST_CONNECTED - return + return update_icon(UPDATE_OVERLAYS) status = UNREVIVABLE + update_icon(UPDATE_OVERLAYS) /obj/structure/morgue/update_overlays() . = ..() @@ -120,16 +138,18 @@ /obj/structure/morgue/attack_hand(mob/user as mob) if(connected) for(var/atom/movable/A in connected.loc) - if(!( A.anchored )) + if(!(A.anchored)) A.forceMove(src) + get_revivable(TRUE) playsound(loc, open_sound, 50, 1) QDEL_NULL(connected) else playsound(loc, open_sound, 50, 1) + get_revivable(FALSE) connect() add_fingerprint(user) - update_icon(update_state()) + update_state() return /obj/structure/morgue/attackby(P as obj, mob/user as mob, params) diff --git a/code/modules/mob/dead/observer/observer_base.dm b/code/modules/mob/dead/observer/observer_base.dm index 05bc4dbfec7..ac94e433c6b 100644 --- a/code/modules/mob/dead/observer/observer_base.dm +++ b/code/modules/mob/dead/observer/observer_base.dm @@ -241,13 +241,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp // Respawnable ghostize(1) - // If mob in morgue tray, update tray - var/obj/structure/morgue/Morgue = locate() in M.loc - if(istype(M.loc, /obj/structure/morgue)) - Morgue = M.loc - if(Morgue) - Morgue.update_state() - // If mob in cryopod, despawn mob if(P) if(!P.control_computer) @@ -303,11 +296,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp mind.current.key = key - var/obj/structure/morgue/Morgue = locate() in mind.current.loc - if(istype(mind.current.loc,/obj/structure/morgue)) - Morgue = mind.current.loc - if(Morgue) - Morgue.update_state() + SEND_SIGNAL(mind.current, COMSIG_LIVING_REENTERED_BODY) return 1 @@ -410,6 +399,8 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp can_reenter_corpse = FALSE if(!QDELETED(mind.current)) // Could change while they're choosing mind.current.remove_status_effect(STATUS_EFFECT_REVIVABLE) + SEND_SIGNAL(mind.current, COMSIG_LIVING_SET_DNR) + /mob/dead/observer/proc/dead_tele() set category = "Ghost" diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index f9b4ac442cf..db5b968856c 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -59,6 +59,7 @@ if(.) if(ranged_ability && prev_client) ranged_ability.remove_mousepointer(prev_client) + SEND_SIGNAL(src, COMSIG_LIVING_GHOSTIZED) /mob/living/proc/OpenCraftingMenu() return