diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index 316330eca41..1e4692b7e3b 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -268,9 +268,7 @@ CREATE TABLE `player` ( `atklog` smallint(4) DEFAULT '0', `fuid` bigint(20) NULL DEFAULT NULL, `fupdate` smallint(4) NULL DEFAULT '0', - `AFK_WATCH_warn_minutes` tinyint(2) NOT NULL DEFAULT '0', - `AFK_WATCH_cryo_minutes` tinyint(1) NOT NULL DEFAULT '0', - 'AFK_WATCH_antag' tinyint(1) NOT NULL DEFAULT '0', + `afk_watch` tinyint(1) NOT NULL DEFAULT '0', `parallax` tinyint(1) DEFAULT '8', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index 94d34935d99..aa5d5895e56 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -267,9 +267,7 @@ CREATE TABLE `SS13_player` ( `atklog` smallint(4) DEFAULT '0', `fuid` bigint(20) NULL DEFAULT NULL, `fupdate` smallint(4) NULL DEFAULT '0', - `AFK_WATCH_warn_minutes` tinyint(2) NOT NULL DEFAULT '0', - `AFK_WATCH_cryo_minutes` tinyint(1) NOT NULL DEFAULT '0', - 'AFK_WATCH_antag' tinyint(1) NOT NULL DEFAULT '0', + `afk_watch` tinyint(1) NOT NULL DEFAULT '0', `parallax` tinyint(1) DEFAULT '8', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) diff --git a/SQL/updates/9-10.sql b/SQL/updates/9-10.sql deleted file mode 100644 index 88e3ebda2b5..00000000000 --- a/SQL/updates/9-10.sql +++ /dev/null @@ -1,7 +0,0 @@ -# Change afk_watch to AFK_WATCH_warn_minutes, AFK_WATCH_cryo_minutes and AFK_WATCH_antag which gives users the option to make use of the AFK watcher subsystem -ALTER TABLE `player` ADD `AFK_WATCH_warn_minutes` tinyint(1) NOT NULL DEFAULT '0' AFTER `afk_watch`; -UPDATE `player` SET `AFK_WATCH_warn_minutes` = 5 WHERE `afk_watch` = 1; -ALTER TABLE `player` ADD `AFK_WATCH_cryo_minutes` tinyint(1) NOT NULL DEFAULT '0' AFTER `AFK_WATCH_warn_minutes`; -UPDATE `player` SET `AFK_WATCH_cryo_minutes` = 2 WHERE `afk_watch` = 1; -ALTER TABLE `player` ADD `AFK_WATCH_antag` tinyint(1) NOT NULL DEFAULT '0' AFTER `AFK_WATCH_cryo_minutes`; -ALTER TABLE `player` DROP COLUMN `afk_watch`; \ No newline at end of file diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 4a60f8d7438..10dbb653453 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -72,7 +72,9 @@ var/assistantlimit = 0 //enables assistant limiting var/assistantratio = 2 //how many assistants to security members - // The AFK subsystem will not be activated if the below config value is equal or less than 0 + // The AFK subsystem will not be activated if any of the below config values are equal or less than 0 + var/warn_afk_minimum = 0 // How long till you get a warning while being AFK + var/auto_cryo_afk = 0 // How long till you get put into cryo when you're AFK var/auto_despawn_afk = 0 // How long till you actually despawn in cryo when you're AFK (Not ssd so not automatic) var/auto_cryo_ssd_mins = 0 @@ -315,7 +317,11 @@ if("shadowling_max_age") config.shadowling_max_age = text2num(value) - + + if("warn_afk_minimum") + config.warn_afk_minimum = text2num(value) + if("auto_cryo_afk") + config.auto_cryo_afk = text2num(value) if("auto_despawn_afk") config.auto_despawn_afk = text2num(value) diff --git a/code/controllers/subsystem/afk.dm b/code/controllers/subsystem/afk.dm index 94e2de34b2a..13c843b75dd 100644 --- a/code/controllers/subsystem/afk.dm +++ b/code/controllers/subsystem/afk.dm @@ -1,15 +1,22 @@ -#define AFK_WARNED 1 -#define AFK_CRYOD 2 +#define AFK_WARNED 1 +#define AFK_CRYOD 2 +#define AFK_ADMINS_WARNED 2 + +#define AFK_FAST_CRYO_WARN 3 +#define AFK_FAST_CRYO_CRYO 5 SUBSYSTEM_DEF(afk) name = "AFK Watcher" wait = 300 flags = SS_BACKGROUND var/list/afk_players = list() // Associative list. ckey as key and AFK state as value + var/list/non_cryo_antags = list( \ + SPECIAL_ROLE_ABDUCTOR_AGENT, SPECIAL_ROLE_ABDUCTOR_SCIENTIST, \ + SPECIAL_ROLE_SHADOWLING, SPECIAL_ROLE_WIZARD, SPECIAL_ROLE_WIZARD_APPRENTICE, SPECIAL_ROLE_NUKEOPS) /datum/controller/subsystem/afk/Initialize() - if(config.auto_despawn_afk <= 0) + if(config.warn_afk_minimum <= 0 || config.auto_cryo_afk <= 0 || config.auto_despawn_afk <= 0) flags |= SS_NO_FIRE /datum/controller/subsystem/afk/fire() @@ -19,22 +26,22 @@ SUBSYSTEM_DEF(afk) continue var/turf/T - var/afk_warn_min - // Only players and players with the AFK watch enabled - // No dead, unconcious, restrained, people without jobs, people on other Z levels than the station or antags (if they have the preference option off) - if(!H.client || !(afk_warn_min = H.client.prefs.AFK_WATCH_warn_minutes) || !H.mind || \ - H.stat || H.restrained() || !H.job || (H.mind.special_role && !H.client.prefs.AFK_WATCH_antag) || \ - !is_station_level((T = get_turf(H)).z)) // Assign the turf as last. Small optimization + // Only players who have a mind + // No dead, unconcious, restrained, people without jobs, people on other Z levels than the station + if(!H.client || !H.mind || H.stat || H.restrained() || \ + !H.job || !is_station_level((T = get_turf(H)).z)) // Assign the turf as last. Small optimization if(afk_players[H.ckey]) toRemove += H.ckey continue var/mins_afk = round(H.client.inactivity / 600) + var/afk_warn_min = H.client.prefs.afk_fast_cryo ? AFK_FAST_CRYO_WARN : config.warn_afk_minimum if(mins_afk < afk_warn_min) if(afk_players[H.ckey]) toRemove += H.ckey continue - var/afk_cryo_min = H.client.prefs.AFK_WATCH_cryo_minutes + afk_warn_min + + var/afk_cryo_min = H.client.prefs.afk_fast_cryo ? AFK_FAST_CRYO_CRYO : config.auto_cryo_afk if(!afk_players[H.ckey]) afk_players[H.ckey] = AFK_WARNED warn(H, "You are AFK for [mins_afk] minutes. You will be cryod after [afk_cryo_min] total minutes and fully despawned after another [config.auto_despawn_afk] minutes. Please move or click in game if you want to avoid being despawned.") @@ -45,16 +52,21 @@ SUBSYSTEM_DEF(afk) if(A.fast_despawn) toRemove += H.ckey warn(H, "You are have been despawned after being AFK for [mins_afk] minutes. You have been despawned instantly due to you being in a secure area.") - msg_admins(H, mins_afk, T, "forcefully despawned", "AFK in a fast despawn area") + log_admins(H, mins_afk, T, "despawned", "AFK in a fast despawn area") force_cryo_human(H) - else if(cryo_ssd(H)) - afk_players[H.ckey] = AFK_CRYOD - msg_admins(H, mins_afk, T, "put into cryostorage") - warn(H, "You are AFK for [mins_afk] minutes and have been moved to cryostorage. After being AFK for another [config.auto_despawn_afk] minutes you will be fully despawned. Please eject yourself (right click, eject) out of the cryostorage if you want to avoid being despawned.") + else + if(can_cryo_antag(H)) + if(cryo_ssd(H)) + afk_players[H.ckey] = AFK_CRYOD + log_admins(H, mins_afk, T, "put into cryostorage") + warn(H, "You are AFK for [mins_afk] minutes and have been moved to cryostorage. After being AFK for another [config.auto_despawn_afk] minutes you will be fully despawned. Please eject yourself (right click, eject) out of the cryostorage if you want to avoid being despawned.") + else + message_admins("[key_name_admin(H)] at ([get_area(T).name] [ADMIN_JMP(T)]) is AFK for [mins_afk] and can't be cryod due to it's antag status: ([H.mind.special_role]).") + afk_players[H.ckey] = AFK_ADMINS_WARNED else if(mins_afk >= config.auto_despawn_afk + afk_cryo_min) var/obj/machinery/cryopod/P = H.loc - msg_admins(H, mins_afk, T, "forcefully despawned") + log_admins(H, mins_afk, T, "despawned") warn(H, "You are have been despawned after being AFK for [mins_afk] minutes.") toRemove += H.ckey P.despawn_occupant() @@ -67,9 +79,11 @@ SUBSYSTEM_DEF(afk) if(H.client) window_flash(H.client) -/datum/controller/subsystem/afk/proc/msg_admins(mob/living/carbon/human/H, mins_afk, turf/location, action, info) +/datum/controller/subsystem/afk/proc/can_cryo_antag(mob/living/carbon/human/H) + return !(H.mind.special_role in non_cryo_antags) + +/datum/controller/subsystem/afk/proc/log_admins(mob/living/carbon/human/H, mins_afk, turf/location, action, info) log_admin("[key_name(H)] has been [action] by the AFK Watcher subsystem after being AFK for [mins_afk] minutes.[info ? " Extra info:" + info : ""]") - message_admins("[key_name_admin(H)] at ([get_area(location).name] [ADMIN_JMP(location)]) has been [action] by the AFK Watcher subsystem after being AFK for [mins_afk] minutes.[info ? " Extra info:" + info : ""]") /datum/controller/subsystem/afk/proc/removeFromWatchList(list/toRemove) for(var/C in toRemove) @@ -79,4 +93,7 @@ SUBSYSTEM_DEF(afk) break #undef AFK_WARNED -#undef AFK_CRYOD \ No newline at end of file +#undef AFK_CRYOD +#undef AFK_ADMINS_WARNED +#undef AFK_FAST_CRYO_WARN +#undef AFK_FAST_CRYO_CRYO \ No newline at end of file diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index 6559a808c41..2ba3580980f 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -93,9 +93,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts var/clientfps = 0 var/atklog = ATKLOG_ALL var/fuid // forum userid - var/AFK_WATCH_warn_minutes = 0 // Number of minutes after which the player gets warned - var/AFK_WATCH_cryo_minutes = 0 // Number of minutes after (after the warning) which the player gets cryod - var/AFK_WATCH_antag = FALSE // If you will cryo when you have a special role + var/afk_fast_cryo = FALSE // If they want to be put into cryo the fast way by the AFK subsystem //ghostly preferences var/ghost_anonsay = 0 @@ -444,7 +442,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "

General Settings

" if(user.client.holder) dat += "Adminhelp sound: [(sound & SOUND_ADMINHELP)?"On":"Off"]
" - dat += "AFK Cryoing: [(AFK_WATCH_warn_minutes) ? "On ([AFK_WATCH_warn_minutes], [AFK_WATCH_cryo_minutes], [AFK_WATCH_antag ? "Y" : "N"])" : "Off"]
" + dat += "AFK Fast Cryoing: [(afk_fast_cryo) ? "On" : "Off"]
" dat += "Ambient Occlusion: [toggles & AMBIENT_OCCLUSION ? "Enabled" : "Disabled"]
" dat += "Attack Animations: [(show_ghostitem_attack) ? "Yes" : "No"]
" @@ -2002,23 +2000,8 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("winflash") windowflashing = !windowflashing - if("afk_watch") - var/afk_new = input(user, "Select a new amount of minutes after which you get warned for being AFK, between 0 and 10 (0 will deactivate)", UI_style_alpha) as num - if(afk_new == 0) - // deactivate the system - AFK_WATCH_warn_minutes = 0 - AFK_WATCH_cryo_minutes = 0 - AFK_WATCH_antag = FALSE - else - if(!afk_new | !(afk_new <= 10 && afk_new >= 1)) return - AFK_WATCH_warn_minutes = afk_new - afk_new = input(user, "Select a new amount of minutes after which you get cryod for being AFK, between 1 and 5", UI_style_alpha) as num - if(!afk_new | !(afk_new <= 5 && afk_new >= 1)) - AFK_WATCH_cryo_minutes = AFK_WATCH_cryo_minutes ? AFK_WATCH_cryo_minutes : 2 // Return to prior value or default to 2 - AFK_WATCH_antag = AFK_WATCH_antag ? AFK_WATCH_antag : FALSE - else - AFK_WATCH_cryo_minutes = afk_new - AFK_WATCH_antag = alert(user, "Do you want to activate the AFK system when you have a special status? (Think of antag, mindslaved, ERT etc)", "Antag activation", "Yes", "No") == "Yes" + if("afk_fast_cryo") + afk_fast_cryo = alert(user, "Would you like to be qualified for the fast cryoing? Being AFK for 5 minutes will result in cryoing then (instead of [config.auto_cryo_afk])", "Fast cryoing", "Yes", "No") == "Yes" if("UIcolor") var/UI_style_color_new = input(user, "Choose your UI color, dark colors are not recommended!", UI_style_color) as color|null diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index 14055980620..2a30c3dd359 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -20,9 +20,7 @@ clientfps, atklog, fuid, - AFK_WATCH_warn_minutes, - AFK_WATCH_cryo_minutes, - AFK_WATCH_antag, + afk_watch, parallax FROM [format_table_name("player")] WHERE ckey='[C.ckey]'"} @@ -56,10 +54,8 @@ clientfps = text2num(query.item[17]) atklog = text2num(query.item[18]) fuid = text2num(query.item[19]) - AFK_WATCH_warn_minutes = text2num(query.item[20]) - AFK_WATCH_cryo_minutes = text2num(query.item[21]) - AFK_WATCH_antag = text2num(query.item[22]) - parallax = text2num(query.item[23]) + afk_fast_cryo = text2num(query.item[20]) + parallax = text2num(query.item[21]) //Sanitize ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor)) @@ -80,9 +76,7 @@ clientfps = sanitize_integer(clientfps, 0, 1000, initial(clientfps)) atklog = sanitize_integer(atklog, 0, 100, initial(atklog)) fuid = sanitize_integer(fuid, 0, 10000000, initial(fuid)) - AFK_WATCH_warn_minutes = sanitize_integer(AFK_WATCH_warn_minutes, 0, 10, initial(AFK_WATCH_warn_minutes)) - AFK_WATCH_cryo_minutes = sanitize_integer(AFK_WATCH_cryo_minutes, 0, 5, initial(AFK_WATCH_cryo_minutes)) - AFK_WATCH_antag = sanitize_integer(AFK_WATCH_antag, 0, 1, initial(AFK_WATCH_antag)) + afk_fast_cryo = sanitize_integer(afk_fast_cryo, 0, 1, initial(afk_fast_cryo)) parallax = sanitize_integer(parallax, 0, 16, initial(parallax)) return 1 @@ -114,9 +108,7 @@ ghost_anonsay='[ghost_anonsay]', clientfps='[clientfps]', atklog='[atklog]', - AFK_WATCH_warn_minutes='[AFK_WATCH_warn_minutes]', - AFK_WATCH_cryo_minutes='[AFK_WATCH_cryo_minutes]', - AFK_WATCH_antag='[AFK_WATCH_antag]', + afk_watch='[afk_fast_cryo]', parallax='[parallax]' WHERE ckey='[C.ckey]'"} ) diff --git a/config/example/config.txt b/config/example/config.txt index dbf7b0be050..865a95fb307 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -88,7 +88,13 @@ LOG_ADMINWARN ## Amount of minutes that a person has to be AFK before he'll be listed on the "List AFK players" verb #LIST_AFK_MINIMUM 5 -## Number of minutes that a person has to be AFK in the cryo tubes before he will be despawned by the AFK subsystem. Leave this 0 to prevent the subsystem from activating +## Amount of minutes that a person has to be AFK before he will be warned by the AFK subsystem. Leave this 0 to prevent the subsystem from activating. With fast cryoing this will be 3 minutes +WARN_AFK_MINIMUM 0 + +## Amount of minutes that a person has to be AFK before he will be cryod by the AFK subsystem. Leave this 0 to prevent the subsystem from activating. With fast cryoing this will be 5 minutes +AUTO_CRYO_AFK 0 + +## Amount of minutes that a person has to be AFK before he will be despawned by the AFK subsystem. Leave this 0 to prevent the subsystem from activating. This is the timer after they get put into cryo AUTO_DESPAWN_AFK 0 ## probablities for game modes chosen in "secret" and "random" modes