|
|
|
@@ -78,6 +78,7 @@
|
|
|
|
|
var/malfhack = 0 //New var for my changes to AI malf. --NeoFite
|
|
|
|
|
var/mob/living/silicon/ai/malfai = null //See above --NeoFite
|
|
|
|
|
var/debug= 0
|
|
|
|
|
var/autoflag= 0 // 0 = off, 1= eqp and lights off, 2 = eqp off, 3 = all on.
|
|
|
|
|
// luminosity = 1
|
|
|
|
|
var/has_electronics = 0 // 0 - none, 1 - plugged in, 2 - secured by screwdriver
|
|
|
|
|
var/overload = 1 //used for the Blackout malf module
|
|
|
|
@@ -142,6 +143,7 @@
|
|
|
|
|
init()
|
|
|
|
|
else
|
|
|
|
|
area = src.loc.loc:master
|
|
|
|
|
area.apc |= src
|
|
|
|
|
opened = 1
|
|
|
|
|
operating = 0
|
|
|
|
|
name = "[area.name] APC"
|
|
|
|
@@ -168,6 +170,7 @@
|
|
|
|
|
cell.charge = start_charge * cell.maxcharge / 100.0 // (convert percentage to actual value)
|
|
|
|
|
|
|
|
|
|
var/area/A = src.loc.loc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if area isn't specified use current
|
|
|
|
|
if(isarea(A) && src.areastring == null)
|
|
|
|
@@ -176,6 +179,7 @@
|
|
|
|
|
else
|
|
|
|
|
src.area = get_area_name(areastring)
|
|
|
|
|
name = "\improper [area.name] APC"
|
|
|
|
|
area.apc |= src
|
|
|
|
|
update_icon()
|
|
|
|
|
|
|
|
|
|
make_terminal()
|
|
|
|
@@ -915,6 +919,7 @@
|
|
|
|
|
if(user.lying)
|
|
|
|
|
user << "\red You must stand to use this [src]!"
|
|
|
|
|
return 0
|
|
|
|
|
autoflag = 5
|
|
|
|
|
if (istype(user, /mob/living/silicon))
|
|
|
|
|
var/mob/living/silicon/ai/AI = user
|
|
|
|
|
var/mob/living/silicon/robot/robot = user
|
|
|
|
@@ -1150,16 +1155,6 @@
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (equipment > 1) // off=0, off auto=1, on=2, on auto=3
|
|
|
|
|
use_power(src.equip_consumption, EQUIP)
|
|
|
|
|
if (lighting > 1) // off=0, off auto=1, on=2, on auto=3
|
|
|
|
|
use_power(src.light_consumption, LIGHT)
|
|
|
|
|
if (environ > 1) // off=0, off auto=1, on=2, on auto=3
|
|
|
|
|
use_power(src.environ_consumption, ENVIRON)
|
|
|
|
|
|
|
|
|
|
area.calc_lighting() */
|
|
|
|
|
|
|
|
|
|
lastused_light = area.usage(LIGHT)
|
|
|
|
|
lastused_equip = area.usage(EQUIP)
|
|
|
|
|
lastused_environ = area.usage(ENVIRON)
|
|
|
|
@@ -1191,10 +1186,12 @@
|
|
|
|
|
world << "Status: [main_status] - Excess: [excess] - Last Equip: [lastused_equip] - Last Light: [lastused_light]"
|
|
|
|
|
|
|
|
|
|
if(cell && !shorted)
|
|
|
|
|
var/cell_charge = cell.charge
|
|
|
|
|
var/cell_maxcharge = cell.maxcharge
|
|
|
|
|
|
|
|
|
|
// draw power from cell as before
|
|
|
|
|
|
|
|
|
|
var/cellused = min(cell.charge, CELLRATE * lastused_total) // clamp deduction to a max, amount left in cell
|
|
|
|
|
var/cellused = min(cell_charge, CELLRATE * lastused_total) // clamp deduction to a max, amount left in cell
|
|
|
|
|
cell.use(cellused)
|
|
|
|
|
|
|
|
|
|
if(excess > 0 || perapc > lastused_total) // if power excess, or enough anyway, recharge the cell
|
|
|
|
@@ -1205,19 +1202,21 @@
|
|
|
|
|
|
|
|
|
|
else // no excess, and not enough per-apc
|
|
|
|
|
|
|
|
|
|
if( (cell.charge/CELLRATE+perapc) >= lastused_total) // can we draw enough from cell+grid to cover last usage?
|
|
|
|
|
if( (cell_charge/CELLRATE+perapc) >= lastused_total) // can we draw enough from cell+grid to cover last usage?
|
|
|
|
|
|
|
|
|
|
cell.charge = min(cell.maxcharge, cell.charge + CELLRATE * perapc) //recharge with what we can
|
|
|
|
|
cell_charge = min(cell_maxcharge, cell_charge + CELLRATE * perapc) //recharge with what we can
|
|
|
|
|
cell.charge = cell_charge
|
|
|
|
|
add_load(perapc) // so draw what we can from the grid
|
|
|
|
|
charging = 0
|
|
|
|
|
|
|
|
|
|
else // not enough power available to run the last tick!
|
|
|
|
|
else if (autoflag != 0) // not enough power available to run the last tick!
|
|
|
|
|
charging = 0
|
|
|
|
|
chargecount = 0
|
|
|
|
|
// This turns everything off in the case that there is still a charge left on the battery, just not enough to run the room.
|
|
|
|
|
equipment = autoset(equipment, 0)
|
|
|
|
|
lighting = autoset(lighting, 0)
|
|
|
|
|
environ = autoset(environ, 0)
|
|
|
|
|
autoflag = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set channels depending on how much charge we have left
|
|
|
|
@@ -1228,39 +1227,44 @@
|
|
|
|
|
else if(longtermpower > -10)
|
|
|
|
|
longtermpower -= 2
|
|
|
|
|
|
|
|
|
|
if(cell.charge <= 0) // zero charge, turn all off
|
|
|
|
|
equipment = autoset(equipment, 0)
|
|
|
|
|
lighting = autoset(lighting, 0)
|
|
|
|
|
environ = autoset(environ, 0)
|
|
|
|
|
area.poweralert(0, src)
|
|
|
|
|
else if(cell.percent() < 15 && longtermpower < 0) // <15%, turn off lighting & equipment
|
|
|
|
|
equipment = autoset(equipment, 2)
|
|
|
|
|
lighting = autoset(lighting, 2)
|
|
|
|
|
environ = autoset(environ, 1)
|
|
|
|
|
area.poweralert(0, src)
|
|
|
|
|
else if(cell.percent() < 30 && longtermpower < 0) // <30%, turn off equipment
|
|
|
|
|
equipment = autoset(equipment, 2)
|
|
|
|
|
lighting = autoset(lighting, 1)
|
|
|
|
|
environ = autoset(environ, 1)
|
|
|
|
|
area.poweralert(0, src)
|
|
|
|
|
else // otherwise all can be on
|
|
|
|
|
equipment = autoset(equipment, 1)
|
|
|
|
|
lighting = autoset(lighting, 1)
|
|
|
|
|
environ = autoset(environ, 1)
|
|
|
|
|
area.poweralert(1, src)
|
|
|
|
|
if(cell.percent() > 75)
|
|
|
|
|
|
|
|
|
|
if(cell_charge >= 1250 || longtermpower > 0) // Put most likely at the top so we don't check it last, effeciency 101
|
|
|
|
|
if(autoflag != 3)
|
|
|
|
|
equipment = autoset(equipment, 1)
|
|
|
|
|
lighting = autoset(lighting, 1)
|
|
|
|
|
environ = autoset(environ, 1)
|
|
|
|
|
autoflag = 3
|
|
|
|
|
area.poweralert(1, src)
|
|
|
|
|
if(cell_charge >= 4000)
|
|
|
|
|
area.poweralert(1, src)
|
|
|
|
|
else if(cell_charge < 1250 && longtermpower < 0) // <30%, turn off equipment
|
|
|
|
|
if(autoflag != 2)
|
|
|
|
|
equipment = autoset(equipment, 2)
|
|
|
|
|
lighting = autoset(lighting, 1)
|
|
|
|
|
environ = autoset(environ, 1)
|
|
|
|
|
area.poweralert(0, src)
|
|
|
|
|
autoflag = 2
|
|
|
|
|
else if(cell_charge < 750 && longtermpower < 0) // <15%, turn off lighting & equipment
|
|
|
|
|
if(autoflag != 1)
|
|
|
|
|
equipment = autoset(equipment, 2)
|
|
|
|
|
lighting = autoset(lighting, 2)
|
|
|
|
|
environ = autoset(environ, 1)
|
|
|
|
|
area.poweralert(0, src)
|
|
|
|
|
autoflag = 1
|
|
|
|
|
else if(cell_charge <= 0) // zero charge, turn all off
|
|
|
|
|
if(autoflag != 0)
|
|
|
|
|
equipment = autoset(equipment, 0)
|
|
|
|
|
lighting = autoset(lighting, 0)
|
|
|
|
|
environ = autoset(environ, 0)
|
|
|
|
|
area.poweralert(0, src)
|
|
|
|
|
autoflag = 0
|
|
|
|
|
|
|
|
|
|
// now trickle-charge the cell
|
|
|
|
|
|
|
|
|
|
if(chargemode && charging == 1 && operating)
|
|
|
|
|
if(excess > 0) // check to make sure we have enough to charge
|
|
|
|
|
// Max charge is perapc share, capped to cell capacity, or % per second constant (Whichever is smallest)
|
|
|
|
|
/* var/ch = min(perapc, (cell.maxcharge - cell.charge), (cell.maxcharge*CHARGELEVEL))
|
|
|
|
|
add_load(ch) // Removes the power we're taking from the grid
|
|
|
|
|
cell.give(ch) // actually recharge the cell
|
|
|
|
|
*/
|
|
|
|
|
var/ch = min(perapc*CELLRATE, (cell.maxcharge - cell.charge), (cell.maxcharge*CHARGELEVEL))
|
|
|
|
|
var/ch = min(perapc*CELLRATE, (cell_maxcharge - cell_charge), (cell_maxcharge*CHARGELEVEL))
|
|
|
|
|
add_load(ch/CELLRATE) // Removes the power we're taking from the grid
|
|
|
|
|
cell.give(ch) // actually recharge the cell
|
|
|
|
|
|
|
|
|
@@ -1270,12 +1274,12 @@
|
|
|
|
|
|
|
|
|
|
// show cell as fully charged if so
|
|
|
|
|
|
|
|
|
|
if(cell.charge >= cell.maxcharge)
|
|
|
|
|
if(cell.charge >= cell_maxcharge)
|
|
|
|
|
charging = 2
|
|
|
|
|
|
|
|
|
|
if(chargemode)
|
|
|
|
|
if(!charging)
|
|
|
|
|
if(excess > cell.maxcharge*CHARGELEVEL)
|
|
|
|
|
if(excess > cell_maxcharge*CHARGELEVEL)
|
|
|
|
|
chargecount++
|
|
|
|
|
else
|
|
|
|
|
chargecount = 0
|
|
|
|
@@ -1297,6 +1301,8 @@
|
|
|
|
|
lighting = autoset(lighting, 0)
|
|
|
|
|
environ = autoset(environ, 0)
|
|
|
|
|
area.poweralert(0, src)
|
|
|
|
|
autoflag = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// update icon & area power if anything changed
|
|
|
|
|
|
|
|
|
|