From b3aa4b75fa0646536bd9c297032710cd806d2d3b Mon Sep 17 00:00:00 2001 From: Killian <49700375+KillianKirilenko@users.noreply.github.com> Date: Sun, 26 May 2024 08:16:44 +0100 Subject: [PATCH] Auto-AFK (#15997) * disable ingame changelog notification * afk marker * Auto-AFK Marking * Update examine.dm * Auto-AFK Marking w/ Pref --- .../client/preference_setup/global/setting_datums.dm | 7 +++++++ code/modules/client/preferences_vr.dm | 11 +++++++++++ code/modules/mob/living/carbon/human/examine.dm | 4 +++- code/modules/mob/living/life.dm | 11 +++++++++++ code/modules/mob/living/living.dm | 2 ++ code/modules/mob/mob_defines.dm | 1 + 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/code/modules/client/preference_setup/global/setting_datums.dm b/code/modules/client/preference_setup/global/setting_datums.dm index 437337f326..6755472b72 100644 --- a/code/modules/client/preference_setup/global/setting_datums.dm +++ b/code/modules/client/preference_setup/global/setting_datums.dm @@ -394,6 +394,13 @@ var/list/_client_preferences_by_type enabled_description = "Extended" disabled_description = "Default" +/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 * diff --git a/code/modules/client/preferences_vr.dm b/code/modules/client/preferences_vr.dm index 79079354e4..ee3363dff5 100644 --- a/code/modules/client/preferences_vr.dm +++ b/code/modules/client/preferences_vr.dm @@ -163,3 +163,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.") diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm index 76083f014d..a7c8a2689b 100644 --- a/code/modules/mob/living/carbon/human/examine.dm +++ b/code/modules/mob/living/carbon/human/examine.dm @@ -310,7 +310,9 @@ else if(!client) msg += "[T.He] [T.is] [ssd_msg]." //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\]" diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index 319fcce97e..ef1072198e 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -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, "You have been idle for too long, and automatically marked as AFK.") + 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, "You have been automatically un-marked as AFK.") + 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() diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 0a41894b37..736fa0b79c 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -129,10 +129,12 @@ remove_status_indicator("afk") to_chat(src, "You are no longer marked as AFK.") away_from_keyboard = FALSE + manual_afk = FALSE else add_status_indicator("afk") to_chat(src, "You are now marked as AFK.") away_from_keyboard = TRUE + manual_afk = TRUE /mob/living/proc/updatehealth() if(status_flags & GODMODE) diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index c56a369ded..b3a0518111 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -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.