mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-11 15:14:27 +01:00
Powernet Tweaks
This commit is contained in:
+12
-15
@@ -28,11 +28,11 @@
|
||||
#define APC_UPOVERLAY_ENVIRON2 2048
|
||||
#define APC_UPOVERLAY_LOCKED 4096
|
||||
|
||||
#define APC_UPDATE_ICON_COOLDOWN 100 // 10 seconds
|
||||
#define APC_UPDATE_ICON_COOLDOWN 200 // 20 seconds
|
||||
|
||||
|
||||
// the Area Power Controller (APC), formerly Power Distribution Unit (PDU)
|
||||
// one per area, needs wire conection to power network
|
||||
// one per area, needs wire conection to power network through a terminal
|
||||
|
||||
// controls power to devices in that area
|
||||
// may be opened to change power cell
|
||||
@@ -1064,7 +1064,7 @@
|
||||
|
||||
/obj/machinery/power/apc/add_load(var/amount)
|
||||
if(terminal && terminal.powernet)
|
||||
terminal.powernet.newload += amount
|
||||
terminal.powernet.load += amount
|
||||
|
||||
/obj/machinery/power/apc/avail()
|
||||
if(terminal)
|
||||
@@ -1102,10 +1102,6 @@
|
||||
else
|
||||
main_status = 2
|
||||
|
||||
var/perapc = 0
|
||||
if(terminal && terminal.powernet)
|
||||
perapc = terminal.powernet.perapc
|
||||
|
||||
//if(debug)
|
||||
//world << "Status: [main_status] - Excess: [excess] - Last Equip: [lastused_equip] - Last Light: [lastused_light]"
|
||||
|
||||
@@ -1113,12 +1109,12 @@
|
||||
var/cell_charge = cell.charge
|
||||
var/cell_maxcharge = cell.maxcharge
|
||||
|
||||
// draw power from cell as before
|
||||
// draw power from cell as before to power the area
|
||||
|
||||
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
|
||||
if(excess > lastused_total) // if power excess recharge the cell
|
||||
// by the same amount just used
|
||||
cell.give(cellused)
|
||||
add_load(cellused/CELLRATE) // add the load used to recharge the cell
|
||||
@@ -1126,10 +1122,10 @@
|
||||
|
||||
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 + excess) >= 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
|
||||
add_load(perapc) // so draw what we can from the grid
|
||||
cell_charge = min(cell_maxcharge, cell_charge + CELLRATE * excess) //recharge with what we can
|
||||
add_load(excess) // so draw what we can from the grid
|
||||
charging = 0
|
||||
|
||||
else if (autoflag != 0) // not enough power available to run the last tick!
|
||||
@@ -1186,8 +1182,8 @@
|
||||
|
||||
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*CELLRATE, (cell_maxcharge - cell_charge), (cell_maxcharge*CHARGELEVEL))
|
||||
// Max charge is capped to % per second constant
|
||||
var/ch = min(excess*CELLRATE, cell.maxcharge*CHARGELEVEL)
|
||||
add_load(ch/CELLRATE) // Removes the power we're taking from the grid
|
||||
cell.give(ch) // actually recharge the cell
|
||||
|
||||
@@ -1197,7 +1193,8 @@
|
||||
|
||||
// show cell as fully charged if so
|
||||
|
||||
if(cell.charge >= cell_maxcharge)
|
||||
if(cell.charge >= cell.maxcharge)
|
||||
cell.charge = cell.maxcharge
|
||||
charging = 2
|
||||
|
||||
if(chargemode)
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
if( !(pn_input.avail >= LOGIC_HIGH))
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) && (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
//OR GATE
|
||||
/obj/machinery/logic/twoinput/or/process()
|
||||
@@ -222,7 +222,7 @@
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) || (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
//XOR GATE
|
||||
/obj/machinery/logic/twoinput/xor/process()
|
||||
@@ -242,7 +242,7 @@
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) != (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
//XNOR GATE (EQUIVALENCE)
|
||||
/obj/machinery/logic/twoinput/xnor/process()
|
||||
@@ -262,7 +262,7 @@
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) == (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
#define RELAY_POWER_TRANSFER 2000 //How much power a relay transfers through.
|
||||
|
||||
@@ -284,7 +284,7 @@
|
||||
return
|
||||
|
||||
if(pn_input2.avail >= RELAY_POWER_TRANSFER)
|
||||
pn_input2.newload += RELAY_POWER_TRANSFER
|
||||
pn_input2.load += RELAY_POWER_TRANSFER
|
||||
pn_output.newavail += RELAY_POWER_TRANSFER
|
||||
|
||||
|
||||
|
||||
+17
-47
@@ -20,7 +20,7 @@
|
||||
|
||||
/obj/machinery/power/proc/add_load(var/amount)
|
||||
if(powernet)
|
||||
powernet.newload += amount
|
||||
powernet.load += amount
|
||||
|
||||
/obj/machinery/power/proc/surplus()
|
||||
if(powernet)
|
||||
@@ -313,55 +313,25 @@
|
||||
|
||||
|
||||
/datum/powernet/proc/reset()
|
||||
load = newload
|
||||
newload = 0
|
||||
|
||||
//see if there's a surplus of power remaining in the powernet and stores unused power in the SMES
|
||||
netexcess = avail - load
|
||||
|
||||
if(netexcess > 100 && nodes && nodes.len) // if there was excess power last cycle
|
||||
for(var/obj/machinery/power/smes/S in nodes) // find the SMESes in the network
|
||||
S.restore() // and restore some of the power that was used
|
||||
|
||||
//updates the viewed load (as seen on power computers)
|
||||
viewload = 0.8*viewload + 0.2*load
|
||||
viewload = round(viewload)
|
||||
|
||||
//reset the powernet
|
||||
load = 0
|
||||
avail = newavail
|
||||
newavail = 0
|
||||
|
||||
|
||||
viewload = 0.8*viewload + 0.2*load
|
||||
|
||||
viewload = round(viewload)
|
||||
|
||||
var/numapc = 0
|
||||
|
||||
if(nodes && nodes.len) // Added to fix a bad list bug -- TLE
|
||||
for(var/obj/machinery/power/terminal/term in nodes)
|
||||
if( istype( term.master, /obj/machinery/power/apc ) )
|
||||
numapc++
|
||||
|
||||
if(numapc)
|
||||
perapc = avail/numapc
|
||||
|
||||
netexcess = avail - load
|
||||
|
||||
if( netexcess > 100) // if there was excess power last cycle
|
||||
if(nodes && nodes.len)
|
||||
for(var/obj/machinery/power/smes/S in nodes) // find the SMESes in the network
|
||||
if(S.powernet == src)
|
||||
S.restore() // and restore some of the power that was used
|
||||
else
|
||||
error("[S.name] (\ref[S]) had a [S.powernet ? "different (\ref[S.powernet])" : "null"] powernet to our powernet (\ref[src]).")
|
||||
nodes.Remove(S)
|
||||
|
||||
/datum/powernet/proc/get_electrocute_damage()
|
||||
switch(avail)/*
|
||||
if (1300000 to INFINITY)
|
||||
return min(rand(70,150),rand(70,150))
|
||||
if (750000 to 1300000)
|
||||
return min(rand(50,115),rand(50,115))
|
||||
if (100000 to 750000-1)
|
||||
return min(rand(35,101),rand(35,101))
|
||||
if (75000 to 100000-1)
|
||||
return min(rand(30,95),rand(30,95))
|
||||
if (50000 to 75000-1)
|
||||
return min(rand(25,80),rand(25,80))
|
||||
if (25000 to 50000-1)
|
||||
return min(rand(20,70),rand(20,70))
|
||||
if (10000 to 25000-1)
|
||||
return min(rand(20,65),rand(20,65))
|
||||
if (1000 to 10000-1)
|
||||
return min(rand(10,20),rand(10,20))*/
|
||||
switch(avail)
|
||||
if (5000000 to INFINITY)
|
||||
return min(rand(200,300),rand(200,300))
|
||||
if (4000000 to 5000000)
|
||||
@@ -502,7 +472,7 @@
|
||||
source_area.use_power(drained_energy/CELLRATE)
|
||||
else if (istype(power_source,/datum/powernet))
|
||||
var/drained_power = drained_energy/CELLRATE //convert from "joules" to "watts"
|
||||
PN.newload+=drained_power
|
||||
PN.load+=drained_power
|
||||
else if (istype(power_source, /obj/item/weapon/stock_parts/cell))
|
||||
cell.use(drained_energy)
|
||||
return drained_energy
|
||||
|
||||
+12
-12
@@ -3,6 +3,7 @@
|
||||
|
||||
#define SMESMAXCHARGELEVEL 200000
|
||||
#define SMESMAXOUTPUT 200000
|
||||
#define SMESRATE 0.05 // rate of internal charge to external power
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +45,7 @@
|
||||
spawn(5)
|
||||
if(!powernet)
|
||||
connect_to_network()
|
||||
|
||||
|
||||
dir_loop:
|
||||
for(var/d in cardinal)
|
||||
var/turf/T = get_step(src, d)
|
||||
@@ -71,7 +72,7 @@
|
||||
for(var/obj/item/weapon/stock_parts/cell/PC in component_parts)
|
||||
C += PC.maxcharge
|
||||
capacity = C / (15000) * 1e6
|
||||
|
||||
|
||||
/obj/machinery/power/smes/proc/updateicon()
|
||||
overlays.Cut()
|
||||
if(stat & BROKEN) return
|
||||
@@ -225,21 +226,20 @@
|
||||
/obj/machinery/power/smes/proc/make_terminal(var/turf/T)
|
||||
terminal = new/obj/machinery/power/terminal(T)
|
||||
terminal.dir = get_dir(T,src)
|
||||
terminal.master = src
|
||||
|
||||
terminal.master = src
|
||||
|
||||
/obj/machinery/power/smes/proc/disconnect_terminal()
|
||||
if(terminal)
|
||||
terminal.master = null
|
||||
terminal = null
|
||||
|
||||
terminal = null
|
||||
|
||||
/obj/machinery/power/smes/proc/chargedisplay()
|
||||
return round(5.5*charge/capacity)
|
||||
|
||||
#define SMESRATE 0.05 // rate of internal charge to external power
|
||||
|
||||
|
||||
/obj/machinery/power/smes/process()
|
||||
if(stat & BROKEN)
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
//store machine state to see if we need to update the icon overlays
|
||||
@@ -326,16 +326,16 @@
|
||||
|
||||
/obj/machinery/power/smes/add_load(var/amount)
|
||||
if(terminal && terminal.powernet)
|
||||
terminal.powernet.newload += amount
|
||||
terminal.powernet.load += amount
|
||||
|
||||
|
||||
/obj/machinery/power/smes/attack_ai(mob/user)
|
||||
add_fingerprint(user)
|
||||
ui_interact(user)
|
||||
|
||||
|
||||
/obj/machinery/power/smes/attack_ghost(mob/user)
|
||||
ui_interact(user)
|
||||
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/smes/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
ui_interact(user)
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
powered = 1
|
||||
if(PN)
|
||||
storedpower += shieldload
|
||||
PN.newload += shieldload //uses powernet power.
|
||||
PN.load += shieldload //uses powernet power.
|
||||
*/
|
||||
|
||||
/obj/machinery/shield_gen/proc/toggle()
|
||||
|
||||
Reference in New Issue
Block a user