From b17a770299ca7fedc22ef4fc74ec7f82981572d1 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 6 Oct 2017 22:34:40 -0400 Subject: [PATCH 1/2] Config option to automatically call the shuttle for high casualties (#31309) --- .../configuration/entries/game_options.dm | 5 ++++ code/controllers/subsystem/shuttle.dm | 28 ++++++++++++++++++- config/game_options.txt | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index 106804a576..cb4109436c 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -264,3 +264,8 @@ CONFIG_DEF(number/bombcap) GLOB.MAX_EX_LIGHT_RANGE = value GLOB.MAX_EX_FLASH_RANGE = value GLOB.MAX_EX_FLAME_RANGE = value + +CONFIG_DEF(number/emergency_shuttle_autocall_threshold) + min_val = 0 + max_val = 1 + integer = FALSE diff --git a/code/controllers/subsystem/shuttle.dm b/code/controllers/subsystem/shuttle.dm index 705f0dbd81..9973a43430 100644 --- a/code/controllers/subsystem/shuttle.dm +++ b/code/controllers/subsystem/shuttle.dm @@ -136,6 +136,7 @@ SUBSYSTEM_DEF(shuttle) if(changed_transit) color_space() #endif + CheckAutoEvac() while(transit_requesters.len) var/requester = popleft(transit_requesters) @@ -148,7 +149,32 @@ SUBSYSTEM_DEF(shuttle) var/obj/docking_port/mobile/M = requester M.transit_failure() if(MC_TICK_CHECK) - return + break + +/datum/controller/subsystem/shuttle/proc/CheckAutoEvac() + if(emergencyNoEscape || emergencyNoRecall || !emergency) + return + + var/threshold = CONFIG_GET(number/emergency_shuttle_autocall_threshold) + if(!threshold) + return + + var/alive = 0 + for(var/I in GLOB.player_list) + var/mob/M = I + if(M.stat != DEAD) + ++alive + + var/total = GLOB.joined_player_list.len + + if(alive / total <= threshold) + var/msg = "Automatically dispatching shuttle due to crew death." + message_admins(msg) + log_game("[msg] Alive: [alive], Roundstart: [total], Threshold: [threshold]") + emergencyNoRecall = TRUE + priority_announce("Catastrophic casualties detected: crisis shuttle protocols activated - jamming recall signals across all frequencies.") + if(emergency.timeLeft(1) > emergencyCallTime * 0.4) + emergency.request(null, set_coefficient = 0.4) /datum/controller/subsystem/shuttle/proc/getShuttle(id) for(var/obj/docking_port/mobile/M in mobile) diff --git a/config/game_options.txt b/config/game_options.txt index 77e33fa873..b3b6024d20 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -496,3 +496,5 @@ ARRIVALS_SHUTTLE_DOCK_WINDOW 55 MICE_ROUNDSTART 10 +## If the percentage of players alive (doesn't count conversions) drops below this threshold the emergency shuttle will be forcefully called (provided it can be) +#EMERGENCY_SHUTTLE_AUTOCALL_THRESHOLD 0.2