From ccaa3a501dd3f254bb6d4c68613428ef71ca3f44 Mon Sep 17 00:00:00 2001 From: CHOMPStation2 <58959929+CHOMPStation2@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:59:17 -0700 Subject: [PATCH] [MIRROR] Toggle Sleep (#8471) Co-authored-by: Killian <49700375+KillianKirilenko@users.noreply.github.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> --- code/modules/mob/living/carbon/carbon.dm | 10 ---------- code/modules/mob/living/carbon/human/life.dm | 3 +-- code/modules/mob/living/life.dm | 16 ++++++++++++++++ code/modules/mob/living/living.dm | 13 +++++++++++++ 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 2a19e5120a..32290bd599 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -395,16 +395,6 @@ return method ? ">250" : "extremely weak and fast, patient's artery feels like a thread" // output for machines^ ^^^^^^^output for people^^^^^^^^^ -/mob/living/carbon/verb/mob_sleep() - set name = "Sleep" - set category = "IC.Game" //CHOMPEdit - - if(usr.sleeping) - to_chat(usr, span_red("You are already sleeping")) - return - if(tgui_alert(src,"You sure you want to sleep for a while?","Sleep",list("Yes","No")) == "Yes") - usr.AdjustSleeping(20) - /mob/living/carbon/Bump(atom/A) if(now_pushing) return diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index db488c89d9..878ddf546d 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1325,8 +1325,7 @@ if (mind) //Are they SSD? If so we'll keep them asleep but work off some of that sleep var in case of stoxin or similar. if(client || sleeping > 3) - AdjustSleeping(-1 * species.waking_speed) //CHOMPEdit - throw_alert("asleep", /obj/screen/alert/asleep) + handle_sleeping() if( prob(2) && health && !hal_crit && client ) spawn(0) emote("snore") diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index 476835329a..aac36198a1 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -295,3 +295,19 @@ //to_world("[src] in B:[round(brightness,0.1)] C:[round(current,0.1)] A2:[round(adjust_to,0.1)] D:[round(distance,0.01)] T:[round(distance*10 SECONDS,0.1)]") animate(dsoverlay, alpha = (adjust_to*255), time = (distance*10 SECONDS)) + +/mob/living/proc/handle_sleeping() + if(stat != DEAD && toggled_sleeping) + Sleeping(2) + if(sleeping) + //CHOMPEdit Start + if(iscarbon(src)) + var/mob/living/carbon/C = src + AdjustSleeping(-1 * C.species.waking_speed) + else + AdjustSleeping(-1) + //CHOMPEdit End + throw_alert("asleep", /obj/screen/alert/asleep) + else + clear_alert("asleep") + return sleeping diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index e54d4a5415..e39220357b 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1387,3 +1387,16 @@ . = ..() if(size_multiplier != 1 || icon_scale_x != DEFAULT_ICON_SCALE_X && center_offset > 0) update_transform(TRUE) + +/mob/living + var/toggled_sleeping = FALSE + +/mob/living/verb/mob_sleep() + set name = "Sleep" + set category = "IC.Game" //CHOMPEdit + if(!toggled_sleeping && alert(src, "Are you sure you wish to go to sleep? You will snooze until you use the Sleep verb again.", "Sleepy Time", "No", "Yes") == "No") + return + toggled_sleeping = !toggled_sleeping + to_chat(src, SPAN_NOTICE("You are [toggled_sleeping ? "now sleeping. Use the Sleep verb again to wake up" : "no longer sleeping"].")) + if(toggled_sleeping) + Sleeping(1)