Modifications to sensors code

- More stuff now triggers powernet warnings: People getting shocked by machinery (primarily door, but can be anything else powered by APC), and grilles. Thanks to @mwerezak for suggestion.
- Monitoring computer now has slightly different icon_state when it detects powernet warning. This is checked and updated every 5 MC ticks (ie, slightly delayed)
- Fixes ocassional runtime in powernet_sensor.dm
- Powersinks buffed a bit more. Drain rate changed from 0.6MW to 1MW. 1MW is full output of main engine SMES.
- Powersinks also dissipate small amount of internal energy charge over time. (20kW)
This commit is contained in:
Atlantiscze
2014-11-12 14:54:56 +01:00
parent f29cd211e6
commit 835d04290c
7 changed files with 64 additions and 21 deletions

View File

@@ -12,7 +12,7 @@
var/perapc_excess = 0
var/netexcess = 0 // excess power on the powernet (typically avail-load)
var/problem = 0 // If either of these is set to 1 there is some sort of issue at the powernet.
var/problem = 0 // If this is not 0 there is some sort of issue in the powernet. Monitors will display warnings.
/datum/powernet/New()
powernets += src

View File

@@ -69,21 +69,26 @@
else
total_load = "[round(total_load)] W"
out += "</table>"
out += "</table><br><b>TOTAL GRID LOAD: [total_load]</b>"
var/textavail = powernet.avail
if(textavail > 1000)
textavail = "[textavail / 1000]"
textavail += " kW"
else
textavail += " W"
var/textavail = powernet.avail
if(textavail > 1000)
textavail = "[textavail / 1000] kW"
else
textavail = "[textavail] W"
out += "<br><b>TOTAL AVAILABLE: [textavail]</b>"
if(powernet.problem)
out += "<br><b>WARNING: Abnormal grid activity detected!</b>"
out += "<br><b>TOTAL GRID LOAD: [total_load]</b>"
out += "<br><b>TOTAL AVAILABLE: [textavail]</b>"
if(powernet.problem)
out += "<br><b>WARNING: Abnormal grid activity detected!</b>"
return out
/obj/machinery/power/sensor/proc/check_grid_warning()
RefreshGrid()
if(powernet)
if(powernet.problem)
return 1
return 0
// Has to be here as we need it to be in Machines list.
/obj/machinery/power/sensor/process()
return 1

View File

@@ -15,10 +15,17 @@
anchored = 1.0
var/circuit = /obj/item/weapon/circuitboard/powermonitor
var/list/grid_sensors = null
var/update_counter = 0 // Next icon update when this reaches 5 (ie every 5 ticks)
use_power = 1
idle_power_usage = 300
active_power_usage = 300
// Update icon every 5 ticks.
/obj/machinery/power/monitor/process()
update_counter++
if(update_counter > 4)
update_icon()
/obj/machinery/power/monitor/New()
..()
refresh_sensors()
@@ -81,7 +88,7 @@
if(S.powernet)
reported_nets += S.powernet
if(duplicities)
t += "<br><b>Ignored [duplicities] duplicite readings"
t += "<br><b><i>Ignored [duplicities] duplicite readings</i></b>"
user << browse(t, "window=powcomp;size=600x900")
onclose(user, "powcomp")
@@ -99,17 +106,38 @@
refresh_sensors()
return
/obj/machinery/power/monitor/update_icon()
update_counter = 0 // Reset the icon update counter.
if(stat & BROKEN)
icon_state = "powerb"
return
if(stat & NOPOWER)
icon_state = "power0"
return
if(check_warnings())
icon_state = "power_alert"
return
icon_state = "power"
/obj/machinery/power/monitor/proc/check_warnings()
var/warn = 0
if(grid_sensors)
for(var/obj/machinery/power/sensor/S in grid_sensors)
if(S.check_grid_warning())
warn = 1
return warn
/obj/machinery/power/monitor/power_change()
..()
if(stat & BROKEN)
icon_state = "broken"
// Leaving this here to preserve that delayed shutdown effect when power goes out.
if (stat & NOPOWER)
spawn(rand(0, 15))
update_icon()
else
if (stat & NOPOWER)
spawn(rand(0, 15))
src.icon_state = "c_unpowered"
else
icon_state = initial(icon_state)
update_icon()
//copied from computer.dm