diff --git a/code/game/objects/items/weapons/defib.dm b/code/game/objects/items/weapons/defib.dm
index 0cef06f2fa2..1b303b0205a 100644
--- a/code/game/objects/items/weapons/defib.dm
+++ b/code/game/objects/items/weapons/defib.dm
@@ -342,6 +342,13 @@
user.visible_message("[user] places [src] on [M.name]'s chest.", "You place [src] on [M.name]'s chest.")
playsound(get_turf(src), 'sound/machines/defib_charge.ogg', 50, 0)
var/mob/dead/observer/ghost = H.get_ghost()
+ if(ghost && !ghost.client)
+ // In case the ghost's not getting deleted for some reason
+ H.key = ghost.key
+ log_to_dd("Ghost of name [ghost.name] is bound to [H.real_name], but lacks a client. Deleting ghost.")
+
+ qdel(ghost)
+ ghost = null
var/tplus = world.time - H.timeofdeath
var/tlimit = 6000 //past this much time the patient is unrecoverable (in deciseconds)
var/tloss = 3000 //brain damage starts setting in on the patient after some time left rotting
@@ -387,11 +394,12 @@
user.visible_message("[defib] buzzes: Resuscitation failed - Heart tissue damage beyond point of no return for defibrillation.")
else if(total_burn >= 180 || total_brute >= 180)
user.visible_message("[defib] buzzes: Resuscitation failed - Severe tissue damage detected.")
+ else if(ghost)
+ user.visible_message("[defib] buzzes: Resuscitation failed: Patient's brain is unresponsive. Further attempts may succeed.")
+ ghost << "Your heart is being defibrillated. Return to your body if you want to be revived! (Verbs -> Ghost -> Re-enter corpse)"
+ ghost << sound('sound/effects/genetics.ogg')
else
user.visible_message("[defib] buzzes: Resuscitation failed.")
- if(ghost)
- ghost << "Your heart is being defibrillated. Return to your body if you want to be revived! (Verbs -> Ghost -> Re-enter corpse)"
- ghost << sound('sound/effects/genetics.ogg')
playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0)
defib.deductcharge(revivecost)
update_icon()
@@ -461,6 +469,13 @@
user.visible_message("[user] places [src] on [M.name]'s chest.", "You place [src] on [M.name]'s chest.")
playsound(get_turf(src), 'sound/machines/defib_charge.ogg', 50, 0)
var/mob/dead/observer/ghost = H.get_ghost()
+ if(ghost && !ghost.client)
+ // In case the ghost's not getting deleted for some reason
+ H.key = ghost.key
+ log_to_dd("Ghost of name [ghost.name] is bound to [H.real_name], but lacks a client. Deleting ghost.")
+
+ qdel(ghost)
+ ghost = null
var/tplus = world.time - H.timeofdeath
var/tlimit = 6000 //past this much time the patient is unrecoverable (in deciseconds)
var/tloss = 3000 //brain damage starts setting in on the patient after some time left rotting
@@ -484,7 +499,7 @@
H.adjustBruteLoss(tobehealed)
user.visible_message("[user] pings: Resuscitation successful.")
playsound(get_turf(src), 'sound/machines/defib_success.ogg', 50, 0)
- H.stat = 1
+ H.stat = UNCONSCIOUS
H.update_revive()
H.emote("gasp")
if(tplus > tloss)
@@ -498,11 +513,12 @@
user.visible_message("[user] buzzes: Resuscitation failed - Heart tissue damage beyond point of no return for defibrillation.")
else if(total_burn >= 180 || total_brute >= 180)
user.visible_message("[user] buzzes: Resuscitation failed - Severe tissue damage detected.")
+ else if(ghost)
+ user.visible_message("[user] buzzes: Resuscitation failed: Patient's brain is unresponsive. Further attempts may succeed.")
+ ghost << "Your heart is being defibrillated. Return to your body if you want to be revived! (Verbs -> Ghost -> Re-enter corpse)"
+ ghost << sound('sound/effects/genetics.ogg')
else
user.visible_message("[user] buzzes: Resuscitation failed.")
- if(ghost)
- ghost << "Your heart is being defibrillated. Return to your body if you want to be revived! (Verbs -> Ghost -> Re-enter corpse)"
- ghost << sound('sound/effects/genetics.ogg')
playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0)
if(isrobot(user))
var/mob/living/silicon/robot/R = user