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 += "