From dcd88dedfa196ac2b55e4d9d97be9464248e7681 Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Wed, 20 Apr 2022 17:57:42 +0200
Subject: [PATCH] [MIRROR] Reworks Mech Extinguisher to be utility equipment,
related balance changes. [MDB IGNORE] (#12929)
* Reworks Mech Extinguisher to be utility equipment, related balance changes. (#66058)
The extinguisher is now utility rather than an active equipment mount. This means it no longer takes up one of a mech's limited hardpoint slots.
Mech extinguishers now extinguish in a 3x3 grid around (and including) themselves.
Mech extinguishers now use 80u of water, and store a maximum of 400u. This adds up to five uses before needing a refil.
* Reworks Mech Extinguisher to be utility equipment, related balance changes.
Co-authored-by: zxaber <37497534+zxaber@users.noreply.github.com>
---
.../mecha/equipment/tools/work_tools.dm | 87 ++++++++++---------
.../tgui/interfaces/Mecha/ArmPane.tsx | 3 -
.../interfaces/Mecha/UtilityModulesPane.tsx | 52 ++++++++++-
3 files changed, 98 insertions(+), 44 deletions(-)
diff --git a/code/modules/vehicles/mecha/equipment/tools/work_tools.dm b/code/modules/vehicles/mecha/equipment/tools/work_tools.dm
index b8d54e0ce3f..65228afa382 100644
--- a/code/modules/vehicles/mecha/equipment/tools/work_tools.dm
+++ b/code/modules/vehicles/mecha/equipment/tools/work_tools.dm
@@ -161,67 +161,74 @@
icon_state = "mecha_exting"
equip_cooldown = 5
energy_drain = 0
+ equipment_slot = MECHA_UTILITY
range = MECHA_MELEE|MECHA_RANGED
mech_flags = EXOSUIT_MODULE_WORKING
- var/sprays_left = 0
+ ///Minimum amount of reagent needed to activate.
+ var/required_amount = 80
/obj/item/mecha_parts/mecha_equipment/extinguisher/Initialize(mapload)
. = ..()
- create_reagents(1000)
- reagents.add_reagent(/datum/reagent/water, 1000)
+ create_reagents(400)
+ reagents.add_reagent(/datum/reagent/water, 400)
-/obj/item/mecha_parts/mecha_equipment/extinguisher/action(mob/source, atom/target, list/modifiers)
- if(!action_checks(target) || get_dist(chassis, target)>3)
+/obj/item/mecha_parts/mecha_equipment/extinguisher/proc/spray_extinguisher(mob/user)
+ if(reagents.total_volume < required_amount)
return
- if(istype(target, /obj/structure/reagent_dispensers/watertank) && get_dist(chassis,target) <= 1)
- var/obj/structure/reagent_dispensers/watertank/WT = target
- WT.reagents.trans_to(src, 1000)
- to_chat(source, "[icon2html(src, source)][span_notice("Extinguisher refilled.")]")
- playsound(chassis, 'sound/effects/refill.ogg', 50, TRUE, -6)
- return
+ for(var/turf/targetturf in RANGE_TURFS(1, chassis))
+ var/obj/effect/particle_effect/water/extinguisher/water = new /obj/effect/particle_effect/water/extinguisher(targetturf)
+ var/datum/reagents/water_reagents = new /datum/reagents(required_amount/8) //required_amount/8, because the water usage is split between eight sprays. As of this comment, required_amount/8 = 10u each.
+ water.reagents = water_reagents
+ water_reagents.my_atom = water
+ reagents.trans_to(water, required_amount/8)
+ water.move_at(get_step(chassis, get_dir(targetturf, chassis)), 2, 4) //Target is the tile opposite of the mech as the starting turf.
- if(reagents.total_volume <= 0)
- return
playsound(chassis, 'sound/effects/extinguish.ogg', 75, TRUE, -3)
- sprays_left += 5
- add_hiddenprint(source) //log prints so admins can figure out who touched it last.
- log_combat(source, target, "fired an extinguisher at")
- spray_extinguisher(target)
- return ..()
-/obj/item/mecha_parts/mecha_equipment/extinguisher/proc/spray_extinguisher(atom/target)
- var/direction = get_dir(chassis, target)
- var/turf/T1 = get_turf(target)
- var/turf/T2 = get_step(T1,turn(direction, 90))
- var/turf/T3 = get_step(T1,turn(direction, -90))
- var/list/targets = list(T1,T2,T3)
-
- var/obj/effect/particle_effect/water/extinguisher/water = new /obj/effect/particle_effect/water/extinguisher(get_turf(chassis))
- var/datum/reagents/water_reagents = new /datum/reagents(5)
- water.reagents = water_reagents
- water_reagents.my_atom = water
- reagents.trans_to(water, 1)
-
- var/delay = 2
- var/datum/move_loop/our_loop = water.move_at(pick(targets), delay, 4)
- RegisterSignal(our_loop, COMSIG_PARENT_QDELETING, .proc/water_finished_moving)
-
-/obj/item/mecha_parts/mecha_equipment/extinguisher/proc/water_finished_moving(datum/move_loop/has_target/source)
- SIGNAL_HANDLER
- sprays_left--
- if(!sprays_left)
+/**
+ * Handles attemted refills of the extinguisher.
+ *
+ * The mech can only refill an extinguisher that is in front of it.
+ * Only water tank objects can be used.
+ */
+/obj/item/mecha_parts/mecha_equipment/extinguisher/proc/attempt_refill(mob/user)
+ if(reagents.maximum_volume == reagents.total_volume)
return
- extinguish(source.target)
+ var/turf/in_front = get_step(chassis, chassis.dir)
+ var/obj/structure/reagent_dispensers/watertank/refill_source = locate(/obj/structure/reagent_dispensers/watertank) in in_front
+ if(!refill_source)
+ to_chat(user, span_notice("Refill failed. No compatible tank found."))
+ return
+ if(!refill_source.reagents?.total_volume)
+ to_chat(user, span_notice("Refill failed. Source tank empty."))
+ return
+
+ refill_source.reagents.trans_to(src, reagents.maximum_volume)
+ playsound(chassis, 'sound/effects/refill.ogg', 50, TRUE, -6)
/obj/item/mecha_parts/mecha_equipment/extinguisher/get_snowflake_data()
return list(
"snowflake_id" = MECHA_SNOWFLAKE_ID_EXTINGUISHER,
"reagents" = reagents.total_volume,
"total_reagents" = reagents.maximum_volume,
+ "minimum_requ" = required_amount,
)
+/obj/item/mecha_parts/mecha_equipment/extinguisher/ui_act(action, list/params)
+ . = ..()
+ if(.)
+ return TRUE
+ switch(action)
+ if("activate")
+ spray_extinguisher(usr)
+ return TRUE
+ if("refill")
+ attempt_refill(usr)
+ return TRUE
+
+
/obj/item/mecha_parts/mecha_equipment/extinguisher/can_attach(obj/vehicle/sealed/mecha/M, attach_right = FALSE)
. = ..()
if(!.)
diff --git a/tgui/packages/tgui/interfaces/Mecha/ArmPane.tsx b/tgui/packages/tgui/interfaces/Mecha/ArmPane.tsx
index 429da85366a..4475519b220 100644
--- a/tgui/packages/tgui/interfaces/Mecha/ArmPane.tsx
+++ b/tgui/packages/tgui/interfaces/Mecha/ArmPane.tsx
@@ -117,7 +117,6 @@ const BallisticStats = (props: {weapon: MechWeapon}, context) => {
const MECHA_SNOWFLAKE_ID_SLEEPER = "sleeper_snowflake";
const MECHA_SNOWFLAKE_ID_SYRINGE = "syringe_snowflake";
const MECHA_SNOWFLAKE_ID_MODE = "mode_snowflake";
-const MECHA_SNOWFLAKE_ID_EXTINGUISHER = "extinguisher_snowflake";
// Handles all the snowflake buttons and whatever
const Snowflake = (props: {weapon: MechWeapon}, context) => {
@@ -129,8 +128,6 @@ const Snowflake = (props: {weapon: MechWeapon}, context) => {
return ;
case MECHA_SNOWFLAKE_ID_SYRINGE:
return ;
- case MECHA_SNOWFLAKE_ID_EXTINGUISHER:
- return ;
case MECHA_SNOWFLAKE_ID_MODE:
return ;
default:
diff --git a/tgui/packages/tgui/interfaces/Mecha/UtilityModulesPane.tsx b/tgui/packages/tgui/interfaces/Mecha/UtilityModulesPane.tsx
index 8a3451cbb04..5c20c597313 100644
--- a/tgui/packages/tgui/interfaces/Mecha/UtilityModulesPane.tsx
+++ b/tgui/packages/tgui/interfaces/Mecha/UtilityModulesPane.tsx
@@ -1,5 +1,5 @@
import { useBackend } from '../../backend';
-import { Button, LabeledList } from '../../components';
+import { Button, LabeledList, ProgressBar } from '../../components';
import { OperatorData, MechaUtility } from './data';
export const UtilityModulesPane = (props, context) => {
@@ -36,6 +36,7 @@ export const UtilityModulesPane = (props, context) => {
};
const MECHA_SNOWFLAKE_ID_EJECTOR = "ejector_snowflake";
+const MECHA_SNOWFLAKE_ID_EXTINGUISHER = "extinguisher_snowflake";
// Handles all the snowflake buttons and whatever
const Snowflake = (props: {module: MechaUtility}, context) => {
@@ -45,6 +46,8 @@ const Snowflake = (props: {module: MechaUtility}, context) => {
switch (snowflake["snowflake_id"]) {
case MECHA_SNOWFLAKE_ID_EJECTOR:
return ;
+ case MECHA_SNOWFLAKE_ID_EXTINGUISHER:
+ return ;
default:
return null;
}
@@ -72,3 +75,50 @@ const SnowflakeEjector = (props: {module: MechaUtility}, context) => {
);
};
+
+const SnowflakeExtinguisher = (props: {module: MechaUtility}, context) => {
+ const { act, data } = useBackend(context);
+ return (
+ <>
+
+ {props.module.snowflake.reagents}
+
+