Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surgeries that are done without anesthetic or painkillers now have a chance to cause extra damage #3286

1 change: 1 addition & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_ABDUCTOR_TRAINING "abductor-training"
#define TRAIT_ABDUCTOR_SCIENTIST_TRAINING "abductor-scientist-training"
#define TRAIT_SURGEON "surgeon"
#define TRAIT_SURGERY_PREPARED "surgery_prepared"
#define TRAIT_STRONG_GRABBER "strong_grabber"
#define TRAIT_MAGIC_CHOKE "magic_choke"
#define TRAIT_SOOTHED_THROAT "soothed-throat"
Expand Down
2 changes: 2 additions & 0 deletions code/datums/brain_damage/special.dm
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,13 @@
/datum/brain_trauma/special/tenacity/on_gain()
ADD_TRAIT(owner, TRAIT_NOSOFTCRIT, TRAUMA_TRAIT)
ADD_TRAIT(owner, TRAIT_NOHARDCRIT, TRAUMA_TRAIT)
ADD_TRAIT(owner, TRAIT_SURGERY_PREPARED, TRAUMA_TRAIT)
..()

/datum/brain_trauma/special/tenacity/on_lose()
REMOVE_TRAIT(owner, TRAIT_NOSOFTCRIT, TRAUMA_TRAIT)
REMOVE_TRAIT(owner, TRAIT_NOHARDCRIT, TRAUMA_TRAIT)
REMOVE_TRAIT(owner, TRAIT_SURGERY_PREPARED, TRAUMA_TRAIT)
..()

/datum/brain_trauma/special/death_whispers
Expand Down
7 changes: 7 additions & 0 deletions code/modules/reagents/chemistry/reagents/medicine_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,15 @@
to_chat(M, "<span class='danger'>You feel your wounds fade away to nothing!</span>" )
..()

/datum/reagent/medicine/mine_salve/on_mob_metabolize(mob/living/L)
..()
ADD_TRAIT(L, TRAIT_SURGERY_PREPARED, type)

/datum/reagent/medicine/mine_salve/on_mob_end_metabolize(mob/living/M)
if(iscarbon(M))
var/mob/living/carbon/N = M
N.hal_screwyhud = SCREWYHUD_NONE
REMOVE_TRAIT(M, TRAIT_SURGERY_PREPARED, type)
..()

/datum/reagent/medicine/synthflesh
Expand Down Expand Up @@ -753,9 +758,11 @@
/datum/reagent/medicine/morphine/on_mob_metabolize(mob/living/L)
..()
L.add_movespeed_mod_immunities(type, /datum/movespeed_modifier/damage_slowdown)
ADD_TRAIT(L, TRAIT_SURGERY_PREPARED, type)

/datum/reagent/medicine/morphine/on_mob_end_metabolize(mob/living/L)
L.remove_movespeed_mod_immunities(type, /datum/movespeed_modifier/damage_slowdown)
REMOVE_TRAIT(L, TRAIT_SURGERY_PREPARED, type)
..()

/datum/reagent/medicine/morphine/on_mob_life(mob/living/carbon/M)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/reagent_containers/borghydro.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Borg Hypospray
var/bypass_protection = 0 //If the hypospray can go through armor or thick material

var/list/datum/reagents/reagent_list = list()
var/list/reagent_ids = list(/datum/reagent/medicine/dexalin, /datum/reagent/medicine/kelotane, /datum/reagent/medicine/bicaridine, /datum/reagent/medicine/antitoxin, /datum/reagent/medicine/epinephrine, /datum/reagent/medicine/spaceacillin, /datum/reagent/medicine/salglu_solution)
var/list/reagent_ids = list(/datum/reagent/medicine/dexalin, /datum/reagent/medicine/kelotane, /datum/reagent/medicine/bicaridine, /datum/reagent/medicine/antitoxin, /datum/reagent/medicine/epinephrine, /datum/reagent/medicine/spaceacillin, /datum/reagent/medicine/salglu_solution, /datum/reagent/medicine/morphine)
var/accepts_reagent_upgrades = TRUE //If upgrades can increase number of reagents dispensed.
var/list/modes = list() //Basically the inverse of reagent_ids. Instead of having numbers as "keys" and strings as values it has strings as keys and numbers as values.
//Used as list for input() in shakers.
Expand Down
1 change: 1 addition & 0 deletions code/modules/surgery/bone_repair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
TOOL_WRENCH = 40)
preop_sound = 'sound/surgery/bone1.ogg'
success_sound = 'sound/surgery/bone3.ogg'
fuckup_damage = 20 //meowzers

/datum/surgery_step/set_bone/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(target_zone == BODY_ZONE_HEAD)
Expand Down
1 change: 1 addition & 0 deletions code/modules/surgery/brain_surgery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
success_sound = 'sound/surgery/hemostat1.ogg'
failure_sound = 'sound/surgery/organ2.ogg'
experience_given = 0 // per_trauma
fuckup_damage = 20

