Skip to content

Commit

Permalink
Idle & Active power rework and defines (#2632)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
Implements new defines set in power.dm for nearly all machines using
idle/active_power_usage
Kills auto_use_power() in favor of useStaticPower() procs
Standardizes power draws for most things using said defines
Decreases power used for lighting by half
Generally increases power used by machinery, especially those that are
only active for short periods.
SSUs now consume power when decontaminating, ORMs and vending machines
now take idle power.

![image](https://github.com/shiptest-ss13/Shiptest/assets/90987989/071f8fa8-0639-4fb5-9c3c-5b4b4ad254e4)
If you have any feedback, feel free to share it! Most of these numbers
are based on their original values, so definitely could be changed.
<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
This PR standardizes the draw of most machinery, while making it easier
to change power use across the board.
Additionally, lighting takes less power, while actual machines have been
tweaked to fill this gap.

<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog

:cl:
tweak: SSUs draw power to decontaminate
balance: lights no longer take 60% of a ships power, machines use more
to account for this.
code: added standardized defines for power usage
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Signed-off-by: HelmCrab <[email protected]>
Co-authored-by: FalloutFalcon <[email protected]>
  • Loading branch information
Thera-Pissed and FalloutFalcon authored May 27, 2024
1 parent 86aeb59 commit 1831332
Show file tree
Hide file tree
Showing 113 changed files with 416 additions and 230 deletions.
13 changes: 13 additions & 0 deletions code/__DEFINES/power.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@

#define TESLA_DEFAULT_POWER 1738260
#define TESLA_MINI_POWER 869130

#define LIGHT_DRAW 10 // mulitplied by brightness, typically 4-8

#define IDLE_DRAW_MINIMAL 50 // 20x = 1kw, used for small things and computers on stand-by
#define IDLE_DRAW_LOW 200 //5x = 1kw, used for always-active computers
#define IDLE_DRAW_MEDIUM 500 //2x = 1kw
#define IDLE_DRAW_HIGH 1000 //1kw

#define ACTIVE_DRAW_MINIMAL 200 //5x = 1kw
#define ACTIVE_DRAW_LOW 500 //2x = 1kw
#define ACTIVE_DRAW_MEDIUM 1000 //microwaves use this
#define ACTIVE_DRAW_HIGH 2000
#define ACTIVE_DRAW_EXTREME 5000 //highest this value should be in most cases
5 changes: 1 addition & 4 deletions code/controllers/subsystem/machines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ SUBSYSTEM_DEF(machines)
while(currentrun.len)
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
else
if(QDELETED(thing) || thing.process(seconds) == PROCESS_KILL)
processing -= thing
if (!QDELETED(thing))
thing.datum_flags &= ~DF_ISPROCESSING
Expand Down
2 changes: 2 additions & 0 deletions code/game/machinery/PDApainter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
icon_state = "pdapainter"
base_icon_state = "pdapainter"
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = IDLE_DRAW_MINIMAL
max_integrity = 200
var/obj/item/pda/storedpda = null
var/list/colorlist = list()
Expand Down
7 changes: 5 additions & 2 deletions code/game/machinery/Sleeper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
icon_state = "sleeper"
base_icon_state = "sleeper"
density = FALSE
use_power = IDLE_POWER_USE
idle_power_usage = IDLE_DRAW_LOW
state_open = TRUE
circuit = /obj/item/circuitboard/machine/sleeper
clicksound = 'sound/machines/pda_button1.ogg'
Expand Down Expand Up @@ -100,7 +102,7 @@
playsound(src, 'sound/machines/synth_yes.ogg', 50, TRUE, frequency = rand(5120, 8800))
target.apply_status_effect(STATUS_EFFECT_STASIS, STASIS_MACHINE_EFFECT)
target.ExtinguishMob()
use_power = ACTIVE_POWER_USE
set_active_power()

/obj/machinery/sleeper/proc/thaw_them(mob/living/target)
if(IS_IN_STASIS(target))
Expand All @@ -109,7 +111,8 @@

/obj/machinery/sleeper/process()
if(!occupant || !isliving(occupant))
use_power = IDLE_POWER_USE
if(use_static_power != IDLE_POWER_USE)
set_idle_power()
return
var/mob/living/L_occupant = occupant
if(stasis_running())
Expand Down
30 changes: 23 additions & 7 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Class Variables:
power_channel (num)
What channel to draw from when drawing power for power mode
Possible Values:
AREA_USAGE_EQUIP:0 -- Equipment Channel
AREA_USAGE_EQUIP:1 -- Equipment Channel
AREA_USAGE_LIGHT:2 -- Lighting Channel
AREA_USAGE_ENVIRON:3 -- Environment Channel
Expand All @@ -44,7 +44,7 @@ Class Procs:
auto_use_power() 'game/machinery/machine.dm'
This proc determines how power mode power is deducted by the machine.
'auto_use_power()' is called by the 'master_controller' game_controller every
tick.
tick. (not anymore)
Return Value:
return:1 -- if object is powered
Expand Down Expand Up @@ -102,6 +102,7 @@ Class Procs:
//0 = dont run the auto
//1 = run auto, use idle
//2 = run auto, use active
var/use_static_power = NO_POWER_USE
var/idle_power_usage = 0
var/active_power_usage = 0
var/power_channel = AREA_USAGE_EQUIP
Expand Down Expand Up @@ -151,7 +152,11 @@ Class Procs:

if(occupant_typecache)
occupant_typecache = typecacheof(occupant_typecache)

switch(use_power)
if(IDLE_POWER_USE)
set_idle_power()
if(ACTIVE_POWER_USE)
set_active_power()
return INITIALIZE_HINT_LATELOAD

/// Helper proc for telling a machine to start processing with the subsystem type that is located in its `subsystem_type` var.
Expand All @@ -168,7 +173,16 @@ Class Procs:
. = ..()
power_change()
become_area_sensitive(ROUNDSTART_TRAIT)
RegisterSignal(src, COMSIG_ENTER_AREA, PROC_REF(power_change))
RegisterSignal(src, COMSIG_ENTER_AREA, PROC_REF(enter_area))
RegisterSignal(src, COMSIG_EXIT_AREA, PROC_REF(exit_area))

/obj/machinery/proc/enter_area(datum/source, area/A)
SIGNAL_HANDLER
power_change(A)

/obj/machinery/proc/exit_area(datum/source, area/A)
SIGNAL_HANDLER
set_no_power(A)

/obj/machinery/Destroy()
GLOB.machines.Remove(src)
Expand All @@ -177,6 +191,7 @@ Class Procs:
lose_area_sensitivity(ROUNDSTART_TRAIT)
QDEL_NULL(circuit)
QDEL_LIST(component_parts)
set_no_power()
return ..()

/obj/machinery/proc/locate_machinery()
Expand Down Expand Up @@ -273,16 +288,16 @@ Class Procs:
target.forceMove(src)
updateUsrDialog()
update_appearance()

/obj/machinery/proc/auto_use_power()
/*
/obj/machinery/proc/auto_use_power() //obsolete, tick controller doesn't call this anymore because machines use addStaticPower now.
if(!powered(power_channel))
return 0
if(use_power == 1)
use_power(idle_power_usage,power_channel)
else if(use_power >= 2)
use_power(active_power_usage,power_channel)
return 1

*/

///Called when we want to change the value of the `is_operational` variable. Boolean.
/obj/machinery/proc/set_is_operational(new_value)
Expand Down Expand Up @@ -618,6 +633,7 @@ Class Procs:

//called on deconstruction before the final deletion
/obj/machinery/proc/on_deconstruction()
set_no_power()
return

/obj/machinery/proc/can_be_overridden()
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/airlock_cycle_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
icon = 'icons/obj/monitors.dmi'
icon_state = "aac"
use_power = IDLE_POWER_USE
idle_power_usage = 4
active_power_usage = 8
idle_power_usage = IDLE_DRAW_MINIMAL
active_power_usage = ACTIVE_DRAW_MINIMAL
power_channel = AREA_USAGE_ENVIRON
req_access = list(ACCESS_ATMOSPHERICS)
max_integrity = 250
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/announcement_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ GLOBAL_LIST_EMPTY(announcement_systems)
verb_ask = "queries"
verb_exclaim = "alarms"

idle_power_usage = 20
active_power_usage = 50
idle_power_usage = IDLE_DRAW_LOW
active_power_usage = IDLE_DRAW_LOW

circuit = /obj/item/circuitboard/machine/announcement_system

Expand Down
11 changes: 7 additions & 4 deletions code/game/machinery/autolathe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
icon_state = "autolathe"
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 10
active_power_usage = 100
idle_power_usage = IDLE_DRAW_LOW
active_power_usage = ACTIVE_DRAW_HIGH
power_channel = AREA_USAGE_EQUIP
circuit = /obj/item/circuitboard/machine/autolathe
layer = BELOW_OBJ_LAYER

Expand Down Expand Up @@ -223,7 +224,7 @@
for(var/MAT in being_built.materials)
total_amount += being_built.materials[MAT]

var/power = max(active_power_usage, (total_amount)*multiplier/5) //Change this to use all materials
var/power = max(active_power_usage, total_amount) //Change this to use all materials

var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)

Expand Down Expand Up @@ -252,6 +253,7 @@
use_power(power)
icon_state = "autolathe_n"
var/time = is_stack ? 32 : (32 * coeff * multiplier) ** 0.8
set_active_power()
addtimer(CALLBACK(src, PROC_REF(make_item), power, materials_used, custom_materials, multiplier, coeff, is_stack, usr), time)
. = TRUE
else
Expand Down Expand Up @@ -326,12 +328,13 @@
else
flick("autolathe_o", src) //plays metal insertion animation

use_power(min(1000, amount_inserted / 100))
use_power(min(active_power_usage, amount_inserted))

/obj/machinery/autolathe/proc/make_item(power, list/materials_used, list/picked_materials, multiplier, coeff, is_stack, mob/user)
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
var/atom/A = drop_location()
use_power(power)
set_idle_power()

materials.use_materials(materials_used)

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/bank_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
desc = "A machine used to deposit and withdraw funds."
icon_screen = "vault"
icon_keyboard = "security_key"
idle_power_usage = 100
idle_power_usage = IDLE_DRAW_LOW

var/siphoning = FALSE
var/next_warning = 0
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/buttons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
var/initialized_button = 0
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
idle_power_usage = IDLE_DRAW_MINIMAL
resistance_flags = LAVA_PROOF | FIRE_PROOF

/obj/machinery/button/indestructible
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
icon_state = "camera" //mapping icon to represent upgrade states. if you want a different base icon, update default_camera_icon as well as this.
light_color = "#CDDDFF"
use_power = ACTIVE_POWER_USE
idle_power_usage = 5
active_power_usage = 10
idle_power_usage = IDLE_DRAW_MINIMAL
active_power_usage = IDLE_DRAW_MINIMAL*2
layer = WALL_OBJ_LAYER
resistance_flags = FIRE_PROOF
damage_deflection = 12
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/cell_charger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
icon = 'icons/obj/power.dmi'
icon_state = "ccharger"
use_power = IDLE_POWER_USE
idle_power_usage = 5
active_power_usage = 60
idle_power_usage = IDLE_DRAW_MINIMAL
active_power_usage = ACTIVE_DRAW_LOW
power_channel = AREA_USAGE_EQUIP
circuit = /obj/item/circuitboard/machine/cell_charger
pass_flags = PASSTABLE
Expand Down
2 changes: 2 additions & 0 deletions code/game/machinery/cloning.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
density = TRUE
icon = 'icons/obj/machines/cloning.dmi'
icon_state = "pod_0"
use_power = IDLE_POWER_USE
idle_power_usage = IDLE_DRAW_LOW
req_access = list(ACCESS_CLONING) //FOR PREMATURE UNLOCKING.
verb_say = "states"
circuit = /obj/item/circuitboard/machine/clonepod
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/computer/_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
icon_state = "computer"
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 300
active_power_usage = 300
idle_power_usage = IDLE_DRAW_LOW
active_power_usage = ACTIVE_DRAW_LOW
max_integrity = 200
integrity_failure = 0.5
armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 40, "acid" = 20)
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/computer/crew.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
icon_screen = "crew"
icon_keyboard = "med_key"
use_power = IDLE_POWER_USE
idle_power_usage = 250
active_power_usage = 500
idle_power_usage = IDLE_DRAW_LOW
active_power_usage = ACTIVE_DRAW_MEDIUM
circuit = /obj/item/circuitboard/computer/crew

