diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm
index bbd89d41e57..9baafac6764 100644
--- a/code/modules/power/smes.dm
+++ b/code/modules/power/smes.dm
@@ -11,16 +11,16 @@
density = 1
anchored = 1
use_power = 0
- var/output = 50000
- var/lastout = 0
- var/loaddemand = 0
- var/capacity = 5e6
- var/charge = 1e6
- var/charging = 0
- var/chargemode = 0
- var/chargecount = 0
- var/chargelevel = 50000
- var/online = 1
+ var/output = 50000 //Amount of power it tries to output
+ var/lastout = 0 //Amount of power it actually outputs to the powernet
+ var/loaddemand = 0 //For use in restore()
+ var/capacity = 5e6 //Maximum amount of power it can hold
+ var/charge = 1e6 //Current amount of power it holds
+ var/charging = 0 //1 if it's actually charging, 0 if not
+ var/chargemode = 0 //1 if it's trying to charge, 0 if not.
+ //var/chargecount = 0
+ var/chargelevel = 50000 //Amount of power it tries to charge from powernet
+ var/online = 1 //1 if it's outputting power, 0 if not.
var/name_tag = null
var/obj/machinery/power/terminal/terminal = null
//Holders for powerout event.
@@ -29,6 +29,8 @@
var/last_online = 0
var/open_hatch = 0
var/building_terminal = 0 //Suggestions about how to avoid clickspam building several terminals accepted!
+ var/input_level_max = SMESMAXCHARGELEVEL
+ var/output_level_max = SMESMAXOUTPUT
/obj/machinery/power/smes/New()
..()
@@ -73,7 +75,6 @@
/obj/machinery/power/smes/process()
-
if(stat & BROKEN) return
//store machine state to see if we need to update the icon overlays
@@ -86,19 +87,18 @@
if(charging)
if(excess >= 0) // if there's power available, try to charge
-
var/load = min((capacity-charge)/SMESRATE, chargelevel) // charge at set rate, limited to spare capacity
-
charge += load * SMESRATE // increase the charge
-
add_load(load) // add the load to the terminal side network
else // if not enough capcity
charging = 0 // stop charging
- chargecount = 0
+ //chargecount = 0
else
- if(chargemode)
+ if (chargemode && excess > 0 && excess >= chargelevel)
+ charging = 1
+ /* if(chargemode)
if(chargecount > rand(3,6))
charging = 1
chargecount = 0
@@ -108,15 +108,12 @@
else
chargecount = 0
else
- chargecount = 0
+ chargecount = 0 */
if(online) // if outputting
lastout = min( charge/SMESRATE, output) //limit output to that stored
-
charge -= lastout*SMESRATE // reduce the storage (may be recovered in /restore() if excessive)
-
add_avail(lastout) // add output to powernet (smes side)
-
if(charge < 0.0001)
online = 0 // stop output if charge falls to zero
@@ -160,7 +157,7 @@
//Will return 1 on failure
/obj/machinery/power/smes/proc/make_terminal(const/mob/user)
if (user.loc == loc)
- user << "You must not be on the same tile as the SMES."
+ user << "You must not be on the same tile as the [src]."
return 1
//Direction the terminal will face to
@@ -178,7 +175,7 @@
if(tempLoc.intact)
user << "You must remove the floor plating first."
return 1
- user << "You start adding cable to the SMES."
+ user << "You start adding cable to the [src]."
if(do_after(user, 50))
terminal = new /obj/machinery/power/terminal(tempLoc)
terminal.dir = tempDir
@@ -216,6 +213,7 @@
var/obj/item/weapon/cable_coil/CC = W
if (CC.amount < 10)
user << "You need more cables."
+ building_terminal = 0
return
if (make_terminal(user))
building_terminal = 0
@@ -223,8 +221,8 @@
building_terminal = 0
CC.use(10)
user.visible_message(\
- "[user.name] has added cables to the SMES.",\
- "You added cables the SMES.")
+ "[user.name] has added cables to the [src].",\
+ "You added cables to the [src].")
terminal.connect_to_network()
stat = 0
@@ -242,6 +240,7 @@
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
+ building_terminal = 0
return
new /obj/item/weapon/cable_coil(loc,10)
user.visible_message(\
@@ -263,10 +262,10 @@
data["charging"] = charging
data["chargeMode"] = chargemode
data["chargeLevel"] = chargelevel
- data["chargeMax"] = SMESMAXCHARGELEVEL
+ data["chargeMax"] = input_level_max
data["outputOnline"] = online
data["outputLevel"] = output
- data["outputMax"] = SMESMAXOUTPUT
+ data["outputMax"] = output_level_max
data["outputLoad"] = round(loaddemand)
// update the ui if it exists, returns null if no ui is passed/found
@@ -316,20 +315,20 @@
if("min")
chargelevel = 0
if("max")
- chargelevel = SMESMAXCHARGELEVEL //30000
+ chargelevel = input_level_max
if("set")
- chargelevel = input(usr, "Enter new input level (0-[SMESMAXCHARGELEVEL])", "SMES Input Power Control", chargelevel) as num
- chargelevel = max(0, min(SMESMAXCHARGELEVEL, chargelevel)) // clamp to range
+ chargelevel = input(usr, "Enter new input level (0-[input_level_max])", "SMES Input Power Control", chargelevel) as num
+ chargelevel = max(0, min(input_level_max, chargelevel)) // clamp to range
else if( href_list["output"] )
switch( href_list["output"] )
if("min")
output = 0
if("max")
- output = SMESMAXOUTPUT //30000
+ output = output_level_max
if("set")
- output = input(usr, "Enter new output level (0-[SMESMAXOUTPUT])", "SMES Output Power Control", output) as num
- output = max(0, min(SMESMAXOUTPUT, output)) // clamp to range
+ output = input(usr, "Enter new output level (0-[output_level_max])", "SMES Output Power Control", output) as num
+ output = max(0, min(output_level_max, output)) // clamp to range
investigate_log("input/output; [chargelevel>output?"":""][chargelevel]/[output] | Output-mode: [online?"on":"off"] | Input-mode: [chargemode?"auto":"off"] by [usr.key]","singulo")
@@ -347,7 +346,7 @@
smoke.set_up(3, 0, src.loc)
smoke.attach(src)
smoke.start()
- explosion(src.loc, -1, 0, 1, 3, 0)
+ explosion(src.loc, -1, 0, 1, 3, 1, 0)
del(src)
return
if(prob(15)) //Power drain