APC & Machinery Refactor + Local Powernets (#19991)

* local powernet and machine power refactor

* some fixes

* more tweaks + powerchange() refactor

* fixes var edited apcs on meatpackers.dmm

* fixes issue with power channels

* Reviews

* delta fix

* Update code/game/machinery/portable_turret.dm

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>

* removed area power change proc

* damn morgues

* requested changes

* request changes

* deconfliction

* mapping fixes

* some fixes from TM

---------

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
This commit is contained in:
Ryan
2023-01-30 22:28:10 +00:00
committed by GitHub
co-authored by Henri215
parent caee0ec975
commit 7c3cd86f14
190 changed files with 2613 additions and 2556 deletions
+4 -6
View File
@@ -2942,16 +2942,14 @@
if("flicklights")
SSblackbox.record_feedback("tally", "admin_secrets_fun_used", 1, "Flicker Lights")
while(!usr.stat)
//knock yourself out to stop the ghosts
//knock yourself out to stop the ghosts
for(var/mob/M in GLOB.player_list)
if(M.stat != 2 && prob(25))
var/area/AffectedArea = get_area(M)
if(AffectedArea.name != "Space" && AffectedArea.name != "Engine Walls" && AffectedArea.name != "Chemical Lab Test Chamber" && AffectedArea.name != "Escape Shuttle" && AffectedArea.name != "Arrival Area" && AffectedArea.name != "Arrival Shuttle" && AffectedArea.name != "start area" && AffectedArea.name != "Engine Combustion Chamber")
AffectedArea.power_light = 0
AffectedArea.power_change()
spawn(rand(55,185))
AffectedArea.power_light = 1
AffectedArea.power_change()
AffectedArea.powernet.set_power_channel(PW_CHANNEL_LIGHTING, FALSE)
spawn(rand(55, 185))
AffectedArea.powernet.set_power_channel(PW_CHANNEL_LIGHTING, TRUE)
var/Message = rand(1,4)
switch(Message)
if(1)
+1 -2
View File
@@ -4,8 +4,7 @@
desc = "One of the most generic arcade games ever."
icon = 'icons/obj/arcade.dmi'
icon_state = "clawmachine_on"
use_power = IDLE_POWER_USE
idle_power_usage = 40
idle_power_consumption = 40
var/tokens = 0
var/freeplay = FALSE //for debugging and admin kindness
+2 -2
View File
@@ -6,8 +6,8 @@
icon_state = "prize_counter-on"
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 40
idle_power_consumption = 40
var/tickets = 0
/obj/machinery/prize_counter/Initialize(mapload)
@@ -73,10 +73,9 @@
icon = 'icons/obj/monitors.dmi'
icon_state = "alarm0"
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 4
active_power_usage = 8
power_channel = ENVIRON
idle_power_consumption = 4
active_power_consumption = 8
power_channel = PW_CHANNEL_ENVIRONMENT
req_one_access = list(ACCESS_ATMOSPHERICS, ACCESS_ENGINE_EQUIP)
max_integrity = 250
integrity_failure = 80
@@ -345,7 +344,7 @@
var/energy_used = max(abs(heat_capacity * (gas.temperature - target_temperature) ), MAX_ENERGY_CHANGE)
//Use power. Assuming that each power unit represents 1000 watts....
use_power(energy_used / 1000, ENVIRON)
use_power(energy_used / 1000, PW_CHANNEL_ENVIRONMENT)
//We need to cool ourselves.
if(heat_capacity)
@@ -1092,12 +1091,11 @@
qdel(src)
/obj/machinery/alarm/power_change()
if(powered(power_channel))
stat &= ~NOPOWER
set_light(1, LIGHTING_MINIMUM_POWER)
else
stat |= NOPOWER
..()
if(stat & NOPOWER)
set_light(0)
else
set_light(1, LIGHTING_MINIMUM_POWER)
update_icon(UPDATE_ICON_STATE | UPDATE_OVERLAYS)
/obj/machinery/alarm/obj_break(damage_flag)
@@ -14,9 +14,8 @@ Pipelines + Other Objects -> Pipe network
resistance_flags = FIRE_PROOF
max_integrity = 200
plane = GAME_PLANE
idle_power_usage = 0
active_power_usage = 0
power_channel = ENVIRON
power_state = NO_POWER_USE
power_channel = PW_CHANNEL_ENVIRONMENT
on_blueprints = TRUE
armor = list(MELEE = 25, BULLET = 10, LASER = 10, ENERGY = 100, BOMB = 0, BIO = 100, RAD = 100, FIRE = 100, ACID = 70)
@@ -410,7 +409,7 @@ Pipelines + Other Objects -> Pipe network
* * user - the mob who is toggling the machine.
*/
/obj/machinery/atmospherics/proc/toggle(mob/living/user)
if(!powered())
if(!has_power())
return
on = !on
update_icon()
@@ -426,7 +425,7 @@ Pipelines + Other Objects -> Pipe network
* * user - the mob who is setting the output pressure to maximum.
*/
/obj/machinery/atmospherics/proc/set_max(mob/living/user)
if(!powered())
if(!has_power())
return
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
@@ -1,7 +1,7 @@
/obj/machinery/atmospherics/binary
dir = SOUTH
initialize_directions = SOUTH|NORTH
use_power = IDLE_POWER_USE
power_state = IDLE_POWER_USE
layer = GAS_PUMP_LAYER
@@ -155,7 +155,8 @@
set_light(0)
else
set_light(light_range_on, light_power_on)
update_icon()
if(.)
update_icon()
/obj/machinery/atmospherics/binary/circulator/update_underlays()
. = ..()
@@ -54,7 +54,7 @@
if(!istype(T))
return
if(!powered())
if(!has_power())
vent_icon += "off"
else
vent_icon += "[on ? "[releasing ? "out" : "in"]" : "off"]"
@@ -56,7 +56,7 @@ Thus, the two variables affect pump operation are set in New():
on = TRUE
/obj/machinery/atmospherics/binary/pump/update_icon_state()
if(!powered())
if(!has_power())
icon_state = "off"
else
icon_state = "[on ? "on" : "off"]"
@@ -150,10 +150,9 @@ Thus, the two variables affect pump operation are set in New():
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
/obj/machinery/atmospherics/binary/pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
if(!..())
return
update_icon()
/obj/machinery/atmospherics/binary/pump/attackby(obj/item/W, mob/user, params)
if(is_pen(W))
@@ -81,7 +81,7 @@
return attack_hand(user)
/obj/machinery/atmospherics/binary/valve/digital/attack_hand(mob/user)
if(!powered())
if(!has_power())
return
if(!allowed(user) && !user.can_advanced_admin_interact())
to_chat(user, "<span class='alert'>Access denied.</span>")
@@ -93,13 +93,12 @@
icon_state = "map_valve1"
/obj/machinery/atmospherics/binary/valve/digital/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon(UPDATE_ICON_STATE)
if(!..())
return
update_icon(UPDATE_ICON_STATE)
/obj/machinery/atmospherics/binary/valve/digital/update_icon_state()
if(!powered())
if(!has_power())
icon_state = "valve[open]nopower"
return
..()
@@ -53,7 +53,7 @@ Thus, the two variables affect pump operation are set in New():
icon_state = "map_on"
/obj/machinery/atmospherics/binary/volume_pump/update_icon_state()
if(!powered())
if(!has_power())
icon_state = "off"
else
icon_state = "[on ? "on" : "off"]"
@@ -146,10 +146,9 @@ Thus, the two variables affect pump operation are set in New():
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", "atmos")
/obj/machinery/atmospherics/binary/volume_pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
if(!..())
return
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/attackby(obj/item/W, mob/user, params)
if(is_pen(W))
@@ -64,7 +64,7 @@
else
icon_state = ""
if(!powered())
if(!has_power())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += on ? "on" : "off"
@@ -89,10 +89,9 @@
add_underlay(T, node3, dir)
/obj/machinery/atmospherics/trinary/filter/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
if(!..())
return
update_icon()
/obj/machinery/atmospherics/trinary/filter/process_atmos()
..()
@@ -45,7 +45,7 @@
else
icon_state = ""
if(!powered())
if(!has_power())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += on ? "on" : "off"
@@ -70,10 +70,9 @@
add_underlay(T, node3, dir)
/obj/machinery/atmospherics/trinary/mixer/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
if(!..())
return
update_icon()
/obj/machinery/atmospherics/trinary/mixer/New()
..()
@@ -1,7 +1,7 @@
/obj/machinery/atmospherics/trinary
dir = SOUTH
initialize_directions = SOUTH|NORTH|WEST
use_power = IDLE_POWER_USE
power_state = IDLE_POWER_USE
layer = GAS_FILTER_LAYER
@@ -124,20 +124,19 @@
state = TVALVE_STATE_SIDE
/obj/machinery/atmospherics/trinary/tvalve/digital/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
if(!..())
return
update_icon()
/obj/machinery/atmospherics/trinary/tvalve/digital/update_icon_state()
if(!powered())
if(!has_power())
icon_state = "tvalvenopower"
/obj/machinery/atmospherics/trinary/tvalve/digital/attack_ai(mob/user)
return attack_hand(user)
/obj/machinery/atmospherics/trinary/tvalve/digital/attack_hand(mob/user)
if(!powered())
if(!has_power())
return
if(!allowed(user) && !user.can_advanced_admin_interact())
to_chat(user, "<span class='alert'>Access denied.</span>")
@@ -3,7 +3,7 @@ GLOBAL_LIST_EMPTY(air_injectors)
/obj/machinery/atmospherics/unary/outlet_injector
icon = 'icons/atmos/injector.dmi'
icon_state = "map_injector"
use_power = IDLE_POWER_USE
power_state = IDLE_POWER_USE
layer = GAS_SCRUBBER_LAYER
resistance_flags = FIRE_PROOF | UNACIDABLE | ACID_PROOF //really helpful in building gas chambers for xenomorphs
@@ -33,7 +33,7 @@ GLOBAL_LIST_EMPTY(air_injectors)
A green light on it means it is on."
/obj/machinery/atmospherics/unary/outlet_injector/update_icon_state()
if(!powered())
if(!has_power())
icon_state = "off"
else
icon_state = "[on ? "on" : "off"]"
@@ -47,10 +47,9 @@ GLOBAL_LIST_EMPTY(air_injectors)
add_underlay(T, node, dir)
/obj/machinery/atmospherics/unary/outlet_injector/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
if(!..())
return
update_icon()
/obj/machinery/atmospherics/unary/outlet_injector/process_atmos()
..()
@@ -107,10 +107,10 @@
var/temperature_delta= abs(old_temperature - air_contents.temperature)
if(temperature_delta > 1)
active_power_usage = (heat_capacity * temperature_delta) / 10 + idle_power_usage
active_power_consumption = (heat_capacity * temperature_delta) / 10 + idle_power_consumption
parent.update = 1
else
active_power_usage = idle_power_usage
active_power_consumption = idle_power_consumption
return 1
/obj/machinery/atmospherics/unary/thermomachine/attackby(obj/item/I, mob/user, params)
@@ -186,7 +186,7 @@
switch(action)
if("power")
on = !on
use_power = on ? ACTIVE_POWER_USE : IDLE_POWER_USE
change_power_mode(on ? ACTIVE_POWER_USE : IDLE_POWER_USE)
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
update_icon()
. = TRUE
@@ -8,7 +8,7 @@
name = "air vent"
desc = "Has a valve and pump attached to it"
use_power = IDLE_POWER_USE
power_state = IDLE_POWER_USE
plane = FLOOR_PLANE
layer = GAS_SCRUBBER_LAYER
@@ -62,7 +62,7 @@
/obj/machinery/atmospherics/unary/vent_pump/high_volume
name = "large air vent"
power_channel = EQUIP
power_channel = PW_CHANNEL_EQUIPMENT
/obj/machinery/atmospherics/unary/vent_pump/high_volume/Initialize(mapload)
. = ..()
@@ -79,7 +79,7 @@
if(welded)
vent_icon += "weld"
else if(!powered())
else if(!has_power())
vent_icon += "off"
else
vent_icon += "[on ? "[releasing ? "out" : "in"]" : "off"]"
@@ -245,10 +245,9 @@
. += "It seems welded shut."
/obj/machinery/atmospherics/unary/vent_pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
if(!..())
return
update_icon()
/obj/machinery/atmospherics/unary/vent_pump/Destroy()
GLOB.all_vent_pumps -= src
@@ -6,9 +6,9 @@
desc = "Has a valve and pump attached to it"
layer = GAS_SCRUBBER_LAYER
plane = FLOOR_PLANE
use_power = IDLE_POWER_USE
idle_power_usage = 10
active_power_usage = 60
power_state = ACTIVE_POWER_USE
idle_power_consumption = 10
active_power_consumption = 60
can_unwrench = TRUE
@@ -56,33 +56,6 @@
if(welded)
. += "It seems welded shut."
/obj/machinery/atmospherics/unary/vent_scrubber/auto_use_power()
if(!powered(power_channel))
return 0
if(!on || welded)
return 0
if(stat & (NOPOWER|BROKEN))
return 0
var/amount = idle_power_usage
if(scrubbing)
if(scrub_CO2)
amount += idle_power_usage
if(scrub_Toxins)
amount += idle_power_usage
if(scrub_N2)
amount += idle_power_usage
if(scrub_N2O)
amount += idle_power_usage
else
amount = active_power_usage
if(widenet)
amount += amount * (length(adjacent_turfs) * (length(adjacent_turfs) / 2))
use_power(amount, power_channel)
return 1
/obj/machinery/atmospherics/unary/vent_scrubber/update_overlays()
. = ..()
plane = FLOOR_PLANE
@@ -92,7 +65,7 @@
if(!istype(T))
return
if(!powered())
if(!has_power())
scrubber_icon += "off"
else
scrubber_icon += "[on ? "[scrubbing ? "on" : "in"]" : "off"]"
@@ -225,10 +198,9 @@
update_icon()
/obj/machinery/atmospherics/unary/vent_scrubber/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
if(!..())
return
update_icon()
/obj/machinery/atmospherics/unary/vent_scrubber/can_crawl_through()
return !welded
@@ -9,11 +9,10 @@ GLOBAL_LIST_EMPTY(gas_meters)
anchored = TRUE
max_integrity = 150
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 100, BOMB = 0, BIO = 100, RAD = 100, FIRE = 40, ACID = 0)
power_channel = ENVIRON
use_power = IDLE_POWER_USE
idle_power_usage = 2
active_power_usage = 5
power_channel = PW_CHANNEL_ENVIRONMENT
power_state = IDLE_POWER_USE
idle_power_consumption = 2
active_power_consumption = 5
var/obj/machinery/atmospherics/pipe/target = null
/obj/machinery/atmospherics/meter/Initialize(mapload)
@@ -3,7 +3,7 @@
var/datum/pipeline/parent
var/volume = 0
force = 20
use_power = NO_POWER_USE
power_state = NO_POWER_USE
can_unwrench = TRUE
damage_deflection = 12
var/alert_pressure = 80*ONE_ATMOSPHERE //minimum pressure before check_pressure(...) should be called
@@ -79,7 +79,7 @@ GLOBAL_DATUM_INIT(canister_icon_container, /datum/canister_icons, new())
pressure_resistance = 7 * ONE_ATMOSPHERE
var/temperature_resistance = 1000 + T0C
volume = 1000
use_power = NO_POWER_USE
power_state = NO_POWER_USE
interact_offline = TRUE
var/release_log = ""
var/update_flag = NONE
@@ -2,7 +2,7 @@
name = "atmoalter"
anchored = FALSE
layer = BELOW_OBJ_LAYER
use_power = NO_POWER_USE
power_state = NO_POWER_USE
max_integrity = 250
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 100, BOMB = 0, BIO = 100, RAD = 100, FIRE = 60, ACID = 30)
var/datum/gas_mixture/air_contents = new
+4 -3
View File
@@ -27,7 +27,7 @@ GLOBAL_DATUM_INIT(the_gateway, /obj/machinery/gateway/centerstation, null)
/obj/machinery/gateway/centerstation
density = TRUE
icon_state = "offcenter"
use_power = IDLE_POWER_USE
power_state = IDLE_POWER_USE
//warping vars
var/list/linked = list()
@@ -93,7 +93,7 @@ GLOBAL_DATUM_INIT(the_gateway, /obj/machinery/gateway/centerstation, null)
return
if(linked.len != 8)
return
if(!powered())
if(!has_power())
return
if(!awaygate)
awaygate = locate(/obj/machinery/gateway/centeraway) in GLOB.machines
@@ -163,7 +163,8 @@ GLOBAL_DATUM_INIT(the_gateway, /obj/machinery/gateway/centerstation, null)
/obj/machinery/gateway/centeraway
density = TRUE
icon_state = "offcenter"
use_power = NO_POWER_USE
power_state = NO_POWER_USE
var/calibrated = 1
var/list/linked = list() //a list of the connected gateway chunks
var/ready = FALSE
+4 -4
View File
@@ -34,10 +34,10 @@
if(!areaname || !length(areaname))
return
storedarea = new areatype
storedarea.power_equip = 0
storedarea.power_light = 0
storedarea.power_environ = 0
storedarea.always_unpowered = 0
storedarea.powernet.equipment_powered = FALSE
storedarea.powernet.lighting_powered = FALSE
storedarea.powernet.environment_powered = FALSE
storedarea.always_unpowered = FALSE
storedarea.name = areaname
areaimage.loc = storedarea // color our area
@@ -12,8 +12,7 @@
icon = 'icons/obj/terminals.dmi'
icon_state = "atm"
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 10
idle_power_consumption = 10
density = FALSE
restricted_bypass = TRUE
@@ -52,7 +51,8 @@
underlays += emissive_appearance(icon, "atm_lightmask")
/obj/machinery/economy/atm/power_change()
..()
if(!..())
return
if(stat & NOPOWER)
set_light(0)
else
@@ -79,12 +79,12 @@
/obj/machinery/economy/atm/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/card/id))
if(powered())
if(has_power())
handle_id_insert(I, user)
return TRUE
else if(authenticated_account)
if(istype(I, /obj/item/stack/spacecash))
if(!powered())
if(!has_power())
return
insert_cash(I, user)
return TRUE
+1 -1
View File
@@ -58,7 +58,7 @@
if(C.operating)
C.toggle_breaker()
// no matter what, ensure the area knows something happened to the power
current_area.power_change()
current_area.powernet.power_change()
affected_apc_count++
log_and_message_admins("APC Overload event deleted [affected_apc_count] underfloor APC terminals.")
+5 -5
View File
@@ -39,7 +39,7 @@
var/obj/item/stock_parts/cell/C = A.get_cell()
if(C)
C.charge = 0
current_area.power_change()
current_area.powernet.power_change()
log_and_message_admins("Power has been drained from all APCs.")
/proc/power_failure(announce = TRUE)
@@ -69,7 +69,7 @@
if(A.operating)
A.toggle_breaker()
// no matter what, ensure the area knows something happened to the power
current_area.power_change()
current_area.powernet.power_change()
affected_apc_count++
log_and_message_admins("APC Short Out event has shorted out [affected_apc_count] APCs.")
@@ -86,7 +86,7 @@
if(!length(A.wires.cut_wires) && A.operating && !A.shorted)
A.recharge_apc()
affected_apc_count++
current_area.power_change()
current_area.powernet.power_change()
log_and_message_admins("Power has been restored to [affected_apc_count] APCs.")
if(power_type == 1) //Repair without charging
if(announce)
@@ -97,7 +97,7 @@
if(!is_station_level(A.z))
continue
A.repair_apc()
current_area.power_change()
current_area.powernet.power_change()
log_and_message_admins("Power has been restored to all APCs.")
if(power_type == 2) //Repair and Power APCs
if(announce)
@@ -110,7 +110,7 @@
continue
A.repair_apc()
A.recharge_apc()
current_area.power_change()
current_area.powernet.power_change()
log_and_message_admins("Power has been restored to all APCs.")
/proc/power_restore_quick(announce = TRUE)
@@ -4,8 +4,7 @@
layer = 2.9
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 5
idle_power_consumption = 5
var/on = FALSE
var/onicon = null
var/officon = null
@@ -20,9 +20,8 @@
var/stealthmode = FALSE
var/list/victims = list()
use_power = IDLE_POWER_USE
idle_power_usage = 2
active_power_usage = 500
idle_power_consumption = 2
active_power_consumption = 500
/obj/machinery/gibber/Initialize(mapload)
. = ..()
@@ -7,9 +7,8 @@
anchored = TRUE
icon = 'icons/obj/kitchen.dmi'
icon_state = "icecream_vat"
use_power = IDLE_POWER_USE
max_integrity = 300
idle_power_usage = 20
idle_power_consumption = 20
var/obj/item/reagent_containers/glass/beaker = null
var/useramount = 15 //Last used amount
@@ -7,9 +7,8 @@
layer = 2.9
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 5
active_power_usage = 100
idle_power_consumption = 5
active_power_consumption = 100
container_type = OPENCONTAINER
var/operating = FALSE // Is it on?
var/dirty = NO_DIRT // = {0..100} Does it need cleaning?
@@ -8,9 +8,8 @@ GLOBAL_LIST_EMPTY(monkey_recyclers)
layer = 2.9
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 5
active_power_usage = 50
idle_power_consumption = 5
active_power_consumption = 50
var/grinded = 0
var/required_grind = 5
var/cube_production = 1
@@ -6,9 +6,9 @@
layer = 2.9
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_consumption = 5
var/candy = FALSE
idle_power_usage = 5
var/on = FALSE //Is it making food already?
var/list/food_choices = list()
@@ -5,12 +5,10 @@
layer = 2.9
density = TRUE
anchored = TRUE
idle_power_consumption = 5
active_power_consumption = 50
var/processing = FALSE
use_power = IDLE_POWER_USE
idle_power_usage = 5
active_power_usage = 50
var/rating_speed = 1
var/rating_amount = 1
@@ -10,9 +10,8 @@
layer = 2.9
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 5
active_power_usage = 100
idle_power_consumption = 5
active_power_consumption = 100
face_while_pulling = TRUE
/// The maximum number of items the fridge can hold. Multiplicated by the matter bin component's rating.
var/max_n_of_items = 1500
@@ -106,13 +105,12 @@
throw_item()
/obj/machinery/smartfridge/power_change()
var/old_stat = stat
..()
if((stat & (BROKEN|NOPOWER)))
. = ..()
if(stat & (BROKEN|NOPOWER))
set_light(0)
else
set_light(light_range_on, light_power_on)
if(old_stat != stat)
if(.)
update_icon(UPDATE_OVERLAYS)
/obj/machinery/smartfridge/extinguish_light(force = FALSE)
@@ -461,7 +459,7 @@
icon = 'icons/obj/kitchen.dmi'
icon_state = "foodcart"
anchored = FALSE
use_power = NO_POWER_USE
power_state = NO_POWER_USE
visible_contents = FALSE
face_while_pulling = FALSE
silicon_controllable = FALSE
@@ -797,9 +795,8 @@
desc = "A wooden contraption, used to dry plant products, food and leather."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "drying_rack"
use_power = IDLE_POWER_USE
idle_power_usage = 5
active_power_usage = 200
idle_power_consumption = 5
active_power_consumption = 200
can_dry = TRUE
visible_contents = FALSE
light_range_on = null
@@ -826,7 +823,7 @@
return
/obj/machinery/smartfridge/drying_rack/power_change()
if(powered() && anchored)
if(has_power() && anchored)
stat &= ~NOPOWER
else
stat |= NOPOWER
@@ -855,7 +852,7 @@
switch(action)
if("drying")
drying = !drying
use_power = drying ? ACTIVE_POWER_USE : IDLE_POWER_USE
change_power_mode(drying ? ACTIVE_POWER_USE : IDLE_POWER_USE)
update_icon(UPDATE_OVERLAYS)
/obj/machinery/smartfridge/drying_rack/update_overlays()
@@ -889,10 +886,10 @@
/obj/machinery/smartfridge/drying_rack/proc/toggle_drying(forceoff)
if(drying || forceoff)
drying = FALSE
use_power = IDLE_POWER_USE
change_power_mode(IDLE_POWER_USE)
else
drying = TRUE
use_power = ACTIVE_POWER_USE
change_power_mode(ACTIVE_POWER_USE)
update_icon(UPDATE_OVERLAYS)
/**
+1 -2
View File
@@ -8,8 +8,7 @@
icon_state = "biogen-empty"
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 40
idle_power_consumption = 40
/// Is the biogenerator curretly grinding up plants?
var/processing = FALSE
/// The container that is used to store reagents from certain products.
+1 -1
View File
@@ -1024,7 +1024,7 @@
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "soil"
density = FALSE
use_power = NO_POWER_USE
power_state = NO_POWER_USE
wrenchable = FALSE
/obj/machinery/hydroponics/soil/update_icon_state()
@@ -25,7 +25,7 @@
icon = 'icons/obj/lavaland/artefacts.dmi'
icon_state = "anomaly_crystal"
light_range = 8
use_power = NO_POWER_USE
power_state = NO_POWER_USE
density = TRUE
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF
var/activation_method = "touch"
+7 -6
View File
@@ -153,21 +153,22 @@
SStgui.update_uis(src)
/obj/machinery/mineral/ore_redemption/power_change()
..()
if(!..())
return
update_icon(UPDATE_ICON_STATE)
if(inserted_id && !powered())
if(inserted_id && !(stat & NOPOWER))
visible_message("<span class='notice'>The ID slot indicator light flickers on [src] as it spits out a card before powering down.</span>")
inserted_id.forceMove(get_turf(src))
inserted_id = null
/obj/machinery/mineral/ore_redemption/update_icon_state()
if(powered())
if(has_power())
icon_state = initial(icon_state)
else
icon_state = "[initial(icon_state)]-off"
/obj/machinery/mineral/ore_redemption/process()
if(panel_open || !powered())
if(panel_open || !has_power())
return
// Check if the input turf has a [/obj/structure/ore_box] to draw ore from. Otherwise suck ore from the turf
var/atom/input = get_step(src, input_dir)
@@ -194,7 +195,7 @@
/obj/machinery/mineral/ore_redemption/attackby(obj/item/I, mob/user, params)
if(exchange_parts(user, I))
return
if(!powered())
if(!has_power())
return ..()
if(istype(I, /obj/item/card/id))
@@ -221,7 +222,7 @@
if(!panel_open)
return
. = TRUE
if(!powered())
if(!has_power())
return
if(!I.tool_start_check(src, user, 0))
return
+6 -5
View File
@@ -94,14 +94,15 @@
prize_list["Extra"] = list() // Used in child vendors
/obj/machinery/mineral/equipment_vendor/power_change()
..()
if(!..())
return
update_icon(UPDATE_ICON_STATE)
if(inserted_id && !powered())
if(inserted_id && !(stat & NOPOWER))
visible_message("<span class='notice'>The ID slot indicator light flickers on \the [src] as it spits out a card before powering down.</span>")
inserted_id.forceMove(loc)
/obj/machinery/mineral/equipment_vendor/update_icon_state()
if(powered())
if(has_power())
icon_state = initial(icon_state)
else
icon_state = "[initial(icon_state)]-off"
@@ -207,12 +208,12 @@
default_deconstruction_crowbar(user, I)
return TRUE
if(istype(I, /obj/item/mining_voucher))
if(!powered())
if(!has_power())
return
redeem_voucher(I, user)
return
if(istype(I, /obj/item/card/id))
if(!powered())
if(!has_power())
return
var/obj/item/card/id/C = user.get_active_hand()
if(istype(C) && !istype(inserted_id))
+4 -5
View File
@@ -346,9 +346,8 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
*/
/obj/machinery/ai_powersupply
name="\improper AI power supply"
active_power_usage=1000
use_power = ACTIVE_POWER_USE
power_channel = EQUIP
active_power_consumption = 1000
power_state = ACTIVE_POWER_USE
var/mob/living/silicon/ai/powered_ai = null
invisibility = 100
@@ -369,9 +368,9 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
return
if(!powered_ai.anchored)
loc = powered_ai.loc
use_power = NO_POWER_USE
change_power_mode(NO_POWER_USE)
if(powered_ai.anchored)
use_power = ACTIVE_POWER_USE
change_power_mode(ACTIVE_POWER_USE)
/mob/living/silicon/ai/proc/pick_icon()
set category = "AI Commands"
+1 -1
View File
@@ -141,7 +141,7 @@
/mob/living/silicon/ai/proc/lacks_power()
var/turf/T = get_turf(src)
var/area/A = get_area(src)
return ((!A.power_equip) && A.requires_power == 1 || isspaceturf(T)) && !isitem(src.loc)
return (!A.powernet.equipment_powered && A.requires_power || isspaceturf(T)) && !isitem(loc)
/mob/living/silicon/ai/rejuvenate()
..()
@@ -9,20 +9,22 @@
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 20
active_power_usage = 5000
idle_power_consumption = 20
active_power_consumption = 5000
var/produce_drones = TRUE
var/drone_progress = 100
var/time_last_drone = 0
/obj/machinery/drone_fabricator/power_change()
if(powered())
stat &= ~NOPOWER
else
/obj/machinery/drone_fabricator/update_icon_state()
. = ..()
if(stat & NOPOWER)
icon_state = "drone_fab_nopower"
stat |= NOPOWER
/obj/machinery/drone_fabricator/power_change()
if(!..())
return
update_icon(UPDATE_ICON_STATE)
/obj/machinery/drone_fabricator/process()
+2 -1
View File
@@ -121,7 +121,8 @@
. += "crack3"
/obj/machinery/newscaster/power_change()
..()
if(!..())
return
if(stat & NOPOWER)
set_light(0)
else
+5 -6
View File
@@ -20,9 +20,8 @@ GLOBAL_LIST_EMPTY(fax_blacklist)
var/long_range_enabled = FALSE
req_one_access = list(ACCESS_LAWYER, ACCESS_HEADS, ACCESS_ARMORY)
use_power = IDLE_POWER_USE
idle_power_usage = 30
active_power_usage = 200
idle_power_consumption = 30
active_power_consumption = 200
/// ID card inserted into the machine, used to log in with
var/obj/item/card/id/scan = null
@@ -286,7 +285,7 @@ GLOBAL_LIST_EMPTY(fax_blacklist)
to_chat(usr, "There is nothing to remove from [src].")
/obj/machinery/photocopier/faxmachine/proc/sendfax(destination, mob/sender)
use_power(active_power_usage)
use_power(active_power_consumption)
var/success = 0
for(var/obj/machinery/photocopier/faxmachine/F in GLOB.allfaxes)
if(F.department == destination)
@@ -328,10 +327,10 @@ GLOBAL_LIST_EMPTY(fax_blacklist)
else
return
use_power(active_power_usage)
use_power(active_power_consumption)
/obj/machinery/photocopier/faxmachine/proc/send_admin_fax(mob/sender, destination)
use_power(active_power_usage)
use_power(active_power_consumption)
if(!(istype(copyitem, /obj/item/paper) || istype(copyitem, /obj/item/paper_bundle) || istype(copyitem, /obj/item/photo)))
visible_message("[src] beeps, \"Error transmitting message.\"")
+6 -8
View File
@@ -9,10 +9,8 @@
anchored = TRUE
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 30
active_power_usage = 200
power_channel = EQUIP
idle_power_consumption = 30
active_power_consumption = 200
max_integrity = 300
integrity_failure = 100
atom_say_verb = "bleeps"
@@ -297,21 +295,21 @@
if(!papercopy(C))
break
toner -= 1
use_power(active_power_usage)
use_power(active_power_consumption)
sleep(PHOTOCOPIER_DELAY)
else if(istype(C, /obj/item/photo))
for(var/i in copies to 1 step -1)
if(!photocopy(C))
break
toner -= 5
use_power(active_power_usage)
use_power(active_power_consumption)
sleep(PHOTOCOPIER_DELAY)
else if(istype(C, /obj/item/paper_bundle))
var/obj/item/paper_bundle/B = C
for(var/i in copies to 1 step -1)
if(!bundlecopy(C, use_toner = TRUE))
break
use_power(active_power_usage)
use_power(active_power_consumption)
sleep(PHOTOCOPIER_DELAY * (B.amount + 1))
else if(check_mob()) //Once we've scanned the copy_mob's ass we do not need to again
for(var/i in copies to 1 step -1)
@@ -345,7 +343,7 @@
to_chat(usr, "<span class='warning'>\The [copyitem] can't be scanned by \the [src].</span>")
copying = FALSE
return
use_power(active_power_usage)
use_power(active_power_consumption)
sleep(PHOTOCOPIER_DELAY)
LAZYADD(saved_documents, O)
copying = FALSE
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+135
View File
@@ -0,0 +1,135 @@
/obj/machinery/power/apc/proc/has_electronics()
return electronics_state != APC_ELECTRONICS_NONE
/obj/machinery/power/apc/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
if(!(stat & BROKEN))
set_broken()
if(opened != APC_COVER_OFF)
opened = APC_COVER_OFF
coverlocked = FALSE
visible_message("<span class='warning'>The APC cover is knocked down!</span>")
update_icon()
/obj/machinery/power/apc/crowbar_act(mob/living/user, obj/item/I)
. = TRUE
if(!I.tool_start_check(src, user, 0))
return
if(opened) // a) on open apc
if(electronics_state == APC_ELECTRONICS_INSTALLED)
if(terminal)
to_chat(user, "<span class='warning'>Disconnect the wires first!</span>")
return
to_chat(user, "<span class='notice'>You start trying to remove the APC electronics...</span>" )
if(I.use_tool(src, user, 50, volume = I.tool_volume))
if(has_electronics())
electronics_state = APC_ELECTRONICS_NONE
if(stat & BROKEN)
user.visible_message(\
"[user.name] has broken the APC electronics inside [name]!",
"<span class='notice'>You break the charred APC electronics and remove the remains.</span>",
"<span class='italics'>You hear a crack.</span>")
return
//SSticker.mode:apcs-- //XSI said no and I agreed. -rastaf0
else if(emagged) // We emag board, not APC's frame
emagged = FALSE
user.visible_message(
"[user.name] has discarded the shorted APC electronics from [name]!",
"<span class='notice'>You discarded the shorted board.</span>")
return
else if(malfhack) // AI hacks board, not APC's frame
user.visible_message(\
"[user.name] has discarded strangely the programmed APC electronics from [name]!",
"<span class='notice'>You discarded the strangely programmed board.</span>")
malfai = null
malfhack = FALSE
return
else
user.visible_message(\
"[user.name] has removed the APC electronics from [name]!",
"<span class='notice'>You remove the APC electronics.</span>")
new /obj/item/apc_electronics(loc)
return
else if(opened != APC_COVER_OFF) //cover isn't removed
opened = APC_CLOSED
coverlocked = TRUE //closing cover relocks it
update_icon()
return
else if(!(stat & BROKEN)) // b) on closed and not broken APC
if(coverlocked && !(stat & MAINT)) // locked...
to_chat(user, "<span class='warning'>The cover is locked and cannot be opened!</span>")
return
else if(panel_open) // wires are exposed
to_chat(user, "<span class='warning'>Exposed wires prevents you from opening it!</span>")
return
else
opened = APC_OPENED
update_icon()
/obj/machinery/power/apc/screwdriver_act(mob/living/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
else if(opened)
if(cell && !(stat & MAINT))
to_chat(user, "<span class='warning'>Close the APC first!</span>") //Less hints more mystery!
return
else
if(electronics_state == APC_ELECTRONICS_INSTALLED)
electronics_state = APC_ELECTRONICS_SECURED
stat &= ~MAINT
to_chat(user, "<span class='notice'>You screw the circuit electronics into place.</span>")
else if(electronics_state == APC_ELECTRONICS_SECURED)
electronics_state = APC_ELECTRONICS_INSTALLED
stat |= MAINT
to_chat(user, "<span class='notice'>You unfasten the electronics.</span>")
else
to_chat(user, "<span class='warning'>There is nothing to secure!</span>")
return
update_icon()
else if(emagged)
to_chat(user, "<span class='warning'>The interface is broken!</span>")
else
panel_open = !panel_open
to_chat(user, "The wires have been [panel_open ? "exposed" : "unexposed"]")
update_icon()
/obj/machinery/power/apc/wirecutter_act(mob/living/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(panel_open && !opened)
wires.Interact(user)
else if(terminal && opened)
terminal.dismantle(user, I)
/obj/machinery/power/apc/multitool_act(mob/living/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(panel_open && !opened)
wires.Interact(user)
/obj/machinery/power/apc/welder_act(mob/user, obj/item/I)
if(!opened || has_electronics() || terminal)
return
. = TRUE
if(!I.tool_use_check(user, 3))
return
WELDER_ATTEMPT_SLICING_MESSAGE
if(I.use_tool(src, user, 50, amount = 3, volume = I.tool_volume))
if((stat & BROKEN) || opened == APC_COVER_OFF)
new /obj/item/stack/sheet/metal(loc)
user.visible_message(\
"[user.name] has cut [src] apart with [I].",\
"<span class='notice'>You disassembled the broken APC frame.</span>")
else
new /obj/item/mounted/frame/apc_frame(loc)
user.visible_message(\
"[user.name] has cut [src] from the wall with [I].",\
"<span class='notice'>You cut the APC frame from the wall.</span>")
qdel(src)
+95
View File
@@ -0,0 +1,95 @@
// APC malf status
#define APC_MALF_NOT_HACKED 1
#define APC_MALF_HACKED 2 // APC hacked by user, and user is in its core.
#define APC_MALF_SHUNTED_HERE 3 // User is shunted in this APC
#define APC_MALF_SHUNTED_OTHER 4 // User is shunted in another APC
/obj/machinery/power/apc/proc/malfhack(mob/living/silicon/ai/malf)
if(!istype(malf))
return
if(get_malf_status(malf) != APC_MALF_NOT_HACKED)
return
if(malf.malfhacking)
to_chat(malf, "You are already hacking an APC.")
return
if(constructed)
to_chat(malf, "<span class='warning'>This APC was only recently constructed, and is not fully linked to station systems. Hacking it would be pointless.</span>")
return
to_chat(malf, "Beginning override of APC systems. This takes some time, and you can only hack one APC at a time.")
malf.malfhack = src
malf.malfhacking = addtimer(CALLBACK(malf, TYPE_PROC_REF(/mob/living/silicon/ai, malfhacked), src), 600, TIMER_STOPPABLE)
var/obj/screen/alert/hackingapc/A
A = malf.throw_alert("hackingapc", /obj/screen/alert/hackingapc)
A.target = src
/obj/machinery/power/apc/proc/malfoccupy(mob/living/silicon/ai/malf)
if(!istype(malf))
return
if(istype(malf.loc, /obj/machinery/power/apc)) // Already in an APC
to_chat(malf, "<span class='warning'>You must evacuate your current APC first!</span>")
return
if(!malf.can_shunt)
to_chat(malf, "<span class='warning'>You cannot shunt!</span>")
return
if(!is_station_level(z))
return
occupier = new /mob/living/silicon/ai(src,malf.laws,null,1)
occupier.adjustOxyLoss(malf.getOxyLoss())
if(!findtext(occupier.name, "APC Copy"))
occupier.name = "[malf.name] APC Copy"
if(malf.parent)
occupier.parent = malf.parent
else
occupier.parent = malf
malf.shunted = TRUE
malf.mind.transfer_to(occupier)
occupier.eyeobj.name = "[occupier.name] (AI Eye)"
if(malf.parent)
qdel(malf)
var/datum/action/innate/ai/return_to_core/R = new
R.Grant(occupier)
occupier.cancel_camera()
if((seclevel2num(get_security_level()) == SEC_LEVEL_DELTA) && malf.nuking)
for(var/obj/item/pinpointer/point in GLOB.pinpointer_list)
point.the_disk = src //the pinpointer will detect the shunted AI
/obj/machinery/power/apc/proc/malfvacate(forced)
if(!occupier)
return
if(occupier.parent && occupier.parent.stat != DEAD)
occupier.mind.transfer_to(occupier.parent)
occupier.parent.shunted = FALSE
occupier.parent.adjustOxyLoss(occupier.getOxyLoss())
occupier.parent.cancel_camera()
qdel(occupier)
if(seclevel2num(get_security_level()) == SEC_LEVEL_DELTA)
for(var/obj/item/pinpointer/point in GLOB.pinpointer_list)
for(var/mob/living/silicon/ai/A in GLOB.ai_list)
if((A.stat != DEAD) && A.nuking)
point.the_disk = A //The pinpointer tracks the AI back into its core.
else
to_chat(occupier, "<span class='danger'>Primary core damaged, unable to return core processes.</span>")
if(forced)
occupier.loc = loc
occupier.death()
occupier.gib()
for(var/obj/item/pinpointer/point in GLOB.pinpointer_list)
point.the_disk = null //Pinpointers go back to tracking the nuke disk
/obj/machinery/power/apc/proc/get_malf_status(mob/living/silicon/ai/malf)
if(!istype(malf))
return FALSE
// Only if they're a traitor OR they have the malf picker from the combat module
if(!malf.mind.has_antag_datum(/datum/antagonist/traitor) && !malf.malf_picker)
return FALSE
if(malfai == (malf.parent || malf))
if(occupier == malf)
return APC_MALF_SHUNTED_HERE
else if(istype(malf.loc, /obj/machinery/power/apc))
return APC_MALF_SHUNTED_OTHER
else
return APC_MALF_HACKED
else
return APC_MALF_NOT_HACKED
+234
View File
@@ -0,0 +1,234 @@
//update_state
#define UPSTATE_CELL_IN 1
#define UPSTATE_OPENED1 2
#define UPSTATE_OPENED2 4
#define UPSTATE_MAINT 8
#define UPSTATE_BROKE 16
#define UPSTATE_BLUESCREEN 32
#define UPSTATE_WIREEXP 64
#define UPSTATE_ALLGOOD 128
//update_overlay
#define APC_UPOVERLAY_CHARGEING0 1
#define APC_UPOVERLAY_CHARGEING1 2
#define APC_UPOVERLAY_CHARGEING2 4
#define APC_UPOVERLAY_EQUIPMENT0 8
#define APC_UPOVERLAY_EQUIPMENT1 16
#define APC_UPOVERLAY_EQUIPMENT2 32
#define APC_UPOVERLAY_LIGHTING0 64
#define APC_UPOVERLAY_LIGHTING1 128
#define APC_UPOVERLAY_LIGHTING2 256
#define APC_UPOVERLAY_ENVIRON0 512
#define APC_UPOVERLAY_ENVIRON1 1024
#define APC_UPOVERLAY_ENVIRON2 2048
#define APC_UPOVERLAY_LOCKED 4096
#define APC_UPDATE_ICON_COOLDOWN 20 SECONDS // 20 seconds
// update the APC icon to show the three base states
// also add overlays for indicator lights
/obj/machinery/power/apc/update_icon(force_update = FALSE)
if(!status_overlays || force_update)
status_overlays = TRUE
status_overlays_lock = new
status_overlays_charging = new
status_overlays_equipment = new
status_overlays_lighting = new
status_overlays_environ = new
status_overlays_lock.len = 2
status_overlays_charging.len = 3
status_overlays_equipment.len = 4
status_overlays_lighting.len = 4
status_overlays_environ.len = 4
status_overlays_lock[1] = image(icon, "apcox-0") // 0=blue 1=red
status_overlays_lock[2] = image(icon, "apcox-1")
status_overlays_charging[1] = image(icon, "apco3-0")
status_overlays_charging[2] = image(icon, "apco3-1")
status_overlays_charging[3] = image(icon, "apco3-2")
status_overlays_equipment[1] = image(icon, "apco0-0") // 0=red, 1=green, 2=blue
status_overlays_equipment[2] = image(icon, "apco0-1")
status_overlays_equipment[3] = image(icon, "apco0-2")
status_overlays_equipment[4] = image(icon, "apco0-3")
status_overlays_lighting[1] = image(icon, "apco1-0")
status_overlays_lighting[2] = image(icon, "apco1-1")
status_overlays_lighting[3] = image(icon, "apco1-2")
status_overlays_lighting[4] = image(icon, "apco1-3")
status_overlays_environ[1] = image(icon, "apco2-0")
status_overlays_environ[2] = image(icon, "apco2-1")
status_overlays_environ[3] = image(icon, "apco2-2")
status_overlays_environ[4] = image(icon, "apco2-3")
var/update = check_updates() //returns 0 if no need to update icons.
// 1 if we need to update the icon_state
// 2 if we need to update the overlays
if(!update && !force_update)
return
if(force_update || update & 1) // Updating the icon state
..(UPDATE_ICON_STATE)
if(!(update_state & UPSTATE_ALLGOOD))
if(managed_overlays)
..(UPDATE_OVERLAYS)
return
if(force_update || update & 2)
..(UPDATE_OVERLAYS)
/obj/machinery/power/apc/update_icon_state()
if(update_state & UPSTATE_ALLGOOD)
icon_state = "apc0"
else if(update_state & (UPSTATE_OPENED1|UPSTATE_OPENED2))
var/basestate = "apc[ cell ? "2" : "1" ]"
if(update_state & UPSTATE_OPENED1)
if(update_state & (UPSTATE_MAINT|UPSTATE_BROKE))
icon_state = "apcmaint" //disabled APC cannot hold cell
else
icon_state = basestate
else if(update_state & UPSTATE_OPENED2)
icon_state = "[basestate]-nocover"
else if(update_state & UPSTATE_BROKE)
icon_state = "apc-b"
else if(update_state & UPSTATE_BLUESCREEN)
icon_state = "apcemag"
else if(update_state & UPSTATE_WIREEXP)
icon_state = "apcewires"
/obj/machinery/power/apc/update_overlays()
. = ..()
underlays.Cut()
if(update_state & UPSTATE_BLUESCREEN)
underlays += emissive_appearance(icon, "emit_apcemag")
return
if(!(update_state & UPSTATE_ALLGOOD))
return
if(!(stat & (BROKEN|MAINT)) && update_state & UPSTATE_ALLGOOD)
var/image/statover_lock = status_overlays_lock[locked + 1]
var/image/statover_charg = status_overlays_charging[charging + 1]
. += statover_lock
. += statover_charg
underlays += emissive_appearance(icon, statover_lock.icon_state)
underlays += emissive_appearance(icon, statover_charg.icon_state)
if(operating)
var/image/statover_equip = status_overlays_equipment[equipment_channel + 1]
var/image/statover_light = status_overlays_lighting[lighting_channel + 1]
var/image/statover_envir = status_overlays_environ[environment_channel + 1]
. += statover_equip
. += statover_light
. += statover_envir
underlays += emissive_appearance(icon, statover_equip.icon_state)
underlays += emissive_appearance(icon, statover_light.icon_state)
underlays += emissive_appearance(icon, statover_envir.icon_state)
/obj/machinery/power/apc/proc/check_updates()
var/last_update_state = update_state
var/last_update_overlay = update_overlay
update_state = NONE
update_overlay = NONE
if(cell)
update_state |= UPSTATE_CELL_IN
if(stat & BROKEN)
update_state |= UPSTATE_BROKE
if(stat & MAINT)
update_state |= UPSTATE_MAINT
if(opened)
if(opened == APC_OPENED)
update_state |= UPSTATE_OPENED1
if(opened == APC_COVER_OFF)
update_state |= UPSTATE_OPENED2
else if(emagged || malfai)
update_state |= UPSTATE_BLUESCREEN
else if(panel_open)
update_state |= UPSTATE_WIREEXP
if(update_state <= 1)
update_state |= UPSTATE_ALLGOOD
if(update_state & UPSTATE_ALLGOOD)
if(locked)
update_overlay |= APC_UPOVERLAY_LOCKED
if(charging == APC_NOT_CHARGING)
update_overlay |= APC_UPOVERLAY_CHARGEING0
else if(charging == APC_IS_CHARGING)
update_overlay |= APC_UPOVERLAY_CHARGEING1
else if(charging == APC_FULLY_CHARGED)
update_overlay |= APC_UPOVERLAY_CHARGEING2
if(!equipment_channel)
update_overlay |= APC_UPOVERLAY_EQUIPMENT0
else if(equipment_channel == CHANNEL_SETTING_AUTO_OFF)
update_overlay |= APC_UPOVERLAY_EQUIPMENT1
else if(equipment_channel == CHANNEL_SETTING_ON)
update_overlay |= APC_UPOVERLAY_EQUIPMENT2
if(!lighting_channel)
update_overlay |= APC_UPOVERLAY_LIGHTING0
else if(lighting_channel == CHANNEL_SETTING_AUTO_OFF)
update_overlay |= APC_UPOVERLAY_LIGHTING1
else if(lighting_channel == CHANNEL_SETTING_ON)
update_overlay |= APC_UPOVERLAY_LIGHTING2
if(!environment_channel)
update_overlay |= APC_UPOVERLAY_ENVIRON0
else if(environment_channel == CHANNEL_SETTING_AUTO_OFF)
update_overlay |= APC_UPOVERLAY_ENVIRON1
else if(environment_channel == CHANNEL_SETTING_ON)
update_overlay |= APC_UPOVERLAY_ENVIRON2
var/results = 0
if(last_update_state == update_state && last_update_overlay == update_overlay)
return 0
if(last_update_state != update_state)
results += 1
if(last_update_overlay != update_overlay)
results += 2
return results
// Used in process so it doesn't update the icon too much
/obj/machinery/power/apc/proc/queue_icon_update()
if(!updating_icon)
updating_icon = TRUE
// Start the update
spawn(APC_UPDATE_ICON_COOLDOWN)
update_icon()
updating_icon = FALSE
/obj/machinery/power/apc/flicker(second_pass = FALSE)
if(opened || panel_open)
return FALSE
if(stat & (NOPOWER | BROKEN))
return FALSE
if(!second_pass) //The first time, we just cut overlays
addtimer(CALLBACK(src, PROC_REF(flicker), TRUE), 1)
cut_overlays()
managed_overlays = null
// APC power distruptions have a chance to propogate to other machines on its network
for(var/obj/machinery/M in apc_area)
// Please don't cascade, thanks
if(M == src)
continue
if(prob(10))
M.flicker()
else
flick("apcemag", src) //Second time we cause the APC to update its icon, then add a timer to update icon later
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, update_icon), TRUE), 10)
return TRUE
#undef APC_UPDATE_ICON_COOLDOWN
+1 -1
View File
@@ -4,7 +4,7 @@
icon_state = "teg"
anchored = FALSE
density = TRUE
use_power = NO_POWER_USE
power_state = NO_POWER_USE
var/obj/machinery/atmospherics/binary/circulator/cold_circ
var/obj/machinery/atmospherics/binary/circulator/hot_circ
+7 -6
View File
@@ -20,7 +20,7 @@ GLOBAL_LIST_EMPTY(gravity_generators)
icon = 'icons/obj/machines/gravity_generator.dmi'
anchored = TRUE
density = TRUE
use_power = NO_POWER_USE
power_state = NO_POWER_USE
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
/obj/machinery/gravity_generator/ex_act(severity)
@@ -73,9 +73,9 @@ GLOBAL_LIST_EMPTY(gravity_generators)
/obj/machinery/gravity_generator/main
icon_state = "generator_body"
layer = MOB_LAYER + 0.1
active_power_usage = 3000
power_channel = ENVIRON
use_power = IDLE_POWER_USE
active_power_consumption = 3000
power_channel = PW_CHANNEL_ENVIRONMENT
power_state = IDLE_POWER_USE
interact_offline = TRUE
/// Is the generator producing gravity
var/on = TRUE
@@ -238,7 +238,8 @@ GLOBAL_LIST_EMPTY(gravity_generators)
// Power and Icon States
/obj/machinery/gravity_generator/main/power_change()
..()
if(!..())
return
investigate_log("has [stat & NOPOWER ? "lost" : "regained"] power.", "gravity")
set_power()
@@ -280,7 +281,7 @@ GLOBAL_LIST_EMPTY(gravity_generators)
var/alert = FALSE // Sound the alert if gravity was just enabled or disabled.
var/area/src_area = get_area(src)
on = gravity
use_power = on ? ACTIVE_POWER_USE : IDLE_POWER_USE
change_power_mode(on ? ACTIVE_POWER_USE : IDLE_POWER_USE)
if(gravity) // If we turned on
if(generators_in_level() == FALSE) // And there's no gravity
+21 -21
View File
@@ -171,16 +171,16 @@
anchored = TRUE
layer = 5
max_integrity = 100
use_power = ACTIVE_POWER_USE
idle_power_usage = 2
active_power_usage = 20
power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list
power_state = ACTIVE_POWER_USE
idle_power_consumption = 2 //when in low power mode
active_power_consumption = 20 //when in full power mode
power_channel = PW_CHANNEL_LIGHTING //Lights are calc'd via area so they dont need to be in the machine list
/// Is the light on or off?
var/on = FALSE
/// Is the light currently turning on?
var/turning_on = FALSE
/// If the light state has changed since the last 'update()', also update the power requirements
var/power_state = FALSE
var/light_state = FALSE
/// How much power does it use?
var/static_power_used = 0
/// Light range (Also used in power calculation)
@@ -317,7 +317,7 @@
*/
/obj/machinery/light/proc/update(trigger = TRUE, instant = FALSE, play_sound = TRUE)
var/area/current_area = get_area(src)
UnregisterSignal(current_area, COMSIG_AREA_POWER_CHANGE)
UnregisterSignal(current_area.powernet, COMSIG_POWERNET_POWER_CHANGE)
switch(status)
if(LIGHT_BROKEN, LIGHT_BURNED, LIGHT_EMPTY)
on = FALSE
@@ -334,17 +334,17 @@
else if(!turned_off())
set_emergency_lights()
else // Turning off
use_power = IDLE_POWER_USE
change_power_mode(IDLE_POWER_USE)
set_light(0)
update_icon()
active_power_usage = (brightness_range * 10)
if(on != power_state) // Light was turned on/off, so update the power usage
power_state = on
active_power_consumption = (brightness_range * 10)
if(on != light_state) // Light was turned on/off, so update the power usage
light_state = on
if(on)
static_power_used = brightness_range * 20 //20W per unit of luminosity
addStaticPower(static_power_used, STATIC_LIGHT)
add_static_power(PW_CHANNEL_LIGHTING, static_power_used)
else
removeStaticPower(static_power_used, STATIC_LIGHT)
remove_static_power(PW_CHANNEL_LIGHTING, static_power_used)
/**
@@ -390,7 +390,7 @@
burnout()
return
use_power = ACTIVE_POWER_USE
change_power_mode(ACTIVE_POWER_USE)
update_icon()
set_light(BR, PO, CO)
if(play_sound)
@@ -566,14 +566,14 @@
// returns if the light has power /but/ is manually turned off
// if a light is turned off, it won't activate emergency power
/obj/machinery/light/proc/turned_off()
var/area/A = get_area(src)
return !A.lightswitch && A.power_light
var/area/machine_area = get_area(src)
return !machine_area.lightswitch && machine_area.powernet.lighting_powered
// returns whether this light has power
// true if area has power and lightswitch is on
/obj/machinery/light/proc/has_power()
var/area/A = get_area(src)
return A.lightswitch && A.power_light
/obj/machinery/light/has_power()
var/area/machine_area = get_area(src)
return machine_area.lightswitch && machine_area.powernet.lighting_powered
// attempts to set emergency lights
/obj/machinery/light/proc/set_emergency_lights()
@@ -592,12 +592,12 @@
emergency_mode = TRUE
set_light(3, 1.7, bulb_emergency_colour)
update_icon()
RegisterSignal(current_area, COMSIG_AREA_POWER_CHANGE, PROC_REF(update), override = TRUE)
RegisterSignal(machine_powernet, COMSIG_POWERNET_POWER_CHANGE, PROC_REF(update), override = TRUE)
/obj/machinery/light/proc/emergency_lights_off(area/current_area, obj/machinery/power/apc/current_apc)
set_light(0, 0, 0) //you, sir, are off!
if(current_apc)
RegisterSignal(current_area, COMSIG_AREA_POWER_CHANGE, PROC_REF(update), override = TRUE)
RegisterSignal(machine_powernet, COMSIG_POWERNET_POWER_CHANGE, PROC_REF(update), override = TRUE)
/obj/machinery/light/flicker(amount = rand(20, 30))
if(flickering)
@@ -755,7 +755,7 @@
/obj/machinery/light/power_change()
var/area/A = get_area(src)
if(A)
seton(A.lightswitch && A.power_light)
seton(A.lightswitch && A.powernet.lighting_powered)
// called when on fire
+2 -3
View File
@@ -8,7 +8,6 @@
icon_state = "portgen0_0"
density = TRUE
anchored = FALSE
use_power = NO_POWER_USE
var/active = FALSE
var/power_gen = 5000
@@ -42,8 +41,8 @@
handleInactive()
update_icon()
/obj/machinery/power/powered()
return 1 //doesn't require an external power source
/obj/machinery/power/has_power()
return TRUE //doesn't require an external power source
/obj/machinery/power/port_gen/attack_hand(mob/user as mob)
if(..())
+5 -48
View File
@@ -11,10 +11,9 @@
icon = 'icons/obj/power.dmi'
anchored = TRUE
on_blueprints = TRUE
power_state = NO_POWER_USE
var/datum/powernet/powernet = null
use_power = NO_POWER_USE
idle_power_usage = 0
active_power_usage = 0
/obj/machinery/power/Destroy()
disconnect_from_network()
@@ -42,7 +41,7 @@
/obj/machinery/power/proc/surplus()
if(powernet)
return clamp(powernet.avail-powernet.load, 0, powernet.avail)
return clamp(powernet.avail - powernet.load, 0, powernet.avail)
else
return 0
@@ -71,48 +70,6 @@
/obj/machinery/power/proc/disconnect_terminal() // machines without a terminal will just return, no harm no fowl.
return
// returns true if the area has power on given channel (or doesn't require power).
// defaults to power_channel
/obj/machinery/proc/powered(chan = -1) // defaults to power_channel
if(!loc)
return FALSE
if(!use_power)
return TRUE
var/area/A = get_area(src) // make sure it's in an area
if(!A)
return FALSE // if not, then not powered
if(chan == -1)
chan = power_channel
return A.powered(chan) // return power status of the area
// increment the power usage stats for an area
/obj/machinery/proc/use_power(amount, chan = -1) // defaults to power_channel
var/area/A = get_area(src) // make sure it's in an area
if(!A)
return
if(chan == -1)
chan = power_channel
A.use_power(amount, chan)
/obj/machinery/proc/addStaticPower(value, powerchannel)
var/area/A = get_area(src)
if(!A)
return
A.addStaticPower(value, powerchannel)
/obj/machinery/proc/removeStaticPower(value, powerchannel)
addStaticPower(-value, powerchannel)
/obj/machinery/proc/power_change() // called whenever the power settings of the containing area change
// by default, check equipment channel & set flag
// can override if needed
if(powered(power_channel))
stat &= ~NOPOWER
else
stat |= NOPOWER
return
// connect the machine to a powernet if a node cable is present on the turf
/obj/machinery/power/proc/connect_to_network()
@@ -351,7 +308,7 @@
var/drained_energy = drained_hp*20
if(source_area)
source_area.use_power(drained_energy/GLOB.CELLRATE)
source_area.powernet.use_active_power(drained_energy / GLOB.CELLRATE)
else if(istype(power_source, /datum/powernet))
var/drained_power = drained_energy/GLOB.CELLRATE //convert from "joules" to "watts"
PN.delayedload += (min(drained_power, max(PN.newavail - PN.delayedload, 0)))
@@ -377,5 +334,5 @@
/area/proc/get_apc()
for(var/thing in GLOB.apcs)
var/obj/machinery/power/apc/APC = thing
if(APC.area == src)
if(APC.apc_area == src)
return APC
@@ -0,0 +1,188 @@
/**
* # local_powernet
*
* Manages all power related mechanics for a single /area
* Machines in areas will directly register to this datum in order to recieve power
*
* Machine/Turf/Item -> Local Powernet -> APC -> Terminal -> Wirenet
*
* Non-machines cannot register to the local powernet and should instead listen for power change signals
*/
/datum/local_powernet
/// The area this local powernet is attached to
var/area/powernet_area = null
/// The APC associated with this powernet
var/obj/machinery/power/apc/powernet_apc = null
/// Bit Flags indicating special behaviour on this powernet, always powered, never powered, etc
var/power_flags
/// Is the equipment power channel on?
var/equipment_powered = TRUE
/// Is the lighting power channel on?
var/lighting_powered = TRUE
/// Is the environment power channel on?
var/environment_powered = TRUE
/* Passive consumption vars, only change when machines are added/removed from the powernet (not if the power channel turns on/off) */
/// The amount of power consumed by equipment in every power cycle
var/passive_equipment_consumption = 0
/// The amount of power consumed by lighting in every power cycle
var/passive_lighting_consumption = 0
/// The amount of power consumed by environment in every power cycle
var/passive_environment_consumption = 0
/* Active consumption vars, changed when machines need spurts of power, unlike passive consumption these reset to 0 every process() cycle */
/// The amount of power consumed by equipment in this power cycle
var/equipment_consumption = 0
/// The amount of power consumed by lighting in this power cycle
var/lighting_consumption = 0
/// The amount of power consumed by environment in this power cycle
var/environment_consumption = 0
/* Total consumption vars, tracking vars that only count aggregate consumption from active power channels */
/// The amount of the total power consumed passively in power cycles (i.e, each cycle), does not include power channels that are off
var/passive_consumption = 0
/// The amount of total power consumed consumed in only this cycle
var/active_consumption = 0
/// All machines registered to this local powernet, strictly typed to machines, everything else needs to register power change signals
var/list/registered_machines = list()
/// tethers a machine to this local powernet
/datum/local_powernet/proc/register_machine(obj/machinery/machine)
if(machine in registered_machines)
machine.power_change() // this is probably what they wanted anyway by calling this proc
log_debug("[machine] try to register to [powernet_apc]'s local powernet but was already registered!")
return
// machines ref'd in this list should clear themselves from it in destroy(), no need for signals here
machine.machine_powernet = src
registered_machines += machine
machine.power_change()
/// untethers a machine to this local powernet
/datum/local_powernet/proc/unregister_machine(obj/machinery/machine)
if(!(machine in registered_machines))
return
machine.machine_powernet = null
registered_machines -= machine
machine.power_change()
/**
* # power_change
*
* Called when the area power status changes
* calls power change on all machines in the area, and sends the `COMSIG_POWERNET_POWER_CHANGE` signal.
*/
/datum/local_powernet/proc/power_change()
for(var/obj/machinery/M as anything in registered_machines) // for each machine in the area
M.power_change() // reverify power status (to update icons etc.)
SEND_SIGNAL(src, COMSIG_POWERNET_POWER_CHANGE)
/// sets a power channel on or off and adjusts total power usage accordingly
/datum/local_powernet/proc/set_power_channel(channel, new_state)
switch(channel)
if(PW_CHANNEL_EQUIPMENT)
if(equipment_powered == new_state)
return
passive_consumption += (passive_equipment_consumption * (new_state ? 1 : -1))
equipment_powered = new_state
if(PW_CHANNEL_LIGHTING)
if(lighting_powered == new_state)
return
passive_consumption += (passive_lighting_consumption * (new_state ? 1 : -1))
lighting_powered = new_state
if(PW_CHANNEL_ENVIRONMENT)
if(environment_powered == new_state)
return
passive_consumption += (passive_environment_consumption * (new_state ? 1 : -1))
environment_powered = new_state
power_change()
/// checks to see if the given channel in this local powernet has power
/datum/local_powernet/proc/has_power(channel)
if(power_flags & PW_ALWAYS_UNPOWERED) //if this local powernet can never be powered, always return FALSE
return FALSE
if(power_flags & PW_ALWAYS_POWERED) //if this powernet is always powered, we always return TRUE
return TRUE
if(powernet_apc?.stat & (BROKEN|MAINT)) //no working apc, no power
return FALSE
switch(channel)
if(PW_CHANNEL_EQUIPMENT)
return equipment_powered
if(PW_CHANNEL_LIGHTING)
return lighting_powered
if(PW_CHANNEL_ENVIRONMENT)
return environment_powered
return FALSE
/// Add active power usage to the given channel, returns FALSE is channel cannot be found or the channel does not have power to give
/datum/local_powernet/proc/use_active_power(channel, amount)
if(!has_power(channel))
return FALSE
if(power_flags & PW_ALWAYS_POWERED)
return TRUE //we check here as well because we want to skip calculations if we will always have power
switch(channel)
if(PW_CHANNEL_EQUIPMENT)
equipment_consumption += amount
if(PW_CHANNEL_LIGHTING)
lighting_consumption += amount
if(PW_CHANNEL_ENVIRONMENT)
environment_consumption += amount
else
return FALSE
active_consumption += amount
return TRUE
/// Adjust static power for a specified channel, does not check to see if channel has power flowing into it
/datum/local_powernet/proc/adjust_static_power(channel, amount)
if(power_flags & PW_ALWAYS_POWERED)
return TRUE //we check here as well because we want to skip calculations if we will always have power
switch(channel)
if(PW_CHANNEL_EQUIPMENT)
passive_equipment_consumption += amount
if(PW_CHANNEL_LIGHTING)
passive_lighting_consumption += amount
if(PW_CHANNEL_ENVIRONMENT)
passive_environment_consumption += amount
else
return FALSE
if(has_power(channel)) // our total consumption vars don't track unpowered channels, so don't change the var if there's no power
passive_consumption += amount
return TRUE
/datum/local_powernet/proc/get_total_usage()
return passive_consumption + active_consumption
/// returns active + passive power of a channel, if the channel is not powered it returns 0 watts
/datum/local_powernet/proc/get_channel_usage(channel)
switch(channel)
if(PW_CHANNEL_EQUIPMENT)
return equipment_powered ? passive_equipment_consumption + equipment_consumption : 0
if(PW_CHANNEL_LIGHTING)
return lighting_powered ? passive_lighting_consumption + lighting_consumption : 0
if(PW_CHANNEL_ENVIRONMENT)
return environment_powered ? passive_environment_consumption + environment_consumption : 0
/datum/local_powernet/proc/clear_usage()
equipment_consumption = 0
lighting_consumption = 0
environment_consumption = 0
active_consumption = 0
/// Handles flicker operations for apc processing, will flicker machines and lights in the powernet's area by random chance
/datum/local_powernet/proc/handle_flicker()
if(prob(MACHINE_FLICKER_CHANCE))
powernet_apc?.flicker()
// lights don't have their own processing loop, so local powernets will be the father they never had. 3x as likely to cause a light flicker in a particular area, pick a light to flicker at random
if(prob(MACHINE_FLICKER_CHANCE * 3))
var/list/lights = list()
for(var/obj/machinery/light/L in powernet_area)
lights += L
if(length(lights))
var/obj/machinery/light/picked_light = pick(lights)
ASSERT(istype(picked_light))
picked_light.flicker()
@@ -8,7 +8,7 @@
move_resist = INFINITY
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
flags_2 = RAD_NO_CONTAMINATE_2
use_power = NO_POWER_USE
power_state = NO_POWER_USE
light_range = 4
layer = OBJ_LAYER + 0.1
var/obj/machinery/field/generator/FG1 = null
+8 -8
View File
@@ -11,9 +11,9 @@
density = TRUE
req_access = list(ACCESS_ENGINE_EQUIP)
use_power = NO_POWER_USE
idle_power_usage = 10
active_power_usage = 300
power_state = NO_POWER_USE
idle_power_consumption = 10
active_power_consumption = 300
/// Is the emitter turned on
var/active = FALSE
@@ -70,7 +70,7 @@
fire_delay = firedelay
for(var/obj/item/stock_parts/manipulator/M in component_parts)
power_usage -= 50 * M.rating
active_power_usage = power_usage
active_power_consumption = power_usage
/obj/machinery/power/emitter/verb/rotate()
set name = "Rotate"
@@ -98,7 +98,7 @@
return ..()
/obj/machinery/power/emitter/update_icon_state()
if(active && powernet && avail(active_power_usage))
if(active && powernet && avail(active_power_consumption))
icon_state = "emitter_+a"
else
icon_state = "emitter"
@@ -246,13 +246,13 @@
/obj/machinery/power/emitter/process()
if((stat & BROKEN) || !active)
return
if(state != EMITTER_WELDED || (!powernet && active_power_usage))
if(state != EMITTER_WELDED || (!powernet && active_power_consumption))
active = FALSE
update_icon()
return
if(!active_power_usage || surplus() >= active_power_usage)
add_load(active_power_usage)
if(!active_power_consumption || surplus() >= active_power_consumption)
add_load(active_power_consumption)
if(!powered)
powered = TRUE
update_icon()
@@ -25,7 +25,7 @@ field_generator power level display
icon_state = "Field_Gen"
anchored = FALSE
density = TRUE
use_power = NO_POWER_USE
power_state = NO_POWER_USE
max_integrity = 500
//100% immune to lasers and energy projectiles since it absorbs their energy.
armor = list(MELEE = 25, BULLET = 10, LASER = 100, ENERGY = 100, BOMB = 0, BIO = 0, RAD = 0, FIRE = 50, ACID = 70)
+1 -1
View File
@@ -6,7 +6,7 @@
icon_state = "TheSingGen"
anchored = FALSE
density = TRUE
use_power = NO_POWER_USE
power_state = NO_POWER_USE
resistance_flags = FIRE_PROOF
var/energy = 0
var/creation_type = /obj/singularity
@@ -251,9 +251,8 @@ So, hopefully this is helpful if any more icons are to be added/changed/wonderin
icon_state = "none"
anchored = FALSE
density = TRUE
use_power = NO_POWER_USE
idle_power_usage = 0
active_power_usage = 0
power_state = NO_POWER_USE
var/construction_state = 0
var/active = FALSE
var/reference = null
@@ -309,11 +308,11 @@ So, hopefully this is helpful if any more icons are to be added/changed/wonderin
if(construction_state == ACCELERATOR_WIRED)
SCREWDRIVER_CLOSE_PANEL_MESSAGE
construction_state = ACCELERATOR_READY
use_power = IDLE_POWER_USE
change_power_mode(IDLE_POWER_USE)
else
construction_state = ACCELERATOR_WIRED
SCREWDRIVER_OPEN_PANEL_MESSAGE
use_power = NO_POWER_USE
change_power_mode(NO_POWER_USE)
update_state()
update_icon()
@@ -6,9 +6,9 @@
reference = "control_box"
anchored = FALSE
density = TRUE
use_power = NO_POWER_USE
idle_power_usage = 500
active_power_usage = 10000
power_state = NO_POWER_USE
idle_power_consumption = 500
active_power_consumption = 10000
construction_state = 0
active = FALSE
dir = 1
@@ -48,7 +48,7 @@
/obj/machinery/particle_accelerator/control_box/update_state()
if(construction_state < 3)
use_power = NO_POWER_USE
change_power_mode(NO_POWER_USE)
assembled = 0
active = FALSE
for(var/obj/structure/particle_accelerator/part in connected_parts)
@@ -58,7 +58,7 @@
connected_parts = list()
return
if(!part_scan())
use_power = IDLE_POWER_USE
change_power_mode(IDLE_POWER_USE)
active = FALSE
connected_parts = list()
@@ -71,7 +71,7 @@
if(stat & NOPOWER)
icon_state = "[reference]w"
return
else if(use_power && assembled)
else if(power_state && assembled)
icon_state = "[reference]p"
else
switch(construction_state)
@@ -150,9 +150,9 @@
..()
if(stat & NOPOWER)
active = FALSE
use_power = NO_POWER_USE
change_power_mode(NO_POWER_USE)
else if(!stat && construction_state <= 3)
use_power = IDLE_POWER_USE
change_power_mode(IDLE_POWER_USE)
update_icon()
if((stat & NOPOWER) || (!stat && construction_state <= 3)) //Only update the part icons if something's changed (i.e. any of the above condition sets are met).
@@ -234,13 +234,13 @@
usr.create_log(MISC_LOG, "PA Control Computer turned ON", src)
log_game("PA Control Computer turned ON by [key_name(usr)] in ([x],[y],[z])")
if(active)
use_power = ACTIVE_POWER_USE
change_power_mode(ACTIVE_POWER_USE)
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = strength
part.powered = TRUE
part.update_icon()
else
use_power = IDLE_POWER_USE
change_power_mode(IDLE_POWER_USE)
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = null
part.powered = FALSE
-1
View File
@@ -12,7 +12,6 @@
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit."
icon_state = "smes"
density = TRUE
use_power = NO_POWER_USE
var/capacity = 5e6 // maximum charge
var/charge = 0 // actual charge
+4 -6
View File
@@ -6,9 +6,6 @@
icon = 'icons/goonstation/objects/power.dmi'
icon_state = "sp_base"
density = TRUE
use_power = NO_POWER_USE
idle_power_usage = 0
active_power_usage = 0
max_integrity = 150
integrity_failure = 50
var/obscured = FALSE
@@ -273,8 +270,8 @@
icon_state = "computer"
anchored = TRUE
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 250
power_state = IDLE_POWER_USE
idle_power_consumption = 250
max_integrity = 200
integrity_failure = 100
var/icon_screen = "solar"
@@ -497,7 +494,8 @@
/obj/machinery/power/solar_control/power_change()
..()
if(!..())
return
update_icon()
-1
View File
@@ -9,7 +9,6 @@
icon = 'icons/goonstation/objects/power.dmi'
icon_state = "tracker"
density = TRUE
use_power = NO_POWER_USE
max_integrity = 250
integrity_failure = 50
+2 -2
View File
@@ -7,7 +7,6 @@
name = "treadmill"
desc = "A power-generating treadmill."
layer = 2.2
use_power = NO_POWER_USE
var/speed = 0
var/friction = 0.15 // lose this much speed every ptick
@@ -164,7 +163,8 @@
frame = !frame
/obj/machinery/treadmill_monitor/power_change()
..()
if(!..())
return
update_icon()
/obj/machinery/treadmill_monitor/examine(mob/user)
@@ -4,8 +4,7 @@
anchored = TRUE
icon = 'icons/obj/chemical.dmi'
icon_state = "dispenser"
use_power = IDLE_POWER_USE
idle_power_usage = 40
idle_power_consumption = 40
resistance_flags = FIRE_PROOF | ACID_PROOF
var/ui_title = "Chem Dispenser 5000"
var/cell_type = /obj/item/stock_parts/cell/high
@@ -123,17 +122,11 @@
return
recharge_counter++
/obj/machinery/chem_dispenser/power_change()
if(powered())
stat &= ~NOPOWER
else
stat |= NOPOWER
/obj/machinery/chem_dispenser/update_icon_state()
if(panel_open)
icon_state = "[initial(icon_state)]-o"
return
if(!powered() && !is_drink)
if(!has_power() && !is_drink)
icon_state = "dispenser_nopower"
return
icon_state = "[initial(icon_state)][beaker ? "_working" : ""]"
@@ -4,9 +4,9 @@
anchored = TRUE
icon = 'icons/obj/chemical.dmi'
icon_state = "mixer0b"
use_power = IDLE_POWER_USE
idle_power_usage = 40
idle_power_consumption = 40
resistance_flags = FIRE_PROOF|ACID_PROOF
var/obj/item/reagent_containers/beaker = null
var/desired_temp = T0C
var/on = FALSE
@@ -55,7 +55,7 @@
SStgui.update_uis(src)
/obj/machinery/chem_heater/power_change()
if(powered())
if(has_power())
stat &= ~NOPOWER
else
stat |= NOPOWER
@@ -10,9 +10,9 @@
anchored = TRUE
icon = 'icons/obj/chemical.dmi'
icon_state = "mixer0"
use_power = IDLE_POWER_USE
idle_power_usage = 20
idle_power_consumption = 20
resistance_flags = FIRE_PROOF | ACID_PROOF
var/obj/item/reagent_containers/beaker = null
var/obj/item/storage/pill_bottle/loaded_pill_bottle = null
var/mode = 0
@@ -22,7 +22,6 @@
var/patchamount = 10
var/bottlesprite = 1
var/pillsprite = 1
var/client/has_sprites = list()
var/printing = FALSE
var/static/list/pill_bottle_wrappers
var/static/list/bottle_styles
@@ -67,11 +66,11 @@
loaded_pill_bottle = null
/obj/machinery/chem_master/update_icon_state()
icon_state = "mixer[beaker ? "1" : "0"][powered() ? "" : "_nopower"]"
icon_state = "mixer[beaker ? "1" : "0"][has_power() ? "" : "_nopower"]"
/obj/machinery/chem_master/update_overlays()
. = ..()
if(powered())
if(has_power())
. += "waitlight"
/obj/machinery/chem_master/blob_act(obj/structure/blob/B)
@@ -79,10 +78,8 @@
qdel(src)
/obj/machinery/chem_master/power_change()
if(powered())
stat &= ~NOPOWER
else
stat |= NOPOWER
if(!..())
return
update_icon()
/obj/machinery/chem_master/attackby(obj/item/I, mob/user, params)
@@ -6,8 +6,7 @@
icon = 'icons/obj/chemical.dmi'
icon_state = "pandemic0"
circuit = /obj/item/circuitboard/pandemic
use_power = IDLE_POWER_USE
idle_power_usage = 20
idle_power_consumption = 20
resistance_flags = ACID_PROOF
var/temp_html = ""
var/printing = null
@@ -57,7 +56,7 @@
if(stat & BROKEN)
icon_state = (beaker ? "pandemic1_b" : "pandemic0_b")
return
icon_state = "pandemic[(beaker)?"1":"0"][(powered()) ? "" : "_nopower"]"
icon_state = "pandemic[(beaker)?"1":"0"][(has_power()) ? "" : "_nopower"]"
/obj/machinery/computer/pandemic/update_overlays()
. = list()
@@ -4,9 +4,8 @@
icon_state = "juicer1"
layer = 2.9
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 5
active_power_usage = 100
idle_power_consumption = 5
active_power_consumption = 100
pass_flags = PASSTABLE
resistance_flags = ACID_PROOF
var/operating = FALSE
+4 -2
View File
@@ -167,7 +167,8 @@ GLOBAL_LIST_INIT(conveyor_switches, list())
clockwise = FALSE
/obj/machinery/conveyor/power_change()
..()
if(!..())
return
update_icon()
/obj/machinery/conveyor/process()
@@ -400,7 +401,8 @@ GLOBAL_LIST_INIT(conveyor_switches, list())
/obj/machinery/conveyor_switch/power_change()
..()
if(!..())
return
update_icon()
// CONVEYOR CONSTRUCTION STARTS HERE
+8 -6
View File
@@ -19,6 +19,9 @@
max_integrity = 200
flags_2 = RAD_PROTECT_CONTENTS_2 | RAD_NO_CONTAMINATE_2
resistance_flags = FIRE_PROOF
active_power_consumption = 600
idle_power_consumption = 100
var/datum/gas_mixture/air_contents // internal reservoir
var/mode = 1 // item mode 0=off 1=charging 2=charged
var/flush = 0 // true if flush handle is pulled
@@ -29,8 +32,6 @@
var/last_sound = 0
var/required_mode_to_deconstruct = -1
var/deconstructs_to = PIPE_DISPOSALS_BIN
active_power_usage = 600
idle_power_usage = 100
/obj/machinery/disposal/proc/trunk_check()
var/obj/structure/disposalpipe/trunk/T = locate() in loc
@@ -363,7 +364,7 @@
// timed process
// charge the gas reservoir and perform flush if ready
/obj/machinery/disposal/process()
use_power = NO_POWER_USE
change_power_mode(NO_POWER_USE)
if(stat & BROKEN) // nothing can happen if broken
return
@@ -383,13 +384,13 @@
if(stat & NOPOWER) // won't charge if no power
return
use_power = IDLE_POWER_USE
change_power_mode(IDLE_POWER_USE)
if(mode != 1) // if off or ready, no need to charge
return
// otherwise charge
use_power = ACTIVE_POWER_USE
change_power_mode(ACTIVE_POWER_USE)
var/atom/L = loc // recharging from loc turf
@@ -454,7 +455,8 @@
// called when area power changes
/obj/machinery/disposal/power_change()
..() // do default setting/reset of stat NOPOWER bit
if(!..())
return // do default setting/reset of stat NOPOWER bit
update() // update icon
if(stat & NOPOWER)
set_light(0)
+1 -1
View File
@@ -21,7 +21,7 @@
icon_state = "h_lathe"
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
power_state = IDLE_POWER_USE
var/recentlyExperimented = 0
var/badThingCoeff = 0
var/resetTime = 15
+4 -7
View File
@@ -51,9 +51,8 @@ GLOBAL_LIST_EMPTY(message_servers)
icon_state = "message_server"
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 10
active_power_usage = 100
idle_power_consumption = 10
active_power_consumption = 100
var/list/datum/data_pda_msg/pda_msgs = list()
var/list/datum/data_rc_msg/rc_msgs = list()
@@ -126,7 +125,5 @@ GLOBAL_LIST_EMPTY(message_servers)
name = "Blackbox Recorder"
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 10
active_power_usage = 100
idle_power_consumption = 10
active_power_consumption = 100
-1
View File
@@ -6,7 +6,6 @@
icon = 'icons/obj/machines/research.dmi'
density = TRUE
anchored = TRUE
use_power = IDLE_POWER_USE
var/busy = FALSE
var/obj/machinery/computer/rdconsole/linked_console
var/obj/item/loaded_item = null
+2 -1
View File
@@ -51,7 +51,8 @@
icon_state = "RD-server-on"
/obj/machinery/r_n_d/server/power_change()
. = ..()
if(!..())
return
update_icon(UPDATE_ICON_STATE)
/obj/machinery/r_n_d/server/proc/initialize_serv()
@@ -17,10 +17,9 @@
var/ert_reason
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 2
active_power_usage = 6
power_channel = ENVIRON
idle_power_consumption = 2
active_power_consumption = 6
power_channel = PW_CHANNEL_ENVIRONMENT
req_access = list(ACCESS_KEYCARD_AUTH)
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
@@ -71,10 +70,8 @@
return ..()
/obj/machinery/keycard_auth/power_change()
if(powered(ENVIRON))
stat &= ~NOPOWER
else
stat |= NOPOWER
if(!..())
return
update_icon()
/obj/machinery/keycard_auth/attack_ghost(mob/user)
@@ -180,7 +180,7 @@ GLOBAL_DATUM_INIT(security_announcement, /datum/announcer, new(config_type = /da
continue
A.emergency_lights = FALSE
AR.area_emergency_mode = TRUE
for(var/obj/machinery/light/L in A.area)
for(var/obj/machinery/light/L in A.apc_area)
if(L.status)
continue
if(GLOB.security_level == SEC_LEVEL_DELTA)
+2 -2
View File
@@ -191,7 +191,7 @@
pixel_y = -64
/// For faking having a big machine, dummy 'machines' that are hidden inside the large sprite and make certain tiles dense. See new and destroy.
var/list/obj/structure/fillers = list()
use_power = NO_POWER_USE // power usage is handelled manually
power_state = NO_POWER_USE // power usage is handelled manually
density = TRUE
interact_offline = TRUE
luminosity = 1
@@ -222,7 +222,7 @@
var/actual_power_usage = 0
// Tweak these and active_power_usage to balance power generation
// Tweak these and active_power_consumption to balance power generation
/// Max power input level, I don't expect this to be ever reached
var/max_level = 20
+10 -2
View File
@@ -202,7 +202,15 @@
top_layer.layer = 4.1
icon_state = "cannon_east"
overlays += top_layer
reload()
/obj/machinery/bsa/full/Initialize(mapload)
. = ..()
return INITIALIZE_HINT_LATELOAD
/obj/machinery/bsa/full/LateInitialize(mapload)
. = ..()
reload() // so we don't try and use the powernet before it initializes
/obj/machinery/bsa/full/proc/fire(mob/user, turf/bullseye, target)
var/turf/point = get_front_turf()
@@ -263,7 +271,7 @@
var/obj/machinery/bsa/full/cannon
var/notice
var/target
use_power = NO_POWER_USE
power_state = NO_POWER_USE
circuit = /obj/item/circuitboard/computer/bsa_control
icon = 'icons/obj/machines/particle_accelerator.dmi'
icon_state = "control_boxp"
+3 -5
View File
@@ -149,7 +149,7 @@ GLOBAL_LIST_INIT(non_simple_animals, typecacheof(list(/mob/living/carbon/human/m
icon_state = "vault"
density = TRUE
anchored = TRUE
idle_power_usage = 5000
idle_power_consumption = 5000
pixel_x = -32
pixel_y = -64
luminosity = 1
@@ -195,10 +195,8 @@ GLOBAL_LIST_INIT(non_simple_animals, typecacheof(list(/mob/living/carbon/human/m
icon_state = "vault"
/obj/machinery/dna_vault/power_change()
if(powered(power_channel))
stat &= ~NOPOWER
else
stat |= NOPOWER
if(!..())
return
update_icon(UPDATE_ICON_STATE)
+1 -1
View File
@@ -104,7 +104,7 @@
var/mode = "NTPROBEV0.8"
var/active = FALSE
density = TRUE
use_power = FALSE
power_state = NO_POWER_USE
var/static/gid = 0
var/id = 0
+4 -6
View File
@@ -5,9 +5,8 @@
icon = 'icons/obj/telescience.dmi'
icon_state = "pad-idle"
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 200
active_power_usage = 5000
idle_power_consumption = 200
active_power_consumption = 5000
var/efficiency
/obj/machinery/telepad/Initialize(mapload)
@@ -67,9 +66,8 @@
icon = 'icons/obj/telescience.dmi'
icon_state = "pad-idle"
anchored = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 20
active_power_usage = 500
idle_power_consumption = 20
active_power_consumption = 500
var/stage = 0
/obj/machinery/telepad_cargo/crowbar_act(mob/living/user, obj/item/I)