mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-23 03:57:48 +01:00
Adds the new Grid Check event to rotation.
Maps in a new Grid Checker machine, located in an expanded substation room in Engineering. When a grid check happens, Engineering can hack that machine to restore power sooner. Wearing insulated gloves is highly recommended.
This commit is contained in:
@@ -1238,7 +1238,7 @@ obj/machinery/power/apc/proc/autoset(var/val, var/on)
|
||||
|
||||
if(prob(40)) // Spooky flickers.
|
||||
for(var/obj/machinery/light/L in area)
|
||||
L.flicker(20)
|
||||
L.flicker(rand(20,30))
|
||||
|
||||
if(prob(25)) // Bluescreens.
|
||||
emagged = 1
|
||||
@@ -1256,4 +1256,12 @@ obj/machinery/power/apc/proc/autoset(var/val, var/on)
|
||||
if(prob(5)) // APC completely ruined.
|
||||
set_broken()
|
||||
|
||||
/obj/machinery/power/apc/do_grid_check()
|
||||
if(is_critical)
|
||||
return
|
||||
grid_check = TRUE
|
||||
spawn(15 MINUTES) // Protection against someone deconning the grid checker after a grid check happens, preventing infinte blackout.
|
||||
if(src && grid_check == TRUE)
|
||||
grid_check = FALSE
|
||||
|
||||
#undef APC_UPDATE_ICON_COOLDOWN
|
||||
|
||||
@@ -236,6 +236,31 @@
|
||||
src.set_dir(turn(src.dir, -90))
|
||||
|
||||
/obj/machinery/power/generator/power_spike()
|
||||
if(effective_gen >= max_power / 2 && powernet) // Don't make a spike if we're not making a whole lot of power.
|
||||
..()
|
||||
// if(!effective_gen >= max_power / 2 && powernet) // Don't make a spike if we're not making a whole lot of power.
|
||||
// return
|
||||
|
||||
var/list/powernet_union = powernet.nodes
|
||||
for(var/obj/machinery/power/terminal/T in powernet.nodes)
|
||||
if(T.master && istype(T.master, /obj/machinery/power/smes))
|
||||
var/obj/machinery/power/smes/S = T.master
|
||||
powernet_union |= S.powernet.nodes
|
||||
|
||||
var/found_grid_checker = FALSE
|
||||
for(var/obj/machinery/power/grid_checker/G in powernet_union)
|
||||
G.power_failure(prob(30)) // If we found a grid checker, then all is well.
|
||||
found_grid_checker = TRUE
|
||||
if(!found_grid_checker) // Otherwise lets break some stuff.
|
||||
spawn(1)
|
||||
command_announcement.Announce("Dangerous power spike detected in the power network. Please check machinery \
|
||||
for electrical damage.",
|
||||
"Critical Power Overload")
|
||||
var/i = 0
|
||||
var/limit = rand(30, 50)
|
||||
for(var/obj/machinery/power/P in powernet_union)
|
||||
P.overload(src)
|
||||
i++
|
||||
if(i % 5)
|
||||
sleep(1)
|
||||
if(i >= limit)
|
||||
break
|
||||
|
||||
|
||||
@@ -73,26 +73,17 @@
|
||||
new_sound = 'sound/AI/poweroff.ogg')
|
||||
power_failing = TRUE
|
||||
if(powernet)
|
||||
for(var/obj/machinery/power/terminal/T in powernet.nodes) // SMESes that are "downstream" of the powernet.
|
||||
for(var/obj/machinery/power/terminal/T in powernet.nodes) // APCs that are "downstream" of the powernet.
|
||||
|
||||
if(istype(T.master, /obj/machinery/power/apc))
|
||||
var/obj/machinery/power/apc/A = T.master
|
||||
if(A.is_critical)
|
||||
continue
|
||||
A.grid_check = TRUE
|
||||
A.do_grid_check()
|
||||
|
||||
for(var/obj/machinery/power/smes/smes in powernet.nodes) // These are "upstream"
|
||||
smes.grid_check = TRUE
|
||||
/*
|
||||
smes.last_charge = smes.charge
|
||||
smes.last_output_attempt = smes.output_attempt
|
||||
smes.last_input_attempt = smes.input_attempt
|
||||
smes.charge = 0
|
||||
smes.inputting(FALSE)
|
||||
smes.outputting(FALSE)
|
||||
smes.update_icon()
|
||||
smes.power_change()
|
||||
*/
|
||||
smes.do_grid_check()
|
||||
|
||||
update_icon()
|
||||
|
||||
spawn(rand(4 MINUTES, 10 MINUTES) )
|
||||
@@ -116,10 +107,3 @@
|
||||
|
||||
for(var/obj/machinery/power/smes/smes in powernet.nodes) // These are "upstream"
|
||||
smes.grid_check = FALSE
|
||||
/*
|
||||
smes.charge = smes.last_charge
|
||||
smes.output_attempt = smes.last_output_attempt
|
||||
smes.input_attempt = smes.last_input_attempt
|
||||
smes.update_icon()
|
||||
smes.power_change()
|
||||
*/
|
||||
@@ -142,24 +142,12 @@
|
||||
/obj/machinery/power/proc/overload(var/obj/machinery/power/source)
|
||||
return
|
||||
|
||||
// Used by the grid checker upon receiving a power spike.
|
||||
/obj/machinery/power/proc/do_grid_check()
|
||||
return
|
||||
|
||||
/obj/machinery/power/proc/power_spike()
|
||||
var/obj/machinery/power/grid_checker/G = locate() in powernet.nodes
|
||||
if(G) // If we found a grid checker, then all is well.
|
||||
G.power_failure(prob(30))
|
||||
else // Otherwise lets break some stuff.
|
||||
spawn(1)
|
||||
command_announcement.Announce("Dangerous power spike detected in the power network. Please check machinery \
|
||||
for electrical damage.",
|
||||
"Critical Power Overload")
|
||||
var/i = 0
|
||||
var/limit = rand(30, 50)
|
||||
for(var/obj/machinery/power/P in powernet.nodes)
|
||||
P.overload(src)
|
||||
i++
|
||||
if(i % 5)
|
||||
sleep(1)
|
||||
if(i >= limit)
|
||||
break
|
||||
return
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Powernet handling helpers
|
||||
|
||||
@@ -421,12 +421,6 @@
|
||||
update_icon()
|
||||
..()
|
||||
|
||||
/obj/machinery/power/smes/overload(var/obj/machinery/power/source) // This propagates the power spike down the powernet.
|
||||
if(istype(source, /obj/machinery/power/smes)) // Prevent infinite loops if two SMESes are hooked up to each other.
|
||||
return
|
||||
power_spike()
|
||||
|
||||
|
||||
/obj/machinery/power/smes/magical
|
||||
name = "magical power storage unit"
|
||||
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit. Magically produces power."
|
||||
|
||||
Reference in New Issue
Block a user