[MIRROR] Auto-AFK (#8450)

Co-authored-by: Killian <49700375+KillianKirilenko@users.noreply.github.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2
2024-06-03 19:53:51 -07:00
committed by GitHub
parent e6de58400f
commit df317e82e1
6 changed files with 35 additions and 1 deletions

View File

@@ -416,6 +416,13 @@ var/list/_client_preferences_by_type
disabled_description = "Silent"
// CHOMPAdd End
/datum/client_preference/auto_afk
description = "Automatic AFK Status"
key = "AUTO_AFK"
enabled_by_default = TRUE
enabled_description = "Automatic"
disabled_description = "Manual Only"
/********************
* Staff Preferences *

View File

@@ -167,3 +167,14 @@
toggle_preference(pref_path)
to_chat(src, "The cooldown between pain messages for minor (under 20/5 injury. Multi-limb injuries are still faster) is now [ (is_preference_enabled(pref_path)) ? "extended" : "default"].")
/client/verb/toggle_automatic_afk()
set name = "Toggle Automatic AFK"
set category = "Preferences"
set desc = "When enabled, causes you to be automatically marked as AFK if you are idle for too long."
var/pref_path = /datum/client_preference/auto_afk
toggle_preference(pref_path)
to_chat(src, "You will [ (is_preference_enabled(pref_path)) ? "now" : "not"] be automatically marked as AFK if you are idle for ten minutes or more.")

View File

@@ -311,7 +311,9 @@
else if(!client)
msg += "<span class='deadsay'>[T.He] [T.is] [ssd_msg].</span>"
//VOREStation Add Start
if(client && ((client.inactivity / 10) / 60 > 10)) //10 Minutes
if(away_from_keyboard && manual_afk)
msg += "\[Away From Keyboard for [round((client.inactivity/10)/60)] minutes\]"
else if(client && ((client.inactivity / 10) / 60 > 10)) //10 Minutes
msg += "\[Inactive for [round((client.inactivity/10)/60)] minutes\]"
else if(disconnect_time)
msg += "\[Disconnected/ghosted [round(((world.realtime - disconnect_time)/10)/60)] minutes ago\]"

View File

@@ -37,6 +37,17 @@
. = 1
if(client)
var/idle_limit = 10 MINUTES
if(client.inactivity >= idle_limit && !away_from_keyboard && src.is_preference_enabled(/datum/client_preference/auto_afk)) //if we're not already afk and we've been idle too long, and we have automarking enabled... then automark it
add_status_indicator("afk")
to_chat(src, "<span class='notice'>You have been idle for too long, and automatically marked as AFK.</span>")
away_from_keyboard = TRUE
else if(away_from_keyboard && client.inactivity < idle_limit && !manual_afk) //if we're afk but we do something AND we weren't manually flagged as afk, unmark it
remove_status_indicator("afk")
to_chat(src, "<span class='notice'>You have been automatically un-marked as AFK.</span>")
away_from_keyboard = FALSE
//Chemicals in the body, this is moved over here so that blood can be added after death
handle_chemicals_in_body()

View File

@@ -125,10 +125,12 @@
remove_status_indicator("afk")
to_chat(src, "<span class='notice'>You are no longer marked as AFK.</span>")
away_from_keyboard = FALSE
manual_afk = FALSE
else
add_status_indicator("afk")
to_chat(src, "<span class='notice'>You are now marked as AFK.</span>")
away_from_keyboard = TRUE
manual_afk = TRUE
/mob/living/proc/updatehealth()
if(status_flags & GODMODE)

View File

@@ -157,6 +157,7 @@
var/can_be_antagged = FALSE // To prevent pAIs/mice/etc from getting antag in autotraitor and future auto- modes. Uses inheritance instead of a bunch of typechecks.
var/away_from_keyboard = FALSE //are we at, or away, from our keyboard?
var/manual_afk = FALSE //did we set afk manually or was it automatic?
//Generic list for proc holders. Only way I can see to enable certain verbs/procs. Should be modified if needed.
var/proc_holder_list[] = list()//Right now unused.