diff --git a/code/modules/surgery/cavity_implant.dm b/code/modules/surgery/cavity_implant.dm index 8bad429102a..0d13e811884 100644 --- a/code/modules/surgery/cavity_implant.dm +++ b/code/modules/surgery/cavity_implant.dm @@ -17,6 +17,11 @@ var/obj/item/bodypart/chest/CH = target.get_bodypart("chest") IC = CH.cavity_item if(tool) + if(istype(tool, /obj/item/surgical_drapes) || istype(tool, /obj/item/bedsheet)) + var/obj/item/inactive = user.get_inactive_held_item() + if(istype(inactive, /obj/item/cautery) || istype(inactive, /obj/item/screwdriver) || iscyborg(user)) + attempt_cancel_surgery(surgery, tool, target, user) + return -1 user.visible_message("[user] begins to insert [tool] into [target]'s [target_zone].", "You begin to insert [tool] into [target]'s [target_zone]...") else user.visible_message("[user] checks for items in [target]'s [target_zone].", "You check for items in [target]'s [target_zone]...") diff --git a/code/modules/surgery/helpers.dm b/code/modules/surgery/helpers.dm index 2f3d3c55ce7..c3322126e48 100644 --- a/code/modules/surgery/helpers.dm +++ b/code/modules/surgery/helpers.dm @@ -72,34 +72,31 @@ else to_chat(user, "You need to expose [M]'s [parse_zone(selected_zone)] first!") - // so hardcoded, we need to do something with it else if(!current_surgery.step_in_progress) - if(current_surgery.status == 1) - M.surgeries -= current_surgery - user.visible_message("[user] removes the drapes from [M]'s [parse_zone(selected_zone)].", \ - "You remove the drapes from [M]'s [parse_zone(selected_zone)].") - qdel(current_surgery) - else if(current_surgery.can_cancel) - if(current_surgery.requires_bodypart_type == BODYPART_ORGANIC) - if(istype(user.get_inactive_held_item(), /obj/item/cautery)) - M.surgeries -= current_surgery - user.visible_message("[user] mends the incision and removes the drapes from [M]'s [parse_zone(selected_zone)].", \ - "You mend the incision and remove the drapes from [M]'s [parse_zone(selected_zone)].") - qdel(current_surgery) - else - to_chat(user, "You need to hold a cautery in inactive hand to stop [M]'s surgery!") - else if(current_surgery.requires_bodypart_type == BODYPART_ROBOTIC) - if(istype(user.get_inactive_held_item(), /obj/item/screwdriver)) - M.surgeries -= current_surgery - user.visible_message("[user] screw the shell and removes the drapes from [M]'s [parse_zone(selected_zone)].", \ - "You screw the shell and remove the drapes from [M]'s [parse_zone(selected_zone)].") - qdel(current_surgery) - else - to_chat(user, "You need to hold a screwdriver in inactive hand to stop [M]'s surgery!") + attempt_cancel_surgery(current_surgery, I, M, user) return 1 - +/proc/attempt_cancel_surgery(datum/surgery/S, obj/item/I, mob/living/M, mob/user) + var/selected_zone = user.zone_selected + if(S.status == 1) + M.surgeries -= S + user.visible_message("[user] removes [I] from [M]'s [parse_zone(selected_zone)].", \ + "You remove [I] from [M]'s [parse_zone(selected_zone)].") + qdel(S) + else if(S.can_cancel) + var/close_tool_type = /obj/item/cautery + var/obj/item/close_tool = user.get_inactive_held_item() + var/is_robotic = S.requires_bodypart_type == BODYPART_ROBOTIC + if(is_robotic) + close_tool_type = /obj/item/screwdriver + if(istype(close_tool, close_tool_type) || iscyborg(user)) + M.surgeries -= S + user.visible_message("[user] closes [M]'s [parse_zone(selected_zone)] with [close_tool] and removes [I].", \ + "You close [M]'s [parse_zone(selected_zone)] with [close_tool] and remove [I].") + qdel(S) + else + to_chat(user, "You need to hold a [is_robotic ? "screwdriver" : "cautery"] in your inactive hand to stop [M]'s surgery!") /proc/get_location_modifier(mob/M) var/turf/T = get_turf(M)