/datum/surgery/brain_surgery/can_start(mob/user, mob/living/carbon/target)
var/obj/item/organ/brain/B = target.getorganslot(ORGAN_SLOT_BRAIN)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/surgery/coronary_bypass.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
preop_sound = 'sound/surgery/scalpel1.ogg'
success_sound = 'sound/surgery/scalpel2.ogg'
failure_sound = 'sound/surgery/organ2.ogg'
fuckup_damage = 20

/datum/surgery_step/incise_heart/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(user, target, "<span class='notice'>You begin to make an incision in [target]'s heart...</span>",
Expand Down Expand Up @@ -69,6 +70,7 @@
success_sound = 'sound/surgery/hemostat1.ogg'
failure_sound = 'sound/surgery/organ2.ogg'
experience_given = MEDICAL_SKILL_ORGAN_FIX
fuckup_damage = 20

/datum/surgery_step/coronary_bypass/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(user, target, "<span class='notice'>You begin to graft a bypass onto [target]'s heart...</span>",
Expand Down
1 change: 1 addition & 0 deletions code/modules/surgery/gastrectomy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/obj/item/shard = 10)
time = 52
experience_given = (MEDICAL_SKILL_ORGAN_FIX*0.8) //for consistency across organ surgeries
fuckup_damage = 15

/datum/surgery_step/gastrectomy/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(user, target, "<span class='notice'>You begin to cut out a damaged piece of [target]'s stomach...</span>",
Expand Down
1 change: 1 addition & 0 deletions code/modules/surgery/healing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
var/brutehealing = 0
var/burnhealing = 0
var/missinghpbonus = 0 //heals an extra point of damager per X missing damage of type (burn damage for burn healing, brute for brute). Smaller Number = More Healing!
fuckup_damage = 0 //When the reckoning is not postponed indefinitely

/datum/surgery_step/heal/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
var/woundtype
Expand Down
1 change: 1 addition & 0 deletions code/modules/surgery/hepatectomy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
/obj/item/shard = 25)
time = 52
experience_given = (MEDICAL_SKILL_ORGAN_FIX*0.8) //repeatable so not as much xp
fuckup_damage = 20

/datum/surgery_step/hepatectomy/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(user, target, "<span class='notice'>You begin to cut out a damaged peice of [target]'s liver...</span>",
Expand Down
1 change: 1 addition & 0 deletions code/modules/surgery/lobectomy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
success_sound = 'sound/surgery/organ1.ogg'
failure_sound = 'sound/surgery/organ2.ogg'
experience_given = MEDICAL_SKILL_ORGAN_FIX
fuckup_damage = 20

/datum/surgery_step/lobectomy/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(user, target, "<span class='notice'>You begin to make an incision in [target]'s lungs...</span>",
Expand Down
3 changes: 3 additions & 0 deletions code/modules/surgery/organic_steps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
time = 2.4 SECONDS
preop_sound = 'sound/surgery/cautery1.ogg'
success_sound = 'sound/surgery/cautery2.ogg'
fuckup_damage_type = BURN

/datum/surgery_step/close/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(user, target, "<span class='notice'>You begin to mend the incision in [target]'s [parse_zone(target_zone)]...</span>",
Expand Down Expand Up @@ -166,6 +167,7 @@
/obj/item = 'sound/surgery/scalpel1.ogg',
)
success_sound = 'sound/surgery/bone3.ogg'
fuckup_damage = 20

/datum/surgery_step/saw/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(user, target, "<span class='notice'>You begin to saw through the bone in [target]'s [parse_zone(target_zone)]...</span>",
Expand Down Expand Up @@ -203,6 +205,7 @@
TOOL_SCREWDRIVER = 33,
/obj/item/kitchen/spoon = 4.13) //i made this as awful as possible.
time = 30
fuckup_damage = 15

/datum/surgery_step/drill/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
display_results(user, target, "<span class='notice'>You begin to drill into the bone in [target]'s [parse_zone(target_zone)]...</span>",
Expand Down
2 changes: 2 additions & 0 deletions code/modules/surgery/organs/lungs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@
if(prob(20))
H.emote(pick("giggle", "laugh"))
SEND_SIGNAL(owner, COMSIG_ADD_MOOD_EVENT, "chemical_euphoria", /datum/mood_event/chemical_euphoria)
ADD_TRAIT(owner, TRAIT_SURGERY_PREPARED, GAS_NITROUS)
else
SEND_SIGNAL(owner, COMSIG_CLEAR_MOOD_EVENT, "chemical_euphoria")
REMOVE_TRAIT(owner, TRAIT_SURGERY_PREPARED, GAS_NITROUS)


// BZ
Expand Down
1 change: 1 addition & 0 deletions code/modules/surgery/remove_embedded_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
time = 32
accept_hand = 1
experience_given = MEDICAL_SKILL_MEDIUM
fuckup_damage = 0 // unrealistic but the alternatives are yanking the thing out or waiting for it to fall out which are both less intensive
var/obj/item/bodypart/L = null

/datum/surgery_step/remove_object/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
Expand Down
40 changes: 37 additions & 3 deletions code/modules/surgery/surgery_step.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#define SURGERY_FUCKUP_CHANCE 50
#define SURGERY_DRUNK_MOD 50

/datum/surgery_step
var/name
/// What tools can be used in this surgery, format is path = probability of success.
Expand All @@ -16,6 +19,11 @@
var/list/chems_needed = list()
/// If *chems_needed* requires all chems in the list or one chem in the list.
var/require_all_chems = TRUE
/// Base damage dealt on a surgery being done without anesthetics on SURGERY_FUCKUP_CHANCE percent chance
var/fuckup_damage = 10
/// Damage type fuckup_damage is dealt as
var/fuckup_damage_type = BRUTE
/// If cyborgs autopass success chance
var/silicons_obey_prob = FALSE
/// Sound played when the step is started
var/preop_sound
Expand Down Expand Up @@ -116,8 +124,15 @@
if(failure(user, target, target_zone, tool, surgery, fail_prob))
play_failure_sound(user, target, target_zone, tool, surgery)
advance = TRUE
if(chem_check_result)
return .(user, target, target_zone, tool, surgery, try_to_fail) //automatically re-attempt if failed for reason other than lack of required chemical
if(!HAS_TRAIT(target, TRAIT_SURGERY_PREPARED) && target.stat != DEAD && !IS_IN_STASIS(target) && fuckup_damage) //not under the effects of anaesthetics or a strong painkiller
if(!HAS_TRAIT(user, TRAIT_SURGEON)) // The patient needs more mouse bites
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abductors are currently the only thing that gets this, it also lets them do ANY surgery i think.

var/obj/item/bodypart/operated_bodypart = target.get_bodypart(target_zone) ? target.get_bodypart(target_zone) : target.get_bodypart(BODY_ZONE_CHEST)
if(operated_bodypart?.bodytype & BODYPART_ORGANIC) //robot limbs are built to be opened and stuff
commit_malpractice(user, target, target_zone, tool, surgery, advance)

if(chem_check_result && !advance)
return .(user, target, target_zone, tool, surgery, try_to_fail) //automatically re-attempt if failed for reason other than lack of required chemical

if(advance && !repeatable)
surgery.status++
if(surgery.status > surgery.steps.len)
Expand Down Expand Up @@ -225,10 +240,29 @@
chems += chemname
return english_list(chems, and_text = require_all_chems ? " and " : " or ")

//Replaces visible_message during operations so only people looking over the surgeon can tell what they're doing, allowing for shenanigans.
/// Replaces visible_message during operations so only people looking over the surgeon can tell what they're doing, allowing for shenanigans.
/datum/surgery_step/proc/display_results(mob/user, mob/living/carbon/target, self_message, detailed_message, vague_message, target_detailed = FALSE)
var/list/detailed_mobs = get_hearers_in_view(1, user) //Only the surgeon and people looking over his shoulder can see the operation clearly
if(!target_detailed)
detailed_mobs -= target //The patient can't see well what's going on, unless it's something like getting cut
user.visible_message(detailed_message, self_message, vision_distance = 1, ignored_mobs = target_detailed ? null : target)
user.visible_message(vague_message, "", ignored_mobs = detailed_mobs)

/// Lacking anesthetic, a surgery has a chance to cause Complications, which this handles
/datum/surgery_step/proc/commit_malpractice(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery, success)
var/ouchie_mod = 1
ouchie_mod *= clamp(1-target.drunkenness/SURGERY_DRUNK_MOD, 0, 1) //Drunkenness up to 50% (points? idk) will improve chances of avoiding horrible pain and suffering
if(target.stat == UNCONSCIOUS) //Being "normally" asleep (or getting choked out) will SLIGHTLY improve your chances since it's intuitive behavior barring access to anything else
ouchie_mod *= 0.8
if(!success) //Failing the surgery increases the chance of causing harm significantly
ouchie_mod *= 1.5
var/final_ouchie_chance = SURGERY_FUCKUP_CHANCE * ouchie_mod
if(!prob(final_ouchie_chance))
return
. = TRUE
user.visible_message("<span class='boldwarning'>[target] flinches, bumping [user]'s [tool ? tool.name : "hand"] into something important!</span>", "<span class='boldwarning'>[target] flinches, bumping your [tool ? tool.name : "hand"] into something important!</span>")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Span macros please

target.apply_damage(fuckup_damage, fuckup_damage_type, target_zone)
if(istype(target) && fuckup_damage_type == BRUTE)
var/obj/item/bodypart/BP = target.get_bodypart(check_zone(surgery.location))
if(BP)
BP.adjust_bleeding(min(fuckup_damage * BLOOD_LOSS_DAMAGE_BASE, BLOOD_LOSS_DAMAGE_MAXIMUM)) //Increased bleeding because you are getting stabbed on the inside
Loading