Files
Bubberstation/code/modules/power/terminal.dm
SkyratBot 52300246b4 [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>
2023-05-01 13:29:07 -07:00

72 lines
1.9 KiB
Plaintext

// the underfloor wiring terminal for the APC
// autogenerated when an APC is placed
// all conduit connects go to this object instead of the APC
// using this solves the problem of having the APC in a wall yet also inside an area
/obj/machinery/power/terminal
name = "terminal"
icon_state = "term"
desc = "It's an underfloor wiring terminal, used to draw power from the grid."
layer = WIRE_TERMINAL_LAYER //a bit above wires
var/obj/machinery/power/master = null
/obj/machinery/power/terminal/Initialize(mapload)
. = ..()
AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE, use_alpha = TRUE)
/obj/machinery/power/terminal/Destroy()
if(master)
master.disconnect_terminal()
master = null
return ..()
/obj/machinery/power/terminal/should_have_node()
return TRUE
/obj/machinery/power/proc/can_terminal_dismantle()
. = FALSE
/obj/machinery/power/apc/can_terminal_dismantle()
. = FALSE
if(opened)
. = TRUE
/obj/machinery/power/smes/can_terminal_dismantle()
. = FALSE
if(panel_open)
. = TRUE
/obj/machinery/power/terminal/proc/dismantle(mob/living/user, obj/item/I)
if(isturf(loc))
var/turf/T = loc
if(T.underfloor_accessibility < UNDERFLOOR_INTERACTABLE)
balloon_alert(user, "must expose the cable terminal!")
return
if(master && !master.can_terminal_dismantle())
return
user.visible_message(span_notice("[user.name] dismantles the cable terminal from [master]."))
balloon_alert(user, "cutting the cables...")
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, TRUE)
if(I.use_tool(src, user, 50))
if(master && !master.can_terminal_dismantle())
return
if(prob(50) && electrocute_mob(user, powernet, src, 1, TRUE))
do_sparks(5, TRUE, master)
return
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)
..()
dismantle(user, I)
return TRUE