mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 11:37:40 +01:00
* Initial commit Fixes up surgery.dm Adds some tool behavior * More basic changes * Checkpointing: this is a little gross right now * Add signal COMPONENT_CANCEL_ATTACK_CHAIN * Cleans up surgery initiator * Mostly gets surgery (and canceling it) working * Add abstract proxy surgery steps Also adds them to organ manipulation * Clean up most existing surgeries * Rework organ openness, adds define for aborting a beginstep * surgery works again, also implements retry defines * fix surgery computer * add limb repair to synth implant removal * retry implant checks * Clean up abductor surgeries as well as some other things * A lot - Reworks organ manipulation to use a series of surgery steps instead - Fixes some runtimes with open hands - Lets mito zero out the germ level while treating necrosis - Adds a debug surgery tool * add debug surgery tool, note some TODOs for later * Add conditional check for surgeries repeating * update surgery retry logic to make it more of a bonus * Lets abductors automatically retry any failed surgery steps * Rework robotic surgery to use abstract/proxy steps * Bunch of bugfixes and more! - Limb reattachment works properly now, you can just slap a limb onto a person - If the limb isn't robotic, it'll be useless until the surgery is finished with a hemostat, though it might be enough to get the patient out of the OR. * Remove more now-implicit checks * Slight reorganization * more fixes across the board * Remove unused variable * Trying not to lose my mind here - Does away with can_run() entirely - Cleans up visible messages in code - begin steps should now all have ..() afterwards - slime bone surgery should be fixed now - more docs * Robotic surgery is stoppable with a crowbar, all surgery can_start now checks parent * Fix some broken robotic typepaths * Typepath fixes, do away with some last TODOs * Forgor * Last cleanups before we go gold * jk lol * Make early surgery termination clearer * More "last" cleanups * Fixes tool flags, surgery initiation - Fixes surgery not being startable by sharp objects - Moves surgical tool flags to item traits * Clean up surgery cancellation, especially for borgos * I think this should GC better * Apply suggestions from code review Co-authored-by: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com> * Status is now step number * Add a 20% chance to find nothing during organ manipulation * Improve documentation, make forced_surgery a normal arg * Charlie's reviews * Why are abductors like this * Little more verification, ensuring limb augmentation and organ manip healing work properly * Fix torso organ manip being unfinishable * Fix cavity implants, open-hand/any item steps * Make sharp objects not try to start an operation with help intent * Comments, quick target fix * Re-order list so advanced bruise pack is pulled first * Make surgical gripper function like an open hand * Make mito only use one unit per organ for now * Check if user is on operable surface before trying to operate * Reduce admin logging * Fix some bugs that appeared during the testmerge - you can no longer start robotic surgeries with a scalpel (lol) - you can now cancel surgeries on the first step after I fixed some bugs that I introduced (woo hoo) - Synthetic limb attachment is now combined into a single startable surgery step, though still retains the fun flavor of both * Swats some more bugs - (hopefully) fixes a huge source of runtimes where we tried to check if we could run surgeries before checking if the surgery used an organ - In doing so, moves the logic for determining if a surgery can start to the mob-level - Fixes robotic reattachment surgery not working * multi-bug drifting??? - Fixes a bug where a branching surgery with an any tool option could possibly override a step with a matching tool - Fixes some intermediate surgeries failing due to not having specified possible_locs * A few more fixes - Fixes any surgery tool steps again - Fixes cavity surgery again * Hopefully fixes getting stuck in robotic organ manip * Remove extra parent call * Steel review * Steel review * Fix spacing for possible locs * Roundstart traits * Advanced surgical traits and other hal fixes Co-authored-by: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>
272 lines
10 KiB
Plaintext
272 lines
10 KiB
Plaintext
//Procedures in this file: Robotic limbs attachment, meat limbs attachment
|
|
//////////////////////////////////////////////////////////////////
|
|
// LIMB SURGERY //
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
/datum/surgery/amputation
|
|
name = "Amputation"
|
|
steps = list(/datum/surgery_step/generic/amputate)
|
|
possible_locs = list(BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_R_ARM, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_R_LEG, BODY_ZONE_PRECISE_R_FOOT, BODY_ZONE_L_LEG, BODY_ZONE_PRECISE_L_FOOT, BODY_ZONE_PRECISE_GROIN)
|
|
requires_organic_bodypart = TRUE
|
|
|
|
/datum/surgery/amputation/can_start(mob/user, mob/living/carbon/target)
|
|
. = ..()
|
|
if(!.)
|
|
return FALSE
|
|
var/obj/item/organ/external/affected = target.get_organ(user.zone_selected)
|
|
if(affected.limb_flags & CANNOT_DISMEMBER)
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/datum/surgery/reattach
|
|
name = "Limb Reattachment"
|
|
requires_bodypart = FALSE
|
|
steps = list(
|
|
/datum/surgery_step/limb/attach,
|
|
/datum/surgery_step/limb/connect
|
|
)
|
|
possible_locs = list(BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_R_ARM, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_R_LEG, BODY_ZONE_PRECISE_R_FOOT, BODY_ZONE_L_LEG, BODY_ZONE_PRECISE_L_FOOT, BODY_ZONE_PRECISE_GROIN)
|
|
|
|
/datum/surgery/reattach/can_start(mob/user, mob/living/carbon/target)
|
|
. = ..()
|
|
if(!.)
|
|
return FALSE
|
|
if(ishuman(target))
|
|
var/mob/living/carbon/human/H = target
|
|
var/obj/item/organ/external/affected = H.get_organ(user.zone_selected)
|
|
if(ismachineperson(target))
|
|
// RIP bi-centennial man
|
|
return FALSE
|
|
if(!affected)
|
|
return TRUE
|
|
// make sure they can actually have this limb
|
|
var/list/organ_data = target.dna.species.has_limbs["[user.zone_selected]"]
|
|
return !isnull(organ_data)
|
|
|
|
return FALSE
|
|
|
|
/datum/surgery/reattach_synth
|
|
name = "Synthetic Limb Reattachment"
|
|
requires_bodypart = FALSE
|
|
steps = list(/datum/surgery_step/limb/attach/robo)
|
|
abstract = TRUE // these shouldn't show in the list; they'll be replaced by attach_robotic_limb
|
|
possible_locs = list(BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_R_ARM, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_R_LEG, BODY_ZONE_PRECISE_R_FOOT, BODY_ZONE_L_LEG, BODY_ZONE_PRECISE_L_FOOT, BODY_ZONE_PRECISE_GROIN)
|
|
|
|
/datum/surgery/robo_attach
|
|
name = "Apply Robotic Prosthetic"
|
|
requires_bodypart = FALSE
|
|
steps = list(/datum/surgery_step/limb/mechanize)
|
|
abstract = TRUE
|
|
possible_locs = list(BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_R_ARM, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_R_LEG, BODY_ZONE_PRECISE_R_FOOT, BODY_ZONE_L_LEG, BODY_ZONE_PRECISE_L_FOOT, BODY_ZONE_PRECISE_GROIN)
|
|
|
|
|
|
/datum/surgery_step/proxy/robo_limb_attach
|
|
name = "apply robotic limb (proxy)"
|
|
branches = list(
|
|
/datum/surgery/robo_attach,
|
|
/datum/surgery/reattach_synth
|
|
)
|
|
insert_self_after = FALSE
|
|
|
|
/datum/surgery/attach_robotic_limb
|
|
name = "Apply Robotic or Synthetic Limb"
|
|
requires_bodypart = FALSE
|
|
steps = list(
|
|
/datum/surgery_step/proxy/robo_limb_attach
|
|
)
|
|
|
|
possible_locs = list(BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_R_ARM, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_R_LEG, BODY_ZONE_PRECISE_R_FOOT, BODY_ZONE_L_LEG, BODY_ZONE_PRECISE_L_FOOT, BODY_ZONE_PRECISE_GROIN)
|
|
|
|
|
|
/datum/surgery_step/limb
|
|
can_infect = FALSE
|
|
|
|
/datum/surgery_step/limb/attach
|
|
name = "attach limb"
|
|
allowed_tools = list(/obj/item/organ/external = 100)
|
|
|
|
time = 3.2 SECONDS
|
|
|
|
/datum/surgery_step/limb/attach/begin_step(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
|
|
|
|
var/obj/item/organ/external/E = tool
|
|
if(target.get_organ(E.limb_name))
|
|
// This catches attaching an arm to a missing hand while the arm is still there
|
|
to_chat(user, "<span class='warning'>[target] already has an [E.name]!</span>")
|
|
return SURGERY_BEGINSTEP_ABORT
|
|
if(E.limb_name != target_zone)
|
|
// This ensures you must be aiming at the appropriate location to attach
|
|
// this limb. (Can't aim at a missing foot to re-attach a missing arm)
|
|
to_chat(user, "<span class='warning'>The [E.name] does not go there.</span>")
|
|
return SURGERY_BEGINSTEP_ABORT
|
|
if(!is_correct_limb(E))
|
|
to_chat(user, "<span class='warning'>This is not the correct limb type for this surgery!</span>")
|
|
return SURGERY_BEGINSTEP_ABORT
|
|
var/list/organ_data = target.dna.species.has_limbs["[user.zone_selected]"]
|
|
if(isnull(organ_data))
|
|
to_chat(user, "<span class='warning'>[target.dna.species] don't have the anatomy for [E.name]!")
|
|
return SURGERY_BEGINSTEP_ABORT
|
|
|
|
user.visible_message(
|
|
"[user] starts attaching [E.name] to [target]'s [E.amputation_point].",
|
|
"You start attaching [E.name] to [target]'s [E.amputation_point]."
|
|
)
|
|
return ..()
|
|
|
|
/datum/surgery_step/limb/attach/end_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
|
|
var/obj/item/organ/external/E = tool
|
|
user.visible_message(
|
|
"<span class='notice'>[user] has attached [target]'s [E.name] to the [E.amputation_point].</span>",
|
|
"<span class='notice'>You have attached [target]'s [E.name] to the [E.amputation_point].</span>"
|
|
)
|
|
attach_limb(user, target, E)
|
|
return SURGERY_STEP_CONTINUE
|
|
|
|
/datum/surgery_step/limb/attach/fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
|
|
var/obj/item/organ/external/E = tool
|
|
user.visible_message(
|
|
"<span class='alert'>[user]'s hand slips, damaging [target]'s [E.amputation_point]!</span>",
|
|
"<span class='alert'>Your hand slips, damaging [target]'s [E.amputation_point]!</span>"
|
|
)
|
|
target.apply_damage(10, BRUTE, null, sharp = TRUE)
|
|
return SURGERY_STEP_RETRY
|
|
|
|
|
|
/datum/surgery_step/limb/attach/proc/is_correct_limb(obj/item/organ/external/E)
|
|
if(E.is_robotic())
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/datum/surgery_step/limb/attach/proc/attach_limb(mob/living/user, mob/living/carbon/human/target, obj/item/organ/external/E)
|
|
user.unEquip(E)
|
|
E.replaced(target)
|
|
if(!E.is_robotic())
|
|
E.properly_attached = FALSE
|
|
target.update_body()
|
|
target.updatehealth()
|
|
target.UpdateDamageIcon()
|
|
|
|
|
|
// This is a step that handles robotic limb attachment while skipping the "connect" step
|
|
// THIS IS DISTINCT FROM USING A CYBORG LIMB TO CREATE A NEW LIMB ORGAN
|
|
/datum/surgery_step/limb/attach/robo
|
|
name = "attach robotic limb"
|
|
|
|
/datum/surgery_step/limb/attach/robo/is_correct_limb(obj/item/organ/external/E)
|
|
if(!E.is_robotic())
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/datum/surgery_step/limb/attach/robo/attach_limb(mob/living/user, mob/living/carbon/human/target, obj/item/organ/external/E)
|
|
// Fixes fabricator IPC heads
|
|
if(!(E.dna) && E.is_robotic() && target.dna)
|
|
E.set_dna(target.dna)
|
|
..()
|
|
if(E.limb_name == BODY_ZONE_HEAD)
|
|
var/obj/item/organ/external/head/H = target.get_organ(BODY_ZONE_HEAD)
|
|
var/datum/robolimb/robohead = GLOB.all_robolimbs[H.model]
|
|
if(robohead.is_monitor) //Ensures that if an IPC gets a head that's got a human hair wig attached to their body, the hair won't wipe.
|
|
H.h_style = "Bald"
|
|
H.f_style = "Shaved"
|
|
target.m_styles["head"] = "None"
|
|
|
|
|
|
/datum/surgery_step/limb/connect
|
|
name = "connect limb"
|
|
allowed_tools = list(
|
|
TOOL_HEMOSTAT = 100,
|
|
/obj/item/stack/cable_coil = 90,
|
|
/obj/item/assembly/mousetrap = 25
|
|
)
|
|
can_infect = TRUE
|
|
|
|
time = 3.2 SECONDS
|
|
|
|
/datum/surgery_step/limb/connect/begin_step(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
|
|
var/obj/item/organ/external/E = target.get_organ(target_zone)
|
|
user.visible_message(
|
|
"[user] starts connecting tendons and muscles in [target]'s [E.amputation_point] with [tool].",
|
|
"You start connecting tendons and muscle in [target]'s [E.amputation_point]."
|
|
)
|
|
return ..()
|
|
|
|
/datum/surgery_step/limb/connect/end_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
|
|
var/obj/item/organ/external/E = target.get_organ(target_zone)
|
|
user.visible_message(
|
|
"<span class='notice'>[user] has connected tendons and muscles in [target]'s [E.amputation_point] with [tool].</span>",
|
|
"<span class='notice'>You have connected tendons and muscles in [target]'s [E.amputation_point] with [tool].</span>"
|
|
)
|
|
E.properly_attached = TRUE
|
|
target.update_body()
|
|
target.updatehealth()
|
|
target.UpdateDamageIcon()
|
|
return SURGERY_STEP_CONTINUE
|
|
|
|
/datum/surgery_step/limb/connect/fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
|
|
var/obj/item/organ/external/E = target.get_organ(target_zone)
|
|
user.visible_message(
|
|
"<span class='alert'>[user]'s hand slips, damaging [target]'s [E.amputation_point]!</span>",
|
|
"<span class='alert'>Your hand slips, damaging [target]'s [E.amputation_point]!</span>"
|
|
)
|
|
target.apply_damage(10, BRUTE, null, sharp = TRUE)
|
|
return SURGERY_STEP_RETRY
|
|
|
|
/datum/surgery_step/limb/mechanize
|
|
name = "apply robotic prosthetic"
|
|
allowed_tools = list(/obj/item/robot_parts = 100)
|
|
|
|
time = 3.2 SECONDS
|
|
|
|
/datum/surgery_step/limb/mechanize/begin_step(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
|
|
|
|
var/obj/item/robot_parts/P = tool
|
|
if(P.part)
|
|
if(!(target_zone in P.part))
|
|
to_chat(user, "<span class='warning'>\The [tool] does not go there!</span>")
|
|
return SURGERY_BEGINSTEP_ABORT
|
|
|
|
user.visible_message(
|
|
"[user] starts attaching \the [tool] to [target].",
|
|
"You start attaching \the [tool] to [target]."
|
|
)
|
|
return ..()
|
|
|
|
/datum/surgery_step/limb/mechanize/end_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
|
|
var/obj/item/robot_parts/L = tool
|
|
user.visible_message(
|
|
"<span class='notice'>[user] has attached \the [tool] to [target].</span>",
|
|
"<span class='notice'>You have attached \the [tool] to [target].</span>"
|
|
)
|
|
|
|
if(L.part)
|
|
for(var/part_name in L.part)
|
|
if(!isnull(target.get_organ(part_name)))
|
|
continue
|
|
var/list/organ_data = target.dna.species.has_limbs["[part_name]"]
|
|
if(!organ_data)
|
|
continue
|
|
// This will break if there's more than one stump ever
|
|
var/obj/item/organ/external/stump = target.bodyparts_by_name["limb stump"]
|
|
if(stump)
|
|
stump.remove(target)
|
|
var/new_limb_type = organ_data["path"]
|
|
var/obj/item/organ/external/new_limb = new new_limb_type(target)
|
|
new_limb.robotize(L.model_info)
|
|
if(L.sabotaged)
|
|
new_limb.sabotaged = TRUE
|
|
target.update_body()
|
|
target.updatehealth()
|
|
target.UpdateDamageIcon()
|
|
|
|
qdel(tool)
|
|
|
|
return SURGERY_STEP_CONTINUE
|
|
|
|
/datum/surgery_step/limb/mechanize/fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
|
|
user.visible_message(
|
|
"<span class='alert'>[user]'s hand slips, damaging [target]'s flesh!</span>",
|
|
"<span class='alert'>Your hand slips, damaging [target]'s flesh!</span>"
|
|
)
|
|
target.apply_damage(10, BRUTE, null, sharp = TRUE)
|
|
return SURGERY_STEP_RETRY
|