Surgery on napping people wakes them up. (#17661)

* Surgery on napping people wakes them up.

* Fix a potential afreeze issue

* Code review

* has_status_effect now returns `null` if no status effect

* move `voluntary` to be an arg to New

* Update code/modules/surgery/helpers.dm

Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com>

* And this other IsSleeping call

Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com>
This commit is contained in:
moxian
2022-06-25 00:20:24 +01:00
committed by GitHub
co-authored by Charlie
parent 5f58a80d8a
commit f4bd86cc5e
6 changed files with 44 additions and 13 deletions
+7 -1
View File
@@ -118,7 +118,13 @@
/proc/get_pain_modifier(mob/living/carbon/human/M) //returns modfier to make surgery harder if patient is conscious and feels pain
if(M.stat) //stat=0 if CONSCIOUS, 1=UNCONSCIOUS and 2=DEAD. Operating on dead people is easy, too. Just sleeping won't work, though.
if(M.stat == DEAD) // Operating on dead people is easy
return 1
var/datum/status_effect/incapacitating/sleeping/S = M.IsSleeping()
if(M.stat == UNCONSCIOUS && !(S?.voluntary))
// Either unconscious due to something other than sleep,
// or "sleeping" due to being hard knocked out (N2O or similar), rather than just napping.
// Either way, not easily woken up.
return 1
if(HAS_TRAIT(M, TRAIT_NOPAIN))//if you don't feel pain, you can hold still
return 1
+10 -1
View File
@@ -114,7 +114,16 @@
if(!ispath(surgery.steps[surgery.status], /datum/surgery_step/robotics))//Repairing robotic limbs doesn't hurt, and neither does cutting someone out of a rig
if(ishuman(target))
var/mob/living/carbon/human/H = target //typecast to human
prob_chance *= get_pain_modifier(H)//operating on conscious people is hard.
var/pain_mod = get_pain_modifier(H)
var/datum/status_effect/incapacitating/sleeping/S = H.IsSleeping()
if(S?.voluntary)
H.SetSleeping(0) // wake up people who are napping through the surgery
if(pain_mod < 0.95)
to_chat(H, "<span class='danger'>The surgery on your [target_zone] is agonizingly painful, and wrecks you out of your shallow slumber!</span>")
else
// Still wake people up, but they shouldn't be as alarmed.
to_chat(H, "<span class='warning'>The surgery being performed on your [target_zone] wakes you up.</span>")
prob_chance *= pain_mod //operating on conscious people is hard.
if(prob(prob_chance) || isrobot(user))
if(end_step(user, target, target_zone, tool, surgery))