From d0c679a2f4624d49da35f50f1fe3e0afa098bfc1 Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+AnArgonianLizardThatStealsPRs@users.noreply.github.com> Date: Sun, 22 Oct 2023 16:14:10 +0300 Subject: [PATCH] [MIRROR] Overclock safety setting for Gygax [MDB IGNORE] (#208) * Overclock safety setting for Gygax (#79101) --------- Co-authored-by: Andrew --- code/modules/vehicles/mecha/_mecha.dm | 18 ++++++- code/modules/vehicles/mecha/combat/gygax.dm | 2 + code/modules/vehicles/mecha/mecha_actions.dm | 1 - code/modules/vehicles/mecha/mecha_ui.dm | 7 +-- code/modules/vehicles/mecha/working/ripley.dm | 4 +- .../tgui/interfaces/Mecha/AlertPane.tsx | 52 +++++++++++++------ tgui/packages/tgui/interfaces/Mecha/data.ts | 28 +++++----- 7 files changed, 78 insertions(+), 34 deletions(-) diff --git a/code/modules/vehicles/mecha/_mecha.dm b/code/modules/vehicles/mecha/_mecha.dm index 0652c554b8a..573e09f347d 100644 --- a/code/modules/vehicles/mecha/_mecha.dm +++ b/code/modules/vehicles/mecha/_mecha.dm @@ -173,6 +173,10 @@ var/overclock_temp = 0 ///Temperature threshold at which actuators may start causing internal damage var/overclock_temp_danger = 15 + ///Whether the mech has an option to enable safe overclocking + var/overclock_safety_available = FALSE + ///Whether the overclocking turns off automatically when overheated + var/overclock_safety = FALSE //Bool for zoom on/off var/zoom_mode = FALSE @@ -520,6 +524,9 @@ overclock_temp = min(overclock_temp + seconds_per_tick, overclock_temp_danger * 2) if(overclock_temp < overclock_temp_danger) return + if(overclock_temp >= overclock_temp_danger && overclock_safety) + toggle_overclock(FALSE) + return var/damage_chance = 100 * ((overclock_temp - overclock_temp_danger) / (overclock_temp_danger * 2)) if(SPT_PROB(damage_chance, seconds_per_tick)) do_sparks(5, TRUE, src) @@ -811,6 +818,15 @@ else overclock_mode = !overclock_mode log_message("Toggled overclocking.", LOG_MECHA) + + for(var/mob/occupant as anything in occupants) + var/datum/action/act = locate(/datum/action/vehicle/sealed/mecha/mech_overclock) in occupant.actions + if(!act) + continue + act.button_icon_state = "mech_overload_[overclock_mode ? "on" : "off"]" + balloon_alert(occupant, "overclock [overclock_mode ? "on":"off"]") + act.build_all_button_icons() + if(overclock_mode) movedelay = movedelay / overclock_coeff visible_message(span_notice("[src] starts heating up, making humming sounds.")) @@ -857,5 +873,5 @@ act.button_icon_state = "mech_lights_on" else act.button_icon_state = "mech_lights_off" - balloon_alert(occupant, "toggled lights [mecha_flags & LIGHTS_ON ? "on":"off"]") + balloon_alert(occupant, "lights [mecha_flags & LIGHTS_ON ? "on":"off"]") act.build_all_button_icons() diff --git a/code/modules/vehicles/mecha/combat/gygax.dm b/code/modules/vehicles/mecha/combat/gygax.dm index 204739cd7fc..223ab66ca31 100644 --- a/code/modules/vehicles/mecha/combat/gygax.dm +++ b/code/modules/vehicles/mecha/combat/gygax.dm @@ -22,6 +22,8 @@ ) step_energy_drain = 4 can_use_overclock = TRUE + overclock_safety_available = TRUE + overclock_safety = TRUE /datum/armor/mecha_gygax melee = 25 diff --git a/code/modules/vehicles/mecha/mecha_actions.dm b/code/modules/vehicles/mecha/mecha_actions.dm index f42e89aa1d5..43301c19605 100644 --- a/code/modules/vehicles/mecha/mecha_actions.dm +++ b/code/modules/vehicles/mecha/mecha_actions.dm @@ -152,6 +152,5 @@ if(!owner || !chassis || !(owner in chassis.occupants)) return chassis.toggle_overclock(forced_state) - chassis.balloon_alert(owner, chassis.overclock_mode ? "started overclocking" : "stopped overclocking") button_icon_state = "mech_overload_[chassis.overclock_mode ? "on" : "off"]" build_all_button_icons() diff --git a/code/modules/vehicles/mecha/mecha_ui.dm b/code/modules/vehicles/mecha/mecha_ui.dm index 815770875ea..76d8b4613fa 100644 --- a/code/modules/vehicles/mecha/mecha_ui.dm +++ b/code/modules/vehicles/mecha/mecha_ui.dm @@ -82,6 +82,8 @@ data["internal_damage"] = internal_damage data["can_use_overclock"] = can_use_overclock + data["overclock_safety_available"] = overclock_safety_available + data["overclock_safety"] = overclock_safety data["overclock_mode"] = overclock_mode data["overclock_temp_percentage"] = overclock_temp / overclock_temp_danger @@ -210,9 +212,8 @@ toggle_lights(user = usr) if("toggle_overclock") toggle_overclock() - var/datum/action/act = locate(/datum/action/vehicle/sealed/mecha/mech_overclock) in usr.actions - act.button_icon_state = "mech_overload_[overclock_mode ? "on" : "off"]" - act.build_all_button_icons() + if("toggle_overclock_safety") + overclock_safety = !overclock_safety if("repair_int_damage") try_repair_int_damage(usr, params["flag"]) return FALSE diff --git a/code/modules/vehicles/mecha/working/ripley.dm b/code/modules/vehicles/mecha/working/ripley.dm index 9db12624125..d2b13d48d26 100644 --- a/code/modules/vehicles/mecha/working/ripley.dm +++ b/code/modules/vehicles/mecha/working/ripley.dm @@ -266,11 +266,11 @@ GLOBAL_DATUM(cargo_ripley, /obj/vehicle/sealed/mecha/ripley/cargo) var/turf/T = get_turf(loc) if(lavaland_equipment_pressure_check(T)) - movedelay = fast_pressure_step_in + movedelay = !overclock_mode ? fast_pressure_step_in : fast_pressure_step_in / overclock_coeff for(var/obj/item/mecha_parts/mecha_equipment/drill/drill in flat_equipment) drill.equip_cooldown = initial(drill.equip_cooldown) * 0.5 else - movedelay = slow_pressure_step_in + movedelay = !overclock_mode ? slow_pressure_step_in : slow_pressure_step_in / overclock_coeff for(var/obj/item/mecha_parts/mecha_equipment/drill/drill in flat_equipment) drill.equip_cooldown = initial(drill.equip_cooldown) diff --git a/tgui/packages/tgui/interfaces/Mecha/AlertPane.tsx b/tgui/packages/tgui/interfaces/Mecha/AlertPane.tsx index c29c60b8bc3..953e1a6b5f8 100644 --- a/tgui/packages/tgui/interfaces/Mecha/AlertPane.tsx +++ b/tgui/packages/tgui/interfaces/Mecha/AlertPane.tsx @@ -27,6 +27,8 @@ export const AlertPane = (props, context) => { scanmod_rating, capacitor_rating, can_use_overclock, + overclock_safety_available, + overclock_safety, overclock_mode, overclock_temp_percentage, } = data; @@ -35,21 +37,41 @@ export const AlertPane = (props, context) => { title="Status" buttons={ (!!overclock_mode || !!can_use_overclock) && ( - + <> + + {!!overclock_safety_available && ( +