diff --git a/baystation12.dme b/baystation12.dme index f1bce8e78d..e02f3589e7 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1305,6 +1305,7 @@ #include "code\modules\security levels\security levels.dm" #include "code\WorkInProgress\buildmode.dm" #include "code\WorkInProgress\explosion_particles.dm" +#include "code\WorkInProgress\surgery.dm" #include "code\WorkInProgress\Cael_Aislinn\energy_field.dm" #include "code\WorkInProgress\Cael_Aislinn\external_shield_gen.dm" #include "code\WorkInProgress\Cael_Aislinn\meteor_battery.dm" diff --git a/code/WorkInProgress/surgery.dm b/code/WorkInProgress/surgery.dm new file mode 100644 index 0000000000..5e119f2186 --- /dev/null +++ b/code/WorkInProgress/surgery.dm @@ -0,0 +1,58 @@ +/datum/surgery_step + // type path referencing the required tool for this step + var/required_tool = null + + // When multiple steps can be applied with the current tool etc., choose the one with higher priority + + // checks whether this step can be applied with the given user and target + proc/can_use(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool) + return 0 + + // does stuff to begin the step, usually just printing messages + proc/begin_step(user, mob/living/carbon/human/target, target_zone, obj/item/tool) + return + + // does stuff to end the step, which is normally print a message + do whatever this step changes + proc/end_step(user, mob/living/carbon/human/target, target_zone, obj/item/tool) + return + + // stuff that happens when the step fails + proc/fail_step(user, mob/living/carbon/human/target, target_zone, obj/item/tool) + return null + + // duration of the step + var/min_duration = 0 + var/max_duration = 0 + + // evil infection stuff that will make everyone hate me + var/can_infect = 0 + +/datum/surgery_step/cut_open_abdomen + required_tool = /obj/item/weapon/scalpel + + can_use(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool) + return target_zone == "groin" + + begin_step(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool) + user.visible_message("[user] starts cutting open [target]'s abdomen with \the [tool]", "You start cutting open [user] with \the [tool]") + + end_step(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool) + var/datum/organ/external/groin = target.get_organ("groin") + groin.open = 1 + +/datum/surgery_step/remove_appendix + required_tool = /obj/item/weapon/scalpel + + can_use(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool) + var/datum/organ/external/groin = target.get_organ("groin") + return target_zone == "groin" && groin.open + +// Build this list by iterating over all typesof(/datum/surgery_step) and sorting the results by priority +var/global/list/surgery_steps = null + +proc/build_surgery_steps_list() + surgery_steps = list() + for(var/T in typesof(/datum/surgery_step)-/datum/surgery_step) + var/datum/surgery_step/S = new T + surgery_steps += S + diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index dc436d29df..e68e62ba5f 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -179,6 +179,29 @@ if (!istype(M)) // not sure if this is the right thing... return + + //if(istype(M) &&((locate(/obj/machinery/optable, M.loc) && M.resting) || (locate(/obj/structure/table/, M.loc) && (M.lying || M.weakened || M.stunned || M.paralysis || M.sleeping || M.stat) && prob(50)))) + if(istype(M,/mob/living/carbon)) + if (user.a_intent == "help") + if(surgery_steps == null) build_surgery_steps_list() + for(var/datum/surgery_step/S in surgery_steps) + var/have_correct_tool = 0 + if(istype(S.required_tool, /list)) + for(var/T in S.required_tool) if(istype(src, T)) + have_correct_tool = 1 + break + else + have_correct_tool = (istype(src, S.required_tool)) + if(!have_correct_tool) continue + if(S.can_use(user, M, user.zone_sel.selecting, src)) + S.begin_step(user, M, user.zone_sel.selecting, src) + if(do_mob(user, M, rand(S.min_duration, S.max_duration))) + S.end_step(user, M, user.zone_sel.selecting, src) + else + S.fail_step(user, M, user.zone_sel.selecting, src) + return //don't want to do weapony things after surgery + + var/messagesource = M if (istype(M,/mob/living/carbon/brain))