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