RCON System (v1.0)

- Allows remote control of SMES units and Breaker Boxes.
- Adds wires to SMES units. Wires may be cut/pulsed for various effects. Signallers are supported.
- RCON console(s) may be used to monitor the SMES units (which have RCON enabled) remotely, showing output loads and charge percentages.
- SMESs may be quickly discharged by cutting the grounding wire. This however comes with little risk of overload which may damage APCs on output powernet.
This commit is contained in:
Atlantiscze
2014-12-08 03:30:20 +01:00
parent 93805d5742
commit 994ad591e6
7 changed files with 334 additions and 12 deletions
+28 -2
View File
@@ -17,6 +17,8 @@
var/on = 0
var/busy = 0
var/directions = list(1,2,4,8,5,6,9,10)
var/RCon_tag = "NO_TAG"
var/update_locked = 0
/obj/machinery/power/breakerbox/activated
icon_state = "bbox_on"
@@ -33,19 +35,29 @@
user << "\red It seems to be offline"
/obj/machinery/power/breakerbox/attack_ai(mob/user)
if(update_locked)
user << "\red System locked. Please try again later."
return
if(busy)
user << "\red System is busy. Please wait until current operation is finished before changing power settings."
return
busy = 1
user << "\green Updating power settings.."
if(do_after(user, 50)) //5s for AI as AIs can manipulate electronics much faster.
if(do_after(user, 50))
set_state(!on)
user << "\green Update Completed. New setting:[on ? "on": "off"]"
update_locked = 1
spawn(600)
update_locked = 0
busy = 0
/obj/machinery/power/breakerbox/attack_hand(mob/user)
if(update_locked)
user << "\red System locked. Please try again later."
return
if(busy)
user << "\red System is busy. Please wait until current operation is finished before changing power settings."
@@ -55,11 +67,14 @@
for(var/mob/O in viewers(user))
O.show_message(text("\red [user] started reprogramming [src]!"), 1)
if(do_after(user, 300)) // 30s for non-AIs as humans have to manually reprogram it and rapid switching may cause some lag / powernet updates flood. If AIs spam it they can be easily traced.
if(do_after(user, 50))
set_state(!on)
user.visible_message(\
"<span class='notice'>[user.name] [on ? "enabled" : "disabled"] the breaker box!</span>",\
"<span class='notice'>You [on ? "enabled" : "disabled"] the breaker box!</span>")
update_locked = 1
spawn(600)
update_locked = 0
busy = 0
/obj/machinery/power/breakerbox/proc/set_state(var/state)
@@ -93,3 +108,14 @@
icon_state = icon_state_off
for(var/obj/structure/cable/C in src.loc)
del(C)
// Used by RCON to toggle the breaker box.
/obj/machinery/power/breakerbox/proc/auto_toggle()
if(!update_locked)
set_state(!on)
update_locked = 1
spawn(600)
update_locked = 0
/obj/machinery/power/breakerbox/process()
return 1
+10 -5
View File
@@ -32,6 +32,11 @@
var/last_input_attempt = 0
var/last_charge = 0
var/input_cut = 0
var/input_pulsed = 0
var/output_cut = 0
var/output_pulsed = 0
var/open_hatch = 0
var/name_tag = null
var/building_terminal = 0 //Suggestions about how to avoid clickspam building several terminals accepted!
@@ -120,7 +125,7 @@
var/last_onln = outputting
//inputting
if(input_attempt)
if(input_attempt && (!input_pulsed && !input_cut))
var/target_load = min((capacity-charge)/SMESRATE, input_level) // charge at set rate, limited to spare capacity
var/actual_load = draw_power(target_load) // add the load to the terminal side network
charge += actual_load * SMESRATE // increase the charge
@@ -133,7 +138,7 @@
inputting = 0
//outputting
if(outputting)
if(outputting && (!output_pulsed && !output_cut))
output_used = min( charge/SMESRATE, output_level) //limit output to that stored
charge -= output_used*SMESRATE // reduce the storage (may be recovered in /restore() if excessive)
@@ -319,6 +324,8 @@
// auto update every Master Controller tick
ui.set_auto_update(1)
/obj/machinery/power/smes/proc/Percentage()
return round(100.0*charge/capacity, 0.1)
/obj/machinery/power/smes/Topic(href, href_list)
..()
@@ -425,6 +432,4 @@
/obj/machinery/power/smes/magical/process()
charge = 5000000
..()
#undef SMESRATE
..()
+43 -5
View File
@@ -31,13 +31,36 @@
var/cur_coils = 1 // Current amount of installed coils
var/safeties_enabled = 1 // If 0 modifications can be done without discharging the SMES, at risk of critical failure.
var/failing = 0 // If 1 critical failure has occured and SMES explosion is imminent.
var/datum/wires/smes/wires
var/grounding = 1 // Cut to quickly discharge, at cost of "minor" electrical issues in output powernet.
var/RCon = 1 // Cut to disable AI and remote control.
var/RCon_tag = "NO_TAG" // RCON tag, change to show it on SMES Remote control console.
charge = 0
should_be_mapped = 1
/obj/machinery/power/smes/buildable/process()
if(!grounding && (Percentage() > 5))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
charge -= (output_level_max * SMESRATE)
if(prob(1)) // Small chance of overload occuring since grounding is disabled.
apcs_overload(5,10)
..()
/obj/machinery/power/smes/buildable/attack_ai()
if(RCon)
..()
else // RCON wire cut
usr << "<span class='warning'>Connection error: Destination Unreachable.</span>"
/obj/machinery/power/smes/buildable/New()
component_parts = list()
component_parts += new /obj/item/stack/cable_coil(src,30)
component_parts += new /obj/item/weapon/circuitboard/smes(src)
src.wires = new /datum/wires/smes(src)
// Allows for mapped-in SMESs with larger capacity/IO
for(var/i = 1, i <= cur_coils, i++)
@@ -46,6 +69,11 @@
recalc_coils()
..()
/obj/machinery/power/smes/buildable/attack_hand()
..()
if(open_hatch)
wires.Interact(usr)
/obj/machinery/power/smes/buildable/proc/recalc_coils()
if ((cur_coils <= max_coils) && (cur_coils >= 1))
capacity = 0
@@ -263,8 +291,18 @@
else
usr << "\red You can't insert more coils to this SMES unit!"
// Multitool - Toggle the safeties.
else if(istype(W, /obj/item/device/multitool))
safeties_enabled = !safeties_enabled
user << "<span class='warning'>You [safeties_enabled ? "connected" : "disconnected"] the safety circuit.</span>"
src.visible_message("\icon[src] <b>[src]</b> beeps: \"Caution. Safety circuit has been: [safeties_enabled ? "re-enabled" : "disabled. Please excercise caution."]\"")
/obj/machinery/power/smes/buildable/proc/toggle_input()
input_attempt = !input_attempt
update_icon()
/obj/machinery/power/smes/buildable/proc/toggle_output()
output_attempt = !output_attempt
update_icon()
/obj/machinery/power/smes/buildable/proc/set_input(var/new_input = 0)
input_level = new_input
update_icon()
/obj/machinery/power/smes/buildable/proc/set_output(var/new_output = 0)
output_level = new_output
update_icon()