Skip to content

Commit

Permalink
Surgery penalties for improvised or poor conditions compensated by sk…
Browse files Browse the repository at this point in the history
…ill (#5137)

# About the pull request

This PR re-adds the possibility of surgery step failures (the surgery
itself dictates whether failure prevents progress) depending on how
unsuitable the conditions or tool. However, it is now compensated by
surgery skill.

Current settings:

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/20dc72b2-a5f5-4d55-8b02-efdb7de0e480)

# Explain why it's good for the game

Using an improvised tool or poor conditions currently has negligible
effect on surgery that makes even the surgical_case not even worth its
single inventory slot. This probably doesn't do enough because its still
left up to chance, but ties together surgery skill level with the
ability to reliability perform surgery in bad conditions with improvised
tools.

# Testing Photographs and Procedure
The white messages displaying penalties and chance at each step were
just debugging messages that are not present in the PR.

<details>
<summary>1. Knife IB Surgery w/ Corpsman on roller</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/7dd05904-8f58-48ef-a6ea-d585108bb960)

</details>

<details>
<summary>2. Shard IB Surgery w/ Corpsman on roller</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/8624556b-b19e-4b7c-be50-4b122b8c5bf1)

</details>

<details>
<summary>3. Surgical_Case IB Surgery w/ Corpsman on roller</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/b71daaef-994f-442e-aad3-d883108899e3)

</details>

<details>
<summary>4/5/6. Shard IB Surgery w/ Corpsman on roller</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/025e8114-3575-4641-ab8e-a643706b59b3)

</details>

<details>
<summary>7. Shard IB Surgery w/ Corpsman on roller</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/1f16bccf-dafb-4d45-9e20-942122873542)

</details>

<details>
<summary>8. Shard IB Surgery w/ Surgeon on roller</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/b3505f68-3d1c-47fe-a86e-5f8259b9bba5)

</details>


# Changelog
:cl: Drathek
balance: Added the possibility of surgery steps failing based on tool
and surface suitability compensated by surgery skill.
/:cl:
  • Loading branch information
Drulikar committed Dec 18, 2023
1 parent 9c20de2 commit ec15414
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
9 changes: 9 additions & 0 deletions code/__DEFINES/surgery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ unless the surgical tool is completely unsuited to what it's being used for.*/
///A tool that's perfect for the surgery.
#define SURGERY_TOOL_MULT_IDEAL 1

///The (no) chance of failure for surgery because the correct tools/conditions are used or skill compensates
#define SURGERY_FAILURE_IMPOSSIBLE 0
///The chance of failure for surgery because the the tool/ground is SURGERY_TOOL_MULT_BAD_SUBSTITUTE/SURGERY_SURFACE_MULT_UNSUITED and skill can't compensate enough
#define SURGERY_FAILURE_UNLIKELY 5
///The chance of failure for surgery because the the tool/ground is SURGERY_TOOL_MULT_AWFUL/SURGERY_SURFACE_MULT_AWFUL and skill can't compensate enough
#define SURGERY_FAILURE_POSSIBLE 25
///The chance of failure for surgery because the the tool and ground is some combination worse than awful and skill can't compensate enough
#define SURGERY_FAILURE_LIKELY 50

//When initiating surgeries, these define their order when listed in initiation selector or 'you can't use this tool for anything, but could x, y, or z' messages.
///Appears first in lists. Ex. larva surgery, opening incision. Immediately life-threatening or initiation surgeries.
#define SURGERY_PRIORITY_MAXIMUM 5
Expand Down
34 changes: 33 additions & 1 deletion code/modules/surgery/surgery_steps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ affected_limb, or location vars. Also, in that case there may be a wait between
var/self_surgery
var/tool_modifier
var/surface_modifier
var/failure_penalties = 0

