diff --git a/code/controllers/subsystem/machines.dm b/code/controllers/subsystem/machines.dm
index 4440d1c17b33..29281498910c 100644
--- a/code/controllers/subsystem/machines.dm
+++ b/code/controllers/subsystem/machines.dm
@@ -48,8 +48,8 @@ SUBSYSTEM_DEF(machines)
var/obj/machinery/thing = currentrun[currentrun.len]
currentrun.len--
if(!QDELETED(thing) && thing.process(seconds) != PROCESS_KILL)
- if(thing.use_power)
- thing.auto_use_power() //add back the power state
+ //if(thing.use_power)
+ //thing.auto_use_power() //add back the power state
else
processing -= thing
if (!QDELETED(thing))
diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm
index db9383955653..878b49caa686 100644
--- a/code/game/machinery/Sleeper.dm
+++ b/code/game/machinery/Sleeper.dm
@@ -102,7 +102,7 @@
playsound(src, 'sound/machines/synth_yes.ogg', 50, TRUE, frequency = rand(5120, 8800))
target.apply_status_effect(STATUS_EFFECT_STASIS, STASIS_MACHINE_EFFECT)
target.ExtinguishMob()
- use_power = ACTIVE_POWER_USE
+ set_active_power()
/obj/machinery/sleeper/proc/thaw_them(mob/living/target)
if(IS_IN_STASIS(target))
@@ -111,7 +111,7 @@
/obj/machinery/sleeper/process()
if(!occupant || !isliving(occupant))
- use_power = IDLE_POWER_USE
+ set_idle_power()
return
var/mob/living/L_occupant = occupant
if(stasis_running())
diff --git a/code/game/machinery/_machinery.dm b/code/game/machinery/_machinery.dm
index f90364bc9ec2..0b23e3b3aa7f 100644
--- a/code/game/machinery/_machinery.dm
+++ b/code/game/machinery/_machinery.dm
@@ -102,6 +102,7 @@ Class Procs:
//0 = dont run the auto
//1 = run auto, use idle
//2 = run auto, use active
+ var/use_static_power = NO_POWER_USE
var/idle_power_usage = 0
var/active_power_usage = 0
var/power_channel = AREA_USAGE_EQUIP
@@ -151,7 +152,11 @@ Class Procs:
if(occupant_typecache)
occupant_typecache = typecacheof(occupant_typecache)
-
+ switch(use_power)
+ if(IDLE_POWER_USE)
+ set_idle_power()
+ if(ACTIVE_POWER_USE)
+ set_active_power()
return INITIALIZE_HINT_LATELOAD
/// Helper proc for telling a machine to start processing with the subsystem type that is located in its `subsystem_type` var.
@@ -175,6 +180,7 @@ Class Procs:
dropContents()
QDEL_NULL(circuit)
QDEL_LIST(component_parts)
+ set_no_power()
return ..()
/obj/machinery/proc/locate_machinery()
@@ -616,6 +622,7 @@ Class Procs:
//called on deconstruction before the final deletion
/obj/machinery/proc/on_deconstruction()
+ set_no_power()
return
/obj/machinery/proc/can_be_overridden()
@@ -651,3 +658,24 @@ Class Procs:
else if(clicksound)
playsound(src, clicksound, clickvol)
return
+
+/obj/machinery/powertest
+ name = "powertest"
+ desc = "test."
+ icon = 'icons/obj/machines/autolathe.dmi'
+ icon_state = "autolathe"
+ use_power = IDLE_POWER_USE
+ idle_power_usage = IDLE_DRAW_LOW
+ active_power_usage = ACTIVE_DRAW_HIGH
+ power_channel = AREA_USAGE_EQUIP
+ var/on = FALSE
+
+/obj/machinery/powertest/CtrlClick(mob/user)
+ if(can_interact(user))
+ on = !on
+ to_chat(usr, "[src] has changed setting!")
+ if(on)
+ set_active_power()
+ else
+ set_idle_power()
+ return ..()
diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm
index 201830422a0d..5e61d276b226 100644
--- a/code/game/machinery/autolathe.dm
+++ b/code/game/machinery/autolathe.dm
@@ -253,7 +253,7 @@
use_power(power)
icon_state = "autolathe_n"
var/time = is_stack ? 32 : (32 * coeff * multiplier) ** 0.8
- use_power = ACTIVE_POWER_USE
+ set_active_power()
addtimer(CALLBACK(src, PROC_REF(make_item), power, materials_used, custom_materials, multiplier, coeff, is_stack, usr), time)
. = TRUE
else
@@ -334,7 +334,7 @@
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
var/atom/A = drop_location()
use_power(power)
- use_power = IDLE_POWER_USE
+ set_idle_power()
materials.use_materials(materials_used)
diff --git a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm
index a0018c48b713..6d4d0dbde485 100644
--- a/code/game/machinery/porta_turret/portable_turret.dm
+++ b/code/game/machinery/porta_turret/portable_turret.dm
@@ -794,7 +794,7 @@ DEFINE_BITFIELD(turret_flags, list(
installation = null
max_integrity = 300
always_up = 1
- use_power = ACTIVE_POWER_USE
+ set_active_power()
active_power_usage = 300
has_cover = 0
scan_range = 9
diff --git a/code/game/machinery/recharger.dm b/code/game/machinery/recharger.dm
index e23fdb801c6c..2720443d2424 100644
--- a/code/game/machinery/recharger.dm
+++ b/code/game/machinery/recharger.dm
@@ -50,11 +50,11 @@
if (new_charging)
START_PROCESSING(SSmachines, src)
finished_recharging = FALSE
- use_power = ACTIVE_POWER_USE
+ set_active_power()
using_power = TRUE
update_appearance()
else
- use_power = IDLE_POWER_USE
+ set_idle_power()
using_power = FALSE
update_appearance()
diff --git a/code/game/machinery/rechargestation.dm b/code/game/machinery/rechargestation.dm
index 36be4c815118..733f227e006a 100644
--- a/code/game/machinery/rechargestation.dm
+++ b/code/game/machinery/rechargestation.dm
@@ -90,12 +90,12 @@
/obj/machinery/recharge_station/open_machine()
. = ..()
- use_power = IDLE_POWER_USE
+ set_idle_power()
/obj/machinery/recharge_station/close_machine()
. = ..()
if(occupant)
- use_power = ACTIVE_POWER_USE //It always tries to charge, even if it can't.
+ set_active_power() //It always tries to charge, even if it can't.
add_fingerprint(occupant)
/obj/machinery/recharge_station/update_icon_state()
diff --git a/code/game/machinery/stasis.dm b/code/game/machinery/stasis.dm
index bf62fc965e0b..2582c57da903 100644
--- a/code/game/machinery/stasis.dm
+++ b/code/game/machinery/stasis.dm
@@ -112,12 +112,12 @@
playsound(src, 'sound/effects/spray.ogg', 5, TRUE, 2, frequency = freq)
target.apply_status_effect(STATUS_EFFECT_STASIS, STASIS_MACHINE_EFFECT)
target.ExtinguishMob()
- use_power = ACTIVE_POWER_USE
+ set_active_power()
/obj/machinery/stasis/proc/thaw_them(mob/living/target)
target.remove_status_effect(STATUS_EFFECT_STASIS, STASIS_MACHINE_EFFECT)
if(target == occupant)
- use_power = IDLE_POWER_USE
+ set_idle_power()
/obj/machinery/stasis/post_buckle_mob(mob/living/L)
if(!can_be_occupant(L))
diff --git a/code/game/mecha/mech_fabricator.dm b/code/game/mecha/mech_fabricator.dm
index 03b983197520..83a2c4861c90 100644
--- a/code/game/mecha/mech_fabricator.dm
+++ b/code/game/mecha/mech_fabricator.dm
@@ -196,10 +196,10 @@
rmat.silo_log(src, "built", -1, "[D.name]", res_coef)
add_overlay("fab-active")
- use_power = ACTIVE_POWER_USE
+ set_active_power()
updateUsrDialog()
sleep(get_construction_time_w_coeff(D))
- use_power = IDLE_POWER_USE
+ set_idle_power()
cut_overlay("fab-active")
desc = initial(desc)
diff --git a/code/modules/NTNet/relays.dm b/code/modules/NTNet/relays.dm
index f653b6e4a318..f161eced8060 100644
--- a/code/modules/NTNet/relays.dm
+++ b/code/modules/NTNet/relays.dm
@@ -64,9 +64,9 @@
/obj/machinery/ntnet_relay/process()
if(is_operational)
- use_power = ACTIVE_POWER_USE
+ set_active_power()
else
- use_power = IDLE_POWER_USE
+ set_idle_power()
update_appearance()
diff --git a/code/modules/atmospherics/machinery/airalarm.dm b/code/modules/atmospherics/machinery/airalarm.dm
index b7ccb8be4da0..895bfdc96cf4 100644
--- a/code/modules/atmospherics/machinery/airalarm.dm
+++ b/code/modules/atmospherics/machinery/airalarm.dm
@@ -753,14 +753,14 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/airalarm, 27)
visible_message("The air alarm makes a quiet click as it stops heating the area")
playsound(src, 'sound/machines/terminal_off.ogg', 40)
heating_current_mode = "Idle"
- use_power = IDLE_POWER_USE
+ set_idle_power()
return
if(wanted_mode == "Heat" & heating_current_mode == "Idle")
visible_message("The air alarm makes a quiet click as it starts heating the area")
playsound(src, 'sound/machines/terminal_on.ogg', 40)
heating_current_mode = "Heat"
- use_power = ACTIVE_POWER_USE
+ set_active_power()
if(heating_current_mode == "Heat")
var/temperature = environment.return_temperature()
diff --git a/code/modules/awaymissions/gateway.dm b/code/modules/awaymissions/gateway.dm
index 9070670d5d67..51ab76479657 100644
--- a/code/modules/awaymissions/gateway.dm
+++ b/code/modules/awaymissions/gateway.dm
@@ -198,7 +198,7 @@ GLOBAL_LIST_EMPTY(gateway_destinations)
target = null
dest.deactivate(src)
QDEL_NULL(portal)
- use_power = IDLE_POWER_USE
+ set_idle_power()
update_appearance()
portal_visuals.reset_visuals()
@@ -221,7 +221,7 @@ GLOBAL_LIST_EMPTY(gateway_destinations)
target.activate(destination)
portal_visuals.setup_visuals(target)
generate_bumper()
- use_power = ACTIVE_POWER_USE
+ set_active_power()
update_appearance()
/obj/machinery/gateway/proc/Transfer(atom/movable/AM)
diff --git a/code/modules/fishing/fishing_portal_machine.dm b/code/modules/fishing/fishing_portal_machine.dm
index dfbd1aac76ba..a070e7b7f797 100644
--- a/code/modules/fishing/fishing_portal_machine.dm
+++ b/code/modules/fishing/fishing_portal_machine.dm
@@ -35,12 +35,12 @@
/obj/machinery/fishing_portal_generator/proc/activate()
active = AddComponent(/datum/component/fishing_spot, fishing_source)
- use_power = ACTIVE_POWER_USE
+ set_active_power()
update_appearance()
/obj/machinery/fishing_portal_generator/proc/deactivate()
QDEL_NULL(active)
- use_power = IDLE_POWER_USE
+ set_idle_power()
update_appearance()
/obj/machinery/fishing_portal_generator/on_set_is_operational(old_value)
diff --git a/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm b/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm
index 189b692436fb..d2e919f00882 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm
@@ -326,10 +326,10 @@
/obj/machinery/smartfridge/drying_rack/proc/toggle_drying(forceoff)
if(drying || forceoff)
drying = FALSE
- use_power = IDLE_POWER_USE
+ set_idle_power()
else
drying = TRUE
- use_power = ACTIVE_POWER_USE
+ set_active_power()
update_appearance()
/obj/machinery/smartfridge/drying_rack/proc/rack_dry()
diff --git a/code/modules/hydroponics/hydroponics.dm b/code/modules/hydroponics/hydroponics.dm
index b6fadd1f7137..e976cd912ccf 100644
--- a/code/modules/hydroponics/hydroponics.dm
+++ b/code/modules/hydroponics/hydroponics.dm
@@ -123,7 +123,7 @@
if(!powered() && self_sustaining)
visible_message("[name]'s auto-grow functionality shuts off!")
- use_power = IDLE_POWER_USE
+ set_idle_power()
self_sustaining = FALSE
update_appearance()
@@ -685,9 +685,9 @@
return
self_sustaining = !self_sustaining
if(self_sustaining)
- use_power = ACTIVE_POWER_USE
+ set_active_power()
else
- use_power = IDLE_POWER_USE
+ set_idle_power()
to_chat(user, "You [self_sustaining ? "activate" : "deactivated"] [src]'s autogrow function[self_sustaining ? ", maintaining the tray's health while using high amounts of power" : ""].")
update_appearance()
@@ -718,7 +718,7 @@
desc = initial(desc)
TRAY_NAME_UPDATE
if(self_sustaining) //No reason to pay for an empty tray.
- use_power = IDLE_POWER_USE
+ set_idle_power()
self_sustaining = FALSE
update_appearance()
diff --git a/code/modules/overmap/missions/research_mission.dm b/code/modules/overmap/missions/research_mission.dm
index a1a4537da534..fe5b90f4f37d 100644
--- a/code/modules/overmap/missions/research_mission.dm
+++ b/code/modules/overmap/missions/research_mission.dm
@@ -122,7 +122,7 @@
if(anchorvalue)
set_is_operational(TRUE)
START_PROCESSING(SSmachines, src)
- use_power = IDLE_POWER_USE
+ set_idle_power()
else
set_is_operational(FALSE)
STOP_PROCESSING(SSmachines, src)
diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm
index 77686eaf96dc..268de49e4222 100644
--- a/code/modules/power/lighting.dm
+++ b/code/modules/power/lighting.dm
@@ -420,7 +420,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/small/built, 28)
if(trigger)
burn_out()
else
- use_power = ACTIVE_POWER_USE
+ set_active_power()
set_light(BR, PO, CO)
else if(has_emergency_power(LIGHT_EMERGENCY_POWER_USE) && !turned_off())
use_power = IDLE_POWER_USE
diff --git a/code/modules/power/monitor.dm b/code/modules/power/monitor.dm
index 706fa10ba8df..ab85a719233d 100644
--- a/code/modules/power/monitor.dm
+++ b/code/modules/power/monitor.dm
@@ -49,10 +49,10 @@
/obj/machinery/computer/monitor/process()
if(!get_powernet())
- use_power = IDLE_POWER_USE
+ set_idle_power()
search()
else
- use_power = ACTIVE_POWER_USE
+ set_active_power()
record()
/obj/machinery/computer/monitor/proc/search() //keep in sync with /datum/computer_file/program/power_monitor's version
diff --git a/code/modules/power/power.dm b/code/modules/power/power.dm
index 3cf5f5766097..5299af33ce69 100644
--- a/code/modules/power/power.dm
+++ b/code/modules/power/power.dm
@@ -19,6 +19,7 @@
/obj/machinery/power/Destroy()
disconnect_from_network()
+ set_no_power()
return ..()
///////////////////////////////
@@ -105,6 +106,24 @@
/obj/machinery/proc/removeStaticPower(value, powerchannel)
addStaticPower(-value, powerchannel)
+/obj/machinery/proc/set_idle_power()
+ set_no_power()
+ use_static_power = IDLE_POWER_USE
+ addStaticPower(idle_power_usage, power_channel + 3)
+
+/obj/machinery/proc/set_active_power()
+ set_no_power()
+ use_static_power = ACTIVE_POWER_USE
+ addStaticPower(active_power_usage, power_channel + 3)
+
+/obj/machinery/proc/set_no_power()
+ switch(use_static_power)
+ if(IDLE_POWER_USE)
+ removeStaticPower(idle_power_usage, power_channel + 3)
+ if(ACTIVE_POWER_USE)
+ removeStaticPower(active_power_usage, power_channel + 3)
+ use_static_power = NO_POWER_USE
+
/**
* Called whenever the power settings of the containing area change
*
diff --git a/code/modules/power/singularity/particle_accelerator/particle_control.dm b/code/modules/power/singularity/particle_accelerator/particle_control.dm
index 7fda9cebcca3..ddcaf026a40e 100644
--- a/code/modules/power/singularity/particle_accelerator/particle_control.dm
+++ b/code/modules/power/singularity/particle_accelerator/particle_control.dm
@@ -53,7 +53,7 @@
connected_parts.Cut()
return
if(!part_scan())
- use_power = IDLE_POWER_USE
+ set_idle_power()
active = FALSE
connected_parts.Cut()
@@ -106,7 +106,7 @@
active = FALSE
use_power = NO_POWER_USE
else if(!machine_stat && construction_state == PA_CONSTRUCTION_COMPLETE)
- use_power = IDLE_POWER_USE
+ set_idle_power()
/obj/machinery/particle_accelerator/control_box/process()
if(active)
@@ -175,14 +175,14 @@
message_admins("PA Control Computer turned [active ?"ON":"OFF"] by [usr ? ADMIN_LOOKUPFLW(usr) : "outside forces"] in [ADMIN_VERBOSEJMP(src)]")
log_game("PA Control Computer turned [active ?"ON":"OFF"] by [usr ? "[key_name(usr)]" : "outside forces"] at [AREACOORD(src)]")
if(active)
- use_power = ACTIVE_POWER_USE
+ set_active_power()
for(var/CP in connected_parts)
var/obj/structure/particle_accelerator/part = CP
part.strength = strength
part.powered = TRUE
part.update_appearance()
else
- use_power = IDLE_POWER_USE
+ set_idle_power()
for(var/CP in connected_parts)
var/obj/structure/particle_accelerator/part = CP
part.strength = null
diff --git a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm
index 99c8c7d66183..5beaca629934 100644
--- a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm
+++ b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm
@@ -263,9 +263,9 @@
/obj/machinery/reagentgrinder/proc/juice()
if(!beaker || machine_stat & (NOPOWER|BROKEN) || beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
return
- use_power = ACTIVE_POWER_USE
+ set_active_power()
operate_for(50, juicing = TRUE)
- use_power = IDLE_POWER_USE
+ set_idle_power()
for(var/obj/item/i in holdingitems)
if(beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
@@ -284,9 +284,9 @@
/obj/machinery/reagentgrinder/proc/grind(mob/user)
if(!beaker || machine_stat & (NOPOWER|BROKEN) || beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
return
- use_power = ACTIVE_POWER_USE
+ set_active_power()
operate_for(60)
- use_power = IDLE_POWER_USE
+ set_idle_power()
for(var/i in holdingitems)
if(beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
@@ -314,9 +314,9 @@
//For butter and other things that would change upon shaking or mixing
if(!beaker || machine_stat & (NOPOWER|BROKEN))
return
- use_power = ACTIVE_POWER_USE
+ set_active_power()
operate_for(50, juicing = TRUE)
- use_power = IDLE_POWER_USE
+ set_idle_power()
addtimer(CALLBACK(src, TYPE_PROC_REF(/obj/machinery/reagentgrinder, mix_complete)), 50)
/obj/machinery/reagentgrinder/proc/mix_complete()
diff --git a/code/modules/research/bepis.dm b/code/modules/research/bepis.dm
index 6d61b62411b1..4b03bdfb15be 100644
--- a/code/modules/research/bepis.dm
+++ b/code/modules/research/bepis.dm
@@ -254,7 +254,7 @@
return
calcsuccess()
use_power(MACHINE_OPERATION * power_saver) //This thing should eat your APC battery if you're not careful.
- use_power = IDLE_POWER_USE //Machine shuts off after use to prevent spam and look better visually.
+ set_idle_power() //Machine shuts off after use to prevent spam and look better visually.
update_icon_state()
if("amount")
var/input = text2num(params["amount"])
@@ -262,9 +262,9 @@
banking_amount = input
if("toggle_power")
if(use_power == ACTIVE_POWER_USE)
- use_power = IDLE_POWER_USE
+ set_idle_power()
else
- use_power = ACTIVE_POWER_USE
+ set_active_power()
update_icon_state()
if("account_reset")
if(use_power == IDLE_POWER_USE)
diff --git a/code/modules/research/machinery/_production.dm b/code/modules/research/machinery/_production.dm
index fdf2e6587b8b..0f8c2eb53c1d 100644
--- a/code/modules/research/machinery/_production.dm
+++ b/code/modules/research/machinery/_production.dm
@@ -100,7 +100,7 @@
if(notify_admins)
investigate_log("[key_name(usr)] built [amount] of [path] at [src]([type]).", INVESTIGATE_RESEARCH)
message_admins("[ADMIN_LOOKUPFLW(usr)] has built [amount] of [path] at \a [src]([type]).")
- use_power = IDLE_POWER_USE
+ set_idle_power()
for(var/i in 1 to amount)
var/obj/item/I = new path(get_turf(src))
if(efficient_with(I.type))
@@ -173,7 +173,7 @@
flick(production_animation, src)
var/timecoeff = D.lathe_time_factor / efficiency_coeff
addtimer(CALLBACK(src, PROC_REF(reset_busy)), (30 * timecoeff * amount) ** 0.5)
- use_power = ACTIVE_POWER_USE
+ set_active_power()
addtimer(CALLBACK(src, PROC_REF(do_print), D.build_path, amount, efficient_mats, D.dangerous_construction), (32 * timecoeff * amount) ** 0.8)
return TRUE