Files
Bubberstation/code/modules/surgery/revival.dm
Bloop a9c80a29a3 [MISSED MIRROR] Implements a macro for checking mind traits (#76548) (#22447)
* Implements a macro for checking mind traits (#76548)

![image](https://github.com/tgstation/tgstation/assets/82850673/f85d0556-1806-40bf-92b8-597e46ccb4af)
Seeing this pattern repeated over various sections of code was starting
to piss me off

Lessens chance to cause errors with mind traits, ensures consistent
behavior, makes it easier to change how mind traits work if necessary.

hopefully not player facing

---------

Co-authored-by: san7890 <the@san7890.com>

* modular stuff

---------

Co-authored-by: ChungusGamer666 <82850673+ChungusGamer666@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>
2023-07-18 21:32:47 -04:00

117 lines
5.2 KiB
Plaintext

/datum/surgery/revival
name = "Revival"
desc = "An experimental surgical procedure which involves reconstruction and reactivation of the patient's brain even long after death. \
The body must still be able to sustain life."
requires_bodypart_type = NONE
possible_locs = list(BODY_ZONE_HEAD)
surgery_flags = SURGERY_REQUIRE_RESTING | SURGERY_REQUIRE_LIMB | SURGERY_MORBID_CURIOSITY
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/saw,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/revive,
/datum/surgery_step/close,
)
/datum/surgery/revival/can_start(mob/user, mob/living/carbon/target)
if(!..())
return FALSE
if(target.stat != DEAD)
return FALSE
if(HAS_TRAIT(target, TRAIT_SUICIDED) || HAS_TRAIT(target, TRAIT_HUSK) || HAS_TRAIT(target, TRAIT_DEFIB_BLACKLISTED))
return FALSE
var/obj/item/organ/internal/brain/target_brain = target.get_organ_slot(ORGAN_SLOT_BRAIN)
if(!target_brain)
return FALSE
return TRUE
/datum/surgery_step/revive
name = "shock brain (defibrillator)"
implements = list(
/obj/item/shockpaddles = 100,
/obj/item/melee/touch_attack/shock = 100,
/obj/item/melee/baton/security = 75,
/obj/item/gun/energy = 60)
repeatable = TRUE
time = 5 SECONDS
success_sound = 'sound/magic/lightningbolt.ogg'
failure_sound = 'sound/magic/lightningbolt.ogg'
/datum/surgery_step/revive/tool_check(mob/user, obj/item/tool)
. = TRUE
if(istype(tool, /obj/item/shockpaddles))
var/obj/item/shockpaddles/paddles = tool
if((paddles.req_defib && !paddles.defib.powered) || !HAS_TRAIT(paddles, TRAIT_WIELDED) || paddles.cooldown || paddles.busy)
to_chat(user, span_warning("You need to wield both paddles, and [paddles.defib] must be powered!"))
return FALSE
if(istype(tool, /obj/item/melee/baton/security))
var/obj/item/melee/baton/security/baton = tool
if(!baton.active)
to_chat(user, span_warning("[baton] needs to be active!"))
return FALSE
if(istype(tool, /obj/item/gun/energy))
var/obj/item/gun/energy/egun = tool
if(egun.chambered && istype(egun.chambered, /obj/item/ammo_casing/energy/electrode))
return TRUE
else
to_chat(user, span_warning("You need an electrode for this!"))
return FALSE
/datum/surgery_step/revive/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(
user,
target,
span_notice("You prepare to give [target]'s brain the spark of life with [tool]."),
span_notice("[user] prepares to shock [target]'s brain with [tool]."),
span_notice("[user] prepares to shock [target]'s brain with [tool]."),
)
target.notify_ghost_cloning("Someone is trying to zap your brain.", source = target)
/datum/surgery_step/revive/play_preop_sound(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(istype(tool, /obj/item/shockpaddles))
playsound(tool, 'sound/machines/defib_charge.ogg', 75, 0)
else
..()
/datum/surgery_step/revive/success(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery, default_display_results)
display_results(
user,
target,
span_notice("You successfully shock [target]'s brain with [tool]..."),
span_notice("[user] send a powerful shock to [target]'s brain with [tool]..."),
span_notice("[user] send a powerful shock to [target]'s brain with [tool]..."),
)
target.grab_ghost()
target.adjustOxyLoss(-50, 0)
target.updatehealth()
if(target.revive())
target.visible_message(span_notice("...[target] wakes up, alive and aware!"))
target.emote("gasp")
target.adjustOrganLoss(ORGAN_SLOT_BRAIN, 50, 199) //MAD SCIENCE
to_chat(target, "<span class='userdanger'>[CONFIG_GET(string/blackoutpolicy)]</span>") //SKYRAT EDIT ADDITION - BLACKOUT POLICY
if(HAS_MIND_TRAIT(user, TRAIT_MORBID) && ishuman(user)) //Contrary to their typical hatred of resurrection, it wouldn't be very thematic if morbid people didn't love playing god
var/mob/living/carbon/human/morbid_weirdo = user
morbid_weirdo.add_mood_event("morbid_revival_success", /datum/mood_event/morbid_revival_success)
return TRUE
else
//SKYRAT EDIT ADDITION - DNR TRAIT - need this so that people dont just keep spamming the revival surgery; it runs success just bc the surgery steps are done
if(HAS_TRAIT(target, TRAIT_DNR))
target.visible_message(span_warning("...[target.p_they()] lies still, unaffected. Further attempts are futile, they're gone."))
else
target.visible_message(span_warning("...[target.p_they()] convulses, then lies still."))
//SKYRAT EDIT ADDITION END - DNR TRAIT - ORIGINAL: target.visible_message(span_warning("...[target.p_they()] convulses, then lies still."))
return FALSE
/datum/surgery_step/revive/failure(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(
user,
target,
span_notice("You shock [target]'s brain with [tool], but [target.p_they()] doesn't react."),
span_notice("[user] send a powerful shock to [target]'s brain with [tool], but [target.p_they()] doesn't react."),
span_notice("[user] send a powerful shock to [target]'s brain with [tool], but [target.p_they()] doesn't react."),
)
target.adjustOrganLoss(ORGAN_SLOT_BRAIN, 15, 180)
return FALSE