Files
S.P.L.U.R.T-Station-13/code/modules/surgery/prosthetic_replacement.dm
DeltaFire 4146566af0 hoo boy
replaces all mentions of bodypart_robotic with is_robotic_limb() where possible, adds BODYPART_HYBRID, adds helpers for organic / robotic limbs (is_robotic_limb() / is_organic_limb(), with a arg to override it accepting hybrid limbs)
Also makes the the surgery to heal robotic limbs work if the torso isn't a robot, but rather if there are robotic bodyparts, makes the IPC brain repair.. only accept IPC brains (obviously), makes the damage threshholds for robo-limbs vars instead of a fix 25 with hybrid ones predefined at 25 / 15 (trigger / mindamage), adds an error message to fixing them if already at theshhold, etc. Now just for replacing BODYPART_ORGANIC with is_organic_limb aswell where applicable.. also actual values for the other robo limbs. Fun!
2020-10-06 17:34:13 +02:00

90 lines
4.5 KiB
Plaintext

/datum/surgery/prosthetic_replacement
name = "Prosthetic replacement"
steps = list(/datum/surgery_step/incise, /datum/surgery_step/clamp_bleeders, /datum/surgery_step/retract_skin, /datum/surgery_step/add_prosthetic)
target_mobtypes = list(/mob/living/carbon/human, /mob/living/carbon/monkey)
possible_locs = list(BODY_ZONE_R_ARM, BODY_ZONE_L_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG, BODY_ZONE_HEAD)
requires_bodypart = FALSE //need a missing limb
requires_bodypart_type = 0
/datum/surgery/prosthetic_replacement/can_start(mob/user, mob/living/carbon/target, obj/item/tool)
if(!iscarbon(target))
return 0
var/mob/living/carbon/C = target
if(!C.get_bodypart(user.zone_selected)) //can only start if limb is missing
return 1
/datum/surgery_step/add_prosthetic
name = "add prosthetic"
implements = list(/obj/item/bodypart = 100, /obj/item/organ_storage = 100, /obj/item/chainsaw = 100, /obj/item/melee/synthetic_arm_blade = 100)
time = 32
var/organ_rejection_dam = 0
/datum/surgery_step/add_prosthetic/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(istype(tool, /obj/item/organ_storage))
if(!tool.contents.len)
to_chat(user, "<span class='notice'>There is nothing inside [tool]!</span>")
return -1
var/obj/item/I = tool.contents[1]
if(!isbodypart(I))
to_chat(user, "<span class='notice'>[I] cannot be attached!</span>")
return -1
tool = I
if(istype(tool, /obj/item/bodypart))
var/obj/item/bodypart/BP = tool
if(ismonkey(target))// monkey patient only accept organic monkey limbs
if(BP.is_robotic_limb() || BP.animal_origin != MONKEY_BODYPART)
to_chat(user, "<span class='warning'>[BP] doesn't match the patient's morphology.</span>")
return -1
if(!BP.is_robotic_limb())
organ_rejection_dam = 10
if(ishuman(target))
if(BP.animal_origin)
to_chat(user, "<span class='warning'>[BP] doesn't match the patient's morphology.</span>")
return -1
var/mob/living/carbon/human/H = target
if(H.dna.species.id != BP.species_id)
organ_rejection_dam = 30
if(target_zone == BP.body_zone) //so we can't replace a leg with an arm, or a human arm with a monkey arm.
display_results(user, target, "<span class ='notice'>You begin to replace [target]'s [parse_zone(target_zone)] with [tool]...</span>",
"[user] begins to replace [target]'s [parse_zone(target_zone)] with [tool].",
"[user] begins to replace [target]'s [parse_zone(target_zone)].")
else
to_chat(user, "<span class='warning'>[tool] isn't the right type for [parse_zone(target_zone)].</span>")
return -1
else if(target_zone == BODY_ZONE_L_ARM || target_zone == BODY_ZONE_R_ARM)
display_results(user, target, "<span class='notice'>You begin to attach [tool] onto [target]...</span>",
"[user] begins to attach [tool] onto [target]'s [parse_zone(target_zone)].",
"[user] begins to attach something onto [target]'s [parse_zone(target_zone)].")
else
to_chat(user, "<span class='warning'>[tool] must be installed onto an arm.</span>")
return -1
/datum/surgery_step/add_prosthetic/success(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(istype(tool, /obj/item/organ_storage))
tool.icon_state = initial(tool.icon_state)
tool.desc = initial(tool.desc)
tool.cut_overlays()
tool = tool.contents[1]
if(istype(tool, /obj/item/bodypart) && user.temporarilyRemoveItemFromInventory(tool))
var/obj/item/bodypart/L = tool
L.attach_limb(target)
if(organ_rejection_dam)
target.adjustToxLoss(organ_rejection_dam)
display_results(user, target, "<span class='notice'>You succeed in replacing [target]'s [parse_zone(target_zone)].</span>",
"[user] successfully replaces [target]'s [parse_zone(target_zone)] with [tool]!",
"[user] successfully replaces [target]'s [parse_zone(target_zone)]!")
return 1
else
var/obj/item/bodypart/L = target.newBodyPart(target_zone, FALSE, FALSE)
L.is_pseudopart = TRUE
L.attach_limb(target)
display_results(user, target, "<span class='notice'>You attach [tool].</span>",
"[user] finishes attaching [tool]!",
"[user] finishes the attachment procedure!")
qdel(tool)
if(istype(tool, /obj/item/chainsaw))
var/obj/item/mounted_chainsaw/new_arm = new(target)
target_zone == BODY_ZONE_R_ARM ? target.put_in_r_hand(new_arm) : target.put_in_l_hand(new_arm)
return 1
else if(istype(tool, /obj/item/melee/synthetic_arm_blade))
var/obj/item/melee/arm_blade/new_arm = new(target,TRUE,TRUE)
target_zone == BODY_ZONE_R_ARM ? target.put_in_r_hand(new_arm) : target.put_in_l_hand(new_arm)
return 1