mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-14 12:13:06 +00:00
- Adds remote powernet sensors, power monitoring computers use these by default to monitor power around the station. Default range is 1 Z level + long range versions of sensors - Powernet sensors mapped in, each subgrid has it's own one (ie: substations compatible) - Telecomms, mining, research and engineering outposts have long range versions installed, visible even cross-Zlevels - Powersinks and ninja gloves now trigger problem warning in powernets they affect. This warning is visible to anyone using power monitoring console. TODO: Add more stuff that triggers warnings. - Powersinks now properly drain APC cells using CELLRATE (@2000W per APC max.) - Powersinks buffed a bit, to compensate for CELLRATE change (previous line)
139 lines
3.8 KiB
Plaintext
139 lines
3.8 KiB
Plaintext
/*
|
|
********** SENSOR MONITOR **********
|
|
- Remotely monitors sensors around the station and displays their readings.
|
|
- Should filter out most duplicities.
|
|
*/
|
|
|
|
/obj/machinery/power/monitor
|
|
name = "Power Monitor"
|
|
desc = "Computer designed to remotely monitor power levels around the station"
|
|
icon = 'icons/obj/computer.dmi'
|
|
icon_state = "power"
|
|
|
|
//computer stuff
|
|
density = 1
|
|
anchored = 1.0
|
|
var/circuit = /obj/item/weapon/circuitboard/powermonitor
|
|
var/list/grid_sensors = null
|
|
use_power = 1
|
|
idle_power_usage = 300
|
|
active_power_usage = 300
|
|
|
|
/obj/machinery/power/monitor/New()
|
|
..()
|
|
refresh_sensors()
|
|
|
|
|
|
/obj/machinery/power/monitor/proc/refresh_sensors()
|
|
grid_sensors = list()
|
|
for(var/obj/machinery/power/sensor/S in machines)
|
|
if((S.loc.z == src.loc.z) || (S.long_range)) // Consoles have range on their Z-Level. Sensors with long_range var will work between Z levels.
|
|
grid_sensors += S
|
|
|
|
/obj/machinery/power/monitor/attack_ai(mob/user)
|
|
add_fingerprint(user)
|
|
|
|
if(stat & (BROKEN|NOPOWER))
|
|
return
|
|
interact(user)
|
|
|
|
/obj/machinery/power/monitor/attack_hand(mob/user)
|
|
add_fingerprint(user)
|
|
|
|
if(stat & (BROKEN|NOPOWER))
|
|
return
|
|
interact(user)
|
|
|
|
/obj/machinery/power/monitor/interact(mob/user)
|
|
|
|
if ( (get_dist(src, user) > 1 ) || (stat & (BROKEN|NOPOWER)) )
|
|
if (!istype(user, /mob/living/silicon))
|
|
user.unset_machine()
|
|
user << browse(null, "window=powcomp")
|
|
return
|
|
|
|
if((!grid_sensors) || (!grid_sensors.len)) // No sensors in list. Refresh just in case.
|
|
refresh_sensors()
|
|
|
|
|
|
|
|
user.set_machine(src)
|
|
var/t = "<TT><B>Station Power Monitoring</B><HR>"
|
|
|
|
t += "<BR><HR><A href='?src=\ref[src];update=1'>Refresh</A>"
|
|
t += "<BR><HR><A href='?src=\ref[src];reset=1'>Reset Sensor List</A>"
|
|
t += "<BR><HR><A href='?src=\ref[src];close=1'>Close</A><br>"
|
|
|
|
if((!grid_sensors) || (!grid_sensors.len))
|
|
t += "<b> ERROR - No Sensors Connected. </b>"
|
|
else
|
|
var/list/reported_nets = list()
|
|
var/duplicities = 0 // Duplicity prevention (substations in Bypass mode)
|
|
|
|
|
|
for(var/obj/machinery/power/sensor/S in grid_sensors) // Show all data from current Z level.
|
|
if(S.powernet && (S.powernet in reported_nets)) // We already reported this powernet. Ignore it.
|
|
duplicities++
|
|
continue
|
|
|
|
t += "<br><br><hr> <b>[S.name_tag] - Sensor Reading</b> <br>"
|
|
t += S.ReturnReading() // Sensors already make quite decent HTML table by themselves.
|
|
if(S.powernet)
|
|
reported_nets += S.powernet
|
|
if(duplicities)
|
|
t += "<br><b>Ignored [duplicities] duplicite readings"
|
|
user << browse(t, "window=powcomp;size=600x900")
|
|
onclose(user, "powcomp")
|
|
|
|
|
|
/obj/machinery/power/monitor/Topic(href, href_list)
|
|
..()
|
|
if( href_list["close"] )
|
|
usr << browse(null, "window=powcomp")
|
|
usr.unset_machine()
|
|
return
|
|
if( href_list["update"] )
|
|
src.updateDialog()
|
|
return
|
|
if( href_list["reset"] )
|
|
refresh_sensors()
|
|
return
|
|
|
|
|
|
/obj/machinery/power/monitor/power_change()
|
|
..()
|
|
if(stat & BROKEN)
|
|
icon_state = "broken"
|
|
else
|
|
if (stat & NOPOWER)
|
|
spawn(rand(0, 15))
|
|
src.icon_state = "c_unpowered"
|
|
else
|
|
icon_state = initial(icon_state)
|
|
|
|
|
|
//copied from computer.dm
|
|
/obj/machinery/power/monitor/attackby(I as obj, user as mob)
|
|
if(istype(I, /obj/item/weapon/screwdriver) && circuit)
|
|
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
|
|
if(do_after(user, 20))
|
|
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
|
|
var/obj/item/weapon/circuitboard/M = new circuit( A )
|
|
A.circuit = M
|
|
A.anchored = 1
|
|
for (var/obj/C in src)
|
|
C.loc = src.loc
|
|
if (src.stat & BROKEN)
|
|
user << "\blue The broken glass falls out."
|
|
new /obj/item/weapon/shard( src.loc )
|
|
A.state = 3
|
|
A.icon_state = "3"
|
|
else
|
|
user << "\blue You disconnect the monitor."
|
|
A.state = 4
|
|
A.icon_state = "4"
|
|
M.deconstruct(src)
|
|
del(src)
|
|
else
|
|
src.attack_hand(user)
|
|
return |