From 60b2a46879a18f47a752b174e4c5fb2453ebbe0d Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4GD565\\LME" Date: Thu, 9 Mar 2023 21:19:56 -0800 Subject: [PATCH 1/7] fix hijack cooldown, implement emag rework --- code/modules/shuttle/emergency.dm | 49 +++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index 47af8f005001a..2d207164bbcb4 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -1,5 +1,6 @@ #define TIME_LEFT (SSshuttle.emergency.timeLeft()) #define ENGINES_START_TIME 100 +#define EMAG_MULTIPLIER 2 //speed at which emag reduces time, increase to reduce time more. #define ENGINES_STARTED (SSshuttle.emergency.mode == SHUTTLE_IGNITING) #define IS_DOCKED (SSshuttle.emergency.mode == SHUTTLE_DOCKED || (ENGINES_STARTED)) #define SHUTTLE_CONSOLE_ACTION_DELAY (5 SECONDS) @@ -25,12 +26,17 @@ var/list/acted_recently = list() var/hijack_last_stage_increase = 0 SECONDS var/hijack_stage_time = 5 SECONDS - var/hijack_stage_cooldown = 5 SECONDS + var/hijack_stage_cooldown = 2 SECONDS var/hijack_flight_time_increase = 30 SECONDS var/hijack_completion_flight_time_set = 10 SECONDS //How long in deciseconds to set shuttle's timer after hijack is done. var/hijack_hacking = FALSE var/hijack_announce = TRUE + var/emag_cooldown = 5 SECONDS + var/emag_last_used = 0 //no spamming the emag ya dingus + var/emag_attempts = 0 + var/emag_required_attempts = 0 + /obj/machinery/computer/emergency_shuttle/examine(mob/user) . = ..() if(hijack_announce) @@ -176,14 +182,25 @@ return . // Check to see if we've reached criteria for early launch - if((authorized.len >= auth_need) || (obj_flags & EMAGGED)) - // shuttle timers use 1/10th seconds internally - SSshuttle.emergency.setTimer(ENGINES_START_TIME) - var/system_error = obj_flags & EMAGGED ? "SYSTEM ERROR:" : null + if(obj_flags & EMAGGED) //Check for emagging first because we want the silly console authorizations + if(emag_attempts <= emag_required_attempts) + return + var/current_time = TIME_LEFT + SSshuttle.emergency.setTimer(current_time / EMAG_MULTIPLIER * 10) minor_announce("The emergency shuttle will launch in \ - [TIME_LEFT] seconds", system_error, alert=TRUE) + [TIME_LEFT] seconds", "SYSTEM ERROR:", alert=TRUE) + emag_required_attempts++ . = TRUE + else if(authorized.len >= auth_need) + SSshuttle.emergency.setTimer(ENGINES_START_TIME) //A proper authorization would give the okay to get the hell outta there + minor_announce("The emergency shuttle will launch in \ + [TIME_LEFT] seconds", "Emergency timer authorized", alert=TRUE) + . = TRUE + + + + /obj/machinery/computer/emergency_shuttle/proc/increase_hijack_stage() var/obj/docking_port/mobile/emergency/shuttle = SSshuttle.emergency shuttle.hijack_status++ @@ -216,7 +233,7 @@ if(SSshuttle.emergency.hijack_status >= HIJACKED) to_chat(user, "The emergency shuttle is already loaded with a corrupt navigational payload. What more do you want from it?") return - if(hijack_last_stage_increase >= world.time + hijack_stage_cooldown) + if(hijack_last_stage_increase <= world.time + hijack_stage_cooldown) say("Error - Catastrophic software error detected. Input is currently on timeout.") return hijack_hacking = TRUE @@ -255,15 +272,27 @@ minor_announce(scramble_message_replace_chars(msg, replaceprob = 10), "Emergency Shuttle", TRUE) /obj/machinery/computer/emergency_shuttle/emag_act(mob/user) + var/time = TIME_LEFT // How did you even get on the shuttle before it go to the station? if(!IS_DOCKED) + to_chat(user, "The shuttle is already in transit!") return - if((obj_flags & EMAGGED) || ENGINES_STARTED) //SYSTEM ERROR: THE SHUTTLE WILL LA-SYSTEM ERROR: THE SHUTTLE WILL LA-SYSTEM ERROR: THE SHUTTLE WILL LAUNCH IN 10 SECONDS + if(ENGINES_STARTED) //SYSTEM ERROR: THE SHUTTLE WILL LA-SYSTEM ERROR: THE SHUTTLE WILL LA-SYSTEM ERROR: THE SHUTTLE WILL LAUNCH IN 10 SECONDS to_chat(user, "The shuttle is already launching!") return - var/time = TIME_LEFT + if((obj_flags & EMAGGED)) + if(emag_last_used <= world.time + emag_cooldown) //if emagging is on cooldown + say("Error - Catastrophic software error detected. Input is currently on timeout.") + return + + emag_attempts++ + emag_last_used = world.time + message_admins("[ADMIN_LOOKUPFLW(user.client)] has emagged the emergency shuttle [emag_attempts] times, [time] seconds before launch.") + log_game("[key_name(user)] has emagged the emergency shuttle in [COORD(src)] [time] seconds before launch. This has occurred [emag_attempts] times.") + return + message_admins("[ADMIN_LOOKUPFLW(user.client)] has emagged the emergency shuttle, [time] seconds before launch.") log_game("[key_name(user)] has emagged the emergency shuttle in [COORD(src)] [time] seconds before launch.") @@ -280,6 +309,8 @@ authorized += ID + emag_last_used = world.time + emag_attempts++ process(SSMACHINES_DT) /obj/machinery/computer/emergency_shuttle/Destroy() From 53df8ead7c700b5e043ebc3fb12f0d1eabf36f48 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4GD565\\LME" Date: Thu, 9 Mar 2023 21:35:38 -0800 Subject: [PATCH 2/7] reduce emag cooldown --- code/modules/shuttle/emergency.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index 2d207164bbcb4..5dddf0409a773 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -32,8 +32,8 @@ var/hijack_hacking = FALSE var/hijack_announce = TRUE - var/emag_cooldown = 5 SECONDS - var/emag_last_used = 0 //no spamming the emag ya dingus + var/emag_cooldown = 2 SECONDS //no spamming the emag ya dingus + var/emag_last_used = 0 var/emag_attempts = 0 var/emag_required_attempts = 0 @@ -186,7 +186,7 @@ if(emag_attempts <= emag_required_attempts) return var/current_time = TIME_LEFT - SSshuttle.emergency.setTimer(current_time / EMAG_MULTIPLIER * 10) + SSshuttle.emergency.setTimer(current_time > ENGINES_START_TIME? current_time / EMAG_MULTIPLIER * 10 : ENGINES_START_TIME) minor_announce("The emergency shuttle will launch in \ [TIME_LEFT] seconds", "SYSTEM ERROR:", alert=TRUE) emag_required_attempts++ From 3c793a9b6476b0a7d830fbf20d7b9c08452812fa Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4GD565\\LME" Date: Thu, 9 Mar 2023 21:40:23 -0800 Subject: [PATCH 3/7] moves multiplier to var, adds some notes --- code/modules/shuttle/emergency.dm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index 5dddf0409a773..4c03e31cb3c50 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -1,6 +1,6 @@ #define TIME_LEFT (SSshuttle.emergency.timeLeft()) #define ENGINES_START_TIME 100 -#define EMAG_MULTIPLIER 2 //speed at which emag reduces time, increase to reduce time more. + #define ENGINES_STARTED (SSshuttle.emergency.mode == SHUTTLE_IGNITING) #define IS_DOCKED (SSshuttle.emergency.mode == SHUTTLE_DOCKED || (ENGINES_STARTED)) #define SHUTTLE_CONSOLE_ACTION_DELAY (5 SECONDS) @@ -32,6 +32,8 @@ var/hijack_hacking = FALSE var/hijack_announce = TRUE + + var/emag_multiplier 2 //speed at which emag reduces time, increase to reduce time more. var/emag_cooldown = 2 SECONDS //no spamming the emag ya dingus var/emag_last_used = 0 var/emag_attempts = 0 @@ -186,7 +188,8 @@ if(emag_attempts <= emag_required_attempts) return var/current_time = TIME_LEFT - SSshuttle.emergency.setTimer(current_time > ENGINES_START_TIME? current_time / EMAG_MULTIPLIER * 10 : ENGINES_START_TIME) + //if it would take it below 10 seconds, make it 10 seconds. Multiplies by 10 because byond + SSshuttle.emergency.setTimer(current_time > ENGINES_START_TIME? current_time / emag_multiplier * 10 : ENGINES_START_TIME) minor_announce("The emergency shuttle will launch in \ [TIME_LEFT] seconds", "SYSTEM ERROR:", alert=TRUE) emag_required_attempts++ From 03d201f296311d7d55a51c1f68e2e68654568f1a Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4GD565\\LME" Date: Thu, 9 Mar 2023 21:45:28 -0800 Subject: [PATCH 4/7] typo --- code/modules/shuttle/emergency.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index 4c03e31cb3c50..f64feaa3682fe 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -33,7 +33,7 @@ var/hijack_announce = TRUE - var/emag_multiplier 2 //speed at which emag reduces time, increase to reduce time more. + var/emag_multiplier = 2 //speed at which emag reduces time, increase to reduce time more. var/emag_cooldown = 2 SECONDS //no spamming the emag ya dingus var/emag_last_used = 0 var/emag_attempts = 0 From 50067f72433e52baf67ae941692dbae5af4408d0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4GD565\\LME" Date: Thu, 9 Mar 2023 22:00:49 -0800 Subject: [PATCH 5/7] math --- code/modules/shuttle/emergency.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index f64feaa3682fe..373a55cfa648c 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -236,7 +236,7 @@ if(SSshuttle.emergency.hijack_status >= HIJACKED) to_chat(user, "The emergency shuttle is already loaded with a corrupt navigational payload. What more do you want from it?") return - if(hijack_last_stage_increase <= world.time + hijack_stage_cooldown) + if((hijack_last_stage_increase + hijack_stage_cooldown) >= world.time) say("Error - Catastrophic software error detected. Input is currently on timeout.") return hijack_hacking = TRUE @@ -286,7 +286,7 @@ return if((obj_flags & EMAGGED)) - if(emag_last_used <= world.time + emag_cooldown) //if emagging is on cooldown + if((emag_last_used + emag_cooldown) >= world.time) //if emagging is on cooldown say("Error - Catastrophic software error detected. Input is currently on timeout.") return From 14cf4b39ba9a1de2efc919c85d496308cf720301 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4GD565\\LME" Date: Thu, 9 Mar 2023 22:49:07 -0800 Subject: [PATCH 6/7] more math :) --- code/modules/shuttle/emergency.dm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index 373a55cfa648c..a186dff503dc9 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -187,9 +187,12 @@ if(obj_flags & EMAGGED) //Check for emagging first because we want the silly console authorizations if(emag_attempts <= emag_required_attempts) return - var/current_time = TIME_LEFT - //if it would take it below 10 seconds, make it 10 seconds. Multiplies by 10 because byond - SSshuttle.emergency.setTimer(current_time > ENGINES_START_TIME? current_time / emag_multiplier * 10 : ENGINES_START_TIME) + var/reduced_time = TIME_LEFT / emag_multiplier * 10 + say("reduced time = [reduced_time]. engines_start_time = [ENGINES_START_TIME]") + if(reduced_time < ENGINES_START_TIME) + SSshuttle.emergency.setTimer(ENGINES_START_TIME) + else + SSshuttle.emergency.setTimer(reduced_time) minor_announce("The emergency shuttle will launch in \ [TIME_LEFT] seconds", "SYSTEM ERROR:", alert=TRUE) emag_required_attempts++ From 3e790b4b5528033b81ef1a1b781af04911d28d91 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4GD565\\LME" Date: Thu, 9 Mar 2023 22:49:36 -0800 Subject: [PATCH 7/7] remove debug stuff --- code/modules/shuttle/emergency.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index a186dff503dc9..fbb6836c77d59 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -188,7 +188,6 @@ if(emag_attempts <= emag_required_attempts) return var/reduced_time = TIME_LEFT / emag_multiplier * 10 - say("reduced time = [reduced_time]. engines_start_time = [ENGINES_START_TIME]") if(reduced_time < ENGINES_START_TIME) SSshuttle.emergency.setTimer(ENGINES_START_TIME) else