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
View File
@@ -402,6 +402,13 @@
id = "sleeping"
tick_interval = 2 SECONDS
needs_update_stat = TRUE
/// Whether we decided to take a nap on our own.
/// As opposed to being hard knocked out with N2O or similar.
var/voluntary = FALSE
/datum/status_effect/incapacitating/sleeping/on_creation(mob/living/new_owner, set_duration, voluntary = FALSE)
..()
src.voluntary = voluntary
/datum/status_effect/incapacitating/sleeping/tick()
if(!iscarbon(owner))
+10 -6
View File
@@ -105,8 +105,9 @@
// HELPER PROCS //
//////////////////
/mob/living/proc/apply_status_effect(effect, ...) //applies a given status effect to this mob, returning the effect if it was successful
. = FALSE
/// Applies a given status effect to this mob, returning the effect if it was successful or null otherwise
/mob/living/proc/apply_status_effect(effect, ...)
. = null
var/datum/status_effect/S1 = effect
LAZYINITLIST(status_effects)
for(var/datum/status_effect/S in status_effects)
@@ -123,7 +124,8 @@
S1 = new effect(arguments)
. = S1
/mob/living/proc/remove_status_effect(effect, ...) //removes all of a given status effect from this mob, returning TRUE if at least one was removed
/// Removes all of a given status effect from this mob, returning TRUE if at least one was removed
/mob/living/proc/remove_status_effect(effect, ...)
. = FALSE
var/list/arguments = args.Copy(2)
if(status_effects)
@@ -133,15 +135,17 @@
qdel(S)
. = TRUE
/mob/living/proc/has_status_effect(effect) //returns the effect if the mob calling the proc owns the given status effect
. = FALSE
/// Returns the effect if the mob calling the proc owns the given status effect, or null otherwise
/mob/living/proc/has_status_effect(effect)
. = null
if(status_effects)
var/datum/status_effect/S1 = effect
for(var/datum/status_effect/S in status_effects)
if(initial(S1.id) == S.id)
return S
/mob/living/proc/has_status_effect_list(effect) //returns a list of effects with matching IDs that the mod owns; use for effects there can be multiple of
/// Returns a list of effects with matching IDs that the mod owns; use for effects there can be multiple of
/mob/living/proc/has_status_effect_list(effect)
. = list()
if(status_effects)
var/datum/status_effect/S1 = effect