Merge pull request #14178 from Poojawa/fancy-AFGs

Fixes #14118
This commit is contained in:
Heroman3003
2022-12-10 10:22:16 +10:00
committed by CHOMPStation2
parent 7566c3306c
commit 6f890fbe98

View File

@@ -98,26 +98,30 @@
/obj/machinery/atmospheric_field_generator/power_change() /obj/machinery/atmospheric_field_generator/power_change()
var/oldstat var/oldstat
..() ..()
if(!(stat & NOPOWER)) if(!(stat & (BROKEN|NOPOWER|EMPED)))
ispowered = 1 ispowered = TRUE
update_icon() update_icon()
if(alwaysactive || wasactive) //reboot our field if we were on or are supposed to be always-on if(alwaysactive || wasactive) //reboot our field if we were on or are supposed to be always-on
generate_field() generate_field()
if(stat != oldstat && isactive && (stat & NOPOWER)) if(stat != oldstat && isactive && (stat & (BROKEN|NOPOWER|EMPED)))
ispowered = 0 ispowered = FALSE
disable_field() disable_field()
update_icon() update_icon()
/obj/machinery/atmospheric_field_generator/emp_act() /obj/machinery/atmospheric_field_generator/emp_act()
. = ..() if(!(stat & EMPED))
stat |= EMPED
disable_field() //shutting dowwwwwwn disable_field() //shutting dowwwwwwn
if(alwaysactive || wasactive) //reboot after a short delay if we were online before
spawn(rand(reboot_delay_min,reboot_delay_max)) spawn(rand(reboot_delay_min,reboot_delay_max))
stat &= ~EMPED
if(alwaysactive || wasactive) //reboot after a short delay if we were online before
generate_field() generate_field()
..()
/obj/machinery/atmospheric_field_generator/ex_act(severity) /obj/machinery/atmospheric_field_generator/ex_act(severity)
switch(severity) switch(severity)
if(1) if(1)
stat |= BROKEN //ensures that always on generators are set as broken prior to being deleted, thus, off.
disable_field() disable_field()
qdel(src) qdel(src)
return return
@@ -134,7 +138,7 @@
if(!ispowered || hatch_open || !wires_intact || isactive) //if it's not powered, the hatch is open, the wires are busted, or it's already on, don't do anything if(!ispowered || hatch_open || !wires_intact || isactive) //if it's not powered, the hatch is open, the wires are busted, or it's already on, don't do anything
return return
else else
isactive = 1 isactive = TRUE
icon_state = "arfg_on" icon_state = "arfg_on"
new field_type (src.loc) new field_type (src.loc)
src.visible_message("<span class='warning'>The ARF-G crackles to life!</span>","<span class='warning'>You hear an ARF-G coming online!</span>") src.visible_message("<span class='warning'>The ARF-G crackles to life!</span>","<span class='warning'>You hear an ARF-G coming online!</span>")
@@ -143,12 +147,15 @@
/obj/machinery/atmospheric_field_generator/proc/disable_field() /obj/machinery/atmospheric_field_generator/proc/disable_field()
if(isactive) if(isactive)
if(alwaysactive == TRUE && !(stat & (BROKEN|NOPOWER|EMPED))) //If we're not damaged, don't turn off if we're always on.
return
else
icon_state = "arfg_off" icon_state = "arfg_off"
for(var/obj/structure/atmospheric_retention_field/F in loc) for(var/obj/structure/atmospheric_retention_field/F in loc)
qdel(F) qdel(F)
src.visible_message("The ARF-G shuts down with a low hum.","You hear an ARF-G powering down.") src.visible_message("The ARF-G shuts down with a low hum.","You hear an ARF-G powering down.")
update_use_power(USE_POWER_IDLE) update_use_power(USE_POWER_IDLE)
isactive = 0 isactive = FALSE
return return
/obj/machinery/atmospheric_field_generator/Initialize() /obj/machinery/atmospheric_field_generator/Initialize()