Emergency shuttle is aware of security level (#78271)

## About The Pull Request

The emergency shuttle maintains its security level coefficient and does
the calculation instead of outside procs that aren't aware of what alert
it was when the shuttle was first called.

If the shuttle auto-call timer should be capped at the current security
level timer, that can be done in a different PR.

## Why It's Good For The Game

Fixes https://github.com/tgstation/tgstation/issues/78159

## Changelog

🆑 LT3
fix: Emergency shuttle should correctly scale timer up/down when
changing security levels
/🆑
This commit is contained in:
lessthanthree
2023-09-13 23:06:22 +01:00
committed by GitHub
parent 06ea966fc0
commit 29cb4b5f35
6 changed files with 35 additions and 22 deletions
+8
View File
@@ -63,6 +63,14 @@
#define ENGINE_COEFF_MAX 2
#define ENGINE_DEFAULT_MAXSPEED_ENGINES 5
// Alert level related
#define ALERT_COEFF_AUTOEVAC_NORMAL 2.5
#define ALERT_COEFF_GREEN 2
#define ALERT_COEFF_BLUE 1
#define ALERT_COEFF_RED 0.5
#define ALERT_COEFF_AUTOEVAC_CRITICAL 0.4
#define ALERT_COEFF_DELTA 0.25
//Docking error flags
#define DOCKING_SUCCESS 0
#define DOCKING_BLOCKED (1<<0)
+1 -5
View File
@@ -41,8 +41,6 @@ SUBSYSTEM_DEF(security_level)
announce_security_level(selected_level) // We want to announce BEFORE updating to the new level
var/old_shuttle_call_time_mod = current_security_level.shuttle_call_time_mod // Need this before we set the new one
SSsecurity_level.current_security_level = selected_level
if(selected_level.looping_sound)
@@ -52,9 +50,7 @@ SUBSYSTEM_DEF(security_level)
can_fire = FALSE
if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL) // By god this is absolutely shit
old_shuttle_call_time_mod = 1 / old_shuttle_call_time_mod
SSshuttle.emergency.modTimer(old_shuttle_call_time_mod)
SSshuttle.emergency.modTimer(selected_level.shuttle_call_time_mod)
SSshuttle.emergency.alert_coeff_change(selected_level.shuttle_call_time_mod)
SEND_SIGNAL(src, COMSIG_SECURITY_LEVEL_CHANGED, selected_level.number_level)
SSnightshift.check_nightshift()
+3 -3
View File
@@ -262,8 +262,8 @@ SUBSYSTEM_DEF(shuttle)
log_shuttle("[msg] Alive: [alive], Roundstart: [total], Threshold: [threshold]")
emergency_no_recall = TRUE
priority_announce("Catastrophic casualties detected: crisis shuttle protocols activated - jamming recall signals across all frequencies.")
if(emergency.timeLeft(1) > emergency_call_time * 0.4)
emergency.request(null, set_coefficient = 0.4)
if(emergency.timeLeft(1) > emergency_call_time * ALERT_COEFF_AUTOEVAC_CRITICAL)
emergency.request(null, set_coefficient = ALERT_COEFF_AUTOEVAC_CRITICAL)
/datum/controller/subsystem/shuttle/proc/block_recall(lockout_timer)
if(admin_emergency_no_recall)
@@ -457,7 +457,7 @@ SUBSYSTEM_DEF(shuttle)
if(callShuttle)
if(EMERGENCY_IDLE_OR_RECALLED)
emergency.request(null, set_coefficient = 2.5)
emergency.request(null, set_coefficient = ALERT_COEFF_AUTOEVAC_NORMAL)
log_shuttle("There is no means of calling the emergency shuttle anymore. Shuttle automatically called.")
message_admins("All the communications consoles were destroyed and all AIs are inactive. Shuttle called.")
@@ -45,7 +45,7 @@
sound = 'sound/misc/notice2.ogg' // Friendly beep
number_level = SEC_LEVEL_GREEN
lowering_to_configuration_key = /datum/config_entry/string/alert_green
shuttle_call_time_mod = 2
shuttle_call_time_mod = ALERT_COEFF_GREEN
/**
* BLUE
@@ -58,7 +58,7 @@
number_level = SEC_LEVEL_BLUE
lowering_to_configuration_key = /datum/config_entry/string/alert_blue_downto
elevating_to_configuration_key = /datum/config_entry/string/alert_blue_upto
shuttle_call_time_mod = 1
shuttle_call_time_mod = ALERT_COEFF_BLUE
/**
* RED
@@ -71,7 +71,7 @@
number_level = SEC_LEVEL_RED
lowering_to_configuration_key = /datum/config_entry/string/alert_red_downto
elevating_to_configuration_key = /datum/config_entry/string/alert_red_upto
shuttle_call_time_mod = 0.5
shuttle_call_time_mod = ALERT_COEFF_RED
/**
* DELTA
@@ -83,4 +83,4 @@
sound = 'sound/misc/airraid.ogg' // Air alarm to signify importance
number_level = SEC_LEVEL_DELTA
elevating_to_configuration_key = /datum/config_entry/string/alert_delta
shuttle_call_time_mod = 0.25
shuttle_call_time_mod = ALERT_COEFF_DELTA
+3 -9
View File
@@ -339,15 +339,9 @@
/obj/docking_port/mobile/emergency/request(obj/docking_port/stationary/S, area/signal_origin, reason, red_alert, set_coefficient=null)
if(!isnum(set_coefficient))
var/security_num = SSsecurity_level.get_current_level_as_number()
switch(security_num)
if(SEC_LEVEL_GREEN)
set_coefficient = 2
if(SEC_LEVEL_BLUE)
set_coefficient = 1
else
set_coefficient = 0.5
var/call_time = SSshuttle.emergency_call_time * set_coefficient * engine_coeff
set_coefficient = SSsecurity_level.current_security_level.shuttle_call_time_mod
alert_coeff = set_coefficient
var/call_time = SSshuttle.emergency_call_time * alert_coeff * engine_coeff
switch(mode)
// The shuttle can not normally be called while "recalling", so
// if this proc is called, it's via admin fiat
+16 -1
View File
@@ -439,7 +439,8 @@
var/current_engine_power = 0
///How much engine power (thrust) the shuttle starts with at mapload.
var/initial_engine_power = 0
///Speed multiplier based on station alert level
var/alert_coeff = ALERT_COEFF_BLUE
///used as a timer (if you want time left to complete move, use timeLeft proc)
var/timer
var/last_timer_length
@@ -927,6 +928,20 @@
last_timer_length *= multiple
setTimer(time_remaining)
/obj/docking_port/mobile/proc/alert_coeff_change(new_coeff)
if(isnull(new_coeff))
return
var/time_multiplier = new_coeff / alert_coeff
var/time_remaining = timer - world.time
if(time_remaining < 0 || !last_timer_length)
return
time_remaining *= time_multiplier
last_timer_length *= time_multiplier
alert_coeff = new_coeff
setTimer(time_remaining)
/obj/docking_port/mobile/proc/invertTimer()
if(!last_timer_length)
return