diff --git a/code/modules/surgery/organs_internal.dm b/code/modules/surgery/organs_internal.dm
index 1d1ef048f65..f86cf41bcd0 100644
--- a/code/modules/surgery/organs_internal.dm
+++ b/code/modules/surgery/organs_internal.dm
@@ -62,18 +62,6 @@
can_infect = 1
blood_level = 1
-/datum/surgery_step/internal/can_use(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool,datum/surgery/surgery)
-
- if(!hasorgans(target))
- return 0
-
- var/obj/item/organ/external/affected = target.get_organ(target_zone)
- if(affected)
- return 1
-
- return 0
-
-
/datum/surgery_step/internal/manipulate_organs
name = "manipulate organs"
@@ -92,15 +80,13 @@
allowed_tools = allowed_tools + implements_extract + implements_mend + implements_finsh
-
-
-/datum/surgery_step/internal/manipulate_organs/begin_step(mob/living/user, mob/living/carbon/target, target_zone, obj/item/tool,datum/surgery/surgery)
-
+/datum/surgery_step/internal/manipulate_organs/begin_step(mob/living/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
I = null
var/mob/living/carbon/human/H
- if(istype(target,/mob/living/carbon/human))
+ if(ishuman(target))
H = target
affected = H.get_organ(target_zone)
+
if(is_int_organ(tool))
current_type = "insert"
I = tool
@@ -115,6 +101,7 @@
if(target.get_int_organ(I))
to_chat(user, " \The [target] already has [I].")
return -1
+
if(affected)
user.visible_message("[user] starts transplanting \the [tool] into [target]'s [affected.name].", \
"You start transplanting \the [tool] into [target]'s [affected.name].")
@@ -135,30 +122,33 @@
var/msg = "[user] starts pulling [target]'s skin back into place with \the [tool]."
var/self_msg = "You start pulling [target]'s skin back into place with \the [tool]."
user.visible_message(msg, self_msg)
- if(affected)
+
+ if(H && affected)
H.custom_pain("Something hurts horribly in your [affected.name]!",1)
+
else if(implement_type in implements_extract)
current_type = "extract"
var/list/organs = target.get_organs_zone(target_zone)
if(!organs.len)
to_chat(user, "There are no removeable organs in [target]'s [parse_zone(target_zone)]!")
return -1
- else
- for(var/obj/item/organ/internal/O in organs)
- O.on_find(user)
- organs -= O
- organs[O.name] = O
- I = input("Remove which organ?", "Surgery", null, null) as null|anything in organs
- if(I && user && target && user.Adjacent(target) && user.get_active_hand() == tool)
- I = organs[I]
- if(!I) return -1
- user.visible_message("[user] starts to separate [target]'s [I] with \the [tool].", \
- "You start to separate [target]'s [I] with \the [tool] for removal." )
- if(affected)
- H.custom_pain("The pain in your [affected.name] is living hell!",1)
- else
+ for(var/obj/item/organ/internal/O in organs)
+ O.on_find(user)
+ organs -= O
+ organs[O.name] = O
+
+ I = input("Remove which organ?", "Surgery", null, null) as null|anything in organs
+ if(I && user && target && user.Adjacent(target) && user.get_active_hand() == tool)
+ I = organs[I]
+ if(!I)
return -1
+ user.visible_message("[user] starts to separate [target]'s [I] with \the [tool].", \
+ "You start to separate [target]'s [I] with \the [tool] for removal." )
+ if(H && affected)
+ H.custom_pain("The pain in your [affected.name] is living hell!",1)
+ else
+ return -1
else if(implement_type in implements_mend)
current_type = "mend"
@@ -173,6 +163,7 @@
if(!hasorgans(target))
to_chat(user, "They do not have organs to mend!")
return
+
for(var/obj/item/organ/internal/I in affected.internal_organs)
if(I && I.damage > 0)
if(I.robotic < 2 && !istype (tool, /obj/item/stack/nanopaste))
@@ -186,14 +177,17 @@
else
to_chat(user, "[I] does not appear to be damaged.")
- H.custom_pain("The pain in your [affected.name] is living hell!",1)
+
+ if(affected)
+ H.custom_pain("The pain in your [affected.name] is living hell!", 1)
else if(istype(tool, /obj/item/weapon/reagent_containers/food/snacks/organ))
to_chat(user, "[tool] was biten by someone! It's too damaged to use!")
return -1
+
..()
-/datum/surgery_step/internal/manipulate_organs/end_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool,datum/surgery/surgery)
+/datum/surgery_step/internal/manipulate_organs/end_step(mob/living/user, mob/living/carbon/target, target_zone, obj/item/tool,datum/surgery/surgery)
if(current_type == "mend")
var/tool_name = "\the [tool]"
if(istype(tool, /obj/item/stack/medical/bruise_pack/advanced))
@@ -205,6 +199,7 @@
if(!hasorgans(target))
return
+
for(var/obj/item/organ/internal/I in affected.internal_organs)
if(I)
I.surgeryize()
@@ -217,7 +212,7 @@
user.visible_message(" [user] treats damage to [target]'s [I.name] with [tool_name].", \
" You treat damage to [target]'s [I.name] with [tool_name]." )
I.damage = 0
- //return 1
+
else if(current_type == "insert")
I = tool
user.drop_item()
@@ -228,16 +223,17 @@
return 0
if(affected)
- user.visible_message(" [user] has transplanted \the [tool] into [target]'s [affected.name].", \
+ user.visible_message(" [user] has transplanted \the [tool] into [target]'s [affected.name].",
" You have transplanted \the [tool] into [target]'s [affected.name].")
else
- user.visible_message(" [user] has transplanted \the [tool] into [target]'s [affected.name].", \
+ user.visible_message(" [user] has transplanted \the [tool] into [target]'s [parse_zone(target_zone)].",
" You have transplanted \the [tool] into [target]'s [parse_zone(target_zone)].")
+
I.status &= ~ORGAN_CUT_AWAY
else if(current_type == "extract")
if(I && I.owner == target)
- user.visible_message(" [user] has separated and extracts [target]'s [I] with \the [tool]." , \
+ user.visible_message(" [user] has separated and extracts [target]'s [I] with \the [tool].",
" You have separated and extracted [target]'s [I] with \the [tool].")
add_logs(user, target, "surgically removed [I.name] from", addition="INTENT: [uppertext(user.a_intent)]")
@@ -251,9 +247,9 @@
else
user.visible_message("[user] can't seem to extract anything from [target]'s [parse_zone(target_zone)]!",
"You can't extract anything from [target]'s [parse_zone(target_zone)]!")
- else if(current_type == "finish")
- if(affected.encased)
+ else if(current_type == "finish")
+ if(affected && affected.encased)
var/msg = " [user] bends [target]'s [affected.encased] back into place with \the [tool]."
var/self_msg = " You bend [target]'s [affected.encased] back into place with \the [tool]."
user.visible_message(msg, self_msg)
@@ -268,13 +264,14 @@
return 0
-/datum/surgery_step/internal/manipulate_organs/fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool,datum/surgery/surgery)
+/datum/surgery_step/internal/manipulate_organs/fail_step(mob/living/user, mob/living/carbon/target, target_zone, obj/item/tool,datum/surgery/surgery)
if(current_type == "mend")
if(!hasorgans(target))
return
user.visible_message(" [user]'s hand slips, getting mess and tearing the inside of [target]'s [affected.name] with \the [tool]!", \
" Your hand slips, getting mess and tearing the inside of [target]'s [affected.name] with \the [tool]!")
+
var/dam_amt = 2
if(istype(tool, /obj/item/stack/medical/bruise_pack/advanced))
@@ -290,27 +287,33 @@
I.take_damage(dam_amt,0)
return 0
- else if(current_type == "insert")
+ else if(current_type == "insert")
user.visible_message(" [user]'s hand slips, damaging \the [tool]!", \
" Your hand slips, damaging \the [tool]!")
var/obj/item/organ/internal/I = tool
- if(istype(I) &&!(I.tough))
+ if(istype(I) && !I.tough)
I.take_damage(rand(3,5),0)
+
return 0
else if(current_type == "extract")
if(I && I.owner == target)
- user.visible_message(" [user]'s hand slips, damaging [target]'s [affected.name] with \the [tool]!", \
- " Your hand slips, damaging [target]'s [affected.name] with \the [tool]!")
- affected.createwound(BRUISE, 20)
+ if(affected)
+ user.visible_message(" [user]'s hand slips, damaging [target]'s [affected.name] with \the [tool]!", \
+ " Your hand slips, damaging [target]'s [affected.name] with \the [tool]!")
+ affected.createwound(BRUISE, 20)
+ else
+ user.visible_message(" [user]'s hand slips, damaging [target]'s [parse_zone(target_zone)] with \the [tool]!", \
+ " Your hand slips, damaging [target]'s [parse_zone(target_zone)] with \the [tool]!")
else
user.visible_message("[user] can't seem to extract anything from [target]'s [parse_zone(target_zone)]!",
"You can't extract anything from [target]'s [parse_zone(target_zone)]!")
return 0
+
else if(current_type == "finish")
- if(affected.encased)
+ if(affected && affected.encased)
var/msg = " [user]'s hand slips, bending [target]'s [affected.encased] the wrong way!"
var/self_msg = " Your hand slips, bending [target]'s [affected.encased] the wrong way!"
user.visible_message(msg, self_msg)
@@ -319,7 +322,8 @@
var/msg = " [user]'s hand slips, tearing the skin!"
var/self_msg = " Your hand slips, tearing skin!"
user.visible_message(msg, self_msg)
- affected.createwound(BRUISE, 20)
+ if(affected)
+ affected.createwound(BRUISE, 20)
return 0