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
+8 -2
View File
@@ -382,7 +382,7 @@
S = apply_status_effect(STATUS_EFFECT_SLEEPING, amount)
return S
/mob/living/proc/SetSleeping(amount, ignore_canstun = FALSE)
/mob/living/proc/SetSleeping(amount, ignore_canstun = FALSE, voluntary = FALSE)
if(frozen) // If the mob has been admin frozen, sleeping should not be changeable
return
if(status_flags & GODMODE)
@@ -393,13 +393,19 @@
if(S)
S.duration = amount + world.time
else if(amount > 0)
S = apply_status_effect(STATUS_EFFECT_SLEEPING, amount)
S = apply_status_effect(STATUS_EFFECT_SLEEPING, amount, voluntary)
if(!voluntary && S)
// Only set it one way (true => false)
// Otherwise if we are hard knocked out, and then try to nap, we'd be
// treated as "just lightly napping" and woken up by trivial stuff.
S.voluntary = FALSE
return S
/mob/living/proc/PermaSleeping() /// used for admin freezing.
var/datum/status_effect/incapacitating/sleeping/S = IsSleeping()
if(S)
S.duration = -1
S.voluntary = FALSE
else
S = apply_status_effect(STATUS_EFFECT_SLEEPING, -1)
return S
+2 -3
View File
@@ -460,9 +460,8 @@ GLOBAL_LIST_INIT(intents, list(INTENT_HELP,INTENT_DISARM,INTENT_GRAB,INTENT_HARM
if(IsSleeping())
to_chat(src, "<span class='notice'>You are already sleeping.</span>")
return
else
if(alert(src, "You sure you want to sleep for a while?", "Sleep", "Yes", "No") == "Yes")
SetSleeping(40 SECONDS) //Short nap
if(alert(src, "You sure you want to sleep for a while?", "Sleep", "Yes", "No") == "Yes")
SetSleeping(40 SECONDS, voluntary = TRUE) //Short nap
/mob/living/verb/lay_down()
set name = "Rest"