/obj/item/weapon/melee/defibrillator name = "emergency defibrillator" desc = "A handheld emergency defibrillator, used to bring people back from the brink of death or put them there." icon_state = "defib_full" item_state = "defib" flags = FPRINT | TABLEPASS slot_flags = SLOT_BELT force = 5 throwforce = 5 w_class = 3 var/emagged = 1 //Because defibs that only save people are boring. Let's have it start dangerous. Everything should be a potential weapon. var/charges = 10 var/status = 0 var/graceperiod = 300 var/datum/effect/effect/system/spark_spread/spark_system = new /datum/effect/effect/system/spark_spread origin_tech = "biotech=3" suicide_act(mob/user) viewers(user) << "\red [user] is putting the live paddles on \his chest! It looks like \he's trying to commit suicide." return (OXYLOSS) proc/toolate(mob/living/carbon/human/M as mob) if(world.time <= M.worldtod + graceperiod) return 1 else return 0 /obj/item/weapon/melee/defibrillator/update_icon() if(!status) if(charges >= 7) icon_state = "defib_full" if(charges <= 6 && charges >= 4) icon_state = "defib_half" if(charges <= 3 && charges >= 1) icon_state = "defib_low" if(charges <= 0) icon_state = "defib_empty" else if(charges >= 7) icon_state = "defibpaddleout_full" if(charges <= 6 && charges >= 4) icon_state = "defibpaddleout_half" if(charges <= 3 && charges >= 1) icon_state = "defibpaddleout_low" /obj/item/weapon/melee/defibrillator/attack_self(mob/user as mob) /* if(status && (M_CLUMSY in user.mutations) && prob(50)) spark_system.attach(user) spark_system.set_up(5, 0, src) spark_system.start() user << "\red You touch the paddles together shorting the device." user.Weaken(5) charges-- if(charges < 1) status = 0 update_icon() return*/ if(charges > 0) status = !status user << "\The [src] is now [status ? "on" : "off"]." playsound(get_turf(src), "sparks", 75, 1, -1) update_icon() else status = 0 user << "\The [src] is out of charge." add_fingerprint(user) /obj/item/weapon/melee/defibrillator/attackby(obj/item/weapon/W as obj, mob/user as mob) ..() if(istype(W, /obj/item/weapon/card/emag)) var/image/I = image("icon" = "icons/obj/weapons.dmi", "icon_state" = "defib_emag") if(emagged == 0) emagged = 1 usr << "\red [W] unlocks [src]'s safety protocols" overlays += I else emagged = 0 usr << "\blue [W] sets [src]'s safety protocols" overlays -= I /obj/item/weapon/melee/defibrillator/attack(mob/living/carbon/human/M as mob, mob/user as mob) var/tobehealed var/threshhold = -config.health_threshold_dead var/mob/living/carbon/human/H = M if(!ishuman(M)) ..() return if(status) if(user.a_intent == "hurt" && emagged) H.visible_message("[M.name] has been touched by the defibrillator paddles by [user]!") if(charges >= 2) H.Weaken(10) H.adjustOxyLoss(10) H.apply_damage(10, BURN, "chest") else H.Weaken(5) H.adjustOxyLoss(5) H.apply_damage(5, BURN, "chest") H.updatehealth() //forces health update before next life tick spark_system.attach(M) spark_system.set_up(5, 0, M) spark_system.start() charges -= 2 if(charges < 0) charges = 0 if(!charges) status = 0 update_icon() playsound(get_turf(src), 'sound/weapons/Egloves.ogg', 50, 1, -1) user.attack_log += "\[[time_stamp()]\] Defibrillated [H.name] ([H.ckey]) with [src.name]" H.attack_log += "\[[time_stamp()]\] Defibrillated by [user.name] ([user.ckey]) with [src.name]" msg_admin_attack("[key_name_admin(user)] defibrillated [key_name_admin(H)] with [src.name] - JMP" ) if(!iscarbon(user)) M.LAssailant = null else M.LAssailant = user return H.visible_message("\blue [user] places the defibrillator paddles on [M.name]'s chest.", "\blue You place the defibrillator paddles on [M.name]'s chest.") if(do_after(user, 10)) if(H.stat == 2 || H.stat == DEAD) var/uni = 0 var/armor = 0 var/health = H.health for(var/obj/item/carried_item in H.contents) if(istype(carried_item, /obj/item/clothing/under)) uni = 1 if(istype(carried_item, /obj/item/clothing/suit/armor)) armor = 1 if(uni && armor && toolate(M)) if(prob(30)) spark_system.attach(M) spark_system.start() if(prob(30)) tobehealed = health + threshhold tobehealed -= 5 //They get 5 health in crit to heal the person or inject stabilizers H.adjustOxyLoss(tobehealed) else if((uni || armor) && toolate(M)) if(prob(30)) spark_system.attach(M) spark_system.start() if(prob(60)) tobehealed = health + threshhold tobehealed -= 5 //They get 5 health in crit to heal the person or inject stabilizers H.adjustOxyLoss(tobehealed) else if(prob(90) && toolate(M)) tobehealed = health + threshhold tobehealed -= 5 //They get 5 health in crit to heal the person or inject stabilizers H.adjustOxyLoss(tobehealed) H.updatehealth() //forces a health update, otherwise the oxyloss adjustment wouldnt do anything M.visible_message("\red [M]'s body convulses a bit.") var/datum/organ/external/temp = H.get_organ("head") if(H.health > -100 && !(temp.status & ORGAN_DESTROYED) && !H.suiciding && (M.has_brain()) && toolate(M)) //!(M_NOCLONE in H.mutations) && We don't have this. viewers(M) << "\blue [src] beeps: Resuscitation successful." spawn(0) H.stat = 1 dead_mob_list -= H living_mob_list |= list(H) H.emote("gasp") else viewers(M) << "\blue [src] beeps: Resuscitation failed." charges-- if(charges < 1) charges = 0 status = 0 update_icon() else user.visible_message("\blue [src] beeps: Patient is not in a valid state.")