//Skill speed modifier.
step_duration *= user.get_skill_duration_multiplier(SKILL_SURGERY)
Expand Down Expand Up @@ -134,23 +135,43 @@ affected_limb, or location vars. Also, in that case there may be a wait between
message += "this tool is[pick("n't ideal", " not the best")]"
if(SURGERY_TOOL_MULT_SUBSTITUTE)
message += "this tool is[pick("n't suitable", " a bad fit", " difficult to use")]"
if(SURGERY_TOOL_MULT_BAD_SUBSTITUTE, SURGERY_TOOL_MULT_AWFUL)
if(SURGERY_TOOL_MULT_BAD_SUBSTITUTE)
message += "this tool is [pick("awful", "barely usable")]"
failure_penalties += 1
if(SURGERY_TOOL_MULT_AWFUL)
message += "this tool is [pick("awful", "barely usable")]"
failure_penalties += 2

switch(surface_modifier)
if(SURGERY_SURFACE_MULT_ADEQUATE)
message += "[pick("it isn't easy, working", "it's tricky to perform complex surgeries", "this would be quicker if you weren't working")] [pick("in the field", "under these conditions", "without a proper surgical theatre")]"
if(SURGERY_SURFACE_MULT_UNSUITED)
message += "[pick("it's difficult to work", "it's slow going, working", "you need to take your time")] in these [pick("primitive", "rough", "crude")] conditions"
failure_penalties += 1
if(SURGERY_SURFACE_MULT_AWFUL)
message += "[pick("you need to work slowly and carefully", "you need to be very careful", "this is delicate work, especially")] [pick("in these", "under such")] [pick("terrible", "awful", "utterly unsuitable")] conditions"
failure_penalties += 2

if(length(message))
to_chat(user, SPAN_WARNING("[capitalize(english_list(message, final_comma_text = ","))]."))

var/advance //Whether to continue to the next step afterwards.
var/pain_failure_chance = max(0, (target.pain?.feels_pain ? surgery.pain_reduction_required - target.pain.reduction_pain : 0) * 2 - human_modifiers["pain_reduction"]) //Each extra pain unit increases the chance by 2

// Skill compensation for difficult conditions/tools
if(skillcheck(user, SKILL_SURGERY, SKILL_SURGERY_EXPERT))
failure_penalties -= 2 // will ultimately be -3
if(skillcheck(user, SKILL_SURGERY, SKILL_SURGERY_TRAINED))
failure_penalties -= 1

var/surgery_failure_chance = SURGERY_FAILURE_IMPOSSIBLE
if(failure_penalties == 1)
surgery_failure_chance = SURGERY_FAILURE_UNLIKELY
else if(failure_penalties == 2)
surgery_failure_chance = SURGERY_FAILURE_POSSIBLE
else if(failure_penalties > 2)
surgery_failure_chance = SURGERY_FAILURE_LIKELY

play_preop_sound(user, target, target_zone, tool, surgery)

if(tool?.flags_item & ANIMATED_SURGICAL_TOOL) //If we have an animated tool sprite, run it while we do any do_afters.
Expand All @@ -171,6 +192,17 @@ affected_limb, or location vars. Also, in that case there may be a wait between
target.emote("pain")
play_failure_sound(user, target, target_zone, tool, surgery)

else if(prob(surgery_failure_chance))
do_after(user, max(rand(step_duration * 0.1, step_duration * 0.5), 0.5), INTERRUPT_ALL|INTERRUPT_DIFF_INTENT,
BUSY_ICON_FRIENDLY, target, INTERRUPT_MOVED, BUSY_ICON_MEDICAL) //Brief do_after so that the interrupt doesn't happen instantly.
user.visible_message(SPAN_DANGER("[user] is struggling to perform surgery."),
SPAN_DANGER("You are struggling to perform the surgery with these tools and conditions!"))
if(failure(user, target, target_zone, tool, tool_type, surgery)) //Failure returns TRUE if the step should complete anyway.
advance = TRUE
target.emote("pain")
play_failure_sound(user, target, target_zone, tool, surgery)
msg_admin_niche("[user] failed a [surgery] step on [target] because of [failure_penalties] failure possibility penalties ([surgery_failure_chance]%)")

else //Help intent.
if(do_after(user, step_duration, INTERRUPT_ALL|INTERRUPT_DIFF_INTENT, BUSY_ICON_FRIENDLY,target,INTERRUPT_MOVED,BUSY_ICON_MEDICAL))
success(user, target, target_zone, tool, tool_type, surgery)
Expand Down

0 comments on commit ec15414

Please sign in to comment.