mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 03:33:21 +00:00
Merge pull request #6948 from atlantiscze/power-related-multifix
[Ready To Merge] Power Multifix
This commit is contained in:
@@ -49,7 +49,7 @@
|
|||||||
if(S.z != 1)
|
if(S.z != 1)
|
||||||
continue
|
continue
|
||||||
S.charge = S.capacity
|
S.charge = S.capacity
|
||||||
S.output = 200000
|
S.output = S.output_level_max // Most new SMESs on map are of buildable type, and may actually have higher output limit than 200kW. Use max output of that SMES instead.
|
||||||
S.online = 1
|
S.online = 1
|
||||||
S.updateicon()
|
S.updateicon()
|
||||||
S.power_change()
|
S.power_change()
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
/obj/item/weapon/rack_parts,
|
/obj/item/weapon/rack_parts,
|
||||||
/obj/item/weapon/camera_assembly,
|
/obj/item/weapon/camera_assembly,
|
||||||
/obj/item/weapon/tank,
|
/obj/item/weapon/tank,
|
||||||
/obj/item/weapon/circuitboard
|
/obj/item/weapon/circuitboard,
|
||||||
|
/obj/item/weapon/smes_coil
|
||||||
)
|
)
|
||||||
|
|
||||||
//Item currently being held.
|
//Item currently being held.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
name = "Breaker Box"
|
name = "Breaker Box"
|
||||||
icon = 'icons/obj/power.dmi'
|
icon = 'icons/obj/power.dmi'
|
||||||
icon_state = "bbox_off"
|
icon_state = "bbox_off"
|
||||||
|
directwired = 0
|
||||||
var/icon_state_on = "bbox_on"
|
var/icon_state_on = "bbox_on"
|
||||||
var/icon_state_off = "bbox_off"
|
var/icon_state_off = "bbox_off"
|
||||||
flags = FPRINT
|
flags = FPRINT
|
||||||
|
|||||||
@@ -207,7 +207,8 @@
|
|||||||
icon_state = "coil"
|
icon_state = "coil"
|
||||||
amount = MAXCOIL
|
amount = MAXCOIL
|
||||||
max_amount = MAXCOIL
|
max_amount = MAXCOIL
|
||||||
item_color = COLOR_RED
|
color = COLOR_RED
|
||||||
|
//item_color = COLOR_RED Use regular "color" var instead. No need to have it duplicate in two vars. Causes confusion.
|
||||||
desc = "A coil of power cable."
|
desc = "A coil of power cable."
|
||||||
throwforce = 10
|
throwforce = 10
|
||||||
w_class = 2.0
|
w_class = 2.0
|
||||||
@@ -227,10 +228,8 @@
|
|||||||
/obj/item/stack/cable_coil/New(loc, length = MAXCOIL, var/param_color = null)
|
/obj/item/stack/cable_coil/New(loc, length = MAXCOIL, var/param_color = null)
|
||||||
..()
|
..()
|
||||||
src.amount = length
|
src.amount = length
|
||||||
if (param_color)
|
if (param_color) // It should be red by default, so only recolor it if parameter was specified.
|
||||||
color = param_color
|
color = param_color
|
||||||
else
|
|
||||||
color = item_color
|
|
||||||
pixel_x = rand(-2,2)
|
pixel_x = rand(-2,2)
|
||||||
pixel_y = rand(-2,2)
|
pixel_y = rand(-2,2)
|
||||||
updateicon()
|
updateicon()
|
||||||
@@ -239,7 +238,6 @@
|
|||||||
/obj/item/stack/cable_coil/proc/updateicon()
|
/obj/item/stack/cable_coil/proc/updateicon()
|
||||||
if (!color)
|
if (!color)
|
||||||
color = pick(COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_ORANGE, COLOR_WHITE, COLOR_PINK, COLOR_YELLOW, COLOR_CYAN)
|
color = pick(COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_ORANGE, COLOR_WHITE, COLOR_PINK, COLOR_YELLOW, COLOR_CYAN)
|
||||||
item_color = color
|
|
||||||
if(amount == 1)
|
if(amount == 1)
|
||||||
icon_state = "coil1"
|
icon_state = "coil1"
|
||||||
name = "cable piece"
|
name = "cable piece"
|
||||||
@@ -277,7 +275,7 @@
|
|||||||
usr << "<span class='warning'>You need at least 15 lengths to make restraints!</span>"
|
usr << "<span class='warning'>You need at least 15 lengths to make restraints!</span>"
|
||||||
return
|
return
|
||||||
var/obj/item/weapon/handcuffs/cable/B = new /obj/item/weapon/handcuffs/cable(usr.loc)
|
var/obj/item/weapon/handcuffs/cable/B = new /obj/item/weapon/handcuffs/cable(usr.loc)
|
||||||
B.color = item_color
|
B.color = color
|
||||||
usr << "<span class='notice'>You wind some cable together to make some restraints.</span>"
|
usr << "<span class='notice'>You wind some cable together to make some restraints.</span>"
|
||||||
src.use(15)
|
src.use(15)
|
||||||
else
|
else
|
||||||
@@ -287,7 +285,7 @@
|
|||||||
/obj/item/stack/cable_coil/attackby(obj/item/weapon/W, mob/user)
|
/obj/item/stack/cable_coil/attackby(obj/item/weapon/W, mob/user)
|
||||||
if( istype(W, /obj/item/weapon/wirecutters) && src.amount > 1)
|
if( istype(W, /obj/item/weapon/wirecutters) && src.amount > 1)
|
||||||
src.amount--
|
src.amount--
|
||||||
new/obj/item/stack/cable_coil(user.loc, 1,item_color)
|
new/obj/item/stack/cable_coil(user.loc, 1,color)
|
||||||
user << "<span class='notice'>You cut a piece off the cable coil.</span>"
|
user << "<span class='notice'>You cut a piece off the cable coil.</span>"
|
||||||
src.updateicon()
|
src.updateicon()
|
||||||
src.update_wclass()
|
src.update_wclass()
|
||||||
@@ -375,7 +373,7 @@
|
|||||||
var/obj/structure/cable/C = new(F)
|
var/obj/structure/cable/C = new(F)
|
||||||
var/obj/structure/cable/D = new(temp.floorbelow)
|
var/obj/structure/cable/D = new(temp.floorbelow)
|
||||||
|
|
||||||
C.cableColor(item_color)
|
C.cableColor(color)
|
||||||
|
|
||||||
C.d1 = 11
|
C.d1 = 11
|
||||||
C.d2 = dirn
|
C.d2 = dirn
|
||||||
@@ -389,7 +387,7 @@
|
|||||||
C.mergeConnectedNetworks(C.d2)
|
C.mergeConnectedNetworks(C.d2)
|
||||||
C.mergeConnectedNetworksOnTurf()
|
C.mergeConnectedNetworksOnTurf()
|
||||||
|
|
||||||
D.cableColor(item_color)
|
D.cableColor(color)
|
||||||
|
|
||||||
D.d1 = 12
|
D.d1 = 12
|
||||||
D.d2 = 0
|
D.d2 = 0
|
||||||
@@ -412,7 +410,7 @@
|
|||||||
|
|
||||||
var/obj/structure/cable/C = new(F)
|
var/obj/structure/cable/C = new(F)
|
||||||
|
|
||||||
C.cableColor(item_color)
|
C.cableColor(color)
|
||||||
|
|
||||||
C.d1 = 0
|
C.d1 = 0
|
||||||
C.d2 = dirn
|
C.d2 = dirn
|
||||||
@@ -475,7 +473,7 @@
|
|||||||
return
|
return
|
||||||
|
|
||||||
var/obj/structure/cable/NC = new(U)
|
var/obj/structure/cable/NC = new(U)
|
||||||
NC.cableColor(item_color)
|
NC.cableColor(color)
|
||||||
|
|
||||||
NC.d1 = 0
|
NC.d1 = 0
|
||||||
NC.d2 = fdirn
|
NC.d2 = fdirn
|
||||||
@@ -513,7 +511,7 @@
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
C.cableColor(item_color)
|
C.cableColor(color)
|
||||||
|
|
||||||
C.d1 = nd1
|
C.d1 = nd1
|
||||||
C.d2 = nd2
|
C.d2 = nd2
|
||||||
@@ -619,28 +617,28 @@ obj/structure/cable/proc/cableColor(var/colorC)
|
|||||||
update_wclass()
|
update_wclass()
|
||||||
|
|
||||||
/obj/item/stack/cable_coil/yellow
|
/obj/item/stack/cable_coil/yellow
|
||||||
item_color = COLOR_YELLOW
|
color = COLOR_YELLOW
|
||||||
|
|
||||||
/obj/item/stack/cable_coil/blue
|
/obj/item/stack/cable_coil/blue
|
||||||
item_color = COLOR_BLUE
|
color = COLOR_BLUE
|
||||||
|
|
||||||
/obj/item/stack/cable_coil/green
|
/obj/item/stack/cable_coil/green
|
||||||
item_color = COLOR_GREEN
|
color = COLOR_GREEN
|
||||||
|
|
||||||
/obj/item/stack/cable_coil/pink
|
/obj/item/stack/cable_coil/pink
|
||||||
item_color = COLOR_PINK
|
color = COLOR_PINK
|
||||||
|
|
||||||
/obj/item/stack/cable_coil/orange
|
/obj/item/stack/cable_coil/orange
|
||||||
item_color = COLOR_ORANGE
|
color = COLOR_ORANGE
|
||||||
|
|
||||||
/obj/item/stack/cable_coil/cyan
|
/obj/item/stack/cable_coil/cyan
|
||||||
item_color = COLOR_CYAN
|
color = COLOR_CYAN
|
||||||
|
|
||||||
/obj/item/stack/cable_coil/white
|
/obj/item/stack/cable_coil/white
|
||||||
item_color = COLOR_WHITE
|
color = COLOR_WHITE
|
||||||
|
|
||||||
/obj/item/stack/cable_coil/random/New()
|
/obj/item/stack/cable_coil/random/New()
|
||||||
item_color = pick(COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_WHITE, COLOR_PINK, COLOR_YELLOW, COLOR_CYAN)
|
color = pick(COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_WHITE, COLOR_PINK, COLOR_YELLOW, COLOR_CYAN)
|
||||||
..()
|
..()
|
||||||
|
|
||||||
/obj/item/stack/cable_coil/attack(mob/M as mob, mob/user as mob)
|
/obj/item/stack/cable_coil/attack(mob/M as mob, mob/user as mob)
|
||||||
|
|||||||
@@ -112,8 +112,7 @@
|
|||||||
C.powernet.cables += C
|
C.powernet.cables += C
|
||||||
|
|
||||||
for(var/obj/machinery/power/M in machines)
|
for(var/obj/machinery/power/M in machines)
|
||||||
if(!M.powernet) continue // APCs have powernet=0 so they don't count as network nodes directly
|
M.connect_to_network()
|
||||||
M.powernet.nodes[M] = M
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -232,12 +231,17 @@
|
|||||||
return .
|
return .
|
||||||
|
|
||||||
/obj/machinery/power/proc/connect_to_network()
|
/obj/machinery/power/proc/connect_to_network()
|
||||||
|
// First disconnect us from the old powernet
|
||||||
|
if(powernet)
|
||||||
|
powernet.nodes -= src
|
||||||
|
powernet = null
|
||||||
|
// Then find any cables on our location
|
||||||
var/turf/T = src.loc
|
var/turf/T = src.loc
|
||||||
var/obj/structure/cable/C = T.get_cable_node()
|
var/obj/structure/cable/C = T.get_cable_node()
|
||||||
if(!C || !C.powernet) return 0
|
if(!C || !C.powernet) return 0
|
||||||
// makepowernets() //TODO: find fast way //EWWWW what are you doing!?
|
// And connect us to their powernet
|
||||||
powernet = C.powernet
|
powernet = C.powernet
|
||||||
powernet.nodes[src] = src
|
powernet.nodes += src
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
/obj/machinery/power/proc/disconnect_from_network()
|
/obj/machinery/power/proc/disconnect_from_network()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
density = 1
|
density = 1
|
||||||
anchored = 1
|
anchored = 1
|
||||||
use_power = 0
|
use_power = 0
|
||||||
|
directwired = 0
|
||||||
var/output = 50000 //Amount of power it tries to output
|
var/output = 50000 //Amount of power it tries to output
|
||||||
var/lastout = 0 //Amount of power it actually outputs to the powernet
|
var/lastout = 0 //Amount of power it actually outputs to the powernet
|
||||||
var/loaddemand = 0 //For use in restore()
|
var/loaddemand = 0 //For use in restore()
|
||||||
@@ -60,7 +61,9 @@
|
|||||||
|
|
||||||
overlays += image('icons/obj/power.dmi', "smes-op[online]")
|
overlays += image('icons/obj/power.dmi', "smes-op[online]")
|
||||||
|
|
||||||
if(charging)
|
if(charging == 2)
|
||||||
|
overlays += image('icons/obj/power.dmi', "smes-oc2")
|
||||||
|
else if (charging == 1)
|
||||||
overlays += image('icons/obj/power.dmi', "smes-oc1")
|
overlays += image('icons/obj/power.dmi', "smes-oc1")
|
||||||
else
|
else
|
||||||
if(chargemode)
|
if(chargemode)
|
||||||
@@ -95,9 +98,11 @@
|
|||||||
var/actual_load = add_load(target_load) // add the load to the terminal side network
|
var/actual_load = add_load(target_load) // add the load to the terminal side network
|
||||||
charge += actual_load * SMESRATE // increase the charge
|
charge += actual_load * SMESRATE // increase the charge
|
||||||
|
|
||||||
if (actual_load >= target_load) // did the powernet have enough power available for us?
|
if (actual_load >= target_load) // Did we charge at full rate?
|
||||||
|
charging = 2
|
||||||
|
else if (actual_load) // If not, did we charge at least partially?
|
||||||
charging = 1
|
charging = 1
|
||||||
else
|
else // Or not at all?
|
||||||
charging = 0
|
charging = 0
|
||||||
|
|
||||||
if(online) // if outputting
|
if(online) // if outputting
|
||||||
@@ -222,6 +227,7 @@
|
|||||||
"<span class='notice'>You added cables to the [src].</span>")
|
"<span class='notice'>You added cables to the [src].</span>")
|
||||||
terminal.connect_to_network()
|
terminal.connect_to_network()
|
||||||
stat = 0
|
stat = 0
|
||||||
|
return 0
|
||||||
|
|
||||||
else if(istype(W, /obj/item/weapon/wirecutters) && terminal && !building_terminal)
|
else if(istype(W, /obj/item/weapon/wirecutters) && terminal && !building_terminal)
|
||||||
building_terminal = 1
|
building_terminal = 1
|
||||||
@@ -245,6 +251,7 @@
|
|||||||
"<span class='notice'>You cut the cables and dismantle the power terminal.</span>")
|
"<span class='notice'>You cut the cables and dismantle the power terminal.</span>")
|
||||||
del(terminal)
|
del(terminal)
|
||||||
building_terminal = 0
|
building_terminal = 0
|
||||||
|
return 0
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
/obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
/obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||||
|
|||||||
@@ -113,7 +113,8 @@
|
|||||||
h_user << "Medium electrical sparks as you touch the [src], severely burning your hand!"
|
h_user << "Medium electrical sparks as you touch the [src], severely burning your hand!"
|
||||||
h_user.adjustFireLoss(rand(10,25))
|
h_user.adjustFireLoss(rand(10,25))
|
||||||
h_user.Paralyse(5)
|
h_user.Paralyse(5)
|
||||||
empulse(src.loc, 2, 4)
|
spawn(0)
|
||||||
|
empulse(src.loc, 2, 4)
|
||||||
charge = 0
|
charge = 0
|
||||||
|
|
||||||
if (36 to 60)
|
if (36 to 60)
|
||||||
@@ -129,7 +130,8 @@
|
|||||||
h_user << "Strong electrical arc sparks between you and [src], knocking you out for a while!"
|
h_user << "Strong electrical arc sparks between you and [src], knocking you out for a while!"
|
||||||
h_user.adjustFireLoss(rand(35,75))
|
h_user.adjustFireLoss(rand(35,75))
|
||||||
h_user.Paralyse(12)
|
h_user.Paralyse(12)
|
||||||
empulse(src.loc, 8, 16)
|
spawn(0)
|
||||||
|
empulse(src.loc, 8, 16)
|
||||||
charge = 0
|
charge = 0
|
||||||
apcs_overload(1, 10)
|
apcs_overload(1, 10)
|
||||||
src.visible_message("\icon[src] <b>[src]</b> beeps: \"Caution. Output regulators malfunction. Uncontrolled discharge detected.\"")
|
src.visible_message("\icon[src] <b>[src]</b> beeps: \"Caution. Output regulators malfunction. Uncontrolled discharge detected.\"")
|
||||||
@@ -143,7 +145,8 @@
|
|||||||
// Remember, we have few gigajoules of electricity here.. Turn them into crispy toast.
|
// Remember, we have few gigajoules of electricity here.. Turn them into crispy toast.
|
||||||
h_user.adjustFireLoss(rand(150,195))
|
h_user.adjustFireLoss(rand(150,195))
|
||||||
h_user.Paralyse(25)
|
h_user.Paralyse(25)
|
||||||
empulse(src.loc, 32, 64)
|
spawn(0)
|
||||||
|
empulse(src.loc, 32, 64)
|
||||||
charge = 0
|
charge = 0
|
||||||
apcs_overload(5, 25)
|
apcs_overload(5, 25)
|
||||||
src.visible_message("\icon[src] <b>[src]</b> beeps: \"Caution. Output regulators malfunction. Significant uncontrolled discharge detected.\"")
|
src.visible_message("\icon[src] <b>[src]</b> beeps: \"Caution. Output regulators malfunction. Significant uncontrolled discharge detected.\"")
|
||||||
@@ -228,7 +231,7 @@
|
|||||||
for(var/obj/I in component_parts)
|
for(var/obj/I in component_parts)
|
||||||
if(I.reliability != 100 && crit_fail)
|
if(I.reliability != 100 && crit_fail)
|
||||||
I.crit_fail = 1
|
I.crit_fail = 1
|
||||||
I.loc = src.loc
|
I.loc = src.loc
|
||||||
del(src)
|
del(src)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -30,3 +30,7 @@
|
|||||||
invisibility = 0
|
invisibility = 0
|
||||||
icon_state = "term"
|
icon_state = "term"
|
||||||
|
|
||||||
|
// Needed so terminals are not removed from machines list.
|
||||||
|
// Powernet rebuilds need this to work properly.
|
||||||
|
/obj/machinery/power/terminal/process()
|
||||||
|
return 1
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
@@ -18,10 +18,12 @@
|
|||||||
<div class="itemContent">
|
<div class="itemContent">
|
||||||
{{:helper.link('Auto', 'refresh', {'cmode' : 1}, data.chargeMode ? 'selected' : null)}}{{:helper.link('Off', 'close', {'cmode' : 1}, data.chargeMode ? null : 'selected')}}
|
{{:helper.link('Auto', 'refresh', {'cmode' : 1}, data.chargeMode ? 'selected' : null)}}{{:helper.link('Off', 'close', {'cmode' : 1}, data.chargeMode ? null : 'selected')}}
|
||||||
|
|
||||||
{{if data.charging}}
|
{{if data.charging == 2}}
|
||||||
[<span class='good'>Charging</span>]
|
[<span class='good'>Charging</span>]
|
||||||
|
{{else data.charging == 1}}
|
||||||
|
[<span class='average'>Partially Charging</span>]
|
||||||
{{else}}
|
{{else}}
|
||||||
[<span class='average'>Not Charging</span>]
|
[<span class='bad'>Not Charging</span>]
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -36,7 +38,7 @@
|
|||||||
{{:helper.link('MIN', null, {'input' : 'min'}, (data.chargeLevel > 0) ? null : 'disabled')}}
|
{{:helper.link('MIN', null, {'input' : 'min'}, (data.chargeLevel > 0) ? null : 'disabled')}}
|
||||||
{{:helper.link('SET', null, {'input' : 'set'}, null)}}
|
{{:helper.link('SET', null, {'input' : 'set'}, null)}}
|
||||||
{{:helper.link('MAX', null, {'input' : 'max'}, (data.chargeLevel < data.chargeMax) ? null : 'disabled')}}
|
{{:helper.link('MAX', null, {'input' : 'max'}, (data.chargeLevel < data.chargeMax) ? null : 'disabled')}}
|
||||||
<div style="float: left; width: 80px; text-align: center;"> {{:data.chargeLevel}} W </div>
|
<div style="float: left; width: 100px; text-align: center;"> {{:data.chargeLevel}} W </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -61,7 +63,7 @@
|
|||||||
{{:helper.link('MIN', null, {'output' : 'min'}, (data.outputLevel > 0) ? null : 'disabled')}}
|
{{:helper.link('MIN', null, {'output' : 'min'}, (data.outputLevel > 0) ? null : 'disabled')}}
|
||||||
{{:helper.link('SET', null, {'output' : 'set'}, null)}}
|
{{:helper.link('SET', null, {'output' : 'set'}, null)}}
|
||||||
{{:helper.link('MAX', null, {'output' : 'max'}, (data.outputLevel < data.outputMax) ? null : 'disabled')}}
|
{{:helper.link('MAX', null, {'output' : 'max'}, (data.outputLevel < data.outputMax) ? null : 'disabled')}}
|
||||||
<div style="float: left; width: 80px; text-align: center;"> {{:data.outputLevel}} W </div>
|
<div style="float: left; width: 100px; text-align: center;"> {{:data.outputLevel}} W </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user