From c730817c31a550a417a253d42726dc52690ada41 Mon Sep 17 00:00:00 2001 From: FlattestGuitar Date: Sat, 27 May 2017 00:38:35 +0200 Subject: [PATCH] 26th century defibs --- code/game/objects/items/weapons/defib.dm | 327 +++++++++++------------ 1 file changed, 160 insertions(+), 167 deletions(-) diff --git a/code/game/objects/items/weapons/defib.dm b/code/game/objects/items/weapons/defib.dm index 5d0dcebcacc..91faedec79e 100644 --- a/code/game/objects/items/weapons/defib.dm +++ b/code/game/objects/items/weapons/defib.dm @@ -339,105 +339,102 @@ update_icon() defib.cooldowncheck(user) return - if(user.zone_sel && user.zone_sel.selecting == "chest") - user.visible_message("[user] begins to place [src] on [M.name]'s chest.", "You begin to place [src] on [M.name]'s chest.") - busy = 1 - update_icon() - if(do_after(user, 30 * toolspeed, target = M)) //beginning to place the paddles on patient's chest to allow some time for people to move away to stop the process - 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_runtime(EXCEPTION("Ghost of name [ghost.name] is bound to [H.real_name], but lacks a client. Deleting ghost."), src) + user.visible_message("[user] begins to place [src] on [M.name]'s chest.", "You begin to place [src] on [M.name]'s chest.") + busy = 1 + update_icon() + if(do_after(user, 30 * toolspeed, target = M)) //beginning to place the paddles on patient's chest to allow some time for people to move away to stop the process + 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_runtime(EXCEPTION("Ghost of name [ghost.name] is bound to [H.real_name], but lacks a client. Deleting ghost."), src) - qdel(ghost) - ghost = null - var/tplus = world.time - H.timeofdeath - var/tlimit = 1800 //past this much time the patient is unrecoverable (in deciseconds) - var/tloss = 600 //brain damage starts setting in on the patient after some time left rotting - var/total_burn = 0 - var/total_brute = 0 - if(do_after(user, 20 * toolspeed, target = M)) //placed on chest and short delay to shock for dramatic effect, revive time is 5sec total - for(var/obj/item/carried_item in H.contents) - if(istype(carried_item, /obj/item/clothing/suit/space)) - if(!defib.combat) - user.visible_message("[defib] buzzes: Patient's chest is obscured. Operation aborted.") - playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0) - busy = 0 - update_icon() - return - if(H.heart_attack) - if(!H.get_int_organ(/obj/item/organ/internal/heart) && !H.get_int_organ(/obj/item/organ/internal/brain/slime)) //prevents defibing someone still alive suffering from a heart attack attack if they lack a heart - user.visible_message("[defib] buzzes: Resuscitation failed - Failed to pick up any heart electrical activity.") + qdel(ghost) + ghost = null + var/tplus = world.time - H.timeofdeath + var/tlimit = 1800 //past this much time the patient is unrecoverable (in deciseconds) + var/tloss = 600 //brain damage starts setting in on the patient after some time left rotting + var/total_burn = 0 + var/total_brute = 0 + if(do_after(user, 20 * toolspeed, target = M)) //placed on chest and short delay to shock for dramatic effect, revive time is 5sec total + for(var/obj/item/carried_item in H.contents) + if(istype(carried_item, /obj/item/clothing/suit/space)) + if(!defib.combat) + user.visible_message("[defib] buzzes: Patient's chest is obscured. Operation aborted.") playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0) busy = 0 update_icon() return - else - H.heart_attack = 0 - user.visible_message("[defib] pings: Cardiac arrhythmia corrected.") - M.visible_message("[M]'s body convulses a bit.") - playsound(get_turf(src), 'sound/machines/defib_zap.ogg', 50, 1, -1) - playsound(get_turf(src), "bodyfall", 50, 1) - playsound(get_turf(src), 'sound/machines/defib_success.ogg', 50, 0) - defib.deductcharge(revivecost) - busy = 0 - cooldown = 1 - update_icon() - defib.cooldowncheck(user) - return - if(H.stat == DEAD) - var/health = H.health - M.visible_message("[M]'s body convulses a bit.") - playsound(get_turf(src), "bodyfall", 50, 1) - playsound(get_turf(src), 'sound/machines/defib_zap.ogg', 50, 1, -1) - for(var/obj/item/organ/external/O in H.bodyparts) - total_brute += O.brute_dam - total_burn += O.burn_dam - if(total_burn <= 180 && total_brute <= 180 && !H.suiciding && !ghost && tplus < tlimit && !(NOCLONE in H.mutations) && (H.get_int_organ(/obj/item/organ/internal/heart) || H.get_int_organ(/obj/item/organ/internal/brain/slime))) - tobehealed = min(health + threshold, 0) // It's HILARIOUS without this min statement, let me tell you - tobehealed -= 5 //They get 5 of each type of damage healed so excessive combined damage will not immediately kill them after they get revived - H.adjustOxyLoss(tobehealed) - H.adjustToxLoss(tobehealed) - H.adjustFireLoss(tobehealed) - H.adjustBruteLoss(tobehealed) - user.visible_message("[defib] pings: Resuscitation successful.") - playsound(get_turf(src), 'sound/machines/defib_success.ogg', 50, 0) - H.update_revive(FALSE) - H.KnockOut(FALSE) - H.Paralyse(5) - H.emote("gasp") - if(tplus > tloss) - H.setBrainLoss( max(0, min(99, ((tlimit - tplus) / tlimit * 100)))) - defib.deductcharge(revivecost) - add_logs(user, M, "revived", object="defibrillator") - else - if(tplus > tlimit|| !H.get_int_organ(/obj/item/organ/internal/heart)) - 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.") - 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) - ghost << sound('sound/effects/genetics.ogg') - else - user.visible_message("[defib] buzzes: Resuscitation failed.") - playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0) - defib.deductcharge(revivecost) - update_icon() - cooldown = 1 - defib.cooldowncheck(user) - else - user.visible_message("[defib] buzzes: Patient is not in a valid state. Operation aborted.") + if(H.heart_attack) + if(!H.get_int_organ(/obj/item/organ/internal/heart) && !H.get_int_organ(/obj/item/organ/internal/brain/slime)) //prevents defibing someone still alive suffering from a heart attack attack if they lack a heart + user.visible_message("[defib] buzzes: Resuscitation failed - Failed to pick up any heart electrical activity.") playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0) - busy = 0 - update_icon() - else - to_chat(user, "You need to target your patient's chest with [src].") - return + busy = 0 + update_icon() + return + else + H.heart_attack = 0 + user.visible_message("[defib] pings: Cardiac arrhythmia corrected.") + M.visible_message("[M]'s body convulses a bit.") + playsound(get_turf(src), 'sound/machines/defib_zap.ogg', 50, 1, -1) + playsound(get_turf(src), "bodyfall", 50, 1) + playsound(get_turf(src), 'sound/machines/defib_success.ogg', 50, 0) + defib.deductcharge(revivecost) + busy = 0 + cooldown = 1 + update_icon() + defib.cooldowncheck(user) + return + if(H.stat == DEAD) + var/health = H.health + M.visible_message("[M]'s body convulses a bit.") + playsound(get_turf(src), "bodyfall", 50, 1) + playsound(get_turf(src), 'sound/machines/defib_zap.ogg', 50, 1, -1) + for(var/obj/item/organ/external/O in H.bodyparts) + total_brute += O.brute_dam + total_burn += O.burn_dam + if(total_burn <= 180 && total_brute <= 180 && !H.suiciding && !ghost && tplus < tlimit && !(NOCLONE in H.mutations) && (H.get_int_organ(/obj/item/organ/internal/heart) || H.get_int_organ(/obj/item/organ/internal/brain/slime))) + tobehealed = min(health + threshold, 0) // It's HILARIOUS without this min statement, let me tell you + tobehealed -= 5 //They get 5 of each type of damage healed so excessive combined damage will not immediately kill them after they get revived + H.adjustOxyLoss(tobehealed) + H.adjustToxLoss(tobehealed) + H.adjustFireLoss(tobehealed) + H.adjustBruteLoss(tobehealed) + user.visible_message("[defib] pings: Resuscitation successful.") + playsound(get_turf(src), 'sound/machines/defib_success.ogg', 50, 0) + H.update_revive(FALSE) + H.KnockOut(FALSE) + H.Paralyse(5) + H.emote("gasp") + if(tplus > tloss) + H.setBrainLoss( max(0, min(99, ((tlimit - tplus) / tlimit * 100)))) + defib.deductcharge(revivecost) + add_logs(user, M, "revived", object="defibrillator") + else + if(tplus > tlimit|| !H.get_int_organ(/obj/item/organ/internal/heart)) + 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.") + 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) + ghost << sound('sound/effects/genetics.ogg') + else + user.visible_message("[defib] buzzes: Resuscitation failed.") + playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0) + defib.deductcharge(revivecost) + update_icon() + cooldown = 1 + defib.cooldowncheck(user) + else + user.visible_message("[defib] buzzes: Patient is not in a valid state. Operation aborted.") + playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0) + busy = 0 + update_icon() + /obj/item/weapon/borg_defib name = "defibrillator paddles" @@ -489,80 +486,76 @@ cooldown = 0 update_icon() return - if(user.zone_sel && user.zone_sel.selecting == "chest") - user.visible_message("[user] begins to place [src] on [M.name]'s chest.", "You begin to place [src] on [M.name]'s chest.") - busy = 1 - update_icon() - if(do_after(user, 30 * toolspeed, target = M)) //beginning to place the paddles on patient's chest to allow some time for people to move away to stop the process - 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_runtime(EXCEPTION("Ghost of name [ghost.name] is bound to [H.real_name], but lacks a client. Deleting ghost."), H) + user.visible_message("[user] begins to place [src] on [M.name]'s chest.", "You begin to place [src] on [M.name]'s chest.") + busy = 1 + update_icon() + if(do_after(user, 30 * toolspeed, target = M)) //beginning to place the paddles on patient's chest to allow some time for people to move away to stop the process + 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_runtime(EXCEPTION("Ghost of name [ghost.name] is bound to [H.real_name], but lacks a client. Deleting ghost."), H) - qdel(ghost) - ghost = null - var/tplus = world.time - H.timeofdeath - var/tlimit = 1800 //past this much time the patient is unrecoverable (in deciseconds) - var/tloss = 600 //brain damage starts setting in on the patient after some time left rotting - var/total_burn = 0 - var/total_brute = 0 - if(do_after(user, 20 * toolspeed, target = M)) //placed on chest and short delay to shock for dramatic effect, revive time is 5sec total - if(H.stat == 2) - var/health = H.health - M.visible_message("[M]'s body convulses a bit.") - playsound(get_turf(src), "bodyfall", 50, 1) - playsound(get_turf(src), 'sound/machines/defib_zap.ogg', 50, 1, -1) - for(var/obj/item/organ/external/O in H.bodyparts) - total_brute += O.brute_dam - total_burn += O.burn_dam - if(total_burn <= 180 && total_brute <= 180 && !H.suiciding && !ghost && tplus < tlimit && !(NOCLONE in H.mutations)) - tobehealed = min(health + threshold, 0) // It's HILARIOUS without this min statement, let me tell you - tobehealed -= 5 //They get 5 of each type of damage healed so excessive combined damage will not immediately kill them after they get revived - H.adjustOxyLoss(tobehealed) - H.adjustToxLoss(tobehealed) - H.adjustFireLoss(tobehealed) - H.adjustBruteLoss(tobehealed) - user.visible_message("[user] pings: Resuscitation successful.") - playsound(get_turf(src), 'sound/machines/defib_success.ogg', 50, 0) - H.update_revive(FALSE) - H.KnockOut(FALSE) - H.Paralyse(5) - H.emote("gasp") - if(tplus > tloss) - H.setBrainLoss( max(0, min(99, ((tlimit - tplus) / tlimit * 100)))) - if(isrobot(user)) - var/mob/living/silicon/robot/R = user - R.cell.use(revivecost) - add_logs(user, M, "revived", object="defibrillator") - else - if(tplus > tlimit) - 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.") - 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) - ghost << sound('sound/effects/genetics.ogg') - else - user.visible_message("[user] buzzes: Resuscitation failed.") - playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0) - if(isrobot(user)) - var/mob/living/silicon/robot/R = user - R.cell.use(revivecost) - update_icon() - cooldown = 1 - spawn(50) - cooldown = 0 - update_icon() + qdel(ghost) + ghost = null + var/tplus = world.time - H.timeofdeath + var/tlimit = 1800 //past this much time the patient is unrecoverable (in deciseconds) + var/tloss = 600 //brain damage starts setting in on the patient after some time left rotting + var/total_burn = 0 + var/total_brute = 0 + if(do_after(user, 20 * toolspeed, target = M)) //placed on chest and short delay to shock for dramatic effect, revive time is 5sec total + if(H.stat == 2) + var/health = H.health + M.visible_message("[M]'s body convulses a bit.") + playsound(get_turf(src), "bodyfall", 50, 1) + playsound(get_turf(src), 'sound/machines/defib_zap.ogg', 50, 1, -1) + for(var/obj/item/organ/external/O in H.bodyparts) + total_brute += O.brute_dam + total_burn += O.burn_dam + if(total_burn <= 180 && total_brute <= 180 && !H.suiciding && !ghost && tplus < tlimit && !(NOCLONE in H.mutations)) + tobehealed = min(health + threshold, 0) // It's HILARIOUS without this min statement, let me tell you + tobehealed -= 5 //They get 5 of each type of damage healed so excessive combined damage will not immediately kill them after they get revived + H.adjustOxyLoss(tobehealed) + H.adjustToxLoss(tobehealed) + H.adjustFireLoss(tobehealed) + H.adjustBruteLoss(tobehealed) + user.visible_message("[user] pings: Resuscitation successful.") + playsound(get_turf(src), 'sound/machines/defib_success.ogg', 50, 0) + H.update_revive(FALSE) + H.KnockOut(FALSE) + H.Paralyse(5) + H.emote("gasp") + if(tplus > tloss) + H.setBrainLoss( max(0, min(99, ((tlimit - tplus) / tlimit * 100)))) + if(isrobot(user)) + var/mob/living/silicon/robot/R = user + R.cell.use(revivecost) + add_logs(user, M, "revived", object="defibrillator") else - user.visible_message("[user] buzzes: Patient is not in a valid state. Operation aborted.") + if(tplus > tlimit) + 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.") + 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) + ghost << sound('sound/effects/genetics.ogg') + else + user.visible_message("[user] buzzes: Resuscitation failed.") playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0) - busy = 0 - update_icon() - else - to_chat(user, "You need to target your patient's chest with [src].") - return + if(isrobot(user)) + var/mob/living/silicon/robot/R = user + R.cell.use(revivecost) + update_icon() + cooldown = 1 + spawn(50) + cooldown = 0 + update_icon() + else + user.visible_message("[user] buzzes: Patient is not in a valid state. Operation aborted.") + playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0) + busy = 0 + update_icon()