From 52430e2afed88a4d3e4dc36383f95e5b54290d0a Mon Sep 17 00:00:00 2001
From: Skies-Of-Blue <86762641+Skies-Of-Blue@users.noreply.github.com>
Date: Sun, 14 Jul 2024 01:29:45 -0700
Subject: [PATCH] SSD Indicators Will Be Real In 2020 (#3067)
## About The Pull Request
Loosely ports https://github.com/Skyrat-SS13/Skyrat13/pull/420, splicing
Novasector's SSD mechanics with our own.
When a player goes SSD, they initially remain awake and gain a Zz icon
above the character indicating they are away.
look here!
![nyaru goes
afk](https://github.com/shiptest-ss13/Shiptest/assets/86762641/98c61f04-7e65-4b24-a434-2769cc8a25f6)
After the player has been disconnected for three minutes, their
character will resume our current implementation of SSD behavior -
losing the Zz icon and falling asleep.
see?
![nyaru has been gone a while,
huh](https://github.com/shiptest-ss13/Shiptest/assets/86762641/8c51e05f-a41d-40af-a259-3a2dc7e7cca2)
This also adds the time spent SSD to examine text.
it's helpful!
![taking a
bit](https://github.com/shiptest-ss13/Shiptest/assets/86762641/15f91ab4-01b8-4d2f-8d8f-f5cf65f99213)
## Why It's Good For The Game
Our current implementation of being SSD leaves some things to be
desired. Whenever you disconnect, your character instantly passes out.
This can lead to:
- dropping critical items in dangerous situations, which is just sort of
the worst
- aghost causing your character to faint on the spot, something I've
heard more than a few admins complain about over the last few years
- players *reacting* to your character falling asleep as if it was a
planned thing within your control
- players moving your character to a bed, disrupting a scene you may
have been intent on continuing if it weren't for that pesky internet cut
- SSD players flooding the nearby chat with *snore out of nowhere
Of course, there's merit to our current implementation as well. Having
characters fall asleep keeps immersion clean, and having an SSD
Indicator can be immersion breaking. This is why I've opted to remove
the indicator and have characters fall asleep after a grace period of
three minutes. It allows players a time to reconnect, or admins time to
view what they needed to, without all of the disruptions listed above.
## Changelog
:cl:
add: an SSD Indicator for when you have been disconnected for less than
three minutes
balance: players will now remain awake for three minutes after
disconnecting, with a new SSD icon to boot!
balance: players SSD longer than three minutes will lose their icon and
fall asleep, much like the previous behavior
/:cl:
---
.../mob/living/carbon/human/examine.dm | 2 +-
code/modules/mob/living/carbon/life.dm | 9 ++++--
code/modules/mob/living/living.dm | 26 ++++++++++++++++++
icons/mob/ssd_indicator.dmi | Bin 0 -> 311 bytes
4 files changed, 33 insertions(+), 4 deletions(-)
create mode 100644 icons/mob/ssd_indicator.dmi
diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm
index 4430fc1da300..ffb2a704279e 100644
--- a/code/modules/mob/living/carbon/human/examine.dm
+++ b/code/modules/mob/living/carbon/human/examine.dm
@@ -330,7 +330,7 @@
if(!key)
msg += "[t_He] [t_is] totally catatonic. The stresses of life in deep-space must have been too much for [t_him]. Any recovery is unlikely.\n"
else if(!client)
- msg += "[t_He] appears to be suffering from SSD - Space Sleep Disorder. [t_He] may snap out of it at any time! Or maybe never. It's best to leave [t_him] be.\n"
+ msg += "[t_He] [t_has] been suffering from SSD - Space Sleep Disorder - for [trunc(((world.time - lastclienttime) / (1 MINUTES)))] minutes. [t_He] may snap out of it at any time! Or maybe never. It's best to leave [t_him] be.\n"
if (length(msg))
. += "[msg.Join("")]"
diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm
index 0fc21db37d8c..c5145600bbf8 100644
--- a/code/modules/mob/living/carbon/life.dm
+++ b/code/modules/mob/living/carbon/life.dm
@@ -25,9 +25,12 @@
if(.) //not dead
handle_blood()
- if(isLivingSSD())//if you're disconnected, you're going to sleep
- if(AmountSleeping() < 20)
- AdjustSleeping(20)//adjust every 10 seconds
+ if(isLivingSSD()) // If you're disconnected, you're going to sleep
+ if(trunc((world.time - lastclienttime) / (3 MINUTES)) > 0) // After a three minute grace period, your character will fall asleep
+ if(AmountSleeping() < 20)
+ AdjustSleeping(20) // Adjust every 10 seconds
+ if(ssd_indicator)
+ cut_overlay(GLOB.ssd_indicator_overlay) // Prevents chronically SSD players from breaking immersion
if(stat != DEAD)
var/bprv = handle_bodyparts()
diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm
index 5c499fe21029..269c74a837bd 100644
--- a/code/modules/mob/living/living.dm
+++ b/code/modules/mob/living/living.dm
@@ -1410,6 +1410,32 @@
if(player_logged && stat != DEAD)
return TRUE
+// The above code is kept to prevent old SSD behavior from breaking, while the code below is dedicated to the SSD Indicator
+
+GLOBAL_VAR_INIT(ssd_indicator_overlay, mutable_appearance('icons/mob/ssd_indicator.dmi', "default0", RUNECHAT_PLANE))
+
+/mob/living
+ var/ssd_indicator = FALSE
+ var/lastclienttime = 0
+
+/mob/living/proc/set_ssd_indicator(state)
+ if(state == ssd_indicator)
+ return
+ ssd_indicator = state
+ if(ssd_indicator && stat != DEAD)
+ add_overlay(GLOB.ssd_indicator_overlay)
+ else
+ cut_overlay(GLOB.ssd_indicator_overlay)
+
+/mob/living/Login()
+ . = ..()
+ set_ssd_indicator(FALSE)
+
+/mob/living/Logout()
+ . = ..()
+ lastclienttime = world.time
+ set_ssd_indicator(TRUE)
+
/mob/living/vv_get_header()
. = ..()
var/refid = REF(src)
diff --git a/icons/mob/ssd_indicator.dmi b/icons/mob/ssd_indicator.dmi
new file mode 100644
index 0000000000000000000000000000000000000000..3f7d100b6c67e725055ef21a964cbcbb113dca6c
GIT binary patch
literal 311
zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJ{HliLl8Vm$j4_H-qwSRlG-d9=Bb7470iYcT0gf&&Q+`DHA9k#g1nzrpr!Ksf{3onM7
zt~9UWyzn9_sPVDb6Mr#vp58;BU%iWc)ikAF(|NJtR<-gE?}Z*GC8T-FPfC$i=+qJG
z0$Sbd>Eaj?(fam^A>RQ74%UGE9|QLOf3o&PfT5_*@}|@3hKi<|{#~sdQzl#Xud3cD(Xnp937P3qET
zuudpu*edNf;oHvH1)_z&{9m+BU|`}