diff --git a/_maps/map_files/Delta/delta.dmm b/_maps/map_files/Delta/delta.dmm
index bb8dd2fc9dd..c4cc9784999 100644
--- a/_maps/map_files/Delta/delta.dmm
+++ b/_maps/map_files/Delta/delta.dmm
@@ -37743,7 +37743,7 @@
/obj/machinery/door/airlock/hatch/gamma{
locked = 1;
req_access_txt = "1";
- use_power = 0
+ power_state = 0
},
/obj/machinery/door/poddoor{
density = 0;
@@ -88625,7 +88625,7 @@
/obj/machinery/door/poddoor{
id_tag = "ToxinsVenting";
name = "Toxins Venting Bay Door";
- use_power = 0
+ power_state = 0
},
/turf/simulated/floor/engine,
/area/toxins/mixing)
diff --git a/_maps/map_files/MetaStation/MetaStation.dmm b/_maps/map_files/MetaStation/MetaStation.dmm
index a3bfee85c08..931b2884883 100644
--- a/_maps/map_files/MetaStation/MetaStation.dmm
+++ b/_maps/map_files/MetaStation/MetaStation.dmm
@@ -30528,7 +30528,7 @@
"bNP" = (
/obj/structure/lattice,
/obj/machinery/camera{
- active_power_usage = 0;
+ active_power_consumption = 0;
c_tag = "Turbine Vent";
dir = 6;
network = list("Turbine")
@@ -73549,7 +73549,7 @@
/obj/machinery/door/airlock/hatch/gamma{
locked = 1;
req_access_txt = "1";
- use_power = 0
+ power_state = 0
},
/obj/machinery/door/firedoor,
/turf/simulated/floor/plasteel{
@@ -78308,7 +78308,7 @@
/obj/machinery/door/poddoor{
id_tag = "ToxinsVenting";
name = "Toxins Venting Bay Door";
- use_power = 0
+ power_state = 0
},
/turf/simulated/floor/engine/vacuum,
/area/toxins/mixing)
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/deepstorage.dmm b/_maps/map_files/RandomRuins/SpaceRuins/deepstorage.dmm
index 2aa3dc957dc..2959974cbd1 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/deepstorage.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/deepstorage.dmm
@@ -668,7 +668,7 @@
/turf/simulated/floor/plasteel,
/area/ruin/space/unpowered)
"bG" = (
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 8;
keep_preset_name = 1;
name = "Bunker APC";
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/dj.dmm b/_maps/map_files/RandomRuins/SpaceRuins/dj.dmm
index c90c76abce0..d7d22b0c582 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/dj.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/dj.dmm
@@ -295,7 +295,7 @@
d2 = 4;
icon_state = "0-4"
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
name = "Worn-out APC";
pixel_y = -24
},
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/meatpackers.dmm b/_maps/map_files/RandomRuins/SpaceRuins/meatpackers.dmm
index f51210398c1..7f44d2633bf 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/meatpackers.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/meatpackers.dmm
@@ -128,11 +128,11 @@
icon_state = "0-2";
pixel_y = 1
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
- environ = 2;
- equipment = 0;
- lighting = 0;
+ environment_channel = 2;
+ equipment_channel = 0;
+ lighting_channel = 0;
locked = 0;
pixel_y = 24;
req_access = ""
@@ -429,10 +429,10 @@
d2 = 2;
icon_state = "0-2"
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
- equipment = 0;
- lighting = 0;
+ equipment_channel = 0;
+ lighting_channel = 0;
locked = 0;
operating = 0;
pixel_y = 24;
@@ -765,9 +765,9 @@
icon_state = "0-2";
pixel_y = 1
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
- environ = 0;
+ environment_channel = 0;
locked = 0;
operating = 0;
pixel_y = 24;
@@ -1126,7 +1126,7 @@
d2 = 2;
icon_state = "0-2"
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
locked = 0;
operating = 0;
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/moonoutpost19.dmm b/_maps/map_files/RandomRuins/SpaceRuins/moonoutpost19.dmm
index 21cce7547e2..3a459fbcabb 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/moonoutpost19.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/moonoutpost19.dmm
@@ -141,7 +141,7 @@
/area/ruin/space/unpowered)
"au" = (
/obj/machinery/light{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 1;
icon_state = "tube-broken";
status = 2
@@ -203,7 +203,7 @@
/area/ruin/space/unpowered)
"aB" = (
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 4;
icon_state = "bulb-broken";
status = 2
@@ -324,7 +324,7 @@
/area/ruin/space/unpowered)
"aP" = (
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 8;
icon_state = "bulb-broken";
status = 2
@@ -561,7 +561,7 @@
layer = 2.9
},
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 1;
icon_state = "bulb-broken";
status = 2
@@ -898,7 +898,7 @@
/area/ruin/space/unpowered)
"bM" = (
/obj/machinery/light{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 4;
icon_state = "tube-broken";
status = 2
@@ -1192,7 +1192,7 @@
icon_state = "1-2";
tag = ""
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
cell_type = 15000;
dir = 4;
locked = 0;
@@ -1435,14 +1435,13 @@
/area/ruin/space/unpowered)
"cO" = (
/obj/structure/cable,
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station/empty_charge{
cell_type = 15000;
dir = 4;
locked = 0;
name = "Research APC";
pixel_x = 25;
- req_access = null;
- start_charge = 0
+ req_access = null
},
/obj/machinery/atmospherics/pipe/simple/hidden/supply,
/turf/simulated/floor/plasteel{
@@ -1462,7 +1461,7 @@
"cQ" = (
/obj/structure/table,
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 4;
icon_state = "bulb-broken";
status = 2
@@ -1475,7 +1474,7 @@
"cR" = (
/obj/structure/filingcabinet/filingcabinet,
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 8;
icon_state = "bulb-broken";
status = 2
@@ -1596,7 +1595,7 @@
/area/ruin/space/unpowered)
"da" = (
/obj/machinery/light{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 4;
icon_state = "tube-broken";
status = 2
@@ -1700,7 +1699,7 @@
/area/ruin/space/unpowered)
"dj" = (
/obj/machinery/light{
- active_power_usage = 0;
+ active_power_consumption = 0;
icon_state = "tube-broken";
status = 2
},
@@ -1817,7 +1816,7 @@
/obj/item/trash/chips,
/obj/effect/decal/cleanable/dirt,
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 1;
icon_state = "bulb-broken";
status = 2
@@ -1879,7 +1878,7 @@
"dB" = (
/obj/structure/filingcabinet/chestdrawer,
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
dir = 1;
icon_state = "bulb-broken";
status = 2
@@ -2025,7 +2024,7 @@
pixel_y = -32
},
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
icon_state = "bulb-broken";
status = 2
},
@@ -2344,7 +2343,7 @@
"eu" = (
/obj/structure/closet/l3closet/general,
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
icon_state = "bulb-broken";
status = 2
},
@@ -2601,7 +2600,7 @@
pixel_y = -32
},
/obj/machinery/light/small{
- active_power_usage = 0;
+ active_power_consumption = 0;
icon_state = "bulb-broken";
status = 2
},
@@ -2982,7 +2981,7 @@
d2 = 2;
icon_state = "0-2"
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
cell_type = 15000;
dir = 1;
locked = 0;
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/oldstation.dmm b/_maps/map_files/RandomRuins/SpaceRuins/oldstation.dmm
index 0aea4b1bdc8..d7412a4bdcd 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/oldstation.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/oldstation.dmm
@@ -164,12 +164,10 @@
/area/ruin/ancientstation/hivebot)
"aE" = (
/obj/structure/cable,
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
dir = 4;
name = "Beta Engineering APC";
- pixel_x = 24;
- report_power_alarm = 0;
- start_charge = 0
+ pixel_x = 24
},
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/plasteel/airless,
@@ -1018,12 +1016,10 @@
icon_state = "0-4"
},
/obj/effect/decal/cleanable/dirt,
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
dir = 1;
- name = "Thete Prototype Lab APC";
- pixel_y = 24;
- report_power_alarm = 0;
- start_charge = 0
+ name = "Theta Prototype Lab APC";
+ pixel_y = 24
},
/turf/simulated/floor/plasteel/white,
/area/ruin/ancientstation/proto)
@@ -1076,12 +1072,10 @@
/area/ruin/ancientstation/comm)
"dd" = (
/obj/structure/cable,
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
dir = 4;
name = "Charlie Main Corridor APC";
- pixel_x = 24;
- report_power_alarm = 0;
- start_charge = 0
+ pixel_x = 24
},
/obj/structure/closet/crate,
/obj/item/storage/backpack/old,
@@ -1426,12 +1420,10 @@
pixel_y = 1
},
/obj/effect/decal/cleanable/dirt,
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
dir = 4;
name = "Charlie Command APC";
- pixel_x = 24;
- report_power_alarm = 0;
- start_charge = 0
+ pixel_x = 24
},
/turf/simulated/floor/plating,
/area/ruin/ancientstation/comm)
@@ -2510,12 +2502,10 @@
icon_state = "0-2";
pixel_y = 1
},
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
dir = 8;
name = "Charlie Security APC";
- pixel_x = -24;
- report_power_alarm = 0;
- start_charge = 0
+ pixel_x = -24
},
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/plasteel{
@@ -3427,12 +3417,10 @@
pixel_y = 1
},
/obj/effect/decal/cleanable/dirt,
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
dir = 1;
name = "Theta Main Corridor APC";
- pixel_y = 24;
- report_power_alarm = 0;
- start_charge = 0
+ pixel_y = 24
},
/turf/simulated/floor/plating,
/area/ruin/ancientstation/thetacorridor)
@@ -3822,12 +3810,10 @@
d2 = 8;
icon_state = "4-8"
},
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
dir = 1;
name = "Charlie Hydroponics APC";
- pixel_y = 24;
- report_power_alarm = 0;
- start_charge = 0
+ pixel_y = 24
},
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/plating,
@@ -4107,11 +4093,9 @@
d2 = 8;
icon_state = "0-8"
},
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
name = "Charlie Kitchen APC";
- pixel_y = -24;
- report_power_alarm = 0;
- start_charge = 0
+ pixel_y = -24
},
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/plating,
@@ -4138,12 +4122,10 @@
d2 = 8;
icon_state = "0-8"
},
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
dir = 4;
name = "Theta RnD APC";
- pixel_x = 24;
- report_power_alarm = 0;
- start_charge = 0
+ pixel_x = 24
},
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/plasteel,
@@ -4689,12 +4671,10 @@
/obj/structure/rack,
/obj/item/stack/cable_coil,
/obj/structure/cable,
-/obj/machinery/power/apc{
+/obj/machinery/power/apc/off_station/empty_charge{
dir = 4;
name = "Charlie Engineering APC";
- pixel_x = 24;
- report_power_alarm = 0;
- start_charge = 0
+ pixel_x = 24
},
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/plasteel{
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/onehalf.dmm b/_maps/map_files/RandomRuins/SpaceRuins/onehalf.dmm
index 5a2bd68f09b..9ff62fb6a29 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/onehalf.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/onehalf.dmm
@@ -245,7 +245,7 @@
dir = 4
},
/obj/structure/cable,
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
keep_preset_name = 1;
name = "Hallway APC";
pixel_y = -24
@@ -401,7 +401,7 @@
/obj/item/healthanalyzer,
/obj/item/reagent_containers/iv_bag/blood/OMinus,
/obj/item/reagent_containers/iv_bag/blood/OMinus,
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 4;
keep_preset_name = 1;
name = "Crew Quarters APC";
@@ -416,7 +416,7 @@
d2 = 8;
icon_state = "0-8"
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
keep_preset_name = 1;
name = "Mining Drone Bay APC";
@@ -761,7 +761,7 @@
d2 = 4;
icon_state = "0-4"
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
keep_preset_name = 1;
name = "Bridge APC";
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/syndie_space_base.dmm b/_maps/map_files/RandomRuins/SpaceRuins/syndie_space_base.dmm
index 079c58b2b52..daf4b6d1b94 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/syndie_space_base.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/syndie_space_base.dmm
@@ -3646,7 +3646,7 @@
/obj/machinery/door/poddoor{
id_tag = "syndbaseventing";
name = "Venting Bay Door";
- use_power = 0
+ power_state = 0
},
/turf/simulated/floor/engine/vacuum,
/area/ruin/unpowered/syndicate_space_base/engineering)
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/syndiecakesfactory.dmm b/_maps/map_files/RandomRuins/SpaceRuins/syndiecakesfactory.dmm
index 4defdd9c8a2..d1b0210602c 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/syndiecakesfactory.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/syndiecakesfactory.dmm
@@ -102,8 +102,8 @@
/turf/template_noop,
/area/space)
"lK" = (
-/obj/machinery/power/apc/noalarm{
- area = null;
+/obj/machinery/power/apc/off_station{
+ apc_area = null;
dir = 8;
keep_preset_name = 1;
light_power = 0;
@@ -231,8 +231,8 @@
/turf/space,
/area/space)
"zd" = (
-/obj/machinery/power/apc/noalarm{
- area = null;
+/obj/machinery/power/apc/off_station{
+ apc_area = null;
dir = 8;
keep_preset_name = 1;
locked = 0;
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/syndiedepot.dmm b/_maps/map_files/RandomRuins/SpaceRuins/syndiedepot.dmm
index 29ec67c9264..c6ca1adb335 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/syndiedepot.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/syndiedepot.dmm
@@ -494,12 +494,12 @@
/area/syndicate_depot/core)
"by" = (
/obj/machinery/door_control{
- active_power_usage = 0;
+ active_power_consumption = 0;
id = "syndi_depot_rear";
- idle_power_usage = 0;
+ idle_power_consumption = 0;
name = "mysterious button";
pixel_x = 24;
- use_power = 0
+ power_state = 0
},
/turf/simulated/floor/plasteel{
icon_state = "dark"
@@ -736,11 +736,11 @@
/area/syndicate_depot/core)
"cf" = (
/obj/machinery/door_control{
- active_power_usage = 0;
+ active_power_consumption = 0;
id = "syndi_depot_rear";
- idle_power_usage = 0;
+ idle_power_consumption = 0;
name = "mysterious button";
- use_power = 0
+ power_state = 0
},
/obj/structure/sign/poster/contraband/syndicate_recruitment,
/turf/simulated/wall/mineral/plastitanium/nodiagonal,
@@ -980,7 +980,7 @@
/area/syndicate_depot/core)
"cJ" = (
/obj/structure/cable,
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 4;
pixel_x = 24;
req_access = list(150)
@@ -1149,7 +1149,7 @@
},
/area/syndicate_depot/core)
"de" = (
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 4;
pixel_x = 24
},
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/turretedoutpost.dmm b/_maps/map_files/RandomRuins/SpaceRuins/turretedoutpost.dmm
index 86a6ef4cdf6..bc1fb78f2d7 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/turretedoutpost.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/turretedoutpost.dmm
@@ -104,7 +104,7 @@
/turf/simulated/floor/plasteel,
/area/ruin/space/unpowered)
"w" = (
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
keep_preset_name = 1;
name = "Outpost APC";
pixel_y = -24
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/ussp.dmm b/_maps/map_files/RandomRuins/SpaceRuins/ussp.dmm
index d6d669e5c7e..938066a1e7c 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/ussp.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/ussp.dmm
@@ -483,7 +483,7 @@
d2 = 4;
icon_state = "0-4"
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 8;
pixel_x = -24
},
@@ -1543,7 +1543,7 @@
d2 = 2;
icon_state = "0-2"
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
pixel_y = 24
},
@@ -1718,7 +1718,7 @@
pixel_y = 1
},
/obj/structure/piano,
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
pixel_y = 24
},
@@ -2748,7 +2748,7 @@
icon_state = "0-2";
pixel_y = 1
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
pixel_y = 24
},
diff --git a/_maps/map_files/RandomRuins/SpaceRuins/ussp_tele.dmm b/_maps/map_files/RandomRuins/SpaceRuins/ussp_tele.dmm
index 5b8a52dcd02..b98bd14d823 100644
--- a/_maps/map_files/RandomRuins/SpaceRuins/ussp_tele.dmm
+++ b/_maps/map_files/RandomRuins/SpaceRuins/ussp_tele.dmm
@@ -168,7 +168,7 @@
/turf/simulated/wall,
/area/ruin/space/derelict/teleporter)
"B" = (
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
name = "Worn-out APC";
pixel_y = -24
},
diff --git a/_maps/map_files/RandomZLevels/evil_santa.dmm b/_maps/map_files/RandomZLevels/evil_santa.dmm
index 06cd9212bf9..010d4b0258b 100644
--- a/_maps/map_files/RandomZLevels/evil_santa.dmm
+++ b/_maps/map_files/RandomZLevels/evil_santa.dmm
@@ -589,7 +589,7 @@
d2 = 8;
icon_state = "0-8"
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 4;
name = "Worn-out APC";
pixel_x = 24
@@ -659,7 +659,7 @@
icon_state = "1-8";
tag = ""
},
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 4;
name = "Worn-out APC";
pixel_x = 24
diff --git a/_maps/map_files/RandomZLevels/example.dmm b/_maps/map_files/RandomZLevels/example.dmm
index 9645933dc60..37d44b4a606 100644
--- a/_maps/map_files/RandomZLevels/example.dmm
+++ b/_maps/map_files/RandomZLevels/example.dmm
@@ -37,7 +37,7 @@
/turf/simulated/floor/plasteel,
/area/awaymission/example)
"ag" = (
-/obj/machinery/power/apc/noalarm{
+/obj/machinery/power/apc/off_station{
dir = 1;
pixel_y = 24
},
diff --git a/_maps/map_files/cerestation/cerestation.dmm b/_maps/map_files/cerestation/cerestation.dmm
index 0248c3d9530..f997e40a823 100644
--- a/_maps/map_files/cerestation/cerestation.dmm
+++ b/_maps/map_files/cerestation/cerestation.dmm
@@ -3632,7 +3632,7 @@
/obj/machinery/door/airlock/hatch/gamma{
locked = 1;
req_access_txt = "1";
- use_power = 0
+ power_state = 0
},
/obj/machinery/door/firedoor,
/obj/structure/cable/orange{
@@ -36809,7 +36809,7 @@
"dgW" = (
/obj/machinery/economy/vending/autodrobe{
desc = "A vending machine for costumes. The machine seems blessed by some higher power, allowing it to function without power. HONK!";
- use_power = 0
+ power_state = 0
},
/turf/simulated/floor/plating,
/area/clownoffice/secret)
diff --git a/_maps/map_files/cyberiad/cyberiad.dmm b/_maps/map_files/cyberiad/cyberiad.dmm
index 0e3c730f199..2aabccab658 100644
--- a/_maps/map_files/cyberiad/cyberiad.dmm
+++ b/_maps/map_files/cyberiad/cyberiad.dmm
@@ -1278,7 +1278,7 @@
/obj/machinery/door/airlock/hatch/gamma{
locked = 1;
req_access_txt = "1";
- use_power = 0
+ power_state = 0
},
/turf/simulated/floor/plasteel{
icon_state = "dark"
@@ -32942,7 +32942,7 @@
/obj/machinery/door/poddoor{
id_tag = "ToxinsVenting";
name = "Toxins Venting Bay Door";
- use_power = 0
+ power_state = 0
},
/turf/simulated/floor/engine,
/area/toxins/mixing)
diff --git a/_maps/map_files/generic/centcomm.dmm b/_maps/map_files/generic/centcomm.dmm
index a7acfc6dff9..571b0296497 100644
--- a/_maps/map_files/generic/centcomm.dmm
+++ b/_maps/map_files/generic/centcomm.dmm
@@ -1256,7 +1256,7 @@
/obj/machinery/economy/vending/wallmed{
name = "Emergency NanoMed";
pixel_y = 32;
- use_power = 0
+ power_state = 0
},
/obj/item/clipboard,
/turf/simulated/floor/plasteel/dark,
diff --git a/_maps/map_files/shuttles/emergency_meta.dmm b/_maps/map_files/shuttles/emergency_meta.dmm
index 2480b0cf3bb..50631fb917b 100644
--- a/_maps/map_files/shuttles/emergency_meta.dmm
+++ b/_maps/map_files/shuttles/emergency_meta.dmm
@@ -286,7 +286,7 @@
"aS" = (
/obj/machinery/economy/vending/wallmed{
name = "Emergency NanoMed";
- use_power = 0
+ power_state = 0
},
/turf/simulated/wall/mineral/titanium,
/area/shuttle/escape)
@@ -329,9 +329,9 @@
"ba" = (
/obj/structure/table,
/obj/machinery/recharger{
- active_power_usage = 0;
- idle_power_usage = 0;
- use_power = 0
+ active_power_consumption = 0;
+ idle_power_consumption = 0;
+ power_state = 0
},
/turf/simulated/floor/mineral/titanium/blue,
/area/shuttle/escape)
@@ -635,9 +635,9 @@
"bR" = (
/obj/structure/table,
/obj/machinery/recharger{
- active_power_usage = 0;
- idle_power_usage = 0;
- use_power = 0
+ active_power_consumption = 0;
+ idle_power_consumption = 0;
+ power_state = 0
},
/turf/simulated/floor/mineral/plastitanium/red/brig,
/area/shuttle/escape)
diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm
index 112d55313aa..acc8cd6ffbe 100644
--- a/code/__DEFINES/dcs/signals.dm
+++ b/code/__DEFINES/dcs/signals.dm
@@ -227,10 +227,11 @@
///from base of atom/MouseDrop_T: (/atom/from, /mob/user)
#define COMSIG_MOUSEDROPPED_ONTO "mousedropped_onto"
-// /area signals
-///from base of area/proc/power_change(): ()
-#define COMSIG_AREA_POWER_CHANGE "area_power_change"
+///from base of /datum/local_powernet/proc/power_change()
+#define COMSIG_POWERNET_POWER_CHANGE "powernet_power_change"
+
+// /area signals
///from base of area/Entered(): (atom/movable/M)
#define COMSIG_AREA_ENTERED "area_entered"
///from base of area/Exited(): (atom/movable/M)
diff --git a/code/__DEFINES/machines.dm b/code/__DEFINES/machines.dm
index 6e4d49aad9f..33bd28e8a4b 100644
--- a/code/__DEFINES/machines.dm
+++ b/code/__DEFINES/machines.dm
@@ -1,25 +1,3 @@
-// channel numbers for power
-#define EQUIP 1
-#define LIGHT 2
-#define ENVIRON 3
-#define TOTAL 4 //for total power used only
-#define STATIC_EQUIP 5
-#define STATIC_LIGHT 6
-#define STATIC_ENVIRON 7
-
-//Power use
-#define NO_POWER_USE 0
-#define IDLE_POWER_USE 1
-#define ACTIVE_POWER_USE 2
-
-//computer3 error codes, move lower in the file when it passes dev -Sayu
- #define PROG_CRASH 1 // Generic crash
- #define MISSING_PERIPHERAL 2 // Missing hardware
- #define BUSTED_ASS_COMPUTER 4 // Self-perpetuating error. BAC will continue to crash forever.
- #define MISSING_PROGRAM 8 // Some files try to automatically launch a program. This is that failing.
- #define FILE_DRM 16 // Some files want to not be copied/moved. This is them complaining that you tried.
- #define NETWORK_FAILURE 32
-
#define IMPRINTER 1 //For circuits. Uses glass/chemicals.
#define PROTOLATHE 2 //New stuff. Uses glass/metal/chemicals
#define AUTOLATHE 4 //Uses glass/metal only.
@@ -32,46 +10,6 @@
#define GAMMALATHE 256
//Note: More then one of these can be added to a design but imprinter and lathe designs are incompatable.
-#define HYDRO_SPEED_MULTIPLIER 1
-
-//Modular computer/NTNet defines
-
-//Modular computer part defines
-#define MC_CPU "CPU"
-#define MC_HDD "HDD"
-#define MC_SDD "SDD"
-#define MC_CARD "CARD"
-#define MC_NET "NET"
-#define MC_PRINT "PRINT"
-#define MC_CELL "CELL"
-#define MC_CHARGE "CHARGE"
-#define MC_AI "AI"
-
-//NTNet stuff, for modular computers
- // NTNet module-configuration values. Do not change these. If you need to add another use larger number (5..6..7 etc)
-#define NTNET_SOFTWAREDOWNLOAD 1 // Downloads of software from NTNet
-#define NTNET_PEERTOPEER 2 // P2P transfers of files between devices
-#define NTNET_COMMUNICATION 3 // Communication (messaging)
-#define NTNET_SYSTEMCONTROL 4 // Control of various systems, RCon, air alarm control, etc.
-
-//NTNet transfer speeds, used when downloading/uploading a file/program.
-#define NTNETSPEED_LOWSIGNAL 0.5 // GQ/s transfer speed when the device is wirelessly connected and on Low signal
-#define NTNETSPEED_HIGHSIGNAL 1 // GQ/s transfer speed when the device is wirelessly connected and on High signal
-#define NTNETSPEED_ETHERNET 2 // GQ/s transfer speed when the device is using wired connection
-
-//Caps for NTNet logging. Less than 10 would make logging useless anyway, more than 500 may make the log browser too laggy. Defaults to 100 unless user changes it.
-#define MAX_NTNET_LOGS 300
-#define MIN_NTNET_LOGS 10
-
-//Program bitflags
-#define PROGRAM_ALL 7
-#define PROGRAM_CONSOLE 1
-#define PROGRAM_LAPTOP 2
-#define PROGRAM_TABLET 4
-//Program states
-#define PROGRAM_STATE_KILLED 0
-#define PROGRAM_STATE_BACKGROUND 1
-#define PROGRAM_STATE_ACTIVE 2
// Demotion Console (card/minor/*) departments
#define TARGET_DEPT_GENERIC 1
@@ -91,11 +29,6 @@
#define SUPERMATTER_EMERGENCY 5 // Integrity < 50%
#define SUPERMATTER_DELAMINATING 6 // Pretty obvious, Integrity < 25%
-//APC charging
-#define APC_NOT_CHARGING 0
-#define APC_IS_CHARGING 1
-#define APC_FULLY_CHARGED 2
-
// Firelock states
#define FD_OPEN 1
#define FD_CLOSED 2
diff --git a/code/__DEFINES/power.dm b/code/__DEFINES/power.dm
new file mode 100644
index 00000000000..0a8694dbb1f
--- /dev/null
+++ b/code/__DEFINES/power.dm
@@ -0,0 +1,40 @@
+/// Power Channel for equipment power users
+#define PW_CHANNEL_EQUIPMENT 1
+/// Power chanel for lighting power users
+#define PW_CHANNEL_LIGHTING 2
+/// Power channel for environmental power users
+#define PW_CHANNEL_ENVIRONMENT 3
+
+/// Local powernet in this area will never be powered, even if its recieving power
+#define PW_ALWAYS_UNPOWERED (1 << 0)
+/// Local powernet in this area will always have power even if its not recieving power
+#define PW_ALWAYS_POWERED (1 << 1)
+
+/// roughly 1/2000 chance of a machine flickering on any given tick. That means in a two hour round each machine will flicker on average a little less than two times.
+#define MACHINE_FLICKER_CHANCE 0.05
+
+// bitflags for machine stat variable
+/// Machine is broken
+#define BROKEN (1 << 0)
+/// Machine is not recieving any power from the local powernet
+#define NOPOWER (1 << 1)
+/// machine is currently under maintenance
+#define MAINT (1 << 2)
+/// Machine is currently affected by EMP pulse
+#define EMPED (1 << 3)
+
+//Power use
+/// This machine is not currently consuming any power passively
+#define NO_POWER_USE 0
+/// This machine is consuming its idle power amount passively
+#define IDLE_POWER_USE 1
+/// This machine is consuming its active power amount passively
+#define ACTIVE_POWER_USE 2
+
+//APC charging
+/// APC is not recieving power
+#define APC_NOT_CHARGING 0
+/// APC is currently recieving power and storing it
+#define APC_IS_CHARGING 1
+/// APC battery is at 100%
+#define APC_FULLY_CHARGED 2
diff --git a/code/__DEFINES/stat.dm b/code/__DEFINES/stat.dm
index 95ed3e10f6a..addf59e2f02 100644
--- a/code/__DEFINES/stat.dm
+++ b/code/__DEFINES/stat.dm
@@ -9,13 +9,6 @@
#define STATUS_DISABLED 0 // RED Visability
#define STATUS_CLOSE -1 // Close the interface
-// bitflags for machine stat variable
-#define BROKEN 1
-#define NOPOWER 2
-#define POWEROFF 4 // tbd
-#define MAINT 8 // under maintaince
-#define EMPED 16 // temporary broken by EMP pulse
-
/*
Shuttles
*/
diff --git a/code/controllers/subsystem/machinery.dm b/code/controllers/subsystem/machinery.dm
index d96865e2e70..20cf2036819 100644
--- a/code/controllers/subsystem/machinery.dm
+++ b/code/controllers/subsystem/machinery.dm
@@ -81,8 +81,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(prob(MACHINE_FLICKER_CHANCE))
+ thing.flicker()
else
processing -= thing
if(!QDELETED(thing))
diff --git a/code/datums/cache/apc.dm b/code/datums/cache/apc.dm
index a49fadf9d35..fe9f1eab21e 100644
--- a/code/datums/cache/apc.dm
+++ b/code/datums/cache/apc.dm
@@ -22,13 +22,13 @@ GLOBAL_DATUM_INIT(apc_repository, /datum/repository/apc, new())
var/list/chg = list("N","C","F") // Charging: no, charging, full
for(var/obj/machinery/power/apc/A in L)
apcData[++apcData.len] = list(
- "Name" = html_encode(A.area.name),
- "Equipment" = Status[A.equipment + 1],
- "Lights" = Status[A.lighting + 1],
- "Environment" = Status[A.environ + 1],
+ "Name" = html_encode(A.apc_area.name),
+ "Equipment" = Status[A.equipment_channel + 1],
+ "Lights" = Status[A.lighting_channel + 1],
+ "Environment" = Status[A.environment_channel + 1],
"CellPct" = A.cell ? round(A.cell.percent(), 1) : 0,
"CellStatus" = A.cell ? chg[A.charging + 1] : "M",
- "Load" = round(A.lastused_total, 1)
+ "Load" = round(A.last_used_total, 1)
)
cache_entry.timestamp = world.time + 5 SECONDS
diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm
index d933ce21f4f..85fbf52c0e6 100644
--- a/code/game/area/areas.dm
+++ b/code/game/area/areas.dm
@@ -13,26 +13,26 @@
luminosity = 0
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
invisibility = INVISIBILITY_LIGHTING
- var/valid_territory = TRUE //used for cult summoning areas on station zlevel
- var/map_name // Set in New(); preserves the name set by the map maker, even if renamed by the Blueprints.
+
+ /// used for cult summoning areas on station zlevel
+ var/valid_territory = TRUE
+ /// Set in New(); preserves the name set by the map maker, even if renamed by the Blueprints.
+ var/map_name
+ /// Is the lightswitch in this area on? Controls whether or not lights are on and off
var/lightswitch = TRUE
-
- var/debug = FALSE
+ /// If TRUE, the local powernet in this area will have all its power channels switched off
+ var/apc_starts_off = FALSE
+ /// If TRUE, this area's local powernet will require power to properly operate machines
var/requires_power = TRUE
- var/always_unpowered = FALSE //this gets overriden to 1 for space in area/New()
-
- var/power_equip = TRUE
- var/power_light = TRUE
- var/power_environ = TRUE
- var/used_equip = FALSE
- var/used_light = FALSE
- var/used_environ = FALSE
- var/static_equip
- var/static_light = FALSE
- var/static_environ
+ /// If TRUE, machines that require power in this area will never be powered
+ var/always_unpowered = FALSE
+ /// The local powernet of this area, this is where all machine/apc/object power related operations are handled
+ var/datum/local_powernet/powernet = null
+ /// All APCs currently constructed in this area
+ var/list/apc = list()
var/has_gravity = TRUE
- var/list/apc = list()
+
var/no_air = null
var/air_doors_activated = FALSE
@@ -92,13 +92,11 @@
map_name = name // Save the initial (the name set in the map) name of the area.
- if(requires_power)
- luminosity = 0
- else
- power_light = TRUE
- power_equip = TRUE
- power_environ = TRUE
+ if(!powernet) // we may already have a powernet due to machine init, better to be safe than sorry
+ create_powernet() // no powernet yet, create one
+ //setting lighting
+ if(!requires_power)
if(dynamic_lighting == DYNAMIC_LIGHTING_FORCED)
dynamic_lighting = DYNAMIC_LIGHTING_ENABLED
luminosity = 0
@@ -118,9 +116,26 @@
return INITIALIZE_HINT_LATELOAD
-/area/LateInitialize()
- . = ..()
- power_change() // all machines set to current power level, also updates lighting icon
+/area/proc/create_powernet()
+ powernet = new()
+ powernet.powernet_area = src
+
+ //setting power flags and channel breakers
+ if(always_unpowered) //area will never be powered, set all power channels to off
+ powernet.lighting_powered = FALSE
+ powernet.equipment_powered = FALSE
+ powernet.environment_powered = FALSE
+ powernet.power_flags |= PW_ALWAYS_UNPOWERED //ensures all power checks will return FALSE
+ else if(requires_power) //area does require power
+ luminosity = 0
+ if(apc_starts_off) //flip all the channels off if apc starts off
+ powernet.lighting_powered = FALSE
+ powernet.equipment_powered = FALSE
+ powernet.environment_powered = FALSE
+ else // area doesn't require power
+ powernet.power_flags |= PW_ALWAYS_POWERED //ensures all power checks will return TRUE
+
+ return powernet
/area/proc/reg_in_areas_in_z()
if(contents.len)
@@ -185,21 +200,23 @@
* Sends to all ai players, alert consoles, drones and alarm monitor programs in the world
*/
/area/proc/poweralert(state, obj/source)
- if(state != poweralm)
- poweralm = state
- if(istype(source)) //Only report power alarms on the z-level where the source is located.
- for(var/thing in cameras)
- var/obj/machinery/camera/C = locateUID(thing)
- if(!QDELETED(C) && is_station_level(C.z))
- if(state)
- C.network -= "Power Alarms"
- else
- C.network |= "Power Alarms"
-
+ if(state == poweralm)
+ return
+ poweralm = state
+ if(!istype(source)) //Only report power alarms on the z-level where the source is located.
+ return
+ for(var/thing in cameras)
+ var/obj/machinery/camera/C = locateUID(thing)
+ if(!QDELETED(C) && is_station_level(C.z))
if(state)
- GLOB.alarm_manager.cancel_alarm("Power", src, source)
+ C.network -= "Power Alarms"
else
- GLOB.alarm_manager.trigger_alarm("Power", src, cameras, source)
+ C.network |= "Power Alarms"
+
+ if(state)
+ GLOB.alarm_manager.cancel_alarm("Power", src, source)
+ else
+ GLOB.alarm_manager.trigger_alarm("Power", src, cameras, source)
/**
* Generate an atmospheric alert for this area
@@ -399,95 +416,6 @@
/area/space/update_icon_state()
icon_state = null
-/*
-#define EQUIP 1
-#define LIGHT 2
-#define ENVIRON 3
-*/
-
-/area/proc/powered(chan) // return true if the area has power to given channel
-
- if(!requires_power)
- return 1
- if(always_unpowered)
- return 0
- switch(chan)
- if(EQUIP)
- return power_equip
- if(LIGHT)
- return power_light
- if(ENVIRON)
- return power_environ
-
- return 0
-
-/area/space/powered(chan) //Nope.avi
- return 0
-
-/**
- * Called when the area power status changes
- *
- * Updates the area icon, calls power change on all machines in the area, and sends the `COMSIG_AREA_POWER_CHANGE` signal.
- */
-/area/proc/power_change()
- for(var/obj/machinery/M in src) // for each machine in the area
- M.power_change() // reverify power status (to update icons etc.)
- SEND_SIGNAL(src, COMSIG_AREA_POWER_CHANGE)
- update_icon(UPDATE_ICON_STATE)
-
-/area/proc/usage(chan)
- var/used = 0
- switch(chan)
- if(LIGHT)
- used += used_light
- if(EQUIP)
- used += used_equip
- if(ENVIRON)
- used += used_environ
- if(TOTAL)
- used += used_light + used_equip + used_environ
- if(STATIC_EQUIP)
- used += static_equip
- if(STATIC_LIGHT)
- used += static_light
- if(STATIC_ENVIRON)
- used += static_environ
- return used
-
-/area/proc/addStaticPower(value, powerchannel)
- switch(powerchannel)
- if(STATIC_EQUIP)
- static_equip += value
- if(STATIC_LIGHT)
- static_light += value
- if(STATIC_ENVIRON)
- static_environ += value
-
-/area/proc/clear_usage()
-
- used_equip = 0
- used_light = 0
- used_environ = 0
-
-/area/proc/use_power(amount, chan)
- switch(chan)
- if(EQUIP)
- used_equip += amount
- if(LIGHT)
- used_light += amount
- if(ENVIRON)
- used_environ += amount
-
-/area/proc/use_battery_power(amount, chan)
- switch(chan)
- if(EQUIP)
- used_equip += amount
- if(LIGHT)
- used_light += amount
- if(ENVIRON)
- used_environ += amount
-
-
/area/Entered(A)
var/area/newarea
var/area/oldarea
diff --git a/code/game/area/areas/mining.dm b/code/game/area/areas/mining.dm
index 3faa54f7bb0..04887ae05a2 100644
--- a/code/game/area/areas/mining.dm
+++ b/code/game/area/areas/mining.dm
@@ -10,9 +10,7 @@
always_unpowered = TRUE
requires_power = TRUE
poweralm = FALSE
- power_environ = FALSE
- power_equip = FALSE
- power_light = FALSE
+ apc_starts_off = TRUE
outdoors = TRUE
ambientsounds = MINING_SOUNDS
flags = NONE
@@ -29,9 +27,7 @@
always_unpowered = TRUE
requires_power = TRUE
poweralm = FALSE
- power_environ = FALSE
- power_equip = FALSE
- power_light = FALSE
+ apc_starts_off = TRUE
outdoors = TRUE
ambientsounds = MINING_SOUNDS
sound_environment = SOUND_AREA_ASTEROID
@@ -139,9 +135,7 @@
icon_state = "explored"
always_unpowered = TRUE
poweralm = FALSE
- power_environ = FALSE
- power_equip = FALSE
- power_light = FALSE
+ apc_starts_off = TRUE
requires_power = TRUE
ambientsounds = MINING_SOUNDS
min_ambience_cooldown = 70 SECONDS
@@ -153,9 +147,7 @@
always_unpowered = TRUE
requires_power = TRUE
poweralm = FALSE
- power_environ = FALSE
- power_equip = FALSE
- power_light = FALSE
+ apc_starts_off = TRUE
ambientsounds = MINING_SOUNDS
min_ambience_cooldown = 70 SECONDS
max_ambience_cooldown = 220 SECONDS
diff --git a/code/game/area/areas/ruins/lavaland.dm b/code/game/area/areas/ruins/lavaland.dm
index fef62d0bbac..766640693b6 100644
--- a/code/game/area/areas/ruins/lavaland.dm
+++ b/code/game/area/areas/ruins/lavaland.dm
@@ -43,9 +43,6 @@
/area/ruin/unpowered/xenonest
name = "The Hive"
always_unpowered = TRUE
- power_environ = FALSE
- power_equip = FALSE
- power_light = FALSE
poweralm = FALSE
//ash walker nest
diff --git a/code/game/area/ss13_areas.dm b/code/game/area/ss13_areas.dm
index 803e48f50cb..70e4ba573f0 100644
--- a/code/game/area/ss13_areas.dm
+++ b/code/game/area/ss13_areas.dm
@@ -33,12 +33,9 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/space
icon_state = "space"
- requires_power = TRUE
+ requires_power = FALSE
always_unpowered = TRUE
dynamic_lighting = DYNAMIC_LIGHTING_DISABLED
- power_light = FALSE
- power_equip = FALSE
- power_environ = FALSE
valid_territory = FALSE
outdoors = TRUE
ambientsounds = SPACE_SOUNDS
@@ -719,9 +716,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/maintenance/abandonedbar
name = "Maintenance Bar"
icon_state = "oldbar"
- power_equip = 0
- power_light = 0
- power_environ = 0
+ apc_starts_off = TRUE
/area/maintenance/library
name = "Abandoned Library"
@@ -730,9 +725,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/maintenance/spacehut
name = "Space Hut"
icon_state = "spacehut"
- power_equip = 0
- power_light = 0
- power_environ = 0
+ apc_starts_off = TRUE
/area/maintenance/electrical_shop
name ="Electronics Den"
@@ -1269,9 +1262,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/assembly/assembly_line //Derelict Assembly Line
name = "\improper Assembly Line"
icon_state = "ass_line"
- power_equip = 0
- power_light = 0
- power_environ = 0
+ apc_starts_off = TRUE
//Teleporter
diff --git a/code/game/dna/dna_modifier.dm b/code/game/dna/dna_modifier.dm
index 7116c1db319..f1479bebcbe 100644
--- a/code/game/dna/dna_modifier.dm
+++ b/code/game/dna/dna_modifier.dm
@@ -61,9 +61,8 @@
icon_state = "scanner_open"
density = TRUE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 50
- active_power_usage = 300
+ idle_power_consumption = 50
+ active_power_consumption = 300
interact_offline = TRUE
var/locked = FALSE
var/mob/living/carbon/occupant = null
@@ -356,9 +355,8 @@
var/obj/item/disk/data/disk = null
var/selected_menu_key = PAGE_UI
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 10
- active_power_usage = 400
+ idle_power_consumption = 10
+ active_power_consumption = 400
/obj/machinery/computer/scan_consolenew/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/disk/data)) //INSERT SOME diskS
diff --git a/code/game/gamemodes/nuclear/nuclearbomb.dm b/code/game/gamemodes/nuclear/nuclearbomb.dm
index a9826b46feb..3507a5fa2e5 100644
--- a/code/game/gamemodes/nuclear/nuclearbomb.dm
+++ b/code/game/gamemodes/nuclear/nuclearbomb.dm
@@ -20,6 +20,8 @@ GLOBAL_VAR(bomb_set)
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
flags_2 = NO_MALF_EFFECT_2 | CRITICAL_ATOM_2
anchored = TRUE
+ power_state = NO_POWER_USE
+
var/extended = TRUE
var/lighthack = FALSE
var/timeleft = 120
@@ -35,7 +37,6 @@ GLOBAL_VAR(bomb_set)
var/is_syndicate = FALSE
/// If this is true you cannot unbolt the NAD with tools, only the NAD
var/requires_NAD_to_unbolt = FALSE
- use_power = NO_POWER_USE
var/previous_level = ""
var/datum/wires/nuclearbomb/wires = null
var/removal_stage = NUKE_INTACT
@@ -44,6 +45,7 @@ GLOBAL_VAR(bomb_set)
///This is so that we can check if the internal components are sealed up properly when the outer hatch is closed.
var/core_stage = NUKE_CORE_EVERYTHING_FINE
+
/obj/machinery/nuclearbomb/syndicate
is_syndicate = TRUE
requires_NAD_to_unbolt = TRUE
diff --git a/code/game/machinery/Beacon.dm b/code/game/machinery/Beacon.dm
index 3107cb97cf0..a38bde82f0c 100644
--- a/code/game/machinery/Beacon.dm
+++ b/code/game/machinery/Beacon.dm
@@ -7,8 +7,6 @@
layer = WIRE_LAYER
plane = FLOOR_PLANE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 0
var/syndicate = FALSE
var/area_bypass = FALSE
var/obj/item/radio/beacon/Beacon
diff --git a/code/game/machinery/OpTable.dm b/code/game/machinery/OpTable.dm
index ff7c8c65297..15cad6b512d 100644
--- a/code/game/machinery/OpTable.dm
+++ b/code/game/machinery/OpTable.dm
@@ -5,9 +5,8 @@
icon_state = "table2-idle"
density = TRUE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 1
- active_power_usage = 5
+ idle_power_consumption = 1
+ active_power_consumption = 5
var/mob/living/carbon/patient
var/obj/machinery/computer/operating/computer
buckle_lying = -1
diff --git a/code/game/machinery/PDApainter.dm b/code/game/machinery/PDApainter.dm
index 4f05dc8cf86..d3e46ed8329 100644
--- a/code/game/machinery/PDApainter.dm
+++ b/code/game/machinery/PDApainter.dm
@@ -18,7 +18,7 @@
if(stat & BROKEN)
icon_state = "[initial(icon_state)]-broken"
return
- if(powered())
+ if(has_power())
icon_state = initial(icon_state)
else
icon_state = "[initial(icon_state)]-off"
@@ -193,5 +193,6 @@
update_icon()
/obj/machinery/pdapainter/power_change()
- ..()
+ if(!..())
+ return
update_icon()
diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm
index a36cbafb574..f3e9152a852 100644
--- a/code/game/machinery/Sleeper.dm
+++ b/code/game/machinery/Sleeper.dm
@@ -26,8 +26,8 @@
var/min_health = -25
var/controls_inside = FALSE
var/auto_eject_dead = FALSE
- idle_power_usage = 1250
- active_power_usage = 2500
+ idle_power_consumption = 1250
+ active_power_consumption = 2500
light_color = LIGHT_COLOR_CYAN
@@ -49,7 +49,7 @@
Note that you cannot control the sleeper while inside of it."
/obj/machinery/sleeper/power_change()
- ..()
+ ..() //we don't check parent return here because we also care about BROKEN
if(!(stat & (BROKEN|NOPOWER)))
set_light(2)
else
diff --git a/code/game/machinery/adv_med.dm b/code/game/machinery/adv_med.dm
index 81d9c394637..c175370a95e 100644
--- a/code/game/machinery/adv_med.dm
+++ b/code/game/machinery/adv_med.dm
@@ -6,8 +6,8 @@
density = TRUE
dir = WEST
anchored = TRUE
- idle_power_usage = 1250
- active_power_usage = 2500
+ idle_power_consumption = 1250
+ active_power_consumption = 2500
light_color = "#00FF00"
var/mob/living/carbon/human/occupant
var/known_implants = list(/obj/item/implant/chem, /obj/item/implant/death_alarm, /obj/item/implant/mindshield, /obj/item/implant/tracking, /obj/item/implant/health)
@@ -30,7 +30,8 @@
return ..()
/obj/machinery/bodyscanner/power_change()
- ..()
+ if(!..())
+ return
if(!(stat & (BROKEN|NOPOWER)))
set_light(2)
else
diff --git a/code/game/machinery/ai_display.dm b/code/game/machinery/ai_display.dm
index 13f00383b2c..e094df65bb4 100644
--- a/code/game/machinery/ai_display.dm
+++ b/code/game/machinery/ai_display.dm
@@ -39,7 +39,8 @@ GLOBAL_LIST_EMPTY(ai_displays)
..(severity)
/obj/machinery/ai_status_display/power_change()
- ..()
+ if(!..())
+ return
if(stat & NOPOWER)
set_light(0)
else
diff --git a/code/game/machinery/ai_slipper.dm b/code/game/machinery/ai_slipper.dm
index cc93eb171a1..4aaa8e8ca0e 100644
--- a/code/game/machinery/ai_slipper.dm
+++ b/code/game/machinery/ai_slipper.dm
@@ -17,10 +17,8 @@
. += "A small counter shows it has: [uses] use\s remaining."
/obj/machinery/ai_slipper/power_change()
- if(powered())
- stat &= ~NOPOWER
- else
- stat |= NOPOWER
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE)
/obj/machinery/ai_slipper/attack_ai(mob/user)
@@ -53,7 +51,7 @@
new /obj/effect/particle_effect/foam(loc)
uses--
cooldown_on = TRUE
- power_change()
+ update_icon(UPDATE_ICON_STATE)
addtimer(CALLBACK(src, PROC_REF(recharge)), cooldown_time)
/obj/machinery/ai_slipper/update_icon_state()
@@ -66,4 +64,4 @@
if(!uses)
return
cooldown_on = FALSE
- power_change()
+ update_icon(UPDATE_ICON_STATE)
diff --git a/code/game/machinery/airlock_control/airlock_button.dm b/code/game/machinery/airlock_control/airlock_button.dm
index eca032cb188..541d3e8c2fa 100644
--- a/code/game/machinery/airlock_control/airlock_button.dm
+++ b/code/game/machinery/airlock_control/airlock_button.dm
@@ -7,7 +7,7 @@ GLOBAL_LIST_EMPTY(all_airlock_access_buttons)
desc = "Controls an airlock controller, requesting the doors open on this side."
layer = ABOVE_WINDOW_LAYER
anchored = TRUE
- power_channel = ENVIRON
+ power_state = PW_CHANNEL_ENVIRONMENT
/// Id to be used by the controller to grab us on spawn
var/autolink_id
/// UID of the airlock controller that owns us
@@ -26,7 +26,7 @@ GLOBAL_LIST_EMPTY(all_airlock_access_buttons)
return ..()
/obj/machinery/access_button/update_icon_state()
- if(powered(power_channel))
+ if(has_power(power_channel))
icon_state = "access_button_standby"
else
icon_state = "access_button_off"
@@ -50,7 +50,7 @@ GLOBAL_LIST_EMPTY(all_airlock_access_buttons)
to_chat(user, "Could not communicate with controller.")
return
- if(!C.powered(C.power_channel))
+ if(!C.has_power(C.power_channel))
to_chat(user, "No response from controller, possibly offline.")
return
diff --git a/code/game/machinery/airlock_control/airlock_controllers.dm b/code/game/machinery/airlock_control/airlock_controllers.dm
index fa92e3d4b4f..800ab525505 100644
--- a/code/game/machinery/airlock_control/airlock_controllers.dm
+++ b/code/game/machinery/airlock_control/airlock_controllers.dm
@@ -5,8 +5,7 @@
icon = 'icons/obj/airlock_machines.dmi'
icon_state = "airlock_control_standby"
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 10
+ idle_power_consumption = 10
// Setup vars
@@ -86,7 +85,7 @@
ui_interact(user)
/obj/machinery/airlock_controller/update_icon_state()
- if(powered(power_channel))
+ if(has_power(power_channel))
if(state != target_state)
icon_state = "airlock_control_process"
else
@@ -337,7 +336,7 @@ send an additional command to open the door again.
icon_state = "access_control_standby"
/obj/machinery/airlock_controller/access_controller/update_icon_state()
- if(powered(power_channel))
+ if(has_power(power_channel))
if(state != target_state)
icon_state = "access_control_process"
else
diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm
index b6ba9232d39..1f7256f4b9c 100644
--- a/code/game/machinery/autolathe.dm
+++ b/code/game/machinery/autolathe.dm
@@ -7,6 +7,8 @@
desc = "It produces items using metal and glass."
icon_state = "autolathe"
density = TRUE
+ idle_power_consumption = 10
+ active_power_consumption = 100
var/list/queue = list()
var/queue_max_len = 12
@@ -20,9 +22,7 @@
var/hack_wire
var/disable_wire
var/shock_wire
- use_power = IDLE_POWER_USE
- idle_power_usage = 10
- active_power_usage = 100
+
var/busy = FALSE
var/prod_coeff
var/datum/wires/autolathe/wires = null
diff --git a/code/game/machinery/buttons.dm b/code/game/machinery/buttons.dm
index a0bacc227b2..e5e64cce974 100644
--- a/code/game/machinery/buttons.dm
+++ b/code/game/machinery/buttons.dm
@@ -10,9 +10,8 @@
icon_state = "launcherbtt"
anchored = TRUE
armor = list(melee = 50, bullet = 50, laser = 50, energy = 50, bomb = 10, bio = 100, rad = 100, fire = 90, acid = 70)
- use_power = IDLE_POWER_USE
- idle_power_usage = 2
- active_power_usage = 4
+ idle_power_consumption = 2
+ active_power_consumption = 4
resistance_flags = LAVA_PROOF | FIRE_PROOF
/// ID tag of the driver to hook to
var/id_tag = "default"
@@ -132,9 +131,8 @@
var/id = null
var/active = FALSE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 2
- active_power_usage = 4
+ idle_power_consumption = 2
+ active_power_consumption = 4
/obj/machinery/ignition_switch/attack_ai(mob/user)
return attack_hand(user)
diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm
index 314c6b09882..52d13d45ca0 100644
--- a/code/game/machinery/camera/camera.dm
+++ b/code/game/machinery/camera/camera.dm
@@ -3,9 +3,9 @@
desc = "It's used to monitor rooms."
icon = 'icons/obj/monitors.dmi'
icon_state = "camera"
- use_power = ACTIVE_POWER_USE
- idle_power_usage = 5
- active_power_usage = 10
+ power_state = ACTIVE_POWER_USE
+ idle_power_consumption = 5
+ active_power_consumption = 10
layer = WALL_OBJ_LAYER
resistance_flags = FIRE_PROOF
damage_deflection = 12
diff --git a/code/game/machinery/camera/presets.dm b/code/game/machinery/camera/presets.dm
index ddf09411c6a..b7058795422 100644
--- a/code/game/machinery/camera/presets.dm
+++ b/code/game/machinery/camera/presets.dm
@@ -97,4 +97,4 @@
mult++
if(isMotion())
mult++
- active_power_usage = mult*initial(active_power_usage)
+ active_power_consumption = mult * initial(active_power_consumption)
diff --git a/code/game/machinery/cell_charger.dm b/code/game/machinery/cell_charger.dm
index f1e565eb90a..66a0a9dd264 100644
--- a/code/game/machinery/cell_charger.dm
+++ b/code/game/machinery/cell_charger.dm
@@ -4,10 +4,9 @@
icon = 'icons/obj/power.dmi'
icon_state = "ccharger0"
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 5
- active_power_usage = 60
- power_channel = EQUIP
+ idle_power_consumption = 5
+ active_power_consumption = 60
+ power_channel = PW_CHANNEL_EQUIPMENT
pass_flags = PASSTABLE
var/obj/item/stock_parts/cell/charging = null
var/chargelevel = -1
@@ -58,7 +57,7 @@
var/area/a = loc.loc // Gets our locations location, like a dream within a dream
if(!isarea(a))
return
- if(a.power_equip == 0) // There's no APC in this area, don't try to cheat power!
+ if(!a.powernet.equipment_powered) // There's no APC in this area, don't try to cheat power!
to_chat(user, "[src] blinks red as you try to insert the cell!")
return
if(!user.drop_item())
diff --git a/code/game/machinery/cloning.dm b/code/game/machinery/cloning.dm
index c5e48444f74..68196992d53 100644
--- a/code/game/machinery/cloning.dm
+++ b/code/game/machinery/cloning.dm
@@ -54,7 +54,7 @@ GLOBAL_LIST_INIT(cloner_biomass_items, list(\
light_color = LIGHT_COLOR_PURE_GREEN
/obj/machinery/clonepod/power_change()
- ..()
+ ..() //we don't check return here because we also care about the BROKEN flag
if(!(stat & (BROKEN|NOPOWER)))
set_light(2)
else
diff --git a/code/game/machinery/computer/HolodeckControl.dm b/code/game/machinery/computer/HolodeckControl.dm
index b63b9a7f819..1c7d611a7db 100644
--- a/code/game/machinery/computer/HolodeckControl.dm
+++ b/code/game/machinery/computer/HolodeckControl.dm
@@ -521,10 +521,9 @@
var/eventstarted = 0
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
/obj/machinery/readybutton/attack_ai(mob/user as mob)
to_chat(user, "The station AI is not to interact with these devices.")
diff --git a/code/game/machinery/computer/brigcells.dm b/code/game/machinery/computer/brigcells.dm
index ccb4a303dba..211ef485ea2 100644
--- a/code/game/machinery/computer/brigcells.dm
+++ b/code/game/machinery/computer/brigcells.dm
@@ -1,14 +1,13 @@
/obj/machinery/computer/brigcells
- name = "cell management computer"
- desc = "Used to manage prison cells."
- icon_keyboard = "security_key"
- icon_screen = "cell_monitor"
- use_power = IDLE_POWER_USE
- idle_power_usage = 250
- active_power_usage = 500
- circuit = /obj/item/circuitboard/brigcells
- light_color = LIGHT_COLOR_DARKRED
- req_access = list(ACCESS_BRIG)
+ name = "cell management computer"
+ desc = "Used to manage prison cells."
+ icon_keyboard = "security_key"
+ icon_screen = "cell_monitor"
+ idle_power_consumption = 250
+ active_power_consumption = 500
+ circuit = /obj/item/circuitboard/brigcells
+ light_color = LIGHT_COLOR_DARKRED
+ req_access = list(ACCESS_BRIG)
/obj/machinery/computer/brigcells/attack_ai(mob/user)
attack_hand(user)
diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm
index 7cb0048c9ab..d3b4d9d6319 100644
--- a/code/game/machinery/computer/camera.dm
+++ b/code/game/machinery/computer/camera.dm
@@ -72,7 +72,7 @@
if(length(watchers) == 1 && is_living)
if(!silent_console)
playsound(src, 'sound/machines/terminal_on.ogg', 25, FALSE)
- use_power(active_power_usage)
+ use_power(active_power_consumption)
// Register map objects
user.client.register_map_obj(cam_screen)
for(var/plane in cam_plane_masters)
diff --git a/code/game/machinery/computer/computer.dm b/code/game/machinery/computer/computer.dm
index e4ecff59ca6..ea84e55eb79 100644
--- a/code/game/machinery/computer/computer.dm
+++ b/code/game/machinery/computer/computer.dm
@@ -4,9 +4,8 @@
icon_state = "computer"
density = TRUE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 300
- active_power_usage = 300
+ idle_power_consumption = 300
+ active_power_consumption = 300
max_integrity = 200
integrity_failure = 100
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 0, RAD = 0, FIRE = 40, ACID = 20)
@@ -88,12 +87,13 @@
underlays += emissive_appearance(icon, "[icon_keyboard]_lightmask")
/obj/machinery/computer/power_change()
- ..()
+ . = ..() //we don't check parent return due to this also being contigent on the BROKEN stat flag
if((stat & (BROKEN|NOPOWER)))
set_light(0)
else
set_light(light_range_on, light_power_on)
- update_icon()
+ if(.)
+ update_icon()
/obj/machinery/computer/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
switch(damage_type)
diff --git a/code/game/machinery/computer/crew.dm b/code/game/machinery/computer/crew.dm
index 373e503b30f..99aff19d932 100644
--- a/code/game/machinery/computer/crew.dm
+++ b/code/game/machinery/computer/crew.dm
@@ -3,9 +3,8 @@
desc = "Used to monitor active health sensors built into most of the crew's uniforms."
icon_keyboard = "med_key"
icon_screen = "crew"
- use_power = IDLE_POWER_USE
- idle_power_usage = 250
- active_power_usage = 500
+ idle_power_consumption = 250
+ active_power_consumption = 500
light_color = LIGHT_COLOR_DARKBLUE
circuit = /obj/item/circuitboard/crew
var/datum/ui_module/crew_monitor/crew_monitor
diff --git a/code/game/machinery/computer/depot.dm b/code/game/machinery/computer/depot.dm
index 36595d0d97e..4e32428c9d7 100644
--- a/code/game/machinery/computer/depot.dm
+++ b/code/game/machinery/computer/depot.dm
@@ -378,7 +378,8 @@
"})
/obj/machinery/computer/syndicate_depot/syndiecomms/power_change()
- . = ..()
+ if(!..())
+ return
if(!security_lockout && (stat & NOPOWER))
security_lockout = TRUE
raise_alert("[src] lost power.")
diff --git a/code/game/machinery/computer/power.dm b/code/game/machinery/computer/power.dm
index 428e44410ba..c711d2dc1b6 100644
--- a/code/game/machinery/computer/power.dm
+++ b/code/game/machinery/computer/power.dm
@@ -3,9 +3,9 @@
desc = "Used to monitor power levels across the station."
icon_screen = "power"
icon_keyboard = "power_key"
- use_power = ACTIVE_POWER_USE
- idle_power_usage = 20
- active_power_usage = 80
+ power_state = ACTIVE_POWER_USE
+ idle_power_consumption = 20
+ active_power_consumption = 80
light_color = LIGHT_COLOR_ORANGE
circuit = /obj/item/circuitboard/powermonitor
var/datum/powernet/powernet = null
diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm
index ab26362b66a..ec4e2b0a01c 100644
--- a/code/game/machinery/constructable_frame.dm
+++ b/code/game/machinery/constructable_frame.dm
@@ -4,7 +4,7 @@
icon_state = "box_0"
density = TRUE
anchored = TRUE
- use_power = NO_POWER_USE
+ power_state = NO_POWER_USE
max_integrity = 250
var/obj/item/circuitboard/circuit = null
var/list/components = null
diff --git a/code/game/machinery/defib_mount.dm b/code/game/machinery/defib_mount.dm
index e759b6922d1..0fe8508c0d6 100644
--- a/code/game/machinery/defib_mount.dm
+++ b/code/game/machinery/defib_mount.dm
@@ -7,10 +7,9 @@
icon = 'icons/obj/machines/defib_mount.dmi'
icon_state = "defibrillator_mount"
density = FALSE
- use_power = IDLE_POWER_USE
anchored = TRUE
- idle_power_usage = 1
- power_channel = EQUIP
+ idle_power_consumption = 1
+ power_channel = PW_CHANNEL_EQUIPMENT
req_one_access = list(ACCESS_MEDICAL, ACCESS_HEADS) //used to control clamps
var/obj/item/defibrillator/defib //this mount's defibrillator
var/clamps_locked = FALSE //if true, and a defib is loaded, it can't be removed without unlocking the clamps
diff --git a/code/game/machinery/dish_drive.dm b/code/game/machinery/dish_drive.dm
index 11fd88e9704..ac69a02fe42 100644
--- a/code/game/machinery/dish_drive.dm
+++ b/code/game/machinery/dish_drive.dm
@@ -5,8 +5,8 @@
Or you can just drop your plates on the floor, like civilized folk."
icon = 'icons/obj/kitchen.dmi'
icon_state = "synthesizer"
- idle_power_usage = 8 //5 with default parts
- active_power_usage = 13 //10 with default parts
+ idle_power_consumption = 8 //5 with default parts
+ active_power_consumption = 13 //10 with default parts
anchored = FALSE
density = FALSE
pass_flags = PASSTABLE
@@ -63,18 +63,18 @@
return TRUE
/obj/machinery/dish_drive/RefreshParts()
- idle_power_usage = initial(idle_power_usage)
- active_power_usage = initial(active_power_usage)
- use_power = initial(use_power)
+ idle_power_consumption = initial(idle_power_consumption)
+ active_power_consumption = initial(active_power_consumption)
+ change_power_mode(initial(power_state))
var/total_rating = 0
for(var/obj/item/stock_parts/S in component_parts)
total_rating += S.rating
- if(total_rating >= 9)
- active_power_usage = 0
- use_power = NO_POWER_USE
+ if(total_rating >= 9) //this entire power use section needs to be cleaned up :sob:
+ active_power_consumption = 0
+ change_power_mode(NO_POWER_USE)
else
- idle_power_usage = max(0, idle_power_usage - total_rating)
- active_power_usage = max(0, active_power_usage - total_rating)
+ change_power_mode((idle_power_consumption - total_rating) > 0 ? ACTIVE_POWER_USE : NO_POWER_USE)
+ active_power_consumption = max(0, active_power_consumption - total_rating)
var/obj/item/circuitboard/dish_drive/board = locate() in component_parts
if(board)
suction_enabled = board.suction
@@ -122,7 +122,7 @@
if(is_type_in_list(I, disposable_items))
LAZYREMOVE(dish_drive_contents, I)
I.forceMove(bin)
- use_power(active_power_usage)
+ use_power(active_power_consumption)
disposed++
if(disposed)
visible_message("[src] [pick("whooshes", "bwooms", "fwooms", "pshooms")] and beams [disposed] stored item\s into the nearby [bin.name].")
diff --git a/code/game/machinery/door_control.dm b/code/game/machinery/door_control.dm
index e5114c57770..ceb562404f3 100644
--- a/code/game/machinery/door_control.dm
+++ b/code/game/machinery/door_control.dm
@@ -3,7 +3,7 @@
desc = "A remote control-switch for a door."
icon = 'icons/obj/stationobjs.dmi'
icon_state = "doorctrl0"
- power_channel = ENVIRON
+ power_channel = PW_CHANNEL_ENVIRONMENT
var/id = null
var/safety_z_check = TRUE
var/normaldoorcontrol = FALSE
@@ -26,9 +26,8 @@
*/
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 2
- active_power_usage = 4
+ idle_power_consumption = 2
+ active_power_consumption = 4
/obj/machinery/door_control/attack_ai(mob/user as mob)
if(wires & 2)
@@ -119,7 +118,8 @@
icon_state = "doorctrl0"
/obj/machinery/door_control/power_change()
- ..()
+ if(!..())
+ return
if(stat & NOPOWER)
icon_state = "doorctrl-p"
else
diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm
index 8e6268ed726..361c605d9a5 100644
--- a/code/game/machinery/doors/airlock.dm
+++ b/code/game/machinery/doors/airlock.dm
@@ -1420,7 +1420,8 @@ GLOBAL_LIST_EMPTY(airlock_emissive_underlays)
prying_so_hard = FALSE
/obj/machinery/door/airlock/power_change() //putting this is obj/machinery/door itself makes non-airlock doors turn invisible for some reason
- ..()
+ if(!..())
+ return
if(stat & NOPOWER)
// If we lost power, disable electrification
// Keeping door lights on, runs on internal battery or something.
diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm
index a29a9794f1d..5289c9721cb 100644
--- a/code/game/machinery/doors/brigdoors.dm
+++ b/code/game/machinery/doors/brigdoors.dm
@@ -178,7 +178,8 @@
// has the door power situation changed, if so update icon.
/obj/machinery/door_timer/power_change()
- ..()
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE)
diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm
index 6c8ffb03d1c..bb4339ddc4b 100644
--- a/code/game/machinery/doors/door.dm
+++ b/code/game/machinery/doors/door.dm
@@ -7,7 +7,7 @@
opacity = TRUE
density = TRUE
layer = OPEN_DOOR_LAYER
- power_channel = ENVIRON
+ power_channel = PW_CHANNEL_ENVIRONMENT
max_integrity = 350
armor = list(MELEE = 30, BULLET = 30, LASER = 20, ENERGY = 20, BOMB = 10, BIO = 100, RAD = 100, FIRE = 80, ACID = 70)
flags = PREVENT_CLICK_UNDER
@@ -73,7 +73,8 @@
update_dir()
/obj/machinery/door/power_change()
- ..()
+ if(!..())
+ return
update_icon()
/obj/machinery/door/proc/update_dir()
diff --git a/code/game/machinery/doors/firedoor.dm b/code/game/machinery/doors/firedoor.dm
index 68c16ce8be7..6ea0767826a 100644
--- a/code/game/machinery/doors/firedoor.dm
+++ b/code/game/machinery/doors/firedoor.dm
@@ -80,11 +80,11 @@
return 0
/obj/machinery/door/firedoor/power_change()
- if(powered(power_channel))
- stat &= ~NOPOWER
+ . = ..()
+ if(!(stat & NOPOWER))
latetoggle()
- else
- stat |= NOPOWER
+ if(!.)
+ return
adjust_light()
update_icon()
diff --git a/code/game/machinery/doppler_array.dm b/code/game/machinery/doppler_array.dm
index c3939f1363d..f96e5c8381d 100644
--- a/code/game/machinery/doppler_array.dm
+++ b/code/game/machinery/doppler_array.dm
@@ -56,6 +56,7 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
anchored = FALSE
WRENCH_UNANCHOR_MESSAGE
power_change()
+ update_icon(UPDATE_ICON_STATE)
/obj/machinery/doppler_array/attack_hand(mob/user)
if(..())
@@ -162,16 +163,18 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
for(var/message in messages)
atom_say(message)
-/obj/machinery/doppler_array/power_change()
+/obj/machinery/doppler_array/update_icon_state()
if(stat & BROKEN)
icon_state = "[initial(icon_state)]-broken"
else
- if(powered() && anchored)
- icon_state = initial(icon_state)
- stat &= ~NOPOWER
- else
- icon_state = "[initial(icon_state)]-off"
- stat |= NOPOWER
+ icon_state = !(stat & NOPOWER) && anchored ? initial(icon_state) : "[initial(icon_state)]-off"
+
+/// overrides base power_change to check to make sure machine is anchored
+/obj/machinery/doppler_array/power_change()
+ if(has_power(power_channel) && anchored)
+ stat &= ~NOPOWER
+ else
+ stat |= NOPOWER
/obj/machinery/doppler_array/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
diff --git a/code/game/machinery/dye_generator.dm b/code/game/machinery/dye_generator.dm
index 8a0def9bb5b..3e7d346ec52 100644
--- a/code/game/machinery/dye_generator.dm
+++ b/code/game/machinery/dye_generator.dm
@@ -5,8 +5,7 @@
density = TRUE
anchored = TRUE
integrity_failure = 100
- use_power = IDLE_POWER_USE
- idle_power_usage = 40
+ idle_power_consumption = 40
var/dye_color = "#FFFFFF"
/obj/machinery/dye_generator/Initialize()
@@ -18,7 +17,7 @@
qdel(src)
/obj/machinery/dye_generator/power_change()
- if(powered() && anchored)
+ if(has_power() && anchored)
stat &= ~NOPOWER
set_light(2, l_color = dye_color)
else
diff --git a/code/game/machinery/firealarm.dm b/code/game/machinery/firealarm.dm
index 91647fd41aa..3d8bf4848d6 100644
--- a/code/game/machinery/firealarm.dm
+++ b/code/game/machinery/firealarm.dm
@@ -20,10 +20,9 @@ FIRE ALARM
max_integrity = 250
integrity_failure = 100
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 100, rad = 100, fire = 90, acid = 30)
- 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
resistance_flags = FIRE_PROOF
light_power = LIGHTING_MINIMUM_POWER
@@ -239,10 +238,8 @@ FIRE ALARM
set_light(l_power = LIGHTING_MINIMUM_POWER)
/obj/machinery/firealarm/power_change()
- if(powered(ENVIRON))
- stat &= ~NOPOWER
- else
- stat |= NOPOWER
+ if(!..())
+ return
update_fire_light()
update_icon()
diff --git a/code/game/machinery/flasher.dm b/code/game/machinery/flasher.dm
index 7cdec1acaa1..da4fa0966ba 100644
--- a/code/game/machinery/flasher.dm
+++ b/code/game/machinery/flasher.dm
@@ -34,17 +34,16 @@
AddComponent(/datum/component/proximity_monitor)
/obj/machinery/flasher/power_change()
- if(powered())
- stat &= ~NOPOWER
- set_light(1, LIGHTING_MINIMUM_POWER)
- else
- stat |= NOPOWER
+ if(!..())
+ return
+ if(stat & NOPOWER)
set_light(0)
+ else
+ set_light(1, LIGHTING_MINIMUM_POWER)
update_icon()
/obj/machinery/flasher/update_icon_state()
. = ..()
-
if((stat & NOPOWER) || !anchored)
icon_state = "[base_state]1-p"
else
@@ -72,7 +71,7 @@
return flash()
/obj/machinery/flasher/proc/flash()
- if(!(powered()))
+ if(!has_power())
return
if((disable) || (last_flash && world.time < last_flash + 150))
@@ -140,9 +139,8 @@
var/id = null
var/active = FALSE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 2
- active_power_usage = 4
+ idle_power_consumption = 2
+ active_power_consumption = 4
/obj/machinery/flasher_button/attack_ai(mob/user as mob)
return attack_hand(user)
diff --git a/code/game/machinery/gameboard.dm b/code/game/machinery/gameboard.dm
index 8c289849eeb..be18b921995 100644
--- a/code/game/machinery/gameboard.dm
+++ b/code/game/machinery/gameboard.dm
@@ -5,10 +5,10 @@
desc = "A holographic table allowing the crew to have fun(TM) on boring shifts! One player per board."
density = TRUE
anchored = TRUE
- use_power = IDLE_POWER_USE
- var/cooling_down = 0
light_color = LIGHT_COLOR_LIGHTBLUE
+ var/cooling_down = 0
+
/obj/machinery/gameboard/Initialize(mapload)
. = ..()
component_parts = list()
@@ -19,7 +19,8 @@
RefreshParts()
/obj/machinery/gameboard/power_change()
- . = ..()
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE)
if(stat & NOPOWER)
set_light(0)
diff --git a/code/game/machinery/hologram.dm b/code/game/machinery/hologram.dm
index a0b7bd0e6d8..89bd759015d 100644
--- a/code/game/machinery/hologram.dm
+++ b/code/game/machinery/hologram.dm
@@ -40,13 +40,13 @@ GLOBAL_LIST_EMPTY(holopads)
desc = "It's a floor-mounted device for projecting holographic images."
icon_state = "holopad0"
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 5
- active_power_usage = 100
+ idle_power_consumption = 5
+ active_power_consumption = 100
layer = HOLOPAD_LAYER //Preventing mice and drones from sneaking under them.
plane = FLOOR_PLANE
max_integrity = 300
armor = list(melee = 50, bullet = 20, laser = 20, energy = 20, bomb = 0, bio = 0, rad = 0, fire = 50, acid = 0)
+
var/list/masters = list()//List of living mobs that use the holopad
var/list/holorays = list()//Holoray-mob link.
var/last_request = 0 //to prevent request spam. ~Carn
@@ -81,14 +81,14 @@ GLOBAL_LIST_EMPTY(holopads)
return ..()
/obj/machinery/hologram/holopad/power_change()
- if(powered())
- stat &= ~NOPOWER
- set_light(1, LIGHTING_MINIMUM_POWER)
- else
- stat |= NOPOWER
+ if(!..())
+ return
+ if(stat & NOPOWER)
if(outgoing_call)
outgoing_call.ConnectionFailure(src)
set_light(0)
+ else
+ set_light(1, LIGHTING_MINIMUM_POWER)
update_icon(UPDATE_OVERLAYS)
/obj/machinery/hologram/holopad/update_overlays()
@@ -417,8 +417,8 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
/obj/machinery/hologram/holopad/proc/SetLightsAndPower()
var/total_users = masters.len + LAZYLEN(holo_calls)
- use_power = total_users > 0 ? ACTIVE_POWER_USE : IDLE_POWER_USE
- active_power_usage = HOLOPAD_PASSIVE_POWER_USAGE + (HOLOGRAM_POWER_USAGE * total_users)
+ change_power_mode(total_users > 0 ? ACTIVE_POWER_USE : IDLE_POWER_USE)
+ active_power_consumption = HOLOPAD_PASSIVE_POWER_USAGE + (HOLOGRAM_POWER_USAGE * total_users)
if(total_users)
set_light(2)
else
diff --git a/code/game/machinery/holosign.dm b/code/game/machinery/holosign.dm
index e5a30cf9733..ebfb2089ee4 100644
--- a/code/game/machinery/holosign.dm
+++ b/code/game/machinery/holosign.dm
@@ -23,6 +23,8 @@
icon_state = on_icon
/obj/machinery/holosign/power_change()
+ if(!..())
+ return
if(stat & NOPOWER)
lit = FALSE
update_icon(UPDATE_ICON_STATE)
@@ -41,9 +43,8 @@
var/id = null
var/active = FALSE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 2
- active_power_usage = 4
+ idle_power_consumption = 2
+ active_power_consumption = 4
/obj/machinery/holosign_switch/attack_ai(mob/user as mob)
return src.attack_hand(user)
diff --git a/code/game/machinery/igniter.dm b/code/game/machinery/igniter.dm
index 3e932306256..7e677361390 100755
--- a/code/game/machinery/igniter.dm
+++ b/code/game/machinery/igniter.dm
@@ -8,9 +8,8 @@
armor = list(melee = 50, bullet = 30, laser = 70, energy = 50, bomb = 20, bio = 0, rad = 0, fire = 100, acid = 70)
resistance_flags = FIRE_PROOF
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 2
- active_power_usage = 4
+ idle_power_consumption = 2
+ active_power_consumption = 4
/// ID to hook buttons into
var/id = null
/// Are we on?
@@ -66,7 +65,8 @@
update_icon()
/obj/machinery/igniter/power_change()
- . = ..()
+ if(!..())
+ return
if(stat & NOPOWER)
on = FALSE
update_icon()
@@ -85,13 +85,16 @@
var/base_state = "migniter"
anchored = TRUE
-/obj/machinery/sparker/power_change()
- if(powered() && !disable)
- stat &= ~NOPOWER
- icon_state = "[base_state]"
- else
- stat |= NOPOWER
+/obj/machinery/sparker/update_icon_state()
+ if(stat & NOPOWER)
icon_state = "[base_state]-p"
+ else
+ icon_state = "[base_state]"
+
+/obj/machinery/sparker/power_change()
+ if(!..())
+ return
+ update_icon(UPDATE_ICON_STATE)
/obj/machinery/sparker/screwdriver_act(mob/user, obj/item/I)
. = TRUE
@@ -105,7 +108,7 @@
icon_state = "[base_state]-d"
else
user.visible_message("[user] has reconnected [src]!", "You fix the connection to [src].")
- if(powered())
+ if(has_power())
icon_state = "[base_state]"
else
icon_state = "[base_state]-p"
@@ -116,7 +119,7 @@
/obj/machinery/sparker/proc/spark()
- if(!powered())
+ if(!has_power())
return
if(disable || (last_spark && world.time < last_spark + 5 SECONDS))
diff --git a/code/game/machinery/lightswitch.dm b/code/game/machinery/lightswitch.dm
index 1f6d246fe64..87dc65a5e47 100644
--- a/code/game/machinery/lightswitch.dm
+++ b/code/game/machinery/lightswitch.dm
@@ -6,6 +6,7 @@
icon = 'icons/obj/power.dmi'
icon_state = "light1"
anchored = TRUE
+ power_channel = PW_CHANNEL_LIGHTING
/obj/machinery/light_switch/Initialize(mapload, build_dir)
. = ..()
@@ -61,17 +62,17 @@
for(var/obj/machinery/light_switch/L in A)
L.update_icon(UPDATE_ICON_STATE)
- A.power_change()
+ machine_powernet.power_change()
/obj/machinery/light_switch/power_change()
- if(powered(LIGHT))
- stat &= ~NOPOWER
- set_light(1, LIGHTING_MINIMUM_POWER)
- else
- stat |= NOPOWER
+ if(!..())
+ return
+ if(stat & NOPOWER)
set_light(0)
+ else
+ set_light(1, LIGHTING_MINIMUM_POWER)
- update_icon(UPDATE_ICON_STATE | UPDATE_OVERLAYS)
+ update_icon(UPDATE_ICON_STATE|UPDATE_OVERLAYS)
/obj/machinery/light_switch/emp_act(severity)
if(stat & (BROKEN|NOPOWER))
diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm
index 9b70460e760..f778a428703 100644
--- a/code/game/machinery/machinery.dm
+++ b/code/game/machinery/machinery.dm
@@ -1,4 +1,3 @@
-#define MACHINE_FLICKER_CHANCE 0.05 // roughly 1/2000 chance of a machine flickering on any given tick. That means in a two hour round each machine will flicker on average a little less than two times.
/obj/machinery
name = "machinery"
@@ -9,38 +8,47 @@
armor = list(melee = 25, bullet = 10, laser = 10, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 50, acid = 70)
atom_say_verb = "beeps"
var/stat = 0
- var/use_power = IDLE_POWER_USE
- //0 = dont run the auto
- //1 = run auto, use idle
- //2 = run auto, use active
- var/idle_power_usage = 0
- var/active_power_usage = 0
- var/power_channel = EQUIP //EQUIP,ENVIRON or LIGHT
+
+ /// How is this machine currently passively consuming power?
+ var/power_state = IDLE_POWER_USE
+ /// Does this machine require power?
+ var/requires_power = TRUE
+ /// How much power does this machine consume when it is idling
+ var/idle_power_consumption = 0
+ /// How much power does this machine consume when it is in use
+ var/active_power_consumption = 0
+ /// The power channel this machine uses, idle/passive power consumption will pull from this channel and machine won't work if power channel has no power
+ var/power_channel = PW_CHANNEL_EQUIPMENT
+ /// The powernet this machine is connected to
+ var/datum/local_powernet/machine_powernet = null
+
+ /// how badly will it shock you?
+ var/siemens_strength = 0.7
+
var/list/component_parts = null //list of all the parts used to build it, if made from certain kinds of frames.
var/panel_open = FALSE
var/interact_offline = FALSE // Can the machine be interacted with while de-powered.
- var/siemens_strength = 0.7 // how badly will it shock you?
/// This is if the machinery is being repaired
var/being_repaired = FALSE
-/*
- * reimp, attempts to flicker this machinery if the behavior is supported.
- */
-/obj/machinery/get_spooked()
- return flicker()
-
-/*
- * Base class, attempt to flicker. Returns TRUE if we complete our 'flicker
- * behavior', false otherwise.
- */
-/obj/machinery/proc/flicker()
- return FALSE
-
/obj/machinery/Initialize(mapload)
. = ..()
-
GLOB.machines += src
+ var/area/machine_area = get_area(src)
+ if(machine_area)
+ // areas don't always initialize before machines so we need to check to see if the powernet exists first
+ if(machine_area.powernet)
+ machine_powernet = machine_area.powernet
+ else
+ machine_powernet = machine_area.create_powernet()
+ machine_powernet.register_machine(src)
+ switch(power_state)
+ if(IDLE_POWER_USE)
+ add_static_power(power_channel, idle_power_consumption)
+ if(ACTIVE_POWER_USE)
+ add_static_power(power_channel, active_power_consumption)
+
if(!speed_process)
START_PROCESSING(SSmachines, src)
else
@@ -65,6 +73,8 @@
START_PROCESSING(SSmachines, src)
/obj/machinery/Destroy()
+ change_power_mode(NO_POWER_USE) //we want to clear our static power usage on the local powernet
+ machine_powernet?.unregister_machine(src)
GLOB.machines.Remove(src)
if(!speed_process)
STOP_PROCESSING(SSmachines, src)
@@ -79,32 +89,71 @@
/obj/machinery/process() // If you dont use process or power why are you here
return PROCESS_KILL
-/obj/machinery/emp_act(severity)
- if(use_power && !stat)
- use_power(7500/severity)
- . = TRUE
- ..()
+////POWER RELATED PROCS
+
+// returns true if the area has power on given channel (or doesn't require power).
+// defaults to power_channel
+/obj/machinery/proc/has_power(channel = power_channel) // defaults to power_channel
+ if(!requires_power)
+ return TRUE
+ if(!machine_powernet)
+ return FALSE
+ return machine_powernet.has_power(channel) // return power status of the area
+
+// use active power from the local powernet
+/obj/machinery/proc/use_power(channel, amount)
+ if(!has_power())
+ return FALSE
+ if(!channel)
+ channel = power_channel
+ return machine_powernet.use_active_power(channel, amount)
+
+/obj/machinery/proc/add_static_power(channel, amount)
+ machine_powernet.adjust_static_power(channel, amount)
+
+/obj/machinery/proc/remove_static_power(channel, amount)
+ machine_powernet.adjust_static_power(channel, -amount)
+
+/*
+ * # power_change()
+ *
+ * Checks to see if the machines set power channel is powered and updates stat accordingly
+ * returns TRUE if machine's stat changes, returns FALSE if it does not, this is to make sure machines dont
+ * update their icon/overlays/lighting uneccesarily if it's contigent on NOPOWER
+ *
+ * NOTE:Subtypes of machinery should call parent here unless they change this proc's behaviour regarding NOPOWER
+*/
+/obj/machinery/proc/power_change()
+ var/old_stat = stat
+ if(has_power(power_channel) || !requires_power) //if we don't require power, we don't give a shit about the power channel!
+ stat &= ~NOPOWER
+ else
+ stat |= NOPOWER
+ return old_stat != stat //performance saving for machines that use power_change() to update icons!
+
+/// Helper proc to change the machines power usage mode, automatically adjusts static power usage to maintain perfect parity
+/obj/machinery/proc/change_power_mode(use_type = IDLE_POWER_USE)
+ if(isnull(use_type) || use_type == power_state || !machine_powernet || !power_channel) //if there is no powernet/channel, just end it here
+ return
+ switch(power_state)
+ if(IDLE_POWER_USE)
+ remove_static_power(power_channel, idle_power_consumption)
+ if(ACTIVE_POWER_USE)
+ remove_static_power(power_channel, active_power_consumption)
+
+ switch(use_type)
+ if(IDLE_POWER_USE)
+ add_static_power(power_channel, idle_power_consumption)
+ if(ACTIVE_POWER_USE)
+ add_static_power(power_channel, active_power_consumption)
+
+ power_state = use_type
/obj/machinery/default_welder_repair(mob/user, obj/item/I)
. = ..()
if(.)
stat &= ~BROKEN
-//sets the use_power var and then forces an area power update
-/obj/machinery/proc/update_use_power(new_use_power)
- use_power = new_use_power
-
-/obj/machinery/proc/auto_use_power()
- if(!powered(power_channel))
- return 0
- if(use_power == IDLE_POWER_USE)
- use_power(idle_power_usage,power_channel, 1)
- else if(use_power >= ACTIVE_POWER_USE)
- use_power(active_power_usage,power_channel, 1)
- if(prob(MACHINE_FLICKER_CHANCE))
- flicker()
- return 1
-
// This proc is only staying because of the fingerprint adding
// IT NEEDS TO DIE
/obj/machinery/Topic(href, href_list, nowindow = 0, datum/ui_state/state = GLOB.default_state)
@@ -428,6 +477,12 @@
/obj/machinery/proc/on_deconstruction()
return
+/obj/machinery/emp_act(severity)
+ if(power_state && !stat)
+ use_power(7500/severity)
+ . = TRUE
+ ..()
+
/obj/machinery/zap_act(power, zap_flags)
if(prob(85) && (zap_flags & ZAP_MACHINE_EXPLOSIVE) && !(resistance_flags & INDESTRUCTIBLE))
explosion(src, 1, 2, 4, flame_range = 2, adminlog = FALSE, smoke = FALSE)
@@ -461,3 +516,17 @@
if(issilicon(user))
return TRUE
return FALSE
+
+
+/*
+ * reimp, attempts to flicker this machinery if the behavior is supported.
+ */
+/obj/machinery/get_spooked()
+ return flicker()
+
+/*
+ * Base class, attempt to flicker. Returns TRUE if we complete our 'flicker
+ * behavior', false otherwise.
+ */
+/obj/machinery/proc/flicker()
+ return FALSE
diff --git a/code/game/machinery/magnet.dm b/code/game/machinery/magnet.dm
index 6d686d2779b..963ae462702 100644
--- a/code/game/machinery/magnet.dm
+++ b/code/game/machinery/magnet.dm
@@ -11,10 +11,9 @@
name = "Electromagnetic Generator"
desc = "A device that uses station power to create points of magnetic energy."
level = 1 // underfloor
- layer = WIRE_LAYER+0.001
+ layer = WIRE_LAYER + 0.001
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 50
+ idle_power_consumption = 50
var/freq = AIRLOCK_FREQ // radio frequency
var/electricity_level = 1 // intensity of the magnetic pull
@@ -139,10 +138,10 @@
// Update power usage:
if(on)
- use_power = 2
- active_power_usage = electricity_level*15
+ change_power_mode(ACTIVE_POWER_USE)
+ active_power_consumption = electricity_level*15
else
- use_power = 0
+ change_power_mode(NO_POWER_USE)
update_icon(UPDATE_ICON_STATE)
@@ -172,8 +171,8 @@
icon_state = "airlock_control_standby"
density = TRUE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 45
+ idle_power_consumption = 45
+
// this is a temp measure
var/frequency = AIRLOCK_FREQ
var/datum/radio_frequency/radio_connection
diff --git a/code/game/machinery/mass_driver.dm b/code/game/machinery/mass_driver.dm
index 46835c87f58..33f061bc1f6 100644
--- a/code/game/machinery/mass_driver.dm
+++ b/code/game/machinery/mass_driver.dm
@@ -4,9 +4,8 @@
icon = 'icons/obj/objects.dmi'
icon_state = "mass_driver"
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 2
- active_power_usage = 50
+ idle_power_consumption = 2
+ active_power_consumption = 50
/// Throw power
var/power = 1
diff --git a/code/game/machinery/portable_tag_turret.dm b/code/game/machinery/portable_tag_turret.dm
index c45a754c971..ba4fcc03c79 100644
--- a/code/game/machinery/portable_tag_turret.dm
+++ b/code/game/machinery/portable_tag_turret.dm
@@ -44,7 +44,7 @@
if(stat & BROKEN)
icon_state = "[lasercolor]destroyed_target_prism"
else
- if(powered())
+ if(has_power())
if(enabled)
if(iconholder)
//lasers have a orange icon
diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm
index 9f73377e1f0..dffd47ebfb8 100644
--- a/code/game/machinery/portable_turret.dm
+++ b/code/game/machinery/portable_turret.dm
@@ -9,10 +9,9 @@
icon_state = "turretCover"
anchored = TRUE
density = FALSE
- use_power = IDLE_POWER_USE //this turret uses and requires power
- idle_power_usage = 50 //when inactive, this turret takes up constant 50 Equipment power
- active_power_usage = 300 //when active, this turret takes up constant 300 Equipment power
- power_channel = EQUIP //drains power from the EQUIPMENT channel
+ idle_power_consumption = 50 //when inactive, this turret takes up constant 50 Equipment power
+ active_power_consumption = 300 //when active, this turret takes up constant 300 Equipment power
+ power_channel = PW_CHANNEL_EQUIPMENT //drains power from the EQUIPMENT channel
armor = list(melee = 50, bullet = 30, laser = 30, energy = 30, bomb = 30, bio = 0, rad = 0, fire = 90, acid = 90)
var/raised = FALSE //if the turret cover is "open" and the turret is raised
var/raising= FALSE //if the turret is currently opening or closing its cover
@@ -158,7 +157,7 @@ GLOBAL_LIST_EMPTY(turret_icons)
if(stat & BROKEN)
icon_state = "destroyed_target_prism"
else if(raised || raising)
- if(powered() && enabled)
+ if(has_power() && enabled)
if(iconholder)
//lasers have a orange icon
icon_state = "orange_target_prism"
@@ -317,10 +316,8 @@ GLOBAL_LIST_EMPTY(turret_icons)
one_access = !one_access
/obj/machinery/porta_turret/power_change()
- if(powered() || !use_power)
- stat &= ~NOPOWER
- else
- stat |= NOPOWER
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE)
@@ -729,7 +726,7 @@ GLOBAL_LIST_EMPTY(turret_icons)
// Lethal/emagged turrets use twice the power due to higher energy beams
// Emagged turrets again use twice as much power due to higher firing rates
- use_power(reqpower * (2 * (emagged || lethal)) * (2 * emagged))
+ use_power(power_channel, reqpower * (2 * (emagged || lethal)) * (2 * emagged))
if(istype(A))
A.original = target
@@ -1022,7 +1019,8 @@ GLOBAL_LIST_EMPTY(turret_icons)
syndicate = TRUE
installation = null
always_up = TRUE
- use_power = NO_POWER_USE
+ requires_power = FALSE
+ power_state = NO_POWER_USE
has_cover = FALSE
raised = TRUE
scan_range = 9
diff --git a/code/game/machinery/quantum_pad.dm b/code/game/machinery/quantum_pad.dm
index 31497c7d1ce..4399e9dced9 100644
--- a/code/game/machinery/quantum_pad.dm
+++ b/code/game/machinery/quantum_pad.dm
@@ -4,9 +4,8 @@
icon = 'icons/obj/telescience.dmi'
icon_state = "qpad-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/teleport_cooldown = 400 //30 seconds base due to base parts
var/teleport_speed = 50
var/last_teleport //to handle the cooldown
diff --git a/code/game/machinery/recharger.dm b/code/game/machinery/recharger.dm
index 67b8ac10660..4780cba784e 100644
--- a/code/game/machinery/recharger.dm
+++ b/code/game/machinery/recharger.dm
@@ -8,9 +8,8 @@
base_icon_state = "recharger"
desc = "A charging dock for energy based weaponry."
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 4
- active_power_usage = 200
+ idle_power_consumption = 4
+ active_power_consumption = 200
pass_flags = PASSTABLE
var/list/allowed_devices = list(/obj/item/gun/energy, /obj/item/melee/baton, /obj/item/rcs, /obj/item/bodyanalyzer, /obj/item/handheld_chem_dispenser, /obj/item/clothing/suit/armor/reactive)
@@ -50,7 +49,7 @@
//Checks to make sure he's not in space doing it, and that the area got proper power.
var/area/A = get_area(src)
- if(!istype(A) || !A.power_equip)
+ if(!istype(A) || !A.powernet.equipment_powered)
to_chat(user, "[src] blinks red as you try to insert [G].")
return
@@ -65,7 +64,7 @@
G.forceMove(src)
charging = G
- use_power = ACTIVE_POWER_USE
+ change_power_mode(ACTIVE_POWER_USE)
using_power = check_cell_needs_recharging(get_cell_from(G))
update_icon()
@@ -116,7 +115,7 @@
charging.forceMove(loc)
user.put_in_hands(charging)
charging = null
- use_power = IDLE_POWER_USE
+ change_power_mode(IDLE_POWER_USE)
update_icon()
/obj/machinery/recharger/attack_tk(mob/user)
@@ -124,7 +123,7 @@
charging.update_icon()
charging.forceMove(loc)
charging = null
- use_power = IDLE_POWER_USE
+ change_power_mode(IDLE_POWER_USE)
update_icon()
/obj/machinery/recharger/process()
@@ -155,7 +154,8 @@
..(severity)
/obj/machinery/recharger/power_change()
- ..()
+ if(!..())
+ return
if(stat & NOPOWER)
set_light(0)
else
diff --git a/code/game/machinery/rechargestation.dm b/code/game/machinery/rechargestation.dm
index 539b39c746a..2dbb813ec43 100644
--- a/code/game/machinery/rechargestation.dm
+++ b/code/game/machinery/rechargestation.dm
@@ -4,9 +4,8 @@
icon_state = "borgcharger0"
density = TRUE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 5
- active_power_usage = 1000
+ idle_power_consumption = 5
+ active_power_consumption = 1000
/// A reference to the occupant currently sitting inside the recharger.
var/mob/occupant = null
/// What type of circuit board is required to build this machine.
@@ -165,7 +164,7 @@
occupant.forceMove(loc)
occupant = null
update_icon(UPDATE_ICON_STATE)
- use_power = IDLE_POWER_USE
+ change_power_mode(IDLE_POWER_USE)
return
/obj/machinery/recharge_station/force_eject_occupant(mob/target)
@@ -235,5 +234,5 @@
add_fingerprint(user)
update_icon(UPDATE_ICON_STATE)
- update_use_power(1)
+ change_power_mode(IDLE_POWER_USE)
return
diff --git a/code/game/machinery/recycler.dm b/code/game/machinery/recycler.dm
index 90865d9e3e7..d74b76325b9 100644
--- a/code/game/machinery/recycler.dm
+++ b/code/game/machinery/recycler.dm
@@ -49,7 +49,8 @@
. += "The safety sensor light is [emagged ? "off!" : "on."]"
/obj/machinery/recycler/power_change()
- ..()
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE)
/obj/machinery/recycler/attackby(obj/item/I, mob/user, params)
diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm
index 49f7c47879b..de308d78313 100644
--- a/code/game/machinery/requests_console.dm
+++ b/code/game/machinery/requests_console.dm
@@ -72,7 +72,8 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
var/radiochannel = ""
/obj/machinery/requests_console/power_change()
- ..()
+ if(!..())
+ return
if(stat & NOPOWER)
set_light(0)
else
diff --git a/code/game/machinery/shieldgen.dm b/code/game/machinery/shieldgen.dm
index bccf06acadc..a0d29e3646a 100644
--- a/code/game/machinery/shieldgen.dm
+++ b/code/game/machinery/shieldgen.dm
@@ -305,12 +305,13 @@
anchored = FALSE
density = TRUE
req_access = list(ACCESS_TELEPORTER)
+ flags = CONDUCT
+ power_state = NO_POWER_USE
+
var/activated = FALSE
var/locked = TRUE
var/list/active_shields
var/stored_power = 0
- flags = CONDUCT
- use_power = NO_POWER_USE
/obj/machinery/shieldwallgen/Initialize(mapload)
. = ..()
diff --git a/code/game/machinery/snow_machine.dm b/code/game/machinery/snow_machine.dm
index 1a5688ff429..d55ccb6366b 100644
--- a/code/game/machinery/snow_machine.dm
+++ b/code/game/machinery/snow_machine.dm
@@ -37,7 +37,7 @@
power_efficiency += L.rating
/obj/machinery/snow_machine/attack_hand(mob/user)
- if(!powered() || !anchored)
+ if(!has_power() || !anchored)
return
if(turn_on_or_off(!active))
to_chat(user, "You [active ? "turn on" : "turn off"] [src].")
@@ -67,7 +67,7 @@
power_used_this_cycle = 0
if(!active || !anchored)
return
- if(!powered())
+ if(!has_power())
return
if(!reagents.has_reagent(reagents.get_master_reagent_id(), 3))
return //This means you don't need to top it up constantly to keep the nice snowclouds going
@@ -84,8 +84,9 @@
make_snowcloud(TF)
/obj/machinery/snow_machine/power_change()
- ..()
- if(!powered())
+ if(!..())
+ return
+ if(stat & NOPOWER)
turn_on_or_off(FALSE, TRUE)
update_icon(UPDATE_ICON_STATE)
diff --git a/code/game/machinery/status_display.dm b/code/game/machinery/status_display.dm
index e58e6173ce4..f0c9602ed58 100644
--- a/code/game/machinery/status_display.dm
+++ b/code/game/machinery/status_display.dm
@@ -12,8 +12,7 @@ GLOBAL_LIST_EMPTY(status_displays)
name = "status display"
anchored = TRUE
density = FALSE
- use_power = IDLE_POWER_USE
- idle_power_usage = 10
+ idle_power_consumption = 10
maptext_height = 26
maptext_width = 32
maptext_y = -1
@@ -55,8 +54,8 @@ GLOBAL_LIST_EMPTY(status_displays)
underlays += emissive_appearance(icon, "lightmask")
/obj/machinery/status_display/power_change()
- ..()
-
+ if(!..())
+ return
if(stat & NOPOWER)
set_light(0)
else
diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm
index 37affdf9370..ba547c9b859 100644
--- a/code/game/machinery/suit_storage_unit.dm
+++ b/code/game/machinery/suit_storage_unit.dm
@@ -402,7 +402,7 @@
/obj/machinery/suit_storage_unit/power_change()
- ..()
+ ..() //we don't check parent return here because `is_operational` cares about other flags in stat
if(!is_operational() && state_open)
open_machine()
dump_contents()
diff --git a/code/game/machinery/tcomms/_base.dm b/code/game/machinery/tcomms/_base.dm
index c277b597964..eca0cc7eed5 100644
--- a/code/game/machinery/tcomms/_base.dm
+++ b/code/game/machinery/tcomms/_base.dm
@@ -34,8 +34,7 @@ GLOBAL_LIST_EMPTY(tcomms_machines)
icon_state = "error"
density = TRUE
anchored = TRUE
- use_power = IDLE_POWER_USE
- idle_power_usage = 500
+ idle_power_consumption = 500
/// Network ID used for names + auto linkage
var/network_id = "None"
/// Is the machine active
@@ -158,7 +157,8 @@ GLOBAL_LIST_EMPTY(tcomms_machines)
* Proc which ensures icons are updated when machines lose power
*/
/obj/machinery/tcomms/power_change()
- ..()
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE)
/**
diff --git a/code/game/machinery/tcomms/relay.dm b/code/game/machinery/tcomms/relay.dm
index 809fbe57106..b13e7bc86ce 100644
--- a/code/game/machinery/tcomms/relay.dm
+++ b/code/game/machinery/tcomms/relay.dm
@@ -130,7 +130,8 @@
* Proc which ensures the host core has its zlevels updated (icons are updated by parent call)
*/
/obj/machinery/tcomms/relay/power_change()
- ..()
+ if(!..())
+ return
if(linked_core)
linked_core.refresh_zlevels()
diff --git a/code/game/machinery/teleporter.dm b/code/game/machinery/teleporter.dm
index b2d9a910e68..bfcad59d5b8 100644
--- a/code/game/machinery/teleporter.dm
+++ b/code/game/machinery/teleporter.dm
@@ -330,9 +330,8 @@
desc = "It's the hub of a teleporting machine."
icon_state = "tele0"
var/accurate = 0
- use_power = IDLE_POWER_USE
- idle_power_usage = 10
- active_power_usage = 2000
+ idle_power_consumption = 10
+ active_power_consumption = 2000
var/obj/machinery/teleport/station/power_station
var/calibrated //Calibration prevents mutation
var/admin_usage = FALSE // if 1, works on CC level. If 0, doesn't. Used for admin room teleport.
@@ -449,11 +448,10 @@
name = "permanent teleporter"
desc = "A teleporter with the target pre-set on the circuit board."
icon_state = "tele0"
- var/recalibrating = FALSE
- use_power = IDLE_POWER_USE
- idle_power_usage = 10
- active_power_usage = 2000
+ idle_power_consumption = 10
+ active_power_consumption = 2000
+ var/recalibrating = FALSE
var/target
var/tele_delay = 50
@@ -492,7 +490,8 @@
update_lighting()
/obj/machinery/teleport/perma/power_change()
- ..()
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE | UPDATE_OVERLAYS)
update_lighting()
@@ -534,14 +533,14 @@
name = "station"
desc = "The power control station for a bluespace teleporter."
icon_state = "controller"
- var/engaged = FALSE
- use_power = IDLE_POWER_USE
- idle_power_usage = 10
- active_power_usage = 2000
+ idle_power_consumption = 10
+ active_power_consumption = 2000
+
var/obj/machinery/computer/teleporter/teleporter_console
var/obj/machinery/teleport/hub/teleporter_hub
var/list/linked_stations = list()
var/efficiency = 0
+ var/engaged = FALSE
/obj/machinery/teleport/station/Initialize(mapload)
. = ..()
@@ -661,7 +660,8 @@
add_fingerprint(user)
/obj/machinery/teleport/station/power_change()
- ..()
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE | UPDATE_OVERLAYS)
if(teleporter_hub)
diff --git a/code/game/machinery/transformer.dm b/code/game/machinery/transformer.dm
index ee7b646326a..63667f9f5c3 100644
--- a/code/game/machinery/transformer.dm
+++ b/code/game/machinery/transformer.dm
@@ -47,7 +47,8 @@
new /obj/machinery/conveyor/auto(west, WEST)
/obj/machinery/transformer/power_change()
- ..()
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE)
/obj/machinery/transformer/update_icon_state()
@@ -165,7 +166,8 @@
new /obj/machinery/conveyor/auto(west2, EAST)
/obj/machinery/transformer/xray/power_change()
- ..()
+ if(!..())
+ return
update_icon(UPDATE_ICON_STATE)
/obj/machinery/transformer/xray/update_icon_state()
diff --git a/code/game/machinery/turret_control.dm b/code/game/machinery/turret_control.dm
index 888da17489b..e00df7f77ca 100644
--- a/code/game/machinery/turret_control.dm
+++ b/code/game/machinery/turret_control.dm
@@ -218,7 +218,8 @@
update_icon(UPDATE_ICON_STATE)
/obj/machinery/turretid/power_change()
- ..()
+ if(!..())
+ return
updateTurrets()
update_icon(UPDATE_ICON_STATE)
diff --git a/code/game/machinery/vendors/vending.dm b/code/game/machinery/vendors/vending.dm
index 858394b685b..fa860051b1f 100644
--- a/code/game/machinery/vendors/vending.dm
+++ b/code/game/machinery/vendors/vending.dm
@@ -40,8 +40,7 @@
/// Icon for the lightmask, defaults to icon_state + _off, _lightmask if one is defined.
var/icon_lightmask
// Power
- use_power = IDLE_POWER_USE
- idle_power_usage = 10
+ idle_power_consumption = 10
var/vend_power_usage = 150
var/light_range_on = 1
@@ -734,15 +733,13 @@
atom_say(message)
/obj/machinery/economy/vending/power_change()
- if(powered())
- stat &= ~NOPOWER
- else
- stat |= NOPOWER
+ ..()
if(stat & (BROKEN|NOPOWER))
set_light(0)
else
set_light(light_range_on, light_power_on)
- update_icon(UPDATE_OVERLAYS)
+ if(.)
+ update_icon(UPDATE_OVERLAYS)
/obj/machinery/economy/vending/obj_break(damage_flag)
if(stat & BROKEN)
diff --git a/code/game/machinery/washing_machine.dm b/code/game/machinery/washing_machine.dm
index fcfdd79ac04..ce1ff42be70 100644
--- a/code/game/machinery/washing_machine.dm
+++ b/code/game/machinery/washing_machine.dm
@@ -208,7 +208,6 @@
/obj/machinery/washing_machine/attackby(obj/item/W as obj, mob/user as mob, params)
if(default_unfasten_wrench(user, W))
- power_change()
return
if(istype(W,/obj/item/toy/crayon) ||istype(W,/obj/item/stamp))
if( state in list( 1, 3, 6 ) )
diff --git a/code/game/machinery/wishgranter.dm b/code/game/machinery/wishgranter.dm
index 23f251efaff..e7de14d163d 100644
--- a/code/game/machinery/wishgranter.dm
+++ b/code/game/machinery/wishgranter.dm
@@ -4,7 +4,7 @@
icon = 'icons/obj/device.dmi'
icon_state = "syndbeacon"
- use_power = NO_POWER_USE
+ power_state = NO_POWER_USE
anchored = TRUE
density = TRUE
diff --git a/code/game/mecha/equipment/tools/other_tools.dm b/code/game/mecha/equipment/tools/other_tools.dm
index 09861974ed0..dae96111ba8 100644
--- a/code/game/mecha/equipment/tools/other_tools.dm
+++ b/code/game/mecha/equipment/tools/other_tools.dm
@@ -233,7 +233,7 @@
energy_drain = 0
range = 0
var/coeff = 100
- var/list/use_channels = list(EQUIP,ENVIRON,LIGHT)
+ var/list/use_channels = list(PW_CHANNEL_EQUIPMENT, PW_CHANNEL_ENVIRONMENT, PW_CHANNEL_LIGHTING)
selectable = 0
/obj/item/mecha_parts/mecha_equipment/tesla_energy_relay/Destroy()
@@ -257,7 +257,7 @@
var/pow_chan
if(A)
for(var/c in use_channels)
- if(A.powered(c))
+ if(A.powernet.has_power(c))
pow_chan = c
break
return pow_chan
@@ -294,14 +294,14 @@
var/area/A = get_area(chassis)
if(A)
var/pow_chan
- for(var/c in list(EQUIP,ENVIRON,LIGHT))
- if(A.powered(c))
+ for(var/c in use_channels)
+ if(A.powernet.has_power(c))
pow_chan = c
break
if(pow_chan)
var/delta = min(20, chassis.cell.maxcharge-cur_charge)
chassis.give_power(delta)
- A.use_power(delta*coeff, pow_chan)
+ A.powernet.use_active_power(pow_chan, delta * coeff)
/////////////////////////////////////////// GENERATOR /////////////////////////////////////////////
diff --git a/code/game/mecha/mech_fabricator.dm b/code/game/mecha/mech_fabricator.dm
index 5b059148e52..c5dcac8c643 100644
--- a/code/game/mecha/mech_fabricator.dm
+++ b/code/game/mecha/mech_fabricator.dm
@@ -15,9 +15,8 @@
icon_state = "fab-idle"
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
// Settings
/// Bitflags of design types that can be produced.
var/allowed_design_types = MECHFAB
@@ -194,7 +193,7 @@
build_start = world.time
build_end = build_start + build_time
desc = "It's building \a [initial(D.name)]."
- use_power = ACTIVE_POWER_USE
+ change_power_mode(ACTIVE_POWER_USE)
add_overlay("fab-active")
addtimer(CALLBACK(src, PROC_REF(build_design_timer_finish), D, final_cost), build_time)
@@ -224,7 +223,7 @@
build_start = 0
build_end = 0
desc = initial(desc)
- use_power = IDLE_POWER_USE
+ change_power_mode(IDLE_POWER_USE)
cut_overlays()
atom_say("[A] is complete.")
diff --git a/code/game/objects/items/blueprints.dm b/code/game/objects/items/blueprints.dm
index 46a8ea629f8..a51e3ef7c9b 100644
--- a/code/game/objects/items/blueprints.dm
+++ b/code/game/objects/items/blueprints.dm
@@ -209,9 +209,9 @@
return area_created
var/area/A = new
A.name = str
- A.power_equip = FALSE
- A.power_light = FALSE
- A.power_environ = FALSE
+ A.powernet.equipment_powered = FALSE
+ A.powernet.lighting_powered = FALSE
+ A.powernet.environment_powered = FALSE
A.always_unpowered = FALSE
A.set_dynamic_lighting()
diff --git a/code/game/objects/items/devices/camera_bug.dm b/code/game/objects/items/devices/camera_bug.dm
index 89493639919..88bfa0ed9bf 100644
--- a/code/game/objects/items/devices/camera_bug.dm
+++ b/code/game/objects/items/devices/camera_bug.dm
@@ -15,7 +15,7 @@
/obj/machinery/computer/security/camera_bug
name = "invasive camera utility"
desc = "How did this get here?! Please report this as a bug to github"
- use_power = NO_POWER_USE
+ power_state = NO_POWER_USE
silent_console = TRUE
/obj/item/camera_bug/Initialize(mapload)
diff --git a/code/game/objects/items/devices/radio/intercom.dm b/code/game/objects/items/devices/radio/intercom.dm
index c50ab43b820..3fb0227468d 100644
--- a/code/game/objects/items/devices/radio/intercom.dm
+++ b/code/game/objects/items/devices/radio/intercom.dm
@@ -249,25 +249,25 @@
if(!current_area)
return
if(on)
- RegisterSignal(current_area, COMSIG_AREA_POWER_CHANGE, PROC_REF(AreaPowerCheck))
+ RegisterSignal(current_area.powernet, COMSIG_POWERNET_POWER_CHANGE, PROC_REF(local_powernet_check))
else
- UnregisterSignal(current_area, COMSIG_AREA_POWER_CHANGE)
+ UnregisterSignal(current_area.powernet, COMSIG_POWERNET_POWER_CHANGE)
/**
- * Proc called whenever the intercom's area loses or gains power. Responsible for setting the `on` variable and calling `update_icon()`.
+ * Proc called whenever the intercom's local powernet loses or gains power. Responsible for setting the `on` variable and calling `update_icon()`.
*
- * Normally called after the intercom's area recieves the `COMSIG_AREA_POWER_CHANGE` signal, but it can also be called directly.
+ * Normally called after the intercom's local powernet sends the `COMSIG_POWERNET_POWER_CHANGE` signal, but it can also be called directly.
* Arguments:
*
* source - the area that just had a power change.
*/
-/obj/item/radio/intercom/proc/AreaPowerCheck(datum/source)
+/obj/item/radio/intercom/proc/local_powernet_check(datum/source)
var/area/current_area = get_area(src)
if(!current_area)
on = FALSE
set_light(0)
else
- on = current_area.powered(EQUIP) // set "on" to the equipment power status of our area.
+ on = current_area.powernet.has_power(PW_CHANNEL_EQUIPMENT) // set "on" to the equipment power status of our area.
set_light(1, LIGHTING_MINIMUM_POWER)
update_icon(UPDATE_ICON_STATE | UPDATE_OVERLAYS)
diff --git a/code/game/objects/structures/electricchair.dm b/code/game/objects/structures/electricchair.dm
index 5528580fa1e..cba1d3c799d 100644
--- a/code/game/objects/structures/electricchair.dm
+++ b/code/game/objects/structures/electricchair.dm
@@ -75,10 +75,9 @@
var/area/A = get_area(src)
if(!isarea(A))
return
- if(!A.powered(EQUIP))
+ if(!A.powernet.has_power(PW_CHANNEL_EQUIPMENT))
return
- A.use_power(5000, EQUIP)
- var/light = A.power_light
+ A.powernet.use_active_power(PW_CHANNEL_EQUIPMENT, 5000)
A.update_icon(UPDATE_ICON_STATE)
flick("echair_shock", src)
@@ -91,5 +90,3 @@
to_chat(buckled_mob, "You feel a deep shock course through your body!")
spawn(1)
buckled_mob.electrocute_act(110, src, 1)
- A.power_light = light
- A.update_icon(UPDATE_ICON_STATE)
diff --git a/code/game/objects/structures/morgue.dm b/code/game/objects/structures/morgue.dm
index 28e1c9b3cc7..d83041e3a87 100644
--- a/code/game/objects/structures/morgue.dm
+++ b/code/game/objects/structures/morgue.dm
@@ -542,10 +542,10 @@ GLOBAL_LIST_EMPTY(crematoriums)
icon = 'icons/obj/power.dmi'
icon_state = "crema_switch"
resistance_flags = INDESTRUCTIBLE // could use a more elegant solution like being able to be rebuilt, broken and repaired, or by directly attaching the switch to the crematorium
- power_channel = EQUIP
- use_power = IDLE_POWER_USE
- idle_power_usage = 100
- active_power_usage = 5000
+ power_channel = PW_CHANNEL_EQUIPMENT
+ power_state = IDLE_POWER_USE
+ idle_power_consumption = 100
+ active_power_consumption = 5000
anchored = TRUE
req_access = list(ACCESS_CREMATORIUM)
/// ID of the crematorium to hook into
@@ -556,7 +556,7 @@ GLOBAL_LIST_EMPTY(crematoriums)
return attack_hand(user)
/obj/machinery/crema_switch/attack_hand(mob/user)
- if(!powered(power_channel)) // Do we have power?
+ if(!has_power(power_channel)) // Do we have power?
return
if(!(allowed(usr) || user.can_advanced_admin_interact()))
diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm
index c6c251fa689..95725eb0c5a 100644
--- a/code/game/objects/structures/watercloset.dm
+++ b/code/game/objects/structures/watercloset.dm
@@ -251,7 +251,7 @@
icon_state = "shower"
density = FALSE
anchored = TRUE
- use_power = NO_POWER_USE
+ power_state = NO_POWER_USE
///Is the shower on or off?
var/on = FALSE
///What temperature the shower reagents are set to.
diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm
index a3775a875be..84ce5ba329a 100644
--- a/code/game/objects/structures/window.dm
+++ b/code/game/objects/structures/window.dm
@@ -599,8 +599,9 @@
D.toggle_polarization()
/obj/machinery/button/windowtint/power_change()
- ..()
- if(active && !powered(power_channel))
+ if(!..())
+ return
+ if(active && (stat & NOPOWER))
toggle_tint()
/obj/machinery/button/windowtint/update_icon_state()
diff --git a/code/game/turfs/simulated/floor/light_floor.dm b/code/game/turfs/simulated/floor/light_floor.dm
index 90183627cff..dcbf61dbdab 100644
--- a/code/game/turfs/simulated/floor/light_floor.dm
+++ b/code/game/turfs/simulated/floor/light_floor.dm
@@ -19,7 +19,7 @@
var/area/current_area = get_area(src)
var/obj/machinery/power/apc/current_apc = current_area.get_apc()
if(current_apc)
- RegisterSignal(current_area, COMSIG_AREA_POWER_CHANGE, PROC_REF(power_update), override = TRUE)
+ RegisterSignal(current_area.powernet, COMSIG_POWERNET_POWER_CHANGE, PROC_REF(power_update), override = TRUE)
toggle_light(TRUE)
/turf/simulated/floor/light/update_icon_state()
@@ -42,7 +42,7 @@
/turf/simulated/floor/light/proc/power_check()
var/area/A = get_area(src)
- return A.powered(LIGHT)
+ return A.powernet.has_power(PW_CHANNEL_LIGHTING)
/turf/simulated/floor/light/attack_hand(mob/user)
if(!can_modify_colour)
@@ -96,11 +96,11 @@
// 1 = ON
on = light
if(!on && using_power)
- A.addStaticPower(-100, STATIC_LIGHT)
+ A.powernet.adjust_static_power(PW_CHANNEL_LIGHTING, -100)
using_power = FALSE
if(on && !using_power)
using_power = TRUE
- A.addStaticPower(100, STATIC_LIGHT)
+ A.powernet.adjust_static_power(PW_CHANNEL_LIGHTING, 100)
update_icon()
/turf/simulated/floor/light/extinguish_light(force = FALSE)
diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm
index 69a6cce793b..db92d027888 100644
--- a/code/modules/admin/topic.dm
+++ b/code/modules/admin/topic.dm
@@ -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)
diff --git a/code/modules/arcade/arcade_base.dm b/code/modules/arcade/arcade_base.dm
index 79d20c30e85..2232b48e290 100644
--- a/code/modules/arcade/arcade_base.dm
+++ b/code/modules/arcade/arcade_base.dm
@@ -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
diff --git a/code/modules/arcade/prize_counter.dm b/code/modules/arcade/prize_counter.dm
index fd24b03d9e9..56e04c96b51 100644
--- a/code/modules/arcade/prize_counter.dm
+++ b/code/modules/arcade/prize_counter.dm
@@ -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)
diff --git a/code/modules/atmospherics/machinery/airalarm.dm b/code/modules/atmospherics/machinery/airalarm.dm
index 5a0dbf38b78..18ecde657df 100644
--- a/code/modules/atmospherics/machinery/airalarm.dm
+++ b/code/modules/atmospherics/machinery/airalarm.dm
@@ -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)
diff --git a/code/modules/atmospherics/machinery/atmospherics.dm b/code/modules/atmospherics/machinery/atmospherics.dm
index 0e6b3f0b7aa..0846bb2aef0 100644
--- a/code/modules/atmospherics/machinery/atmospherics.dm
+++ b/code/modules/atmospherics/machinery/atmospherics.dm
@@ -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()
diff --git a/code/modules/atmospherics/machinery/components/binary_devices/binary_atmos_base.dm b/code/modules/atmospherics/machinery/components/binary_devices/binary_atmos_base.dm
index b28a9ded640..12360e6a1ed 100644
--- a/code/modules/atmospherics/machinery/components/binary_devices/binary_atmos_base.dm
+++ b/code/modules/atmospherics/machinery/components/binary_devices/binary_atmos_base.dm
@@ -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
diff --git a/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm b/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm
index d0442c11459..a135352d684 100644
--- a/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm
+++ b/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm
@@ -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()
. = ..()
diff --git a/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm
index f8438387f29..8bb026e0f23 100644
--- a/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm
+++ b/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm
@@ -54,7 +54,7 @@
if(!istype(T))
return
- if(!powered())
+ if(!has_power())
vent_icon += "off"
else
vent_icon += "[on ? "[releasing ? "out" : "in"]" : "off"]"
diff --git a/code/modules/atmospherics/machinery/components/binary_devices/pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/pump.dm
index 8e4b8fdca0b..b40346de723 100644
--- a/code/modules/atmospherics/machinery/components/binary_devices/pump.dm
+++ b/code/modules/atmospherics/machinery/components/binary_devices/pump.dm
@@ -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))
diff --git a/code/modules/atmospherics/machinery/components/binary_devices/valve.dm b/code/modules/atmospherics/machinery/components/binary_devices/valve.dm
index 55a4964360d..0645f204554 100644
--- a/code/modules/atmospherics/machinery/components/binary_devices/valve.dm
+++ b/code/modules/atmospherics/machinery/components/binary_devices/valve.dm
@@ -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, "Access denied.")
@@ -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
..()
diff --git a/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm
index 9e6cd917ec7..5e24a87a7f6 100644
--- a/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm
+++ b/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm
@@ -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))
diff --git a/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm b/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm
index 85aa7b92b94..988d3c897c7 100644
--- a/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm
+++ b/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm
@@ -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()
..()
diff --git a/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm b/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm
index 860c8e9503d..353cc920387 100644
--- a/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm
+++ b/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm
@@ -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()
..()
diff --git a/code/modules/atmospherics/machinery/components/trinary_devices/trinary_base.dm b/code/modules/atmospherics/machinery/components/trinary_devices/trinary_base.dm
index aa2914a7343..748f9af726e 100644
--- a/code/modules/atmospherics/machinery/components/trinary_devices/trinary_base.dm
+++ b/code/modules/atmospherics/machinery/components/trinary_devices/trinary_base.dm
@@ -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
diff --git a/code/modules/atmospherics/machinery/components/trinary_devices/tvalve.dm b/code/modules/atmospherics/machinery/components/trinary_devices/tvalve.dm
index 278b17908f8..ed6f8cf2f50 100644
--- a/code/modules/atmospherics/machinery/components/trinary_devices/tvalve.dm
+++ b/code/modules/atmospherics/machinery/components/trinary_devices/tvalve.dm
@@ -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, "Access denied.")
diff --git a/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm b/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm
index 91c70204e44..5204046cf88 100644
--- a/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm
+++ b/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm
@@ -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()
..()
diff --git a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm
index c5353ab1e92..c26483f89b0 100644
--- a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm
+++ b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm
@@ -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
diff --git a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm
index 03a365bd915..46d6178a1a0 100644
--- a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm
+++ b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm
@@ -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
diff --git a/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm b/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm
index d5afae13384..7a998c3b119 100644
--- a/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm
+++ b/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm
@@ -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
diff --git a/code/modules/atmospherics/machinery/other/meter.dm b/code/modules/atmospherics/machinery/other/meter.dm
index 04cc4c8ab73..e100c027da5 100644
--- a/code/modules/atmospherics/machinery/other/meter.dm
+++ b/code/modules/atmospherics/machinery/other/meter.dm
@@ -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)
diff --git a/code/modules/atmospherics/machinery/pipes/pipe.dm b/code/modules/atmospherics/machinery/pipes/pipe.dm
index b7573997cf8..418b143bcb5 100644
--- a/code/modules/atmospherics/machinery/pipes/pipe.dm
+++ b/code/modules/atmospherics/machinery/pipes/pipe.dm
@@ -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
diff --git a/code/modules/atmospherics/machinery/portable/canister.dm b/code/modules/atmospherics/machinery/portable/canister.dm
index 03065dd1f78..bd0f54e300e 100644
--- a/code/modules/atmospherics/machinery/portable/canister.dm
+++ b/code/modules/atmospherics/machinery/portable/canister.dm
@@ -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
diff --git a/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm b/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm
index 15da2e4f673..9d4b25d5eee 100644
--- a/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm
+++ b/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm
@@ -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
diff --git a/code/modules/awaymissions/gateway.dm b/code/modules/awaymissions/gateway.dm
index cc92fbe9809..c927e93d26a 100644
--- a/code/modules/awaymissions/gateway.dm
+++ b/code/modules/awaymissions/gateway.dm
@@ -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
diff --git a/code/modules/buildmode/submodes/area_edit.dm b/code/modules/buildmode/submodes/area_edit.dm
index d60950d294f..2478ae0430b 100644
--- a/code/modules/buildmode/submodes/area_edit.dm
+++ b/code/modules/buildmode/submodes/area_edit.dm
@@ -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
diff --git a/code/modules/economy/economy_machinery/atm.dm b/code/modules/economy/economy_machinery/atm.dm
index dbe7dac0f0a..47d2d1c7c49 100644
--- a/code/modules/economy/economy_machinery/atm.dm
+++ b/code/modules/economy/economy_machinery/atm.dm
@@ -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
diff --git a/code/modules/events/apc_overload.dm b/code/modules/events/apc_overload.dm
index 330dbdadf45..8830ce98a6e 100644
--- a/code/modules/events/apc_overload.dm
+++ b/code/modules/events/apc_overload.dm
@@ -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.")
diff --git a/code/modules/events/apc_short.dm b/code/modules/events/apc_short.dm
index 3b9720e4957..7af88445c54 100644
--- a/code/modules/events/apc_short.dm
+++ b/code/modules/events/apc_short.dm
@@ -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)
diff --git a/code/modules/food_and_drinks/kitchen_machinery/cooker.dm b/code/modules/food_and_drinks/kitchen_machinery/cooker.dm
index 9bfe7f2384f..5df528da14b 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/cooker.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/cooker.dm
@@ -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
diff --git a/code/modules/food_and_drinks/kitchen_machinery/gibber.dm b/code/modules/food_and_drinks/kitchen_machinery/gibber.dm
index 97fcc57c265..b8850429bf9 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/gibber.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/gibber.dm
@@ -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)
. = ..()
diff --git a/code/modules/food_and_drinks/kitchen_machinery/icecream_vat.dm b/code/modules/food_and_drinks/kitchen_machinery/icecream_vat.dm
index e514ed60658..0b5b2fe16cf 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/icecream_vat.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/icecream_vat.dm
@@ -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
diff --git a/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm b/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm
index 35d2045bb26..1c8eb739f9a 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm
@@ -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?
diff --git a/code/modules/food_and_drinks/kitchen_machinery/monkeyrecycler.dm b/code/modules/food_and_drinks/kitchen_machinery/monkeyrecycler.dm
index 1d85ab1facf..76792806490 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/monkeyrecycler.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/monkeyrecycler.dm
@@ -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
diff --git a/code/modules/food_and_drinks/kitchen_machinery/oven.dm b/code/modules/food_and_drinks/kitchen_machinery/oven.dm
index 4d24f62288d..0b571d393c3 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/oven.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/oven.dm
@@ -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()
diff --git a/code/modules/food_and_drinks/kitchen_machinery/processor.dm b/code/modules/food_and_drinks/kitchen_machinery/processor.dm
index 5abc6b962ae..54291db7963 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/processor.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/processor.dm
@@ -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
diff --git a/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm b/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm
index 2663c975b87..123f3417a23 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm
@@ -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)
/**
diff --git a/code/modules/hydroponics/biogenerator.dm b/code/modules/hydroponics/biogenerator.dm
index 130bd794908..447083963f4 100644
--- a/code/modules/hydroponics/biogenerator.dm
+++ b/code/modules/hydroponics/biogenerator.dm
@@ -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.
diff --git a/code/modules/hydroponics/hydroponics.dm b/code/modules/hydroponics/hydroponics.dm
index 0497d8f43db..a4b60868000 100644
--- a/code/modules/hydroponics/hydroponics.dm
+++ b/code/modules/hydroponics/hydroponics.dm
@@ -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()
diff --git a/code/modules/mining/lavaland/loot/colossus_loot.dm b/code/modules/mining/lavaland/loot/colossus_loot.dm
index 4dd7f108d04..7fa85ae1db0 100644
--- a/code/modules/mining/lavaland/loot/colossus_loot.dm
+++ b/code/modules/mining/lavaland/loot/colossus_loot.dm
@@ -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"
diff --git a/code/modules/mining/machine_redemption.dm b/code/modules/mining/machine_redemption.dm
index 803636253fe..c622899260f 100644
--- a/code/modules/mining/machine_redemption.dm
+++ b/code/modules/mining/machine_redemption.dm
@@ -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("The ID slot indicator light flickers on [src] as it spits out a card before powering down.")
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
diff --git a/code/modules/mining/machine_vending.dm b/code/modules/mining/machine_vending.dm
index 451a774656d..d2ea1d41b7c 100644
--- a/code/modules/mining/machine_vending.dm
+++ b/code/modules/mining/machine_vending.dm
@@ -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("The ID slot indicator light flickers on \the [src] as it spits out a card before powering down.")
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))
diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm
index 3d1aa07e33c..ba3a5a502e2 100644
--- a/code/modules/mob/living/silicon/ai/ai.dm
+++ b/code/modules/mob/living/silicon/ai/ai.dm
@@ -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"
diff --git a/code/modules/mob/living/silicon/ai/life.dm b/code/modules/mob/living/silicon/ai/life.dm
index f37d7bbca71..7156f3a1e8b 100644
--- a/code/modules/mob/living/silicon/ai/life.dm
+++ b/code/modules/mob/living/silicon/ai/life.dm
@@ -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()
..()
diff --git a/code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm b/code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm
index 0f599b6479b..e73d5a9fee5 100644
--- a/code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm
+++ b/code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm
@@ -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()
diff --git a/code/modules/newscaster/obj/newscaster.dm b/code/modules/newscaster/obj/newscaster.dm
index 6d83eed3795..11b0abdbd3c 100644
--- a/code/modules/newscaster/obj/newscaster.dm
+++ b/code/modules/newscaster/obj/newscaster.dm
@@ -121,7 +121,8 @@
. += "crack3"
/obj/machinery/newscaster/power_change()
- ..()
+ if(!..())
+ return
if(stat & NOPOWER)
set_light(0)
else
diff --git a/code/modules/paperwork/faxmachine.dm b/code/modules/paperwork/faxmachine.dm
index 86de41257a0..f40e00a1fd4 100644
--- a/code/modules/paperwork/faxmachine.dm
+++ b/code/modules/paperwork/faxmachine.dm
@@ -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.\"")
diff --git a/code/modules/paperwork/photocopier.dm b/code/modules/paperwork/photocopier.dm
index 39d66fc72aa..604f1e78a03 100644
--- a/code/modules/paperwork/photocopier.dm
+++ b/code/modules/paperwork/photocopier.dm
@@ -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, "\The [copyitem] can't be scanned by \the [src].")
copying = FALSE
return
- use_power(active_power_usage)
+ use_power(active_power_consumption)
sleep(PHOTOCOPIER_DELAY)
LAZYADD(saved_documents, O)
copying = FALSE
diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm
deleted file mode 100644
index 41c2d477e50..00000000000
--- a/code/modules/power/apc.dm
+++ /dev/null
@@ -1,1468 +0,0 @@
-//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
-
-//opened
-#define APC_CLOSED 0
-#define APC_OPENED 1
-#define APC_COVER_OFF 2
-
-//electronics_state
-#define APC_ELECTRONICS_NONE 0
-#define APC_ELECTRONICS_INSTALLED 1
-#define APC_ELECTRONICS_SECURED 2
-
-//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 200 // 20 seconds
-
-// main_status var
-#define APC_EXTERNAL_POWER_NOTCONNECTED 0
-#define APC_EXTERNAL_POWER_NOENERGY 1
-#define APC_EXTERNAL_POWER_GOOD 2
-
-// 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
-
-// the Area Power Controller (APC), formerly Power Distribution Unit (PDU)
-// one per area, needs wire conection to power network through a terminal
-
-// controls power to devices in that area
-// may be opened to change power cell
-// three different channels (lighting/equipment/environ) - may each be set to on, off, or auto
-
-
-//NOTE: STUFF STOLEN FROM AIRLOCK.DM thx
-
-
-/obj/machinery/power/apc
- name = "area power controller"
- desc = "A control terminal for the area electrical systems."
- icon_state = "apc0"
- use_power = NO_POWER_USE
- max_integrity = 200
- integrity_failure = 50
- resistance_flags = FIRE_PROOF
- req_access = list(ACCESS_ENGINE_EQUIP)
- siemens_strength = 1
- damage_deflection = 10
- move_resist = INFINITY
- var/area/area
- var/areastring = null
- var/obj/item/stock_parts/cell/cell
- var/start_charge = 90 // initial cell charge %
- var/cell_type = 2500 //Base cell has 2500 capacity. Enter the path of a different cell you want to use. cell determines charge rates, max capacity, ect. These can also be changed with other APC vars, but isn't recommended to minimize the risk of accidental usage of dirty editted APCs
- var/opened = APC_CLOSED
- var/shorted = FALSE
- var/lighting = 3
- var/equipment = 3
- var/environ = 3
- var/operating = TRUE
- var/charging = APC_NOT_CHARGING
- var/chargemode = 1
- var/chargecount = 0
- var/locked = TRUE
- var/coverlocked = TRUE
- var/aidisabled = FALSE
- var/obj/machinery/power/terminal/terminal = null
- var/lastused_light = 0
- var/lastused_equip = 0
- var/lastused_environ = 0
- var/lastused_total = 0
- var/main_status = APC_EXTERNAL_POWER_NOTCONNECTED
- powernet = 0 // set so that APCs aren't found as powernet nodes //Hackish, Horrible, was like this before I changed it :(
- var/malfhack = FALSE //New var for my changes to AI malf. --NeoFite
- var/mob/living/silicon/ai/malfai = null //See above --NeoFite
- var/debug = FALSE
- var/autoflag= 0 // 0 = off, 1= eqp and lights off, 2 = eqp off, 3 = all on.
-// luminosity = 1
- var/electronics_state = APC_ELECTRONICS_NONE
- var/overload = 1 //used for the Blackout malf module
- var/mob/living/silicon/ai/occupier = null
- var/longtermpower = 10
- var/update_state = -1
- var/update_overlay = -1
- var/global/status_overlays = FALSE
- var/updating_icon = FALSE
- var/datum/wires/apc/wires = null
- var/global/list/status_overlays_lock
- var/global/list/status_overlays_charging
- var/global/list/status_overlays_equipment
- var/global/list/status_overlays_lighting
- var/global/list/status_overlays_environ
- var/keep_preset_name = FALSE
- /// Was this APC built instead of already existing? Used for malfhack to keep borgs from building apcs in space
- var/constructed = FALSE
-
- var/report_power_alarm = TRUE
-
- var/shock_proof = FALSE //if set to FALSE, this APC will not arc bolts of electricity if it's overloaded.
-
- // Nightshift
- var/nightshift_lights = FALSE
- var/last_nightshift_switch = 0
-
- ///Used to determine if emergency lights should be on or off
- var/emergency_power = TRUE
- var/emergency_power_timer
- var/emergency_lights = FALSE
-
-/obj/machinery/power/apc/worn_out
- name = "\improper Worn out APC"
- keep_preset_name = TRUE
- locked = FALSE
- environ = 0
- equipment = 0
- lighting = 0
- operating = FALSE
- emergency_power = FALSE
-
-/obj/machinery/power/apc/noalarm
- report_power_alarm = FALSE
-
-/obj/machinery/power/apc/syndicate //general syndicate access
- req_access = list(ACCESS_SYNDICATE)
- report_power_alarm = FALSE
-
-/obj/machinery/power/apc/syndicate/off
- environ = 0
- equipment = 0
- lighting = 0
- operating = 0
-
-/obj/machinery/power/apc/syndicate/off/Initialize(mapload)
- . = ..()
- cell.charge = 0
-
-/obj/item/apc_electronics
- name = "APC electronics"
- desc = "Heavy-duty switching circuits for power control."
- icon = 'icons/obj/module.dmi'
- icon_state = "power_mod"
- w_class = WEIGHT_CLASS_SMALL
- origin_tech = "engineering=2;programming=1"
- item_state = "electronic"
- flags = CONDUCT
- usesound = 'sound/items/deconstruct.ogg'
- toolspeed = 1
-
-/obj/machinery/power/apc/get_cell()
- return cell
-
-/obj/machinery/power/apc/proc/has_electronics()
- return electronics_state != APC_ELECTRONICS_NONE
-
-/obj/machinery/power/apc/connect_to_network()
- //Override because the APC does not directly connect to the network; it goes through a terminal.
- //The terminal is what the power computer looks for anyway.
- if(terminal)
- terminal.connect_to_network()
-
-/obj/machinery/power/apc/New(turf/loc, direction, building = 0)
- if(!armor)
- armor = list(MELEE = 20, BULLET = 20, LASER = 10, ENERGY = 100, BOMB = 30, BIO = 100, RAD = 100, FIRE = 90, ACID = 50)
- ..()
- GLOB.apcs += src
- GLOB.apcs = sortAtom(GLOB.apcs)
-
- wires = new(src)
-
- if(building)
- // Offset 24 pixels in direction of dir. This allows the APC to be embedded in a wall, yet still inside an area
- setDir(direction) // This is only used for pixel offsets, and later terminal placement. APC dir doesn't affect its sprite since it only has one orientation.
- set_pixel_offsets_from_dir(24, -24, 24, -24)
-
- area = get_area(src)
- area.apc |= src
- opened = APC_OPENED
- operating = FALSE
- name = "[area.name] APC"
- stat |= MAINT
- constructed = TRUE
- update_icon()
- addtimer(CALLBACK(src, PROC_REF(update)), 5)
-
-/obj/machinery/power/apc/Destroy()
- SStgui.close_uis(wires)
- GLOB.apcs -= src
- area.power_light = 0
- area.power_equip = 0
- area.power_environ = 0
- area.power_change()
- if(occupier)
- malfvacate(1)
- QDEL_NULL(wires)
- QDEL_NULL(cell)
- if(terminal)
- disconnect_terminal()
- area.apc -= src
- return ..()
-
-/obj/machinery/power/apc/proc/make_terminal()
- // create a terminal object at the same position as original turf loc
- // wires will attach to this
- terminal = new/obj/machinery/power/terminal(get_turf(src))
- terminal.setDir(dir)
- terminal.master = src
-
-/obj/machinery/power/apc/Initialize(mapload)
- . = ..()
- if(!mapload)
- return
- electronics_state = APC_ELECTRONICS_SECURED
- // is starting with a power cell installed, create it and set its charge level
- if(cell_type)
- cell = new/obj/item/stock_parts/cell/upgraded(src)
- cell.maxcharge = cell_type // cell_type is maximum charge (old default was 1000 or 2500 (values one and two respectively)
- cell.charge = start_charge * cell.maxcharge / 100 // (convert percentage to actual value)
-
- var/area/A = get_area(src)
-
-
- //if area isn't specified use current
- if(keep_preset_name)
- if(isarea(A))
- area = A
- // no-op, keep the name
- else if(isarea(A) && !areastring)
- area = A
- name = "\improper [area.name] APC"
- else
- name = "\improper [get_area_name(area, TRUE)] APC"
- area.apc |= src
-
- update_icon()
-
- make_terminal()
-
- set_light(1, LIGHTING_MINIMUM_POWER)
-
- addtimer(CALLBACK(src, PROC_REF(update)), 5)
-
-/obj/machinery/power/apc/examine(mob/user)
- . = ..()
- if(in_range(user, src))
- if(stat & BROKEN)
- return
- if(opened)
- if(has_electronics() && terminal)
- . += "The cover is [opened == APC_OPENED ? "removed" : "open"] and the power cell is [ cell ? "installed" : "missing"]."
- else if(!has_electronics() && terminal)
- . += "There are some wires but no electronics."
- else if(has_electronics() && !terminal)
- . += "Electronics installed but not wired."
- else /* if(!has_electronics() && !terminal) */
- . += "There are no electronics nor connected wires."
- else
- if(stat & MAINT)
- . += "The cover is closed. Something wrong with it: it doesn't work."
- else if(malfhack)
- . += "The cover is broken. It may be hard to force it open."
- else
- . += "The cover is closed."
-
-/obj/machinery/power/apc/detailed_examine()
- return "An APC (Area Power Controller) regulates and supplies backup power for the area they are in. Their power channels are divided \
- out into 'environmental' (Items that manipulate airflow and temperature), 'lighting' (the lights), and 'equipment' (Everything else that consumes power). \
- Power consumption and backup power cell charge can be seen from the interface, further controls (turning a specific channel on, off or automatic, \
- toggling the APC's ability to charge the backup cell, or toggling power for the entire area via master breaker) first requires the interface to be unlocked \
- with an ID with Engineering access or by one of the station's robots or the artificial intelligence."
-
-/obj/machinery/power/apc/detailed_examine_antag()
- return "This can be emagged to unlock it. It will cause the APC to have a blue error screen. \
- Wires can be pulsed remotely with a signaler attached to it. A powersink will also drain any APCs connected to the same wire the powersink is on."
-
-// 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 + 1]
- var/image/statover_light = status_overlays_lighting[lighting + 1]
- var/image/statover_envir = status_overlays_environ[environ + 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)
- update_overlay |= APC_UPOVERLAY_EQUIPMENT0
- else if(equipment == 1)
- update_overlay |= APC_UPOVERLAY_EQUIPMENT1
- else if(equipment == 2)
- update_overlay |= APC_UPOVERLAY_EQUIPMENT2
-
- if(!lighting)
- update_overlay |= APC_UPOVERLAY_LIGHTING0
- else if(lighting == 1)
- update_overlay |= APC_UPOVERLAY_LIGHTING1
- else if(lighting == 2)
- update_overlay |= APC_UPOVERLAY_LIGHTING2
-
- if(!environ)
- update_overlay |= APC_UPOVERLAY_ENVIRON0
- else if(environ==1)
- update_overlay |= APC_UPOVERLAY_ENVIRON1
- else if(environ==2)
- 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 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
-
-//attack with an item - open/close cover, insert cell, or (un)lock interface
-/obj/machinery/power/apc/attackby(obj/item/W, mob/living/user, params)
-
- if(issilicon(user) && get_dist(src, user) > 1)
- return attack_hand(user)
-
- else if (istype(W, /obj/item/stock_parts/cell) && opened) // trying to put a cell inside
- if(cell)
- to_chat(user, "There is a power cell already installed!")
- return
- else
- if(stat & MAINT)
- to_chat(user, "There is no connector for your power cell!")
- return
- if(!user.drop_item())
- return
- W.forceMove(src)
- cell = W
- user.visible_message(\
- "[user.name] has inserted the power cell to [name]!",\
- "You insert the power cell.")
- chargecount = 0
- update_icon()
-
- else if(W.GetID()) // trying to unlock the interface with an ID card
- togglelock(user)
-
- else if(istype(W, /obj/item/stack/cable_coil) && opened)
- var/turf/host_turf = get_turf(src)
- if(!host_turf)
- throw EXCEPTION("attackby on APC when it's not on a turf")
- return
- if(host_turf.intact)
- to_chat(user, "You must remove the floor plating in front of the APC first!")
- return
- else if(terminal) // it already have terminal
- to_chat(user, "This APC is already wired!")
- return
- else if(!has_electronics())
- to_chat(user, "There is nothing to wire!")
- return
-
- var/obj/item/stack/cable_coil/C = W
- if(C.get_amount() < 10)
- to_chat(user, "You need ten lengths of cable for APC!")
- return
- user.visible_message("[user.name] adds cables to the APC frame.", \
- "You start adding cables to the APC frame...")
- playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE)
- if(do_after(user, 20, target = src))
- if(C.get_amount() < 10 || !C)
- return
- if(C.get_amount() >= 10 && !terminal && opened && has_electronics())
- var/turf/T = get_turf(src)
- var/obj/structure/cable/N = T.get_cable_node()
- if(prob(50) && electrocute_mob(usr, N, N, 1, TRUE))
- do_sparks(5, TRUE, src)
- return
- C.use(10)
- to_chat(user, "You add cables to the APC frame.")
- make_terminal()
- terminal.connect_to_network()
-
- else if(istype(W, /obj/item/apc_electronics) && opened)
- if(has_electronics()) // there are already electronicks inside
- to_chat(user, "You cannot put the board inside, there already is one!")
- return
- else if(stat & BROKEN)
- to_chat(user, "You cannot put the board inside, the frame is damaged!")
- return
-
- user.visible_message("[user.name] inserts [W] into [src].", \
- "You start to insert [W] into the frame...")
- playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE)
- if(do_after(user, 10, target = src))
- if(!has_electronics())
- electronics_state = APC_ELECTRONICS_INSTALLED
- locked = FALSE
- to_chat(user, "You place [W] inside the frame.")
- qdel(W)
-
- else if(istype(W, /obj/item/mounted/frame/apc_frame) && opened)
- if(!(stat & BROKEN || opened == APC_COVER_OFF || obj_integrity < max_integrity)) // There is nothing to repair
- to_chat(user, "You found no reason for repairing this APC")
- return
- if(!(stat & BROKEN) && opened == APC_COVER_OFF) // Cover is the only thing broken, we do not need to remove elctronicks to replace cover
- user.visible_message("[user.name] replaces missing APC's cover.",\
- "You begin to replace APC's cover...")
- if(do_after(user, 20, target = src)) // replacing cover is quicker than replacing whole frame
- to_chat(user, "You replace missing APC's cover.")
- qdel(W)
- opened = APC_OPENED
- update_icon()
- return
- if(has_electronics())
- to_chat(user, "You cannot repair this APC until you remove the electronics still inside!")
- return
- user.visible_message("[user.name] replaces the damaged APC frame with a new one.",\
- "You begin to replace the damaged APC frame...")
- if(do_after(user, 50, target = src))
- to_chat(user, "You replace the damaged APC frame with a new one.")
- qdel(W)
- stat &= ~BROKEN
- obj_integrity = max_integrity
- if(opened == APC_COVER_OFF)
- opened = APC_OPENED
- update_icon()
- return
- else
- return ..()
-
-
-/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, "Disconnect the wires first!")
- return
- to_chat(user, "You start trying to remove the APC electronics..." )
- 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]!",
- "You break the charred APC electronics and remove the remains.",
- "You hear a crack.")
- 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]!",
- "You discarded the shorted board.")
- 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]!",
- "You discarded the strangely programmed board.")
- malfai = null
- malfhack = FALSE
- return
- else
- user.visible_message(\
- "[user.name] has removed the APC electronics from [name]!",
- "You remove the APC electronics.")
- 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, "The cover is locked and cannot be opened!")
- return
- else if(panel_open) // wires are exposed
- to_chat(user, "Exposed wires prevents you from opening it!")
- 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, "Close the APC first!") //Less hints more mystery!
- return
- else
- if(electronics_state == APC_ELECTRONICS_INSTALLED)
- electronics_state = APC_ELECTRONICS_SECURED
- stat &= ~MAINT
- to_chat(user, "You screw the circuit electronics into place.")
- else if(electronics_state == APC_ELECTRONICS_SECURED)
- electronics_state = APC_ELECTRONICS_INSTALLED
- stat |= MAINT
- to_chat(user, "You unfasten the electronics.")
- else
- to_chat(user, "There is nothing to secure!")
- return
- update_icon()
- else if(emagged)
- to_chat(user, "The interface is broken!")
- 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/proc/togglelock(mob/living/user)
- if(emagged)
- to_chat(user, "The interface is broken!")
- else if(opened)
- to_chat(user, "You must close the cover to swipe an ID card!")
- else if(panel_open)
- to_chat(user, "You must close the panel!")
- else if(stat & (BROKEN|MAINT))
- to_chat(user, "Nothing happens!")
- else
- if(allowed(usr) && !wires.is_cut(WIRE_IDSCAN) && !malfhack)
- locked = !locked
- to_chat(user, "You [ locked ? "lock" : "unlock"] the APC interface.")
- update_icon()
- else
- to_chat(user, "Access denied.")
-
-/obj/machinery/power/apc/run_obj_armor(damage_amount, damage_type, damage_flag = 0, attack_dir)
- if(stat & BROKEN)
- return damage_amount
- . = ..()
-
-/obj/machinery/power/apc/obj_break(damage_flag)
- if(!(flags & NODECONSTRUCT))
- set_broken()
-
-/obj/machinery/power/apc/deconstruct(disassembled = TRUE)
- if(!(flags & NODECONSTRUCT))
- if(!(stat & BROKEN))
- set_broken()
- if(opened != 2)
- opened = APC_COVER_OFF
- coverlocked = FALSE
- visible_message("The APC cover is knocked down!")
- update_icon()
-
-/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].",\
- "You disassembled the broken APC frame.")
- else
- new /obj/item/mounted/frame/apc_frame(loc)
- user.visible_message(\
- "[user.name] has cut [src] from the wall with [I].",\
- "You cut the APC frame from the wall.")
- qdel(src)
-
-/obj/machinery/power/apc/emag_act(user as mob)
- if(!(emagged || malfhack)) // trying to unlock with an emag card
- if(opened)
- to_chat(user, "You must close the cover to swipe an ID card.")
- else if(panel_open)
- to_chat(user, "You must close the panel first.")
- else if(stat & (BROKEN|MAINT))
- to_chat(user, "Nothing happens.")
- else
- flick("apc-spark", src)
- emagged = TRUE
- locked = FALSE
- to_chat(user, "You emag the APC interface.")
- update_icon()
-
-// attack with hand - remove cell (if cover open) or interact with the APC
-/obj/machinery/power/apc/attack_hand(mob/user)
- if(!user)
- return
- add_fingerprint(user)
-
- if(usr == user && opened && !issilicon(user))
- if(cell)
- user.visible_message("[user.name] removes [cell] from [src]!", "You remove [cell].")
- user.put_in_hands(cell)
- cell.add_fingerprint(user)
- cell.update_icon(UPDATE_OVERLAYS)
- cell = null
- charging = APC_NOT_CHARGING
- update_icon()
- return
- if(stat & (BROKEN|MAINT))
- return
-
- interact(user)
-
-/obj/machinery/power/apc/attack_ghost(mob/user)
- if(panel_open)
- wires.Interact(user)
- return ui_interact(user)
-
-/obj/machinery/power/apc/interact(mob/user)
- if(!user)
- return
-
- if(panel_open)
- wires.Interact(user)
-
- return ui_interact(user)
-
-
-/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
-
-/obj/machinery/power/apc/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
- ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
- if(!ui)
- ui = new(user, src, ui_key, "APC", name, 510, 460, master_ui, state)
- ui.open()
-
-/obj/machinery/power/apc/ui_data(mob/user)
- var/list/data = list()
- data["locked"] = is_locked(user)
- data["normallyLocked"] = locked
- data["isOperating"] = operating
- data["externalPower"] = main_status
- data["powerCellStatus"] = cell ? cell.percent() : null
- data["chargeMode"] = chargemode
- data["chargingStatus"] = charging
- data["totalLoad"] = round(lastused_equip + lastused_light + lastused_environ)
- data["coverLocked"] = coverlocked
- data["siliconUser"] = issilicon(user)
- data["siliconLock"] = locked
- data["malfStatus"] = get_malf_status(user)
- data["nightshiftLights"] = nightshift_lights
- data["emergencyLights"] = !emergency_lights
-
- var/powerChannels[0]
- powerChannels[++powerChannels.len] = list(
- "title" = "Equipment",
- "powerLoad" = round(lastused_equip),
- "status" = equipment,
- "topicParams" = list(
- "auto" = list("eqp" = 3),
- "on" = list("eqp" = 2),
- "off" = list("eqp" = 1)
- )
- )
- powerChannels[++powerChannels.len] = list(
- "title" = "Lighting",
- "powerLoad" = round(lastused_light),
- "status" = lighting,
- "topicParams" = list(
- "auto" = list("lgt" = 3),
- "on" = list("lgt" = 2),
- "off" = list("lgt" = 1)
- )
- )
- powerChannels[++powerChannels.len] = list(
- "title" = "Environment",
- "powerLoad" = round(lastused_environ),
- "status" = environ,
- "topicParams" = list(
- "auto" = list("env" = 3),
- "on" = list("env" = 2),
- "off" = list("env" = 1)
- )
- )
-
- data["powerChannels"] = powerChannels
-
- return data
-
-/obj/machinery/power/apc/proc/report()
- return "[area.name] : [equipment]/[lighting]/[environ] ([lastused_equip+lastused_light+lastused_environ]) : [cell? cell.percent() : "N/C"] ([charging])"
-
-/obj/machinery/power/apc/proc/update()
- if(operating && !shorted)
- area.power_light = (lighting > 1)
- area.power_equip = (equipment > 1)
- area.power_environ = (environ > 1)
- if(lighting)
- emergency_power = TRUE
- if(emergency_power_timer)
- deltimer(emergency_power_timer)
- emergency_power_timer = null
- else
- emergency_power_timer = addtimer(CALLBACK(src, PROC_REF(turn_emergency_power_off)), 10 MINUTES, TIMER_UNIQUE|TIMER_STOPPABLE)
-// if(area.name == "AI Chamber")
-// spawn(10)
-// to_chat(world, " [area.name] [area.power_equip]")
- else
- area.power_light = 0
- area.power_equip = 0
- area.power_environ = 0
- emergency_power_timer = addtimer(CALLBACK(src, PROC_REF(turn_emergency_power_off)), 10 MINUTES, TIMER_UNIQUE|TIMER_STOPPABLE)
-// if(area.name == "AI Chamber")
-// to_chat(world, "[area.power_equip]")
- area.power_change()
-
-/obj/machinery/power/apc/proc/turn_emergency_power_off()
- emergency_power = FALSE
- for(var/obj/machinery/light/L in area)
- INVOKE_ASYNC(L, TYPE_PROC_REF(/obj/machinery/light, update), FALSE)
-
-/obj/machinery/power/apc/proc/can_use(mob/user, loud = 0) //used by attack_hand() and Topic()
- if(user.can_admin_interact())
- return 1
-
- autoflag = 5
- if(issilicon(user))
- var/mob/living/silicon/ai/AI = user
- var/mob/living/silicon/robot/robot = user
- if( \
- aidisabled || \
- malfhack && istype(malfai) && \
- ( \
- (istype(AI) && (malfai!=AI && malfai != AI.parent)) || \
- (istype(robot) && (robot in malfai.connected_robots)) \
- ) \
- )
- if(!loud)
- to_chat(user, "\The [src] has AI control disabled!")
- return FALSE
- else
- if((!in_range(src, user) || !isturf(loc)))
- return FALSE
-
- var/mob/living/carbon/human/H = user
- if(istype(H))
- if(H.getBrainLoss() >= 60)
- for(var/mob/M in viewers(src, null))
- to_chat(M, "[H] stares cluelessly at [src] and drools.")
- return FALSE
- else if(prob(H.getBrainLoss()))
- to_chat(user, "You momentarily forget how to use [src].")
- return FALSE
- return TRUE
-
-/obj/machinery/power/apc/proc/is_authenticated(mob/user as mob)
- if(user.can_admin_interact())
- return 1
- if(isAI(user) || isrobot(user))
- return 1
- else
- return !locked
-
-/obj/machinery/power/apc/proc/is_locked(mob/user as mob)
- if(user.can_admin_interact())
- return 0
- if(isAI(user) || isrobot(user))
- return 0
- else
- return locked
-
-/obj/machinery/power/apc/ui_act(action, params)
- if(..() || !can_use(usr, TRUE) || (locked && !usr.has_unlimited_silicon_privilege && (action != "toggle_nightshift") && !usr.can_admin_interact()))
- return
- . = TRUE
- switch(action)
- if("lock")
- if(usr.has_unlimited_silicon_privilege)
- if(emagged || stat & BROKEN)
- to_chat(usr, "The APC does not respond to the command!")
- return FALSE
- else
- locked = !locked
- update_icon()
- else
- to_chat(usr, "Access Denied!")
- return FALSE
- if("cover")
- coverlocked = !coverlocked
- if("breaker")
- toggle_breaker(usr)
- if("toggle_nightshift")
- if(last_nightshift_switch > world.time + 100) // don't spam...
- to_chat(usr, "[src]'s night lighting circuit breaker is still cycling!")
- return FALSE
- last_nightshift_switch = world.time
- set_nightshift(!nightshift_lights)
- if("charge")
- chargemode = !chargemode
- if("channel")
- if(params["eqp"])
- equipment = setsubsystem(text2num(params["eqp"]))
- update_icon()
- update()
- else if(params["lgt"])
- lighting = setsubsystem(text2num(params["lgt"]))
- update_icon()
- update()
- else if(params["env"])
- environ = setsubsystem(text2num(params["env"]))
- update_icon()
- update()
- if("overload")
- if(usr.has_unlimited_silicon_privilege)
- INVOKE_ASYNC(src, TYPE_PROC_REF(/obj/machinery/power/apc, overload_lighting))
- if("hack")
- if(get_malf_status(usr))
- malfhack(usr)
- if("occupy")
- if(get_malf_status(usr))
- malfoccupy(usr)
- if("deoccupy")
- if(get_malf_status(usr))
- malfvacate()
- if("emergency_lighting")
- emergency_lights = !emergency_lights
- for(var/obj/machinery/light/L in area)
- INVOKE_ASYNC(L, TYPE_PROC_REF(/obj/machinery/light, update), FALSE)
- CHECK_TICK
-
-/obj/machinery/power/apc/proc/toggle_breaker()
- operating = !operating
- update()
- update_icon()
-
-/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, "This APC was only recently constructed, and is not fully linked to station systems. Hacking it would be pointless.")
- 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, "You must evacuate your current APC first!")
- return
- if(!malf.can_shunt)
- to_chat(malf, "You cannot shunt!")
- 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, "Primary core damaged, unable to return core processes.")
- 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/ion_act()
- //intended to be exactly the same as an AI malf attack
- if(!malfhack && is_station_level(z))
- if(prob(3))
- locked = TRUE
- if(cell.charge > 0)
- cell.charge = 0
- cell.corrupt()
- malfhack = TRUE
- update_icon()
- var/datum/effect_system/smoke_spread/smoke = new
- smoke.set_up(3, FALSE, loc)
- smoke.attach(src)
- smoke.start()
- do_sparks(3, 1, src)
- for(var/mob/M in viewers(src))
- M.show_message("[src] suddenly lets out a blast of smoke and some sparks!", 3, "You hear sizzling electronics.", 2)
-
-
-/obj/machinery/power/apc/surplus()
- if(terminal)
- return terminal.surplus()
- else
- return 0
-
-/obj/machinery/power/apc/add_load(amount)
- if(terminal && terminal.powernet)
- terminal.add_load(amount)
-
-/obj/machinery/power/apc/avail()
- if(terminal)
- return terminal.avail()
- else
- return 0
-
-/obj/machinery/power/apc/process()
- if(stat & (BROKEN|MAINT))
- return
- if(!area.requires_power)
- return
-
- lastused_light = area.usage(STATIC_LIGHT)
- lastused_light += area.usage(LIGHT)
- lastused_equip = area.usage(EQUIP)
- lastused_equip += area.usage(STATIC_EQUIP)
- lastused_environ = area.usage(ENVIRON)
- lastused_environ += area.usage(STATIC_ENVIRON)
- area.clear_usage()
-
- lastused_total = lastused_light + lastused_equip + lastused_environ
-
- //store states to update icon if any change
- var/last_lt = lighting
- var/last_eq = equipment
- var/last_en = environ
- var/last_ch = charging
-
- var/excess = surplus()
-
- if(!avail())
- main_status = APC_EXTERNAL_POWER_NOTCONNECTED
- else if(excess < 0)
- main_status = APC_EXTERNAL_POWER_NOENERGY
- else
- main_status = APC_EXTERNAL_POWER_GOOD
-
- if(debug)
- log_debug("Status: [main_status] - Excess: [excess] - Last Equip: [lastused_equip] - Last Light: [lastused_light] - Longterm: [longtermpower]")
-
- if(cell && !shorted)
- // draw power from cell as before to power the area
- var/cellused = min(cell.charge, GLOB.CELLRATE * lastused_total) // clamp deduction to a max, amount left in cell
- cell.use(cellused)
-
- if(excess > lastused_total) // if power excess recharge the cell
- // by the same amount just used
- cell.give(cellused)
- add_load(cellused/GLOB.CELLRATE) // add the load used to recharge the cell
-
-
- else // no excess, and not enough per-apc
- if((cell.charge/GLOB.CELLRATE + excess) >= lastused_total) // can we draw enough from cell+grid to cover last usage?
- cell.charge = min(cell.maxcharge, cell.charge + GLOB.CELLRATE * excess) //recharge with what we can
- add_load(excess) // so draw what we can from the grid
- charging = APC_NOT_CHARGING
-
- else // not enough power available to run the last tick!
- charging = APC_NOT_CHARGING
- chargecount = 0
- // This turns everything off in the case that there is still a charge left on the battery, just not enough to run the room.
- equipment = autoset(equipment, 0)
- lighting = autoset(lighting, 0)
- environ = autoset(environ, 0)
- autoflag = 0
-
-
- // Set channels depending on how much charge we have left
-
- // Allow the APC to operate as normal if the cell can charge
- if(charging != APC_NOT_CHARGING && longtermpower < 10)
- longtermpower += 1
- else if(longtermpower > -10)
- longtermpower -= 2
-
- if(cell.charge >= 1250 || longtermpower > 0) // Put most likely at the top so we don't check it last, effeciency 101
- if(autoflag != 3)
- equipment = autoset(equipment, 1)
- lighting = autoset(lighting, 1)
- environ = autoset(environ, 1)
- autoflag = 3
- if(report_power_alarm)
- area.poweralert(TRUE, src)
- else if(cell.charge < 1250 && cell.charge > 750 && longtermpower < 0) // <30%, turn off equipment
- if(autoflag != 2)
- equipment = autoset(equipment, 2)
- lighting = autoset(lighting, 1)
- environ = autoset(environ, 1)
- if(report_power_alarm)
- area.poweralert(FALSE, src)
- autoflag = 2
- else if(cell.charge < 750 && cell.charge > 10) // <15%, turn off lighting & equipment
- if((autoflag > 1 && longtermpower < 0) || (autoflag > 1 && longtermpower >= 0))
- equipment = autoset(equipment, 2)
- lighting = autoset(lighting, 2)
- environ = autoset(environ, 1)
- if(report_power_alarm)
- area.poweralert(FALSE, src)
- autoflag = 1
- else if(cell.charge <= 0) // zero charge, turn all off
- if(autoflag != 0)
- equipment = autoset(equipment, 0)
- lighting = autoset(lighting, 0)
- environ = autoset(environ, 0)
- if(report_power_alarm)
- area.poweralert(FALSE, src)
- autoflag = 0
-
- // now trickle-charge the cell
- if(chargemode && charging == APC_IS_CHARGING && operating)
- if(excess > 0) // check to make sure we have enough to charge
- // Max charge is capped to % per second constant
- var/ch = min(excess*GLOB.CELLRATE, cell.maxcharge*GLOB.CHARGELEVEL)
- add_load(ch/GLOB.CELLRATE) // Removes the power we're taking from the grid
- cell.give(ch) // actually recharge the cell
-
- else
- charging = APC_NOT_CHARGING // stop charging
- chargecount = 0
-
- // show cell as fully charged if so
- if(cell.charge >= cell.maxcharge)
- cell.charge = cell.maxcharge
- charging = APC_FULLY_CHARGED
-
- if(chargemode)
- if(charging == APC_NOT_CHARGING)
- if(excess > cell.maxcharge*GLOB.CHARGELEVEL)
- chargecount++
- else
- chargecount = 0
-
- if(chargecount == 10)
-
- chargecount = 0
- charging = APC_IS_CHARGING
-
- else // chargemode off
- charging = APC_NOT_CHARGING
- chargecount = 0
-
- if(excess >= 2500000 && !shock_proof)
- var/shock_chance = 5 // 5%
- if(excess >= 7500000)
- shock_chance = 15
- else if(excess >= 5000000)
- shock_chance = 10
- if(prob(shock_chance))
- var/list/shock_mobs = list()
- for(var/C in view(get_turf(src), 5)) //We only want to shock a single random mob in range, not every one.
- if(isliving(C))
- shock_mobs += C
- if(shock_mobs.len)
- var/mob/living/L = pick(shock_mobs)
- L.electrocute_act(rand(5, 25), "electrical arc")
- playsound(get_turf(L), 'sound/effects/eleczap.ogg', 75, TRUE)
- Beam(L, icon_state = "lightning[rand(1, 12)]", icon = 'icons/effects/effects.dmi', time = 5)
-
- else // no cell, switch everything off
-
- charging = APC_NOT_CHARGING
- chargecount = 0
- equipment = autoset(equipment, 0)
- lighting = autoset(lighting, 0)
- environ = autoset(environ, 0)
- if(report_power_alarm)
- area.poweralert(FALSE, src)
- autoflag = 0
-
- // update icon & area power if anything changed
-
- if(last_lt != lighting || last_eq != equipment || last_en != environ)
- queue_icon_update()
- update()
- else if(last_ch != charging)
- queue_icon_update()
-
- if(prob(MACHINE_FLICKER_CHANCE))
- flicker()
-
- // lights don't have their own processing loop, so APCs 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 area)
- lights += L
-
- if(lights.len > 0)
- var/obj/machinery/light/picked_light = pick(lights)
- ASSERT(istype(picked_light))
- picked_light.flicker()
-
-
-/obj/machinery/power/apc/proc/autoset(val, on)
- if(on==0)
- if(val==2) // if on, return off
- return 0
- else if(val==3) // if auto-on, return auto-off
- return 1
-
- else if(on==1)
- if(val==1) // if auto-off, return auto-on
- return 3
-
- else if(on==2)
- if(val==3) // if auto-on, return auto-off
- return 1
-
- return val
-
-// damage and destruction acts
-
-/obj/machinery/power/apc/emp_act(severity)
- if(cell)
- cell.emp_act(severity)
- if(occupier)
- occupier.emp_act(severity)
- lighting = 0
- equipment = 0
- environ = 0
- update_icon()
- update()
- spawn(600)
- equipment = 3
- environ = 3
- update_icon()
- update()
- ..()
-
-/obj/machinery/power/apc/ex_act(severity)
- ..()
- if(severity < EXPLODE_LIGHT)
- power_destroy()
-
-/obj/machinery/power/apc/zap_act(power, zap_flags)
- . = ..()
- power_destroy()
-
-/obj/machinery/power/apc/proc/power_destroy() // Caused only by explosions and teslas, not for deconstruction
- if(obj_integrity > integrity_failure || opened != APC_COVER_OFF)
- return
- var/drop_loc = drop_location()
- new /obj/item/stack/sheet/metal(drop_loc, 3) // Metal from the frame
- new /obj/item/stack/cable_coil(drop_loc, 10) // wiring from the terminal and the APC, some lost due to explosion
- QDEL_NULL(terminal) // We don't want floating terminals
- qdel(src)
-
-/obj/machinery/power/apc/blob_act(obj/structure/blob/B)
- set_broken()
-
-/obj/machinery/power/apc/disconnect_terminal()
- if(terminal)
- terminal.master = null
- terminal = null
-
-/obj/machinery/power/apc/proc/set_broken()
- stat |= BROKEN
- operating = FALSE
- if(occupier)
- malfvacate(1)
- update_icon()
- update()
-
-// overload all the lights in this APC area
-
-/obj/machinery/power/apc/proc/overload_lighting(chance = 100)
- if(!operating || shorted)
- return
- if(cell && cell.charge >= 20)
- cell.use(20)
- for(var/obj/machinery/light/L in area)
- if(prob(chance))
- L.break_light_tube(0, 1)
- stoplag()
-
-/obj/machinery/power/apc/proc/null_charge()
- for(var/obj/machinery/light/L in area)
- L.break_light_tube(0, 1)
- stoplag()
-
-/obj/machinery/power/apc/proc/setsubsystem(val)
- if(cell && cell.charge > 0)
- return (val==1) ? 0 : val
- else if(val == 3)
- return 1
- else
- return 0
-
-/obj/machinery/power/apc/proc/set_nightshift(on)
- set waitfor = FALSE
- nightshift_lights = on
- for(var/obj/machinery/light/L in area)
- if(L.nightshift_allowed)
- L.nightshift_enabled = nightshift_lights
- L.update(FALSE, play_sound = FALSE)
- CHECK_TICK
-
-/obj/machinery/power/apc/proc/relock_callback()
- locked = TRUE
- updateDialog()
-
-/obj/machinery/power/apc/proc/check_main_power_callback()
- if(!wires.is_cut(WIRE_MAIN_POWER1) && !wires.is_cut(WIRE_MAIN_POWER2))
- shorted = FALSE
- updateDialog()
-
-/obj/machinery/power/apc/proc/check_ai_control_callback()
- if(!wires.is_cut(WIRE_AI_CONTROL))
- aidisabled = FALSE
- updateDialog()
-
-/obj/machinery/power/apc/proc/repair_apc()
- if(wires)
- wires.repair()
- if(!operating)
- toggle_breaker()
- if(shorted)
- shorted = FALSE
-
-/obj/machinery/power/apc/proc/recharge_apc()
- var/obj/item/stock_parts/cell/C = get_cell()
- if(C)
- C.charge = C.maxcharge
-
-#undef APC_UPDATE_ICON_COOLDOWN
-#undef APC_EXTERNAL_POWER_NOTCONNECTED
-#undef APC_EXTERNAL_POWER_NOENERGY
-#undef APC_EXTERNAL_POWER_GOOD
diff --git a/code/modules/power/apc/apc.dm b/code/modules/power/apc/apc.dm
new file mode 100644
index 00000000000..7ca7a3ba856
--- /dev/null
+++ b/code/modules/power/apc/apc.dm
@@ -0,0 +1,1063 @@
+// main_status var
+#define APC_EXTERNAL_POWER_NOTCONNECTED 0
+#define APC_EXTERNAL_POWER_NOENERGY 1
+#define APC_EXTERNAL_POWER_GOOD 2
+
+//opened
+#define APC_CLOSED 0
+#define APC_OPENED 1
+#define APC_COVER_OFF 2
+
+#define APC_AUTOFLAG_ALL_OFF 0
+#define APC_AUTOFLAG_ENVIRO_ONLY 1
+#define APC_AUTOFLAG_EQUIPMENT_OFF 2
+#define APC_AUTOFLAG_ALL_ON 3
+
+//electronics_state
+#define APC_ELECTRONICS_NONE 0
+#define APC_ELECTRONICS_INSTALLED 1
+#define APC_ELECTRONICS_SECURED 2
+
+/// Power channel is off, anything connected to it is not powered, cannot be set manually by players
+#define CHANNEL_SETTING_OFF 0
+/// APC power channel Setting Off, if set while apc is "on" set apc to "off" otherwise set to "auto-off"
+#define CHANNEL_SETTING_AUTO_OFF 1
+/// APC power channel setting on,
+#define CHANNEL_SETTING_ON 2 //on
+// APC user setting,
+#define CHANNEL_SETTING_AUTO_ON 3 //auto
+
+// the Area Power Controller (APC), formerly Power Distribution Unit (PDU)
+// one per area, needs wire conection to power network through a terminal
+
+// controls power to devices in that area
+// may be opened to change power cell
+// three different channels (lighting/equipment/environ) - may each be set to on, off, or auto
+
+/obj/machinery/power/apc
+ name = "area power controller"
+ desc = "A control terminal for the area electrical systems."
+ icon_state = "apc0"
+ max_integrity = 200
+ integrity_failure = 50
+ resistance_flags = FIRE_PROOF
+ req_access = list(ACCESS_ENGINE_EQUIP)
+ siemens_strength = 1
+ damage_deflection = 10
+ move_resist = INFINITY
+
+ // set so that APCs aren't found as powernet nodes //Hackish, Horrible, was like this before I changed it :(
+ powernet = 0
+
+ /*** APC Area/Powernet vars ***/
+ /// the area that this APC is in
+ var/area/apc_area
+ /// the set string name of the area, used in naming the APC
+ var/areastring = null
+ /// The power terminal connected to this APC
+ var/obj/machinery/power/terminal/terminal = null
+ /// The status of the terminals powernet that this APC is connected to: not connected, no power, or recieving power
+ var/main_status = APC_EXTERNAL_POWER_NOTCONNECTED
+
+ /// amount of power used in the last cycle for lighting channel
+ var/last_used_lighting = 0
+ /// amount of power used in the last cycle for equipment channel
+ var/last_used_equipment = 0
+ /// amount of power used in the last cycle for environment channel
+ var/last_used_environment = 0
+ /// amount of power used in the last cycle in total
+ var/last_used_total = 0
+
+ /*** APC Cell Vars ***/
+ /// the cell type stored in this APC
+ var/obj/item/stock_parts/cell/cell
+ /// the percentage charge the internal battery will start with
+ var/start_charge = 90
+ /// Base cell has 2500 capacity. Enter the path of a different cell you want to use. cell determines charge rates, max capacity, ect. These can also be changed with other APC vars, but isn't recommended to minimize the risk of accidental usage of dirty editted APCs
+ var/cell_type = 2500
+
+ /*** APC Status Vars ***/
+ /// The wire panel associated with this APC
+ var/datum/wires/apc/wires = null
+ /// Can the APC recieve/transmit power? Determined by the condition of the 2 Main Power Wires
+ var/shorted = FALSE
+ /// Is the APC on and transmitting power to enabled breakers? Think of this var as the master breaker for the APC
+ var/operating = TRUE
+ /// The current charging mode of the APC: not charging, charging, fully charged
+ var/charging = APC_NOT_CHARGING
+ /// A counter var used to help determine if the APC has not been charging long enough to justify not performing certain auto setting such as turning all channels back on
+ var/longtermpower = 10
+ /// State of the APC Cover - Closed, Open, or Off
+ var/opened = APC_CLOSED
+ /// Can silicons access this APC?
+ var/aidisabled = FALSE
+ var/electronics_state = APC_ELECTRONICS_NONE
+
+ /*** APC Settings Vars ***/
+ /// The current setting for the lighting channel
+ var/lighting_channel = CHANNEL_SETTING_AUTO_ON
+ /// The current setting for the equipment channel
+ var/equipment_channel = CHANNEL_SETTING_AUTO_ON
+ /// The current setting for the environment channel
+ var/environment_channel = CHANNEL_SETTING_AUTO_ON
+ /// Is the APC cover locked? i.e cannot be opened?
+ var/coverlocked = TRUE
+ /// Is the APC User Interface locked (prevents interaction)? Will not prevent silicons or admin observers from interacting
+ var/locked = TRUE
+ /// If TRUE, the APC will automatically draw power from connect terminal, if FALSE it will not charge
+ var/chargemode = TRUE
+ /// Counter var, ticks up when the APC recieves power from terminal and resets to 0 when not charging, used for the `var/charging` var
+ var/chargecount = 0
+ var/report_power_alarm = TRUE
+
+ var/shock_proof = FALSE //if set to FALSE, this APC will not arc bolts of electricity if it's overloaded.
+
+ // Nightshift
+ var/nightshift_lights = FALSE
+ var/last_nightshift_switch = 0
+
+ /// Used to determine if emergency lights should be on or off
+ var/emergency_power = TRUE
+ var/emergency_power_timer
+ var/emergency_lights = FALSE
+
+ /// settings variable for having the APC auto use certain power channel settings
+ var/autoflag = APC_AUTOFLAG_ALL_OFF // 0 = off, 1= eqp and lights off, 2 = eqp off, 3 = all on.
+
+ /*** APC Malf AI Vars ****/
+ var/malfhack = FALSE //New var for my changes to AI malf. --NeoFite
+ var/mob/living/silicon/ai/malfai = null //See above --NeoFite
+ var/mob/living/silicon/ai/occupier = null
+ /// Was this APC built instead of already existing? Used for malfhack to keep borgs from building apcs in space
+ var/constructed = FALSE
+ var/overload = 1 //used for the Blackout malf module
+
+ /*** APC Overlay Vars ***/
+ var/update_state = -1
+ var/update_overlay = -1
+ var/global/status_overlays = FALSE
+ var/updating_icon = FALSE
+ var/global/list/status_overlays_lock
+ var/global/list/status_overlays_charging
+ var/global/list/status_overlays_equipment
+ var/global/list/status_overlays_lighting
+ var/global/list/status_overlays_environ
+ var/keep_preset_name = FALSE
+
+/obj/machinery/power/apc/New(turf/loc, direction, building = 0)
+ if(!armor)
+ armor = list(MELEE = 20, BULLET = 20, LASER = 10, ENERGY = 100, BOMB = 30, BIO = 100, RAD = 100, FIRE = 90, ACID = 50)
+ ..()
+ GLOB.apcs += src
+ GLOB.apcs = sortAtom(GLOB.apcs)
+
+ wires = new(src)
+
+ if(building)
+ // Offset 24 pixels in direction of dir. This allows the APC to be embedded in a wall, yet still inside an area
+ setDir(direction) // This is only used for pixel offsets, and later terminal placement. APC dir doesn't affect its sprite since it only has one orientation.
+ set_pixel_offsets_from_dir(24, -24, 24, -24)
+
+ apc_area = get_area(src)
+ apc_area.apc |= src
+ opened = APC_OPENED
+ operating = FALSE
+ name = "[apc_area.name] APC"
+ stat |= MAINT
+ constructed = TRUE
+ update_icon()
+ addtimer(CALLBACK(src, PROC_REF(update)), 5)
+
+/obj/machinery/power/apc/Destroy()
+ SStgui.close_uis(wires)
+ GLOB.apcs -= src
+
+ machine_powernet.set_power_channel(PW_CHANNEL_LIGHTING, FALSE)
+ machine_powernet.set_power_channel(PW_CHANNEL_EQUIPMENT, FALSE)
+ machine_powernet.set_power_channel(PW_CHANNEL_LIGHTING, FALSE)
+ machine_powernet.power_change()
+ if(occupier)
+ malfvacate(1)
+ QDEL_NULL(wires)
+ QDEL_NULL(cell)
+ if(terminal)
+ disconnect_terminal()
+ machine_powernet.powernet_apc = null
+ return ..()
+
+
+
+/obj/machinery/power/apc/Initialize(mapload)
+ . = ..()
+ if(!mapload)
+ return
+ electronics_state = APC_ELECTRONICS_SECURED
+ // is starting with a power cell installed, create it and set its charge level
+ if(cell_type)
+ cell = new /obj/item/stock_parts/cell/upgraded(src)
+ cell.maxcharge = cell_type // cell_type is maximum charge (old default was 1000 or 2500 (values one and two respectively)
+ cell.charge = start_charge * cell.maxcharge / 100 // (convert percentage to actual value)
+
+ var/area/A = get_area(src)
+
+
+ //if area isn't specified use current
+ if(keep_preset_name)
+ if(isarea(A))
+ apc_area = A
+ // no-op, keep the name
+ else if(isarea(A) && !areastring)
+ apc_area = A
+ name = "\improper [apc_area.name] APC"
+ else
+ name = "\improper [get_area_name(apc_area, TRUE)] APC"
+ apc_area.apc |= src
+
+ update_icon()
+
+ make_terminal()
+
+ set_light(1, LIGHTING_MINIMUM_POWER)
+
+ addtimer(CALLBACK(src, PROC_REF(update)), 5)
+
+/obj/machinery/power/apc/examine(mob/user)
+ . = ..()
+ if(in_range(user, src))
+ if(stat & BROKEN)
+ return
+ if(opened)
+ if(has_electronics() && terminal)
+ . += "The cover is [opened == APC_OPENED ? "removed" : "open"] and the power cell is [ cell ? "installed" : "missing"]."
+ else if(!has_electronics() && terminal)
+ . += "There are some wires but no electronics."
+ else if(has_electronics() && !terminal)
+ . += "Electronics installed but not wired."
+ else /* if(!has_electronics() && !terminal) */
+ . += "There are no electronics nor connected wires."
+ else
+ if(stat & MAINT)
+ . += "The cover is closed. Something wrong with it: it doesn't work."
+ else if(malfhack)
+ . += "The cover is broken. It may be hard to force it open."
+ else
+ . += "The cover is closed."
+
+/obj/machinery/power/apc/detailed_examine()
+ return "An APC (Area Power Controller) regulates and supplies backup power for the area they are in. Their power channels are divided \
+ out into 'environmental' (Items that manipulate airflow and temperature), 'lighting' (the lights), and 'equipment' (Everything else that consumes power). \
+ Power consumption and backup power cell charge can be seen from the interface, further controls (turning a specific channel on, off or automatic, \
+ toggling the APC's ability to charge the backup cell, or toggling power for the entire area via master breaker) first requires the interface to be unlocked \
+ with an ID with Engineering access or by one of the station's robots or the artificial intelligence."
+
+/obj/machinery/power/apc/detailed_examine_antag()
+ return "This can be emagged to unlock it. It will cause the APC to have a blue error screen. \
+ Wires can be pulsed remotely with a signaler attached to it. A powersink will also drain any APCs connected to the same wire the powersink is on."
+
+//attack with an item - open/close cover, insert cell, or (un)lock interface
+/obj/machinery/power/apc/attackby(obj/item/W, mob/living/user, params)
+
+ if(issilicon(user) && get_dist(src, user) > 1)
+ return attack_hand(user)
+
+ else if(istype(W, /obj/item/stock_parts/cell) && opened) // trying to put a cell inside
+ if(cell)
+ to_chat(user, "There is a power cell already installed!")
+ return
+ else
+ if(stat & MAINT)
+ to_chat(user, "There is no connector for your power cell!")
+ return
+ if(!user.drop_item())
+ return
+ W.forceMove(src)
+ cell = W
+ user.visible_message(\
+ "[user.name] has inserted the power cell to [name]!",\
+ "You insert the power cell.")
+ chargecount = 0
+ update_icon()
+
+ else if(W.GetID()) // trying to unlock the interface with an ID card
+ togglelock(user)
+
+ else if(istype(W, /obj/item/stack/cable_coil) && opened)
+ var/turf/host_turf = get_turf(src)
+ if(!host_turf)
+ throw EXCEPTION("attackby on APC when it's not on a turf")
+ return
+ if(host_turf.intact)
+ to_chat(user, "You must remove the floor plating in front of the APC first!")
+ return
+ else if(terminal) // it already have terminal
+ to_chat(user, "This APC is already wired!")
+ return
+ else if(!has_electronics())
+ to_chat(user, "There is nothing to wire!")
+ return
+
+ var/obj/item/stack/cable_coil/C = W
+ if(C.get_amount() < 10)
+ to_chat(user, "You need ten lengths of cable for APC!")
+ return
+ user.visible_message("[user.name] adds cables to the APC frame.", \
+ "You start adding cables to the APC frame...")
+ playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE)
+ if(do_after(user, 20, target = src))
+ if(C.get_amount() < 10 || !C)
+ return
+ if(C.get_amount() >= 10 && !terminal && opened && has_electronics())
+ var/turf/T = get_turf(src)
+ var/obj/structure/cable/N = T.get_cable_node()
+ if(prob(50) && electrocute_mob(usr, N, N, 1, TRUE))
+ do_sparks(5, TRUE, src)
+ return
+ C.use(10)
+ to_chat(user, "You add cables to the APC frame.")
+ make_terminal()
+ terminal.connect_to_network()
+
+ else if(istype(W, /obj/item/apc_electronics) && opened)
+ if(has_electronics()) // there are already electronicks inside
+ to_chat(user, "You cannot put the board inside, there already is one!")
+ return
+ else if(stat & BROKEN)
+ to_chat(user, "You cannot put the board inside, the frame is damaged!")
+ return
+
+ user.visible_message("[user.name] inserts [W] into [src].", \
+ "You start to insert [W] into the frame...")
+ playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE)
+ if(do_after(user, 10, target = src))
+ if(!has_electronics())
+ electronics_state = APC_ELECTRONICS_INSTALLED
+ locked = FALSE
+ to_chat(user, "You place [W] inside the frame.")
+ qdel(W)
+
+ else if(istype(W, /obj/item/mounted/frame/apc_frame) && opened)
+ if(!(stat & BROKEN || opened == APC_COVER_OFF || obj_integrity < max_integrity)) // There is nothing to repair
+ to_chat(user, "You found no reason for repairing this APC")
+ return
+ if(!(stat & BROKEN) && opened == APC_COVER_OFF) // Cover is the only thing broken, we do not need to remove elctronicks to replace cover
+ user.visible_message("[user.name] replaces missing APC's cover.",\
+ "You begin to replace APC's cover...")
+ if(do_after(user, 20, target = src)) // replacing cover is quicker than replacing whole frame
+ to_chat(user, "You replace missing APC's cover.")
+ qdel(W)
+ opened = APC_OPENED
+ update_icon()
+ return
+ if(has_electronics())
+ to_chat(user, "You cannot repair this APC until you remove the electronics still inside!")
+ return
+ user.visible_message("[user.name] replaces the damaged APC frame with a new one.",\
+ "You begin to replace the damaged APC frame...")
+ if(do_after(user, 50, target = src))
+ to_chat(user, "You replace the damaged APC frame with a new one.")
+ qdel(W)
+ stat &= ~BROKEN
+ obj_integrity = max_integrity
+ if(opened == APC_COVER_OFF)
+ opened = APC_OPENED
+ update_icon()
+ return
+ else
+ return ..()
+
+/obj/machinery/power/apc/run_obj_armor(damage_amount, damage_type, damage_flag = 0, attack_dir)
+ if(stat & BROKEN)
+ return damage_amount
+ . = ..()
+
+/obj/machinery/power/apc/obj_break(damage_flag)
+ if(!(flags & NODECONSTRUCT))
+ set_broken()
+
+// attack with hand - remove cell (if cover open) or interact with the APC
+/obj/machinery/power/apc/attack_hand(mob/user)
+ if(!user)
+ return
+ add_fingerprint(user)
+
+ if(usr == user && opened && !issilicon(user))
+ if(cell)
+ user.visible_message("[user.name] removes [cell] from [src]!", "You remove [cell].")
+ user.put_in_hands(cell)
+ cell.add_fingerprint(user)
+ cell.update_icon(UPDATE_OVERLAYS)
+ cell = null
+ charging = APC_NOT_CHARGING
+ update_icon()
+ return
+ if(stat & (BROKEN|MAINT))
+ return
+
+ interact(user)
+
+/obj/machinery/power/apc/attack_ghost(mob/user)
+ if(panel_open)
+ wires.Interact(user)
+ return ui_interact(user)
+
+/obj/machinery/power/apc/interact(mob/user)
+ if(!user)
+ return
+
+ if(panel_open)
+ wires.Interact(user)
+
+ return ui_interact(user)
+
+/obj/machinery/power/apc/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
+ ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
+ if(!ui)
+ ui = new(user, src, ui_key, "APC", name, 510, 460, master_ui, state)
+ ui.open()
+
+/obj/machinery/power/apc/ui_data(mob/user)
+ var/list/data = list()
+ data["locked"] = is_locked(user)
+ data["normallyLocked"] = locked
+ data["isOperating"] = operating
+ data["externalPower"] = main_status
+ data["powerCellStatus"] = cell ? cell.percent() : null
+ data["chargeMode"] = chargemode
+ data["chargingStatus"] = charging
+ data["totalLoad"] = round(last_used_equipment + last_used_lighting + last_used_environment)
+ data["coverLocked"] = coverlocked
+ data["siliconUser"] = issilicon(user)
+ data["siliconLock"] = locked
+ data["malfStatus"] = get_malf_status(user)
+ data["nightshiftLights"] = nightshift_lights
+ data["emergencyLights"] = !emergency_lights
+
+ var/list/power_channels = list()
+ power_channels += list(list(
+ "title" = "Equipment",
+ "powerLoad" = round(last_used_equipment),
+ "status" = equipment_channel,
+ "topicParams" = list(
+ "auto" = list("eqp" = 3),
+ "on" = list("eqp" = 2),
+ "off" = list("eqp" = 1)
+ )
+ ))
+ power_channels += list(list(
+ "title" = "Lighting",
+ "powerLoad" = round(last_used_lighting),
+ "status" = lighting_channel,
+ "topicParams" = list(
+ "auto" = list("lgt" = 3),
+ "on" = list("lgt" = 2),
+ "off" = list("lgt" = 1)
+ )
+ ))
+ power_channels += list(list(
+ "title" = "Environment",
+ "powerLoad" = round(last_used_environment),
+ "status" = environment_channel,
+ "topicParams" = list(
+ "auto" = list("env" = 3),
+ "on" = list("env" = 2),
+ "off" = list("env" = 1)
+ )
+ ))
+
+ data["powerChannels"] = power_channels
+
+ return data
+
+/obj/machinery/power/apc/proc/update()
+ if(operating && !shorted)
+ machine_powernet.set_power_channel(PW_CHANNEL_LIGHTING, (lighting_channel > CHANNEL_SETTING_AUTO_OFF))
+ machine_powernet.set_power_channel(PW_CHANNEL_EQUIPMENT, (equipment_channel > CHANNEL_SETTING_AUTO_OFF))
+ machine_powernet.set_power_channel(PW_CHANNEL_ENVIRONMENT, (environment_channel > CHANNEL_SETTING_AUTO_OFF))
+ if(lighting_channel)
+ emergency_power = TRUE
+ if(emergency_power_timer)
+ deltimer(emergency_power_timer)
+ emergency_power_timer = null
+ else
+ emergency_power_timer = addtimer(CALLBACK(src, PROC_REF(turn_emergency_power_off)), 10 MINUTES, TIMER_UNIQUE|TIMER_STOPPABLE)
+ else
+ machine_powernet.set_power_channel(PW_CHANNEL_LIGHTING, FALSE)
+ machine_powernet.set_power_channel(PW_CHANNEL_EQUIPMENT, FALSE)
+ machine_powernet.set_power_channel(PW_CHANNEL_ENVIRONMENT, FALSE)
+ emergency_power_timer = addtimer(CALLBACK(src, PROC_REF(turn_emergency_power_off)), 10 MINUTES, TIMER_UNIQUE|TIMER_STOPPABLE)
+ machine_powernet.power_change()
+
+/obj/machinery/power/apc/proc/can_use(mob/user, loud = 0) //used by attack_hand() and Topic()
+ if(user.can_admin_interact())
+ return TRUE
+
+ autoflag = 5 //why the hell is this being set to 5, fucking malf code -sirryan
+ if(issilicon(user))
+ var/mob/living/silicon/ai/AI = user
+ var/mob/living/silicon/robot/robot = user
+ if(aidisabled || malfhack && istype(malfai))
+ if((istype(AI) && (malfai!=AI && malfai != AI.parent)) || (istype(robot) && (robot in malfai.connected_robots)))
+ if(!loud)
+ to_chat(user, "\The [src] has AI control disabled!")
+ return FALSE
+ else
+ if((!in_range(src, user) || !isturf(loc)))
+ return FALSE
+
+ var/mob/living/carbon/human/H = user
+ if(istype(H))
+ if(H.getBrainLoss() >= 60)
+ for(var/mob/M in viewers(src, null))
+ to_chat(M, "[H] stares cluelessly at [src] and drools.")
+ return FALSE
+ else if(prob(H.getBrainLoss()))
+ to_chat(user, "You momentarily forget how to use [src].")
+ return FALSE
+ return TRUE
+
+/obj/machinery/power/apc/proc/is_authenticated(mob/user as mob)
+ if(user.can_admin_interact())
+ return TRUE
+ if(isAI(user) || isrobot(user))
+ return TRUE
+ else
+ return !locked
+
+/obj/machinery/power/apc/proc/is_locked(mob/user as mob)
+ if(user.can_admin_interact())
+ return FALSE
+ if(isAI(user) || isrobot(user))
+ return FALSE
+ else
+ return locked
+
+/obj/machinery/power/apc/ui_act(action, params, datum/tgui/ui)
+ var/mob/user = ui.user
+ if(..() || !can_use(user, TRUE) || (locked && !user.has_unlimited_silicon_privilege && (action != "toggle_nightshift") && !user.can_admin_interact()))
+ return
+ . = TRUE
+ switch(action)
+ if("lock")
+ if(user.has_unlimited_silicon_privilege)
+ if(emagged || stat & BROKEN)
+ to_chat(user, "The APC does not respond to the command!")
+ return FALSE
+ else
+ locked = !locked
+ update_icon()
+ else
+ to_chat(user, "Access Denied!")
+ return FALSE
+ if("cover")
+ coverlocked = !coverlocked
+ if("breaker")
+ toggle_breaker(user)
+ if("toggle_nightshift")
+ if(last_nightshift_switch > world.time + 100) // don't spam...
+ to_chat(user, "[src]'s night lighting circuit breaker is still cycling!")
+ return FALSE
+ last_nightshift_switch = world.time
+ set_nightshift(!nightshift_lights)
+ if("charge")
+ chargemode = !chargemode
+ if("channel")
+ if(params["eqp"])
+ equipment_channel = setsubsystem(text2num(params["eqp"]))
+ update_icon()
+ update()
+ else if(params["lgt"])
+ lighting_channel = setsubsystem(text2num(params["lgt"]))
+ update_icon()
+ update()
+ else if(params["env"])
+ environment_channel = setsubsystem(text2num(params["env"]))
+ update_icon()
+ update()
+ if("overload")
+ if(user.has_unlimited_silicon_privilege)
+ INVOKE_ASYNC(src, PROC_REF(overload_lighting))
+ if("hack")
+ if(get_malf_status(user))
+ malfhack(user)
+ if("occupy")
+ if(get_malf_status(user))
+ malfoccupy(usr)
+ if("deoccupy")
+ if(get_malf_status(user))
+ malfvacate()
+ if("emergency_lighting")
+ emergency_lights = !emergency_lights
+ for(var/obj/machinery/light/L in apc_area)
+ INVOKE_ASYNC(L, TYPE_PROC_REF(/obj/machinery/light, update), FALSE)
+ CHECK_TICK
+
+/obj/machinery/power/apc/proc/update_last_used()
+ last_used_lighting = machine_powernet.get_channel_usage(PW_CHANNEL_LIGHTING)
+ last_used_equipment = machine_powernet.get_channel_usage(PW_CHANNEL_EQUIPMENT)
+ last_used_environment = machine_powernet.get_channel_usage(PW_CHANNEL_ENVIRONMENT)
+ last_used_total = machine_powernet.get_total_usage()
+ machine_powernet.clear_usage()
+
+/// What the APC will do every process interval, updates power settings and power changes depending on powernet state
+/obj/machinery/power/apc/process()
+ if(stat & (BROKEN|MAINT)) // if the APC is broken, don't even bother
+ return
+ if(!apc_area.requires_power) // if the area doesn't use power, don't even bother
+ return
+
+ //We store the initial power channel states so we can check if they've changed at the end of the proc so we can update overlays efficiently
+ var/last_lighting_state = lighting_channel
+ var/last_equipment_state = equipment_channel
+ var/last_environment_state = environment_channel
+ var/last_charging_state = charging
+ update_last_used() // get local powernet usage and clear it for next cycle
+
+ var/excess = surplus()
+ //Now we calculate the state of the external powernet
+ if(!avail())
+ main_status = APC_EXTERNAL_POWER_NOTCONNECTED
+ else if(excess < 0)
+ main_status = APC_EXTERNAL_POWER_NOENERGY // there's more demand than supply on powernet, there's not enough power
+ else
+ main_status = APC_EXTERNAL_POWER_GOOD // there's some excess power on the powernet!
+
+ if(cell && !shorted)
+ // draw power from cell as before to power the area
+ var/cell_used = min(cell.charge, GLOB.CELLRATE * last_used_total) // clamp deduction to a max, amount left in cell
+ cell.use(cell_used)
+
+ if(excess > last_used_total) // if power excess recharge the cell by the same amount just used
+ cell.give(cell_used)
+ add_load(cell_used / GLOB.CELLRATE) // add the load used to recharge the cell
+ else // no excess, and not enough per-apc
+ if((cell.charge / GLOB.CELLRATE + excess) >= last_used_total) // can we draw enough from cell+grid to cover last usage?
+ cell.charge = min(cell.maxcharge, cell.charge + GLOB.CELLRATE * excess) //recharge with what we can
+ add_load(excess) // so draw what we can from the grid
+ charging = APC_NOT_CHARGING
+ else // not enough power available to run the last tick!
+ charging = APC_NOT_CHARGING
+ chargecount = 0
+ // This turns everything off in the case that there is still a charge left on the battery, just not enough to run the room.
+ equipment_channel = autoset(equipment_channel, CHANNEL_SETTING_OFF)
+ lighting_channel = autoset(lighting_channel, CHANNEL_SETTING_OFF)
+ environment_channel = autoset(environment_channel, CHANNEL_SETTING_OFF)
+ autoflag = APC_AUTOFLAG_ALL_OFF
+
+ // Set channels depending on how much charge we have left
+
+ // Allow the APC to operate as normal if the cell can charge
+ if(charging != APC_NOT_CHARGING && longtermpower < 10)
+ longtermpower += 1
+ else if(longtermpower > -10)
+ longtermpower -= 2
+
+ handle_autoflag()
+
+ // now trickle-charge the cell
+ if(chargemode && charging == APC_IS_CHARGING && operating)
+ if(excess > 0) // check to make sure we have enough to charge
+ // Max charge is capped to % per second constant
+ var/ch = min(excess*GLOB.CELLRATE, cell.maxcharge*GLOB.CHARGELEVEL)
+ add_load(ch/GLOB.CELLRATE) // Removes the power we're taking from the grid
+ cell.give(ch) // actually recharge the cell
+
+ else
+ charging = APC_NOT_CHARGING // stop charging
+ chargecount = 0
+
+ // show cell as fully charged if so
+ if(cell.charge >= cell.maxcharge)
+ cell.charge = cell.maxcharge
+ charging = APC_FULLY_CHARGED
+
+ if(chargemode)
+ if(charging == APC_NOT_CHARGING)
+ if(excess > cell.maxcharge * GLOB.CHARGELEVEL)
+ chargecount++
+ else
+ chargecount = 0
+
+ if(chargecount == 10)
+
+ chargecount = 0
+ charging = APC_IS_CHARGING
+
+ else // chargemode off
+ charging = APC_NOT_CHARGING
+ chargecount = 0
+
+ if(!shock_proof)
+ handle_shock_chance(excess)
+
+ else // no cell, switch everything off
+ charging = APC_NOT_CHARGING
+ chargecount = 0
+ equipment_channel = autoset(equipment_channel, CHANNEL_SETTING_OFF)
+ lighting_channel = autoset(lighting_channel, CHANNEL_SETTING_OFF)
+ environment_channel = autoset(environment_channel, CHANNEL_SETTING_OFF)
+ if(report_power_alarm)
+ apc_area.poweralert(FALSE, src)
+ autoflag = APC_AUTOFLAG_ALL_OFF
+
+ // update icon & area power if anything changed
+
+ if(last_lighting_state != lighting_channel || last_equipment_state != equipment_channel || last_environment_state != environment_channel)
+ queue_icon_update()
+ update()
+ else if(last_charging_state != charging)
+ queue_icon_update()
+
+ machine_powernet.handle_flicker() // try and flicker machines/lights in the area randomly
+
+/obj/machinery/power/apc/proc/handle_autoflag()
+ // Put most likely at the top so we don't check it last, effeciency 101 <--- old coders can't spell
+ if(cell.charge >= 1250 || longtermpower > 0)
+ if(autoflag != APC_AUTOFLAG_ALL_ON)
+ equipment_channel = autoset(equipment_channel, CHANNEL_SETTING_AUTO_OFF)
+ lighting_channel = autoset(lighting_channel, CHANNEL_SETTING_AUTO_OFF)
+ environment_channel = autoset(environment_channel, CHANNEL_SETTING_AUTO_OFF)
+ autoflag = APC_AUTOFLAG_ALL_ON
+ if(report_power_alarm)
+ apc_area.poweralert(TRUE, src)
+ return
+ if(cell.charge < 1250 && cell.charge > 750 && longtermpower < 0) // <30%, turn off equipment
+ if(autoflag != APC_AUTOFLAG_EQUIPMENT_OFF)
+ equipment_channel = autoset(equipment_channel, CHANNEL_SETTING_ON)
+ lighting_channel = autoset(lighting_channel, CHANNEL_SETTING_AUTO_OFF)
+ environment_channel = autoset(environment_channel, CHANNEL_SETTING_AUTO_OFF)
+ if(report_power_alarm)
+ apc_area.poweralert(FALSE, src)
+ autoflag = APC_AUTOFLAG_EQUIPMENT_OFF
+ else if(cell.charge < 750 && cell.charge > 10) // <15%, turn off lighting & equipment
+ if(autoflag > APC_AUTOFLAG_ENVIRO_ONLY)
+ equipment_channel = autoset(equipment_channel, CHANNEL_SETTING_ON)
+ lighting_channel = autoset(lighting_channel, CHANNEL_SETTING_ON)
+ environment_channel = autoset(environment_channel, CHANNEL_SETTING_AUTO_OFF)
+ if(report_power_alarm)
+ apc_area.poweralert(FALSE, src)
+ autoflag = APC_AUTOFLAG_ENVIRO_ONLY
+ else if(cell.charge <= 0) // zero charge, turn all off
+ if(autoflag != APC_AUTOFLAG_ALL_OFF)
+ equipment_channel = autoset(equipment_channel, CHANNEL_SETTING_OFF)
+ lighting_channel = autoset(lighting_channel, CHANNEL_SETTING_OFF)
+ environment_channel = autoset(environment_channel, CHANNEL_SETTING_OFF)
+ if(report_power_alarm)
+ apc_area.poweralert(FALSE, src)
+ autoflag = APC_AUTOFLAG_ALL_OFF
+
+/// Handles APC arc'ing every APC process interval
+/obj/machinery/power/apc/proc/handle_shock_chance(excess = 0)
+ if(excess < 2500000)
+ return
+ var/shock_chance = 5 // 5%
+ if(excess >= 7500000)
+ shock_chance = 15
+ else if(excess >= 5000000)
+ shock_chance = 10
+ if(prob(shock_chance))
+ var/list/shock_mobs = list()
+ for(var/C in view(get_turf(src), 5)) //We only want to shock a single random mob in range, not every one.
+ if(isliving(C))
+ shock_mobs += C
+ if(length(shock_mobs))
+ var/mob/living/L = pick(shock_mobs)
+ L.electrocute_act(rand(5, 25), "electrical arc")
+ playsound(get_turf(L), 'sound/effects/eleczap.ogg', 75, TRUE)
+ Beam(L, icon_state = "lightning[rand(1, 12)]", icon = 'icons/effects/effects.dmi', time = 5)
+
+
+/// *************
+/// APC Power Procs
+/// *************
+
+/obj/machinery/power/apc/get_cell()
+ return cell
+
+/// Override because the APC does not directly connect to the network; it goes through a terminal.
+/obj/machinery/power/apc/connect_to_network()
+ terminal?.connect_to_network() //The terminal is what the power computer looks for
+
+/obj/machinery/power/apc/surplus()
+ if(terminal)
+ return terminal.surplus()
+ else
+ return 0 //not FALSE
+
+/obj/machinery/power/apc/add_load(amount)
+ if(terminal?.powernet)
+ terminal.add_load(amount)
+
+/obj/machinery/power/apc/avail()
+ if(terminal)
+ return terminal.avail()
+ else
+ return 0 //not FALSE
+
+/obj/machinery/power/apc/proc/power_destroy() // Caused only by explosions and teslas, not for deconstruction
+ if(obj_integrity > integrity_failure || opened != APC_COVER_OFF)
+ return
+ var/drop_loc = drop_location()
+ new /obj/item/stack/sheet/metal(drop_loc, 3) // Metal from the frame
+ new /obj/item/stack/cable_coil(drop_loc, 10) // wiring from the terminal and the APC, some lost due to explosion
+ QDEL_NULL(terminal) // We don't want floating terminals
+ qdel(src)
+
+/obj/machinery/power/apc/proc/make_terminal()
+ // create a terminal object at the same position as original turf loc
+ // wires will attach to this
+ terminal = new/obj/machinery/power/terminal(get_turf(src))
+ terminal.setDir(dir)
+ terminal.master = src
+
+/obj/machinery/power/apc/disconnect_terminal()
+ if(terminal)
+ terminal.master = null
+ terminal = null
+
+/// *************
+/// APC Settings
+/// *************
+
+/obj/machinery/power/apc/proc/togglelock(mob/living/user)
+ if(emagged)
+ to_chat(user, "The interface is broken!")
+ else if(opened)
+ to_chat(user, "You must close the cover to swipe an ID card!")
+ else if(panel_open)
+ to_chat(user, "You must close the panel!")
+ else if(stat & (BROKEN|MAINT))
+ to_chat(user, "Nothing happens!")
+ else
+ if(allowed(user) && !wires.is_cut(WIRE_IDSCAN) && !malfhack)
+ locked = !locked
+ to_chat(user, "You [locked ? "lock" : "unlock"] the APC interface.")
+ update_icon()
+ else
+ to_chat(user, "Access denied.")
+
+/obj/machinery/power/apc/proc/toggle_breaker()
+ operating = !operating
+ update()
+ update_icon()
+
+/**
+ * # autoset
+ *
+ * this proc is rather confusing at first glance, it handles apc power channel settings when trying to
+ * auto set values to it, good luck understanding how this works but I sure as hell don't
+*/
+/obj/machinery/power/apc/proc/autoset(current_setting, new_setting)
+ switch(new_setting)
+ if(CHANNEL_SETTING_OFF)
+ if(current_setting == CHANNEL_SETTING_ON) // if on, return off
+ return CHANNEL_SETTING_OFF
+ if(current_setting == CHANNEL_SETTING_AUTO_ON) // if auto-on, return auto-off
+ return CHANNEL_SETTING_AUTO_OFF
+ if(CHANNEL_SETTING_AUTO_OFF)
+ if(current_setting == CHANNEL_SETTING_AUTO_OFF) // if auto-off, return auto-on
+ return CHANNEL_SETTING_AUTO_ON
+ if(CHANNEL_SETTING_ON)
+ if(current_setting == CHANNEL_SETTING_AUTO_ON) // if auto-on, return auto-off
+ return CHANNEL_SETTING_AUTO_OFF
+ return current_setting //if setting is not changed, just keep current setting
+
+/obj/machinery/power/apc/proc/setsubsystem(new_setting)
+ if(cell?.charge > 1) //if there's a charge
+ if(new_setting == CHANNEL_SETTING_AUTO_OFF) //and apc now set to off, return off
+ return CHANNEL_SETTING_OFF
+ return new_setting //else return the new setting
+ if(new_setting == CHANNEL_SETTING_AUTO_ON) //if no charge and set to auto, set to auto off
+ return CHANNEL_SETTING_AUTO_OFF
+ return CHANNEL_SETTING_OFF //if set to on and no charge, set to off
+
+/// ************* ---
+/// APC Helper Procs --- Antag Abilities/Fun Stuff
+/// ************* ---
+
+/// set APC stat as broken and set it to be non operational, kick out an AI if there's a malf one in it
+/obj/machinery/power/apc/proc/set_broken()
+ stat |= BROKEN
+ operating = FALSE
+ if(occupier)
+ malfvacate(1)
+ update_icon()
+ update()
+
+/// overload all the lights in this APC area
+/obj/machinery/power/apc/proc/overload_lighting(chance = 100)
+ if(!operating || shorted)
+ return
+ if(cell && cell.charge >= 20)
+ cell.use(20)
+ for(var/obj/machinery/light/L in apc_area)
+ if(prob(chance))
+ L.break_light_tube(0, 1)
+ stoplag()
+
+/// turns off emergency power and sets each light to update
+/obj/machinery/power/apc/proc/turn_emergency_power_off()
+ emergency_power = FALSE
+ for(var/obj/machinery/light/L in apc_area)
+ INVOKE_ASYNC(L, TYPE_PROC_REF(/obj/machinery/light, update), FALSE)
+
+/// sets nightshift mode on for the APC
+/obj/machinery/power/apc/proc/set_nightshift(on)
+ set waitfor = FALSE
+ nightshift_lights = on
+ for(var/obj/machinery/light/L in apc_area)
+ if(L.nightshift_allowed)
+ L.nightshift_enabled = nightshift_lights
+ L.update(FALSE, play_sound = FALSE)
+ CHECK_TICK
+
+/obj/machinery/power/apc/proc/relock_callback()
+ locked = TRUE
+ updateDialog()
+
+/// Updates APC to not be shorted if both main power wires are mended
+/obj/machinery/power/apc/proc/check_main_power_callback()
+ if(!wires.is_cut(WIRE_MAIN_POWER1) && !wires.is_cut(WIRE_MAIN_POWER2))
+ shorted = FALSE
+ updateDialog()
+
+/// Updates APC to AI accesible if AI Wire is mended
+/obj/machinery/power/apc/proc/check_ai_control_callback()
+ if(!wires.is_cut(WIRE_AI_CONTROL))
+ aidisabled = FALSE
+ updateDialog()
+
+/// Repairs all wires, enables all breakers, and unshorts the APC
+/obj/machinery/power/apc/proc/repair_apc()
+ if(wires)
+ wires.repair()
+ if(!operating)
+ toggle_breaker()
+ if(shorted)
+ shorted = FALSE
+
+/// If the APC has a cell, recharge it
+/obj/machinery/power/apc/proc/recharge_apc()
+ var/obj/item/stock_parts/cell/C = get_cell()
+ if(C)
+ C.charge = C.maxcharge
+
+/obj/machinery/power/apc/proc/emp_callback()
+ equipment_channel = 3
+ environment_channel = 3
+ update_icon()
+ update()
+
+/// *************
+/// External Acts on the APCS
+/// *************
+
+/obj/machinery/power/apc/emp_act(severity)
+ if(cell)
+ cell.emp_act(severity)
+ if(occupier)
+ occupier.emp_act(severity)
+ lighting_channel = 0
+ equipment_channel = 0
+ environment_channel = 0
+ update_icon()
+ update()
+ addtimer(CALLBACK(src, PROC_REF(emp_callback)), 60 SECONDS)
+ ..()
+
+/obj/machinery/power/apc/blob_act(obj/structure/blob/B)
+ set_broken()
+
+/obj/machinery/power/apc/ex_act(severity)
+ ..()
+ if(severity < EXPLODE_LIGHT)
+ power_destroy()
+
+/obj/machinery/power/apc/zap_act(power, zap_flags)
+ . = ..()
+ power_destroy()
+
+/obj/machinery/power/apc/proc/ion_act()
+ //intended to be exactly the same as an AI malf attack
+ if(!malfhack && is_station_level(z))
+ if(prob(3))
+ locked = TRUE
+ if(cell.charge > 0)
+ cell.charge = 0
+ cell.corrupt()
+ malfhack = TRUE
+ update_icon()
+ var/datum/effect_system/smoke_spread/smoke = new
+ smoke.set_up(3, FALSE, loc)
+ smoke.attach(src)
+ smoke.start()
+ do_sparks(3, 1, src)
+ for(var/mob/M in viewers(src))
+ M.show_message("[src] suddenly lets out a blast of smoke and some sparks!", 3, "You hear sizzling electronics.", 2)
+
+/obj/machinery/power/apc/emag_act(user as mob)
+ if(!(emagged || malfhack)) // trying to unlock with an emag card
+ if(opened)
+ to_chat(user, "You must close the cover to swipe an ID card.")
+ else if(panel_open)
+ to_chat(user, "You must close the panel first.")
+ else if(stat & (BROKEN|MAINT))
+ to_chat(user, "Nothing happens.")
+ else
+ flick("apc-spark", src)
+ emagged = TRUE
+ locked = FALSE
+ to_chat(user, "You emag the APC interface.")
+ update_icon()
+
+/// *************
+/// APC subtypes
+/// *************
+
+/obj/machinery/power/apc/worn_out
+ name = "\improper Worn out APC"
+ keep_preset_name = TRUE
+ locked = FALSE
+ environment_channel = 0
+ equipment_channel = 0
+ lighting_channel = 0
+ operating = FALSE
+ emergency_power = FALSE
+
+/// APC type used for when you don't want the power alarm on the APC to show up on AI reports
+/obj/machinery/power/apc/off_station
+ report_power_alarm = FALSE
+
+/// APCs used for ruins, this version also starts devoid of a charge
+/obj/machinery/power/apc/off_station/empty_charge
+ start_charge = 0
+
+/obj/machinery/power/apc/syndicate //general syndicate access
+ req_access = list(ACCESS_SYNDICATE)
+ report_power_alarm = FALSE
+
+/obj/machinery/power/apc/syndicate/off
+ environment_channel = 0
+ equipment_channel = 0
+ lighting_channel = 0
+ operating = FALSE
+
+/obj/machinery/power/apc/syndicate/off/Initialize(mapload)
+ . = ..()
+ cell.charge = 0
+
+/obj/item/apc_electronics
+ name = "APC electronics"
+ desc = "Heavy-duty switching circuits for power control."
+ icon = 'icons/obj/module.dmi'
+ icon_state = "power_mod"
+ w_class = WEIGHT_CLASS_SMALL
+ origin_tech = "engineering=2;programming=1"
+ item_state = "electronic"
+ flags = CONDUCT
+ usesound = 'sound/items/deconstruct.ogg'
+ toolspeed = 1
+
+
+#undef APC_EXTERNAL_POWER_NOTCONNECTED
+#undef APC_EXTERNAL_POWER_NOENERGY
+#undef APC_EXTERNAL_POWER_GOOD
diff --git a/code/modules/power/apc/apc_construction.dm b/code/modules/power/apc/apc_construction.dm
new file mode 100644
index 00000000000..1de6d19cd78
--- /dev/null
+++ b/code/modules/power/apc/apc_construction.dm
@@ -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("The APC cover is knocked down!")
+ 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, "Disconnect the wires first!")
+ return
+ to_chat(user, "You start trying to remove the APC electronics..." )
+ 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]!",
+ "You break the charred APC electronics and remove the remains.",
+ "You hear a crack.")
+ 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]!",
+ "You discarded the shorted board.")
+ 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]!",
+ "You discarded the strangely programmed board.")
+ malfai = null
+ malfhack = FALSE
+ return
+ else
+ user.visible_message(\
+ "[user.name] has removed the APC electronics from [name]!",
+ "You remove the APC electronics.")
+ 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, "The cover is locked and cannot be opened!")
+ return
+ else if(panel_open) // wires are exposed
+ to_chat(user, "Exposed wires prevents you from opening it!")
+ 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, "Close the APC first!") //Less hints more mystery!
+ return
+ else
+ if(electronics_state == APC_ELECTRONICS_INSTALLED)
+ electronics_state = APC_ELECTRONICS_SECURED
+ stat &= ~MAINT
+ to_chat(user, "You screw the circuit electronics into place.")
+ else if(electronics_state == APC_ELECTRONICS_SECURED)
+ electronics_state = APC_ELECTRONICS_INSTALLED
+ stat |= MAINT
+ to_chat(user, "You unfasten the electronics.")
+ else
+ to_chat(user, "There is nothing to secure!")
+ return
+ update_icon()
+ else if(emagged)
+ to_chat(user, "The interface is broken!")
+ 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].",\
+ "You disassembled the broken APC frame.")
+ else
+ new /obj/item/mounted/frame/apc_frame(loc)
+ user.visible_message(\
+ "[user.name] has cut [src] from the wall with [I].",\
+ "You cut the APC frame from the wall.")
+ qdel(src)
diff --git a/code/modules/power/apc/apc_malfunction.dm b/code/modules/power/apc/apc_malfunction.dm
new file mode 100644
index 00000000000..ced656f13f6
--- /dev/null
+++ b/code/modules/power/apc/apc_malfunction.dm
@@ -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, "This APC was only recently constructed, and is not fully linked to station systems. Hacking it would be pointless.")
+ 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, "You must evacuate your current APC first!")
+ return
+ if(!malf.can_shunt)
+ to_chat(malf, "You cannot shunt!")
+ 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, "Primary core damaged, unable to return core processes.")
+ 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
diff --git a/code/modules/power/apc/apc_overlay.dm b/code/modules/power/apc/apc_overlay.dm
new file mode 100644
index 00000000000..6c1b6a2cd98
--- /dev/null
+++ b/code/modules/power/apc/apc_overlay.dm
@@ -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
diff --git a/code/modules/power/generator.dm b/code/modules/power/generator.dm
index 8f7ca7d303d..e3bfc19d839 100644
--- a/code/modules/power/generator.dm
+++ b/code/modules/power/generator.dm
@@ -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
diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm
index 8cc398aeab8..d2864672a1b 100644
--- a/code/modules/power/gravitygenerator.dm
+++ b/code/modules/power/gravitygenerator.dm
@@ -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
diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm
index d12a46a07c1..4a063414d0b 100644
--- a/code/modules/power/lighting.dm
+++ b/code/modules/power/lighting.dm
@@ -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
diff --git a/code/modules/power/port_gen.dm b/code/modules/power/port_gen.dm
index 9c51a4a2aa0..14c5d70f7c0 100644
--- a/code/modules/power/port_gen.dm
+++ b/code/modules/power/port_gen.dm
@@ -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(..())
diff --git a/code/modules/power/power.dm b/code/modules/power/power.dm
index 34e1e74febe..21bcb2af549 100644
--- a/code/modules/power/power.dm
+++ b/code/modules/power/power.dm
@@ -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
diff --git a/code/modules/power/powernets/local_powernet.dm b/code/modules/power/powernets/local_powernet.dm
new file mode 100644
index 00000000000..76c633bcdf6
--- /dev/null
+++ b/code/modules/power/powernets/local_powernet.dm
@@ -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()
diff --git a/code/modules/power/singularity/containment_field.dm b/code/modules/power/singularity/containment_field.dm
index 49193d00399..13ddaa13d9f 100644
--- a/code/modules/power/singularity/containment_field.dm
+++ b/code/modules/power/singularity/containment_field.dm
@@ -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
diff --git a/code/modules/power/singularity/emitter.dm b/code/modules/power/singularity/emitter.dm
index beaf1034315..915cab25b51 100644
--- a/code/modules/power/singularity/emitter.dm
+++ b/code/modules/power/singularity/emitter.dm
@@ -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()
diff --git a/code/modules/power/singularity/field_generator.dm b/code/modules/power/singularity/field_generator.dm
index d2648a66b73..a7f47d81cee 100644
--- a/code/modules/power/singularity/field_generator.dm
+++ b/code/modules/power/singularity/field_generator.dm
@@ -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)
diff --git a/code/modules/power/singularity/generator.dm b/code/modules/power/singularity/generator.dm
index 152b5e4f112..9c0e6a48e17 100644
--- a/code/modules/power/singularity/generator.dm
+++ b/code/modules/power/singularity/generator.dm
@@ -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
diff --git a/code/modules/power/singularity/particle_accelerator/particle_accelerator.dm b/code/modules/power/singularity/particle_accelerator/particle_accelerator.dm
index cbc34ac53c8..065c6e24485 100644
--- a/code/modules/power/singularity/particle_accelerator/particle_accelerator.dm
+++ b/code/modules/power/singularity/particle_accelerator/particle_accelerator.dm
@@ -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()
diff --git a/code/modules/power/singularity/particle_accelerator/particle_control.dm b/code/modules/power/singularity/particle_accelerator/particle_control.dm
index cdc130d8988..d0c54a21fb7 100644
--- a/code/modules/power/singularity/particle_accelerator/particle_control.dm
+++ b/code/modules/power/singularity/particle_accelerator/particle_control.dm
@@ -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
diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm
index cc14a132daa..81ac0a376b2 100644
--- a/code/modules/power/smes.dm
+++ b/code/modules/power/smes.dm
@@ -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
diff --git a/code/modules/power/solar.dm b/code/modules/power/solar.dm
index 4b29746d368..d1394edf5d2 100644
--- a/code/modules/power/solar.dm
+++ b/code/modules/power/solar.dm
@@ -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()
diff --git a/code/modules/power/tracker.dm b/code/modules/power/tracker.dm
index 684496903bc..442a9a7f386 100644
--- a/code/modules/power/tracker.dm
+++ b/code/modules/power/tracker.dm
@@ -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
diff --git a/code/modules/power/treadmill.dm b/code/modules/power/treadmill.dm
index e4f7738798c..fd41e56ac7b 100644
--- a/code/modules/power/treadmill.dm
+++ b/code/modules/power/treadmill.dm
@@ -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)
diff --git a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm
index 1502f88dd14..6804d2f03c1 100644
--- a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm
+++ b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm
@@ -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" : ""]"
diff --git a/code/modules/reagents/chemistry/machinery/chem_heater.dm b/code/modules/reagents/chemistry/machinery/chem_heater.dm
index 9c2e3af3fdc..ccac492e3d7 100644
--- a/code/modules/reagents/chemistry/machinery/chem_heater.dm
+++ b/code/modules/reagents/chemistry/machinery/chem_heater.dm
@@ -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
diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm
index 9bd1059e321..14ee31b3214 100644
--- a/code/modules/reagents/chemistry/machinery/chem_master.dm
+++ b/code/modules/reagents/chemistry/machinery/chem_master.dm
@@ -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)
diff --git a/code/modules/reagents/chemistry/machinery/pandemic.dm b/code/modules/reagents/chemistry/machinery/pandemic.dm
index 4b3597b347d..8cf36eb86f0 100644
--- a/code/modules/reagents/chemistry/machinery/pandemic.dm
+++ b/code/modules/reagents/chemistry/machinery/pandemic.dm
@@ -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()
diff --git a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm
index 19f41fa4d32..1b42275e2d2 100644
--- a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm
+++ b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm
@@ -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
diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm
index 45ae5d95c73..b6db1c6c303 100644
--- a/code/modules/recycling/conveyor2.dm
+++ b/code/modules/recycling/conveyor2.dm
@@ -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
diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm
index abac0d2f31c..ce6b46a21b5 100644
--- a/code/modules/recycling/disposal.dm
+++ b/code/modules/recycling/disposal.dm
@@ -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)
diff --git a/code/modules/research/experimentor.dm b/code/modules/research/experimentor.dm
index 3687655d2ee..65c054315de 100644
--- a/code/modules/research/experimentor.dm
+++ b/code/modules/research/experimentor.dm
@@ -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
diff --git a/code/modules/research/message_server.dm b/code/modules/research/message_server.dm
index 1fbb00c866e..5031b3b1828 100644
--- a/code/modules/research/message_server.dm
+++ b/code/modules/research/message_server.dm
@@ -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
diff --git a/code/modules/research/rdmachines.dm b/code/modules/research/rdmachines.dm
index ad09e951fae..f51b323b7a7 100644
--- a/code/modules/research/rdmachines.dm
+++ b/code/modules/research/rdmachines.dm
@@ -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
diff --git a/code/modules/research/server.dm b/code/modules/research/server.dm
index 3635c429151..00cb7e1f0cb 100644
--- a/code/modules/research/server.dm
+++ b/code/modules/research/server.dm
@@ -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()
diff --git a/code/modules/security_levels/keycard_authentication.dm b/code/modules/security_levels/keycard_authentication.dm
index e0343b2265d..45da8899c1b 100644
--- a/code/modules/security_levels/keycard_authentication.dm
+++ b/code/modules/security_levels/keycard_authentication.dm
@@ -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)
diff --git a/code/modules/security_levels/security_levels.dm b/code/modules/security_levels/security_levels.dm
index a01a6019311..7dd46cad551 100644
--- a/code/modules/security_levels/security_levels.dm
+++ b/code/modules/security_levels/security_levels.dm
@@ -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)
diff --git a/code/modules/station_goals/bluespace_tap.dm b/code/modules/station_goals/bluespace_tap.dm
index 9646a2dae18..4f15eacffd8 100644
--- a/code/modules/station_goals/bluespace_tap.dm
+++ b/code/modules/station_goals/bluespace_tap.dm
@@ -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
diff --git a/code/modules/station_goals/bsa.dm b/code/modules/station_goals/bsa.dm
index 0d88988d060..1874be3b727 100644
--- a/code/modules/station_goals/bsa.dm
+++ b/code/modules/station_goals/bsa.dm
@@ -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"
diff --git a/code/modules/station_goals/dna_vault.dm b/code/modules/station_goals/dna_vault.dm
index 1eb681a33ff..dcd7addaa3c 100644
--- a/code/modules/station_goals/dna_vault.dm
+++ b/code/modules/station_goals/dna_vault.dm
@@ -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)
diff --git a/code/modules/station_goals/shield.dm b/code/modules/station_goals/shield.dm
index 7baa35a3b1a..62b4ce1e37f 100644
--- a/code/modules/station_goals/shield.dm
+++ b/code/modules/station_goals/shield.dm
@@ -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
diff --git a/code/modules/telesci/telepad.dm b/code/modules/telesci/telepad.dm
index 654e64dbcfd..88b78120916 100644
--- a/code/modules/telesci/telepad.dm
+++ b/code/modules/telesci/telepad.dm
@@ -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)
diff --git a/paradise.dme b/paradise.dme
index d8b3993bed3..5adb29113a0 100644
--- a/paradise.dme
+++ b/paradise.dme
@@ -79,6 +79,7 @@
#include "code\__DEFINES\muzzle_flash.dm"
#include "code\__DEFINES\pda.dm"
#include "code\__DEFINES\pipes.dm"
+#include "code\__DEFINES\power.dm"
#include "code\__DEFINES\preferences.dm"
#include "code\__DEFINES\qdel.dm"
#include "code\__DEFINES\radiation.dm"
@@ -2282,7 +2283,6 @@
#include "code\modules\pda\utilities.dm"
#include "code\modules\persistence\persistence.dm"
#include "code\modules\point\point.dm"
-#include "code\modules\power\apc.dm"
#include "code\modules\power\cable.dm"
#include "code\modules\power\cable_logic.dm"
#include "code\modules\power\cell.dm"
@@ -2298,6 +2298,11 @@
#include "code\modules\power\tracker.dm"
#include "code\modules\power\treadmill.dm"
#include "code\modules\power\turbine.dm"
+#include "code\modules\power\apc\apc.dm"
+#include "code\modules\power\apc\apc_construction.dm"
+#include "code\modules\power\apc\apc_malfunction.dm"
+#include "code\modules\power\apc\apc_overlay.dm"
+#include "code\modules\power\powernets\local_powernet.dm"
#include "code\modules\power\singularity\collector.dm"
#include "code\modules\power\singularity\containment_field.dm"
#include "code\modules\power\singularity\emitter.dm"