light_color = LIGHT_COLOR_BLUE
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/computer/dna_console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
circuit = /obj/item/circuitboard/computer/scan_consolenew

use_power = IDLE_POWER_USE
idle_power_usage = 10
active_power_usage = 400
idle_power_usage = IDLE_DRAW_LOW
active_power_usage = ACTIVE_DRAW_MEDIUM
light_color = LIGHT_COLOR_BLUE

/// Link to the techweb's stored research. Used to retrieve stored mutations
Expand Down
2 changes: 2 additions & 0 deletions code/game/machinery/dance_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
icon_state = "jukebox-"
verb_say = "states"
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = IDLE_DRAW_MINIMAL
var/active = FALSE
var/list/rangers = list()
var/stop = 0
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/defibrillator_mount.dm
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
name = "PENLITE defibrillator mount"
desc = "Holds defibrillators. You can grab the paddles if one is mounted. This PENLITE variant also allows for slow, passive recharging of the defibrillator."
icon_state = "penlite_mount"
idle_power_usage = 1
idle_power_usage = 0
wallframe_type = /obj/item/wallframe/defib_mount/charging


Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/dish_drive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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_usage = IDLE_DRAW_MINIMAL //lower
active_power_usage = ACTIVE_DRAW_MINIMAL //lower ingame because stockparts
density = FALSE
circuit = /obj/item/circuitboard/machine/dish_drive
pass_flags = PASSTABLE
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/dna_scanner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
base_icon_state = "scanner"
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 50
active_power_usage = 300
idle_power_usage = IDLE_DRAW_MINIMAL
active_power_usage = ACTIVE_DRAW_MEDIUM
occupant_typecache = list(/mob/living, /obj/item/bodypart/head, /obj/item/organ/brain)
circuit = /obj/item/circuitboard/machine/dnascanner
var/locked = FALSE
Expand Down
2 changes: 2 additions & 0 deletions code/game/machinery/doppler_array.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
icon = 'icons/obj/machines/research.dmi'
base_icon_state = "tdoppler"
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = IDLE_DRAW_LOW
verb_say = "states coldly"
var/cooldown = 10
var/next_announce = 0
Expand Down
2 changes: 2 additions & 0 deletions code/game/machinery/droneDispenser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
icon = 'icons/obj/machines/droneDispenser.dmi'
icon_state = "on"
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = IDLE_DRAW_LOW

max_integrity = 250
integrity_failure = 0.33
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/embedded_controller/access_controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/obj/machinery/doorButtons
power_channel = AREA_USAGE_ENVIRON
use_power = IDLE_POWER_USE
idle_power_usage = 2
active_power_usage = 4
idle_power_usage = IDLE_DRAW_MINIMAL
active_power_usage = ACTIVE_DRAW_MINIMAL
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
var/idSelf

Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/firealarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
integrity_failure = 0.4
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
idle_power_usage = IDLE_DRAW_MINIMAL
active_power_usage = ACTIVE_DRAW_MINIMAL
power_channel = AREA_USAGE_ENVIRON
resistance_flags = FIRE_PROOF

Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/gulag_item_reclaimer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
req_access = list(ACCESS_SECURITY) //REQACCESS TO ACCESS ALL STORED ITEMS
density = FALSE
use_power = IDLE_POWER_USE
idle_power_usage = 100
active_power_usage = 2500
idle_power_usage = IDLE_DRAW_LOW
active_power_usage = IDLE_DRAW_MEDIUM

var/list/stored_items = list()
var/obj/machinery/gulag_teleporter/linked_teleporter = null
Expand Down
Loading

0 comments on commit 1831332

Please sign in to comment.