From 18b15163f6ca70b2e84f53355b854a020e337983 Mon Sep 17 00:00:00 2001 From: Anewbe Date: Fri, 28 Oct 2016 23:19:27 -0500 Subject: [PATCH] Fixes some surgery bugs --- code/_onclick/item_attack.dm | 7 +++++-- code/modules/surgery/face.dm | 1 + code/modules/surgery/generic.dm | 4 ++++ code/modules/surgery/limb_reattach.dm | 1 + code/modules/surgery/other.dm | 1 + code/modules/surgery/robotics.dm | 1 + code/modules/surgery/surgery.dm | 18 +++++++++++++++++- 7 files changed, 30 insertions(+), 3 deletions(-) diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 411d25befb..88e69696bf 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -39,8 +39,11 @@ avoid code duplication. This includes items that may sometimes act as a standard /mob/living/attackby(obj/item/I, mob/user) if(!ismob(user)) return 0 - if(can_operate(src) && I.do_surgery(src,user)) //Surgery - return 1 + if(can_operate(src) && I.do_surgery(src,user)) + if(I.can_do_surgery(src,user)) + return 1 + else + return 0 return I.attack(src, user, user.zone_sel.selecting) // Proximity_flag is 1 if this afterattack was called on something adjacent, in your square, or on your person. diff --git a/code/modules/surgery/face.dm b/code/modules/surgery/face.dm index 744b1d56dd..dc1c0ab31c 100644 --- a/code/modules/surgery/face.dm +++ b/code/modules/surgery/face.dm @@ -5,6 +5,7 @@ /datum/surgery_step/face priority = 2 + req_open = 0 can_infect = 0 can_use(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool) if (!hasorgans(target)) diff --git a/code/modules/surgery/generic.dm b/code/modules/surgery/generic.dm index e6dc9d9860..f08d677f6a 100644 --- a/code/modules/surgery/generic.dm +++ b/code/modules/surgery/generic.dm @@ -29,6 +29,7 @@ /obj/item/weapon/melee/energy/sword = 5 ) priority = 2 + req_open = 0 min_duration = 90 max_duration = 110 @@ -67,6 +68,7 @@ /obj/item/weapon/scalpel/manager = 100 ) priority = 2 + req_open = 0 min_duration = 80 max_duration = 120 @@ -108,6 +110,7 @@ /obj/item/weapon/material/knife = 75, \ /obj/item/weapon/material/shard = 50, \ ) + req_open = 0 min_duration = 90 max_duration = 110 @@ -273,6 +276,7 @@ /obj/item/weapon/circular_saw = 100, \ /obj/item/weapon/material/hatchet = 75 ) + req_open = 0 min_duration = 110 max_duration = 160 diff --git a/code/modules/surgery/limb_reattach.dm b/code/modules/surgery/limb_reattach.dm index 8e6e8da21f..3b6be3b9eb 100644 --- a/code/modules/surgery/limb_reattach.dm +++ b/code/modules/surgery/limb_reattach.dm @@ -5,6 +5,7 @@ /datum/surgery_step/limb/ priority = 3 // Must be higher than /datum/surgery_step/internal + req_open = 0 can_infect = 0 can_use(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool) if (!hasorgans(target)) diff --git a/code/modules/surgery/other.dm b/code/modules/surgery/other.dm index d0ba959111..4362dc969f 100644 --- a/code/modules/surgery/other.dm +++ b/code/modules/surgery/other.dm @@ -175,6 +175,7 @@ /obj/item/weapon/circular_saw = 60, /obj/item/weapon/pickaxe/plasmacutter = 100 ) + req_open = 0 can_infect = 0 blood_level = 0 diff --git a/code/modules/surgery/robotics.dm b/code/modules/surgery/robotics.dm index 17729a6304..544ddbbcfe 100644 --- a/code/modules/surgery/robotics.dm +++ b/code/modules/surgery/robotics.dm @@ -27,6 +27,7 @@ /obj/item/weapon/coin = 50, /obj/item/weapon/material/kitchen/utensil/knife = 50 ) + req_open = 0 min_duration = 90 max_duration = 110 diff --git a/code/modules/surgery/surgery.dm b/code/modules/surgery/surgery.dm index 109da96b69..387621f3d6 100644 --- a/code/modules/surgery/surgery.dm +++ b/code/modules/surgery/surgery.dm @@ -3,6 +3,8 @@ /datum/surgery_step var/priority = 0 //steps with higher priority would be attempted first + var/req_open = 1 //1 means the part must be cut open, 0 means it doesn't + // type path referencing tools that can be used for this step, and how well are they suited for it var/list/allowed_tools = null // type paths referencing races that this step applies to. @@ -77,6 +79,20 @@ E.germ_level = max(germ_level,E.germ_level) //as funny as scrubbing microbes out with clean gloves is - no. + +/obj/item/proc/can_do_surgery(mob/living/carbon/M, mob/living/user) + if(M == user) + return 0 + if(!ishuman(M)) + return 1 + var/mob/living/carbon/human/H = M + var/obj/item/organ/external/affected = H.get_organ(user.zone_sel.selecting) + if(affected) + for(var/datum/surgery_step/S in surgery_steps) + if(!affected.open && S.req_open) + return 0 + return 0 + /obj/item/proc/do_surgery(mob/living/carbon/M, mob/living/user) if(!istype(M)) return 0 @@ -109,7 +125,7 @@ return 1 //don't want to do weapony things after surgery if (user.a_intent == I_HELP) - user << "You can't see any useful way to use [src] on [M]." + user << "You can't see any surgical way to use [src] on [M]." return 1 return 0