The Great Fire Extinguisher Refactor (#28005)

* Creation (suffering), success

* AGHHHH! SPACES!

* Update watertank.dm

* comment update

* Apply suggestions from code review

Co-authored-by: Charlie Nolan <funnyman3595@gmail.com>
Signed-off-by: CRUNCH <143041327+Fordoxia@users.noreply.github.com>

---------

Signed-off-by: CRUNCH <143041327+Fordoxia@users.noreply.github.com>
Co-authored-by: Charlie Nolan <funnyman3595@gmail.com>
This commit is contained in:
CRUNCH
2025-02-09 18:13:20 +00:00
committed by GitHub
parent 2ca7c0fd7e
commit d9e6e40ed0
4 changed files with 155 additions and 177 deletions
+18 -88
View File
@@ -159,49 +159,31 @@
/// Atmos water tank module
/obj/item/mod/module/firefighting_tank
name = "MOD firefighting tank"
desc = "A refrigerated and pressurized module tank with an extinguisher nozzle, intended to fight fires. Swaps between extinguisher, nanofrost launcher, and metal foam dispenser for breaches. Nanofrost converts plasma in the air to nitrogen, but only if it is combusting at the time."
icon_state = "firefighting_tank"
module_type = MODULE_ACTIVE
complexity = 2
active_power_cost = DEFAULT_CHARGE_DRAIN * 3
device = /obj/item/extinguisher/mini/mod
#define EXTINGUISHER 0
#define NANOFROST 1
#define METAL_FOAM 2
/obj/item/extinguisher/mini/mod
/obj/item/mod/module/firefighting_tank
name = "MOD firefighting tank"
desc = "A refrigerated and pressurized module tank with an extinguisher nozzle, intended to fight fires. \
Swaps between extinguisher, nanofrost launcher, and metal foam dispenser for breaches. Nanofrost converts plasma in the air to nitrogen, but only if it is combusting at the time.\
The smaller volume compared to a dedicated firefighting backpack means that non-water modes suffer from longer cooldowns."
icon_state = "firefighting_tank"
module_type = MODULE_ACTIVE
complexity = 2
active_power_cost = DEFAULT_CHARGE_DRAIN * 3
incompatible_modules = list(/obj/item/mod/module/firefighting_tank)
device = /obj/item/extinguisher/mini/nozzle/mod
// Used by nozzle code.
var/volume = 500
/obj/item/extinguisher/mini/nozzle/mod
name = "modsuit extinguisher nozzle"
desc = "A heavy duty nozzle attached to a modsuit's internal tank."
icon = 'icons/obj/watertank.dmi'
icon_state = "atmos_nozzle_1"
item_state = "nozzleatmos"
safety = 0
max_water = 500
precision = 1
cooling_power = 5
w_class = WEIGHT_CLASS_HUGE
flags = NODROP // Necessary to ensure that the nozzle and tank never seperate
var/nozzle_mode = EXTINGUISHER
var/metal_synthesis_charge = 5
COOLDOWN_DECLARE(nanofrost_cooldown)
metal_regen_time = 5 SECONDS
nanofrost_cooldown_time = 10 SECONDS
/obj/item/extinguisher/mini/mod/attack_self__legacy__attackchain(mob/user)
switch(nozzle_mode)
if(EXTINGUISHER)
nozzle_mode = NANOFROST
to_chat(user, "<span class='notice'>Swapped to nanofrost launcher.</span>")
if(NANOFROST)
nozzle_mode = METAL_FOAM
to_chat(user, "<span class='notice'>Swapped to metal foam synthesizer.</span>")
if(METAL_FOAM)
nozzle_mode = EXTINGUISHER
to_chat(user, "<span class='notice'>Swapped to water extinguisher.</span>")
update_icon(UPDATE_ICON_STATE)
/obj/item/extinguisher/mini/mod/update_icon_state()
/obj/item/extinguisher/mini/nozzle/mod/update_icon_state()
switch(nozzle_mode)
if(EXTINGUISHER)
icon_state = "atmos_nozzle_1"
@@ -210,58 +192,6 @@
if(METAL_FOAM)
icon_state = "atmos_nozzle_3"
/obj/item/extinguisher/mini/mod/examine(mob/user)
. = ..()
switch(nozzle_mode)
if(EXTINGUISHER)
. += "<span class='notice'>[src] is currently set to extinguishing mode.</span>"
if(NANOFROST)
. += "<span class='notice'>[src] is currently set to nanofrost mode.</span>"
if(METAL_FOAM)
. += "<span class='notice'>[src] is currently set to metal foam mode.</span>"
/obj/item/extinguisher/mini/mod/afterattack__legacy__attackchain(atom/target, mob/user)
var/is_adjacent = user.Adjacent(target)
if(is_adjacent && AttemptRefill(target, user))
return
switch(nozzle_mode)
if(EXTINGUISHER)
..()
if(NANOFROST)
if(reagents.total_volume < 100)
to_chat(user, "<span class='warning'>You need at least 100 units of water to use the nanofrost launcher!</span>")
return
if(!COOLDOWN_FINISHED(src, nanofrost_cooldown))
to_chat(user, "<span class='warning'>Nanofrost launcher is still recharging.</span>")
return
COOLDOWN_START(src, nanofrost_cooldown, 10 SECONDS)
reagents.remove_any(100)
var/obj/effect/nanofrost_container/A = new /obj/effect/nanofrost_container(get_turf(src))
log_game("[key_name(user)] used Nanofrost at [get_area(user)] ([user.x], [user.y], [user.z]).")
playsound(src, 'sound/items/syringeproj.ogg', 40, TRUE)
A.throw_at(target, 6, 2, user)
sleep(2)
A.Smoke()
if(METAL_FOAM)
if(!is_adjacent|| !isturf(target))
return
if(metal_synthesis_charge <= 0)
to_chat(user, "<span class='warning'>Metal foam mix is still being synthesized.</span>")
return
if(reagents.total_volume < 10)
to_chat(user, "<span class='warning'>You need at least 10 units of water to use the metal foam synthesizer!</span>")
return
var/obj/effect/particle_effect/foam/metal/F = new /obj/effect/particle_effect/foam/metal(get_turf(target), TRUE)
F.spread_amount = 0
reagents.remove_any(10)
metal_synthesis_charge--
addtimer(CALLBACK(src, PROC_REF(decrease_metal_charge)), 5 SECONDS)
/obj/item/extinguisher/mini/mod/proc/decrease_metal_charge()
metal_synthesis_charge++
#undef EXTINGUISHER
#undef NANOFROST
#undef METAL_FOAM