[MIRROR] Fire/Air alarms properly dismantle when they are destroyed & fixes balloon alert runtimes when cutting terminals [MDB IGNORE] (#20870)

* Fire/Air alarms properly dismantle when they are destroyed & fixes balloon alert runtimes when cutting terminals (#74918)

Firealarms & Airalarms `deconstruct()` procs are wrong, they spew out
electronics & cable regardless of what build stage their on

Fire alarms providing free electronics & cable without even installing
them

https://user-images.githubusercontent.com/110812394/233784785-650fbd64-3c6c-44c8-b377-c3a8244d28ac.mp4

Air alarms providing free electronics & cable without even installing
them

https://user-images.githubusercontent.com/110812394/233784799-cdd38967-8a59-454d-8da4-1360d03ff12c.mp4

Bug exploits now come to an end

Also fixes balloon alerts run timing when cutting terminals connected to
apc's/smes etc. because the atom gets deleted, by the time the balloon
alert gets executed it adds a timer on the deleted object causing
runtimes.

## Changelog
🆑
fix: air alarms correctly spew out cable & electronics depending on
their build stage when their integrity reaches 0 i.e. destroyed
fix: fire alarms correctly spew out cable & electronics depending on
their build stage when their integrity reaches 0 i.e. destroyed
fix: balloon alerts runtiming when cutting terminals
/🆑

---------

Co-authored-by: san7890 <the@ san7890.com>

* Fire/Air alarms properly dismantle when they are destroyed & fixes balloon alert runtimes when cutting terminals

---------

Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: san7890 <the@ san7890.com>
This commit is contained in:
SkyratBot
2023-05-01 13:29:07 -07:00
committed by GitHub
co-authored by san7890 SyncIt21
parent f203dec6a2
commit 52300246b4
5 changed files with 39 additions and 26 deletions
@@ -41,6 +41,15 @@
/// Air alarm has all components but isn't completed
#define AIR_ALARM_BUILD_COMPLETE 2
// Fire alarm buildstage [/obj/machinery/firealarm/buildstage]
/// Fire alarm missing circuit
#define FIRE_ALARM_BUILD_NO_CIRCUIT 0
/// Fire alarm has circuit but is missing wires
#define FIRE_ALARM_BUILD_NO_WIRES 1
/// Fire alarm has all components but isn't completed
#define FIRE_ALARM_BUILD_SECURED 2
// threshold_type values for [/datum/tlv/proc/set_value] and [/datum/tlv/proc/reset_value]
/// [/datum/tlv/var/warning_min]
#define TLV_VAR_WARNING_MIN (1 << 0)
+20 -19
View File
@@ -31,8 +31,8 @@
luminosity = 1
//We want to use area sensitivity, let us
always_area_sensitive = TRUE
///Buildstate for contruction steps. 2 = complete, 1 = no wires, 0 = circuit gone
var/buildstage = 2
///Buildstate for contruction steps
var/buildstage = FIRE_ALARM_BUILD_SECURED
///Our home area, set in Init. Due to loading step order, this seems to be null very early in the server setup process, which is why some procs use `my_area?` for var or list checks.
var/area/my_area = null
///looping sound datum for our fire alarm siren.
@@ -45,7 +45,7 @@
/obj/machinery/firealarm/Initialize(mapload, dir, building)
. = ..()
if(building)
buildstage = 0
buildstage = FIRE_ALARM_BUILD_NO_CIRCUIT
set_panel_open(TRUE)
if(name == initial(name))
name = "[get_area_name(src)] [initial(name)]"
@@ -288,14 +288,14 @@
update_use_power(IDLE_POWER_USE)
/obj/machinery/firealarm/attack_hand(mob/user, list/modifiers)
if(buildstage != 2)
if(buildstage != FIRE_ALARM_BUILD_SECURED)
return
. = ..()
add_fingerprint(user)
alarm(user)
/obj/machinery/firealarm/attack_hand_secondary(mob/user, list/modifiers)
if(buildstage != 2)
if(buildstage != FIRE_ALARM_BUILD_SECURED)
return ..()
add_fingerprint(user)
reset(user)
@@ -316,7 +316,7 @@
/obj/machinery/firealarm/attackby(obj/item/tool, mob/living/user, params)
add_fingerprint(user)
if(tool.tool_behaviour == TOOL_SCREWDRIVER && buildstage == 2)
if(tool.tool_behaviour == TOOL_SCREWDRIVER && buildstage == FIRE_ALARM_BUILD_SECURED)
tool.play_tool_sound(src)
toggle_panel_open()
to_chat(user, span_notice("The wires have been [panel_open ? "exposed" : "unexposed"]."))
@@ -344,7 +344,7 @@
toggle_fire_detect(user)
return
if(tool.tool_behaviour == TOOL_WIRECUTTER)
buildstage = 1
buildstage = FIRE_ALARM_BUILD_NO_WIRES
tool.play_tool_sound(src)
new /obj/item/stack/cable_coil(user.loc, 5)
to_chat(user, span_notice("You cut the wires from \the [src]."))
@@ -365,7 +365,7 @@
to_chat(user, span_warning("You need more cable for this!"))
else
coil.use(5)
buildstage = 2
buildstage = FIRE_ALARM_BUILD_SECURED
to_chat(user, span_notice("You wire \the [src]."))
update_appearance()
return
@@ -374,21 +374,21 @@
user.visible_message(span_notice("[user.name] removes the electronics from [src.name]."), \
span_notice("You start prying out the circuit..."))
if(tool.use_tool(src, user, 20, volume=50))
if(buildstage == 1)
if(buildstage == FIRE_ALARM_BUILD_NO_WIRES)
if(machine_stat & BROKEN)
to_chat(user, span_notice("You remove the destroyed circuit."))
set_machine_stat(machine_stat & ~BROKEN)
else
to_chat(user, span_notice("You pry out the circuit."))
new /obj/item/electronics/firealarm(user.loc)
buildstage = 0
buildstage = FIRE_ALARM_BUILD_NO_CIRCUIT
update_appearance()
return
if(0)
if(istype(tool, /obj/item/electronics/firealarm))
to_chat(user, span_notice("You insert the circuit."))
qdel(tool)
buildstage = 1
buildstage = FIRE_ALARM_BUILD_NO_WIRES
update_appearance()
return
@@ -398,7 +398,7 @@
return
user.visible_message(span_notice("[user] fabricates a circuit and places it into [src]."), \
span_notice("You adapt a fire alarm circuit and slot it into the assembly."))
buildstage = 1
buildstage = FIRE_ALARM_BUILD_NO_WIRES
update_appearance()
return
@@ -413,7 +413,7 @@
return ..()
/obj/machinery/firealarm/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
if((buildstage == 0) && (the_rcd.upgrade & RCD_UPGRADE_SIMPLE_CIRCUITS))
if((buildstage == FIRE_ALARM_BUILD_NO_CIRCUIT) && (the_rcd.upgrade & RCD_UPGRADE_SIMPLE_CIRCUITS))
return list("mode" = RCD_WALLFRAME, "delay" = 20, "cost" = 1)
return FALSE
@@ -422,7 +422,7 @@
if(RCD_WALLFRAME)
user.visible_message(span_notice("[user] fabricates a circuit and places it into [src]."), \
span_notice("You adapt a fire alarm circuit and slot it into the assembly."))
buildstage = 1
buildstage = FIRE_ALARM_BUILD_NO_WIRES
update_appearance()
return TRUE
return FALSE
@@ -430,8 +430,8 @@
/obj/machinery/firealarm/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1, attack_dir)
. = ..()
if(.) //damage received
if(atom_integrity > 0 && !(machine_stat & BROKEN) && buildstage != 0)
if(prob(33))
if(atom_integrity > 0 && !(machine_stat & BROKEN) && buildstage != FIRE_ALARM_BUILD_NO_CIRCUIT)
if(prob(33) && buildstage == FIRE_ALARM_BUILD_SECURED) //require fully wired electronics to set of the alarms
alarm()
/obj/machinery/firealarm/singularity_pull(S, current_size)
@@ -440,18 +440,19 @@
return ..()
/obj/machinery/firealarm/atom_break(damage_flag)
if(buildstage == 0) //can't break the electronics if there isn't any inside.
if(buildstage == FIRE_ALARM_BUILD_NO_CIRCUIT) //can't break the electronics if there isn't any inside.
return
return ..()
/obj/machinery/firealarm/deconstruct(disassembled = TRUE)
if(!(flags_1 & NODECONSTRUCT_1))
new /obj/item/stack/sheet/iron(loc, 1)
if(!(machine_stat & BROKEN))
if(buildstage > FIRE_ALARM_BUILD_NO_CIRCUIT)
var/obj/item/item = new /obj/item/electronics/firealarm(loc)
if(!disassembled)
item.update_integrity(item.max_integrity * 0.5)
new /obj/item/stack/cable_coil(loc, 3)
if(buildstage > FIRE_ALARM_BUILD_NO_WIRES)
new /obj/item/stack/cable_coil(loc, 3)
qdel(src)
// Allows users to examine the state of the thermal sensor
@@ -92,10 +92,12 @@
/obj/machinery/airalarm/deconstruct(disassembled = TRUE)
if(!(flags_1 & NODECONSTRUCT_1))
new /obj/item/stack/sheet/iron(loc, 2)
var/obj/item/I = new /obj/item/electronics/airalarm(loc)
if(!disassembled)
I.take_damage(I.max_integrity * 0.5, sound_effect=FALSE)
new /obj/item/stack/cable_coil(loc, 3)
if((buildstage == AIR_ALARM_BUILD_NO_WIRES) || (buildstage == AIR_ALARM_BUILD_COMPLETE))
var/obj/item/electronics/airalarm/alarm = new(loc)
if(!disassembled)
alarm.take_damage(alarm.max_integrity * 0.5, sound_effect = FALSE)
if((buildstage == AIR_ALARM_BUILD_COMPLETE))
new /obj/item/stack/cable_coil(loc, 3)
qdel(src)
/obj/machinery/airalarm/attackby(obj/item/W, mob/user, params)
+2 -1
View File
@@ -207,7 +207,7 @@
GLOB.apcs_list -= src
if(malfai && operating)
malfai.malf_picker.processing_time = clamp(malfai.malf_picker.processing_time - 10,0,1000)
malfai.malf_picker.processing_time = clamp(malfai.malf_picker.processing_time - 10, 0, 1000)
disconnect_from_area()
QDEL_NULL(alarm_manager)
if(occupier)
@@ -218,6 +218,7 @@
QDEL_NULL(cell)
if(terminal)
disconnect_terminal()
return ..()
/obj/machinery/power/apc/proc/assign_to_area(area/target_area = get_area(src))
+2 -2
View File
@@ -61,9 +61,9 @@
do_sparks(5, TRUE, master)
return
new /obj/item/stack/cable_coil(drop_location(), 10)
balloon_alert(user, "cable terminal dismantled")
var/obj/item/stack/cable_coil/cable = new (drop_location(), 10)
qdel(src)
cable.balloon_alert(user, "cable terminal dismantled")
/obj/machinery/power/terminal/wirecutter_act(mob/living/user, obj/item/I)
..()