mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-08-23 20:16:19 +01:00
Merge pull request #7275 from atlantiscze/substation-features
RCON System
This commit is contained in:
@@ -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,13 +67,27 @@
|
||||
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/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
|
||||
if(istype(W, /obj/item/device/multitool))
|
||||
var/newtag = input(user, "Enter new RCON tag. Use \"NO_TAG\" to disable RCON or leave empty to cancel.", "SMES RCON system") as text
|
||||
if(newtag)
|
||||
RCon_tag = newtag
|
||||
user << "<span class='notice'>You changed the RCON tag to: [newtag]</span>"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/obj/machinery/power/breakerbox/proc/set_state(var/state)
|
||||
on = state
|
||||
if(on)
|
||||
@@ -93,3 +119,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
|
||||
@@ -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
|
||||
..()
|
||||
@@ -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
|
||||
@@ -205,8 +233,15 @@
|
||||
// - No action was taken in parent function (terminal de/construction atm).
|
||||
if (..())
|
||||
|
||||
// Multitool - change RCON tag
|
||||
if(istype(W, /obj/item/device/multitool))
|
||||
var/newtag = input(user, "Enter new RCON tag. Use \"NO_TAG\" to disable RCON or leave empty to cancel.", "SMES RCON system") as text
|
||||
if(newtag)
|
||||
RCon_tag = newtag
|
||||
user << "<span class='notice'>You changed the RCON tag to: [newtag]</span>"
|
||||
return
|
||||
// Charged above 1% and safeties are enabled.
|
||||
if((charge > (capacity/100)) && safeties_enabled && (!istype(W, /obj/item/device/multitool)))
|
||||
if((charge > (capacity/100)) && safeties_enabled)
|
||||
user << "<span class='warning'>Safety circuit of [src] is preventing modifications while it's charged!</span>"
|
||||
return
|
||||
|
||||
@@ -263,8 +298,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()
|
||||
@@ -202,6 +202,15 @@ datum/design/air_management
|
||||
materials = list("$glass" = 2000, "sacid" = 20)
|
||||
build_path = /obj/item/weapon/circuitboard/air_management
|
||||
|
||||
datum/design/rcon_console
|
||||
name = "Circuit Design (RCON Console)"
|
||||
desc = "Allows for the construction of circuit boards used to build an RCON Remote Control Console."
|
||||
id = "rcon_console"
|
||||
req_tech = list("programming" = 4, "engineering" = 3, "powerstorage" = 5)
|
||||
build_type = IMPRINTER
|
||||
materials = list("$glass" = 2000, "sacid" = 20)
|
||||
build_path = /obj/item/weapon/circuitboard/rcon_console
|
||||
|
||||
/* Uncomment if someone makes these buildable
|
||||
datum/design/general_alert
|
||||
name = "Circuit Design (General Alert Console)"
|
||||
|
||||
Reference in New Issue
Block a user