Fixed being able to switch surgery targets mid-step

This commit is contained in:
ZomgPonies
2015-04-06 17:05:48 -04:00
parent 9dfe308b3d
commit 2de3b7148a
+26 -11
View File
@@ -77,22 +77,37 @@ proc/spread_germs_to_organ(obj/item/organ/external/E, mob/living/carbon/human/us
if(!(E.status & ORGAN_ROBOT)) //Germs on robotic limbs bad
E.germ_level = max(germ_level,E.germ_level) //as funny as scrubbing microbes out with clean gloves is - no.
proc/do_surgery(mob/living/M, mob/living/user, obj/item/tool)
if(!istype(M,/mob/living/carbon))
proc/do_surgery(mob/living/carbon/M, mob/living/user, obj/item/tool)
if(!istype(M))
return 0
if (user.a_intent == "harm") //check for Hippocratic Oath
return 0
var/zone = user.zone_sel.selecting
if(zone in M.op_stage.in_progress) //Can't operate on someone repeatedly.
user << "\red You can't operate on this area while surgery is already in progress."
return 1
for(var/datum/surgery_step/S in surgery_steps)
//check if tool is right or close enough and if this step is possible
if( S.tool_quality(tool) && S.can_use(user, M, user.zone_sel.selecting, tool) && S.is_valid_target(M))
S.begin_step(user, M, user.zone_sel.selecting, tool) //start on it
//We had proper tools! (or RNG smiled.) and User did not move or change hands.
if( prob(S.tool_quality(tool)) && do_mob(user, M, rand(S.min_duration, S.max_duration)))
S.end_step(user, M, user.zone_sel.selecting, tool) //finish successfully
else //or
if(!isrobot(user))
S.fail_step(user, M, user.zone_sel.selecting, tool) //malpractice~
return 1 //don't want to do weapony things after surgery
if(S.tool_quality(tool))
var/step_is_valid = S.can_use(user, M, zone, tool)
if(step_is_valid && S.is_valid_target(M))
if(step_is_valid == 2) // This is a failure that already has a message for failing.
return 1
M.op_stage.in_progress += zone
S.begin_step(user, M, zone, tool) //start on it
//We had proper tools! (or RNG smiled.) and user did not move or change hands.
if(prob(S.tool_quality(tool)) && do_mob(user, M, rand(S.min_duration, S.max_duration)))
S.end_step(user, M, zone, tool) //finish successfully
else if ((tool in user.contents) && user.Adjacent(M)) //or
S.fail_step(user, M, zone, tool) //malpractice~
else // This failing silently was a pain.
user << "\red You must remain close to your patient to conduct surgery."
M.op_stage.in_progress -= zone // Clear the in-progress flag.
return 1 //don't want to do weapony things after surgery
if (user.a_intent == "help")
user << "\red You can't see any useful way to use [tool] on [M]."
return 1
return 0
proc/sort_surgeries()