Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Use cell defined constants for various stuff #2983

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/__DEFINES/lights.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///How much power emergency lights will consume per tick
#define LIGHT_EMERGENCY_POWER_USE (0.1 KILO WATTS)
#define LIGHT_EMERGENCY_POWER_USE (0.0001 * STANDARD_CELL_RATE)
// status values shared between lighting fixtures and items
#define LIGHT_OK 0
#define LIGHT_EMPTY 1
Expand Down
8 changes: 6 additions & 2 deletions code/__DEFINES/power.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
///The joule is the standard unit of energy for this codebase. You can use this with other defines to clarify that it will not be multiplied by time.
#define JOULES * JOULE

///The amount of energy, in joules, a standard powercell has.
#define STANDARD_CELL_CHARGE (1 MEGA JOULES) // 1 MJ.
///The capacity of a standard power cell
#define STANDARD_CELL_VALUE (1 MEGA)
///The amount of energy, in joules, a standard powercell has.
#define STANDARD_CELL_CHARGE (STANDARD_CELL_VALUE JOULES) // 1 MJ.
///The amount of power, in watts, a standard powercell can give.
#define STANDARD_CELL_RATE (STANDARD_CELL_VALUE WATTS) // 1 MW.

GLOBAL_VAR_INIT(CHARGELEVEL, 0.01) // Cap for how fast cells charge, as a percentage per second (.01 means cellcharge is capped to 1% per second)

Expand Down
2 changes: 1 addition & 1 deletion code/datums/actions/mobs/charge_apc.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///how much charge are we giving off to an APC?
#define CHARGE_AMOUNT (80 KILO JOULES)
#define CHARGE_AMOUNT (0.08 * STANDARD_CELL_CHARGE)

/datum/action/cooldown/mob_cooldown/charge_apc
name = "Charge APCs"
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/autolathe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
icon = 'icons/obj/machines/lathes.dmi'
icon_state = "autolathe"
density = TRUE
//Energy cost per full stack of sheets worth of materials used. Material insertion is 40% of this.
active_power_usage = 25 * BASE_MACHINE_ACTIVE_CONSUMPTION
///Energy cost per full stack of sheets worth of materials used. Material insertion is 40% of this.
active_power_usage = 0.025 * STANDARD_CELL_RATE
circuit = /obj/item/circuitboard/machine/autolathe
layer = BELOW_OBJ_LAYER
processing_flags = NONE
Expand Down
7 changes: 4 additions & 3 deletions code/game/machinery/cell_charger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
circuit = /obj/item/circuitboard/machine/cell_charger
pass_flags = PASSTABLE
var/obj/item/stock_parts/cell/charging = null
var/charge_rate = 250 KILO WATTS
var/charge_rate = 0.25 * STANDARD_CELL_RATE

/* OVERWRITTEN IN modular_nova\modules\aesthetics\cells\cell.dm
/obj/machinery/cell_charger/update_overlays()
Expand Down Expand Up @@ -133,7 +133,7 @@

/obj/machinery/cell_charger/RefreshParts()
. = ..()
charge_rate = 250 KILO WATTS
charge_rate = 0.25 * STANDARD_CELL_RATE
for(var/datum/stock_part/capacitor/capacitor in component_parts)
charge_rate *= capacitor.tier

Expand All @@ -147,7 +147,8 @@
if(!main_draw)
return

use_energy(main_draw * 0.01) //use a small bit for the charger itself, but power usage scales up with the part tier
//use a small bit for the charger itself, but power usage scales up with the part tier
use_energy(main_draw * 0.01)
charge_cell(main_draw, charging, grid_only = TRUE)

update_appearance()
2 changes: 1 addition & 1 deletion code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@
return
if(istype(attacking_object, /obj/item/electroadaptive_pseudocircuit))
var/obj/item/electroadaptive_pseudocircuit/raspberrypi = attacking_object
if(!raspberrypi.adapt_circuit(user, circuit_cost = DEFAULT_STEP_TIME * 0.5 KILO JOULES))
if(!raspberrypi.adapt_circuit(user, circuit_cost = DEFAULT_STEP_TIME * 0.0005 * STANDARD_CELL_CHARGE))
return
user.visible_message(span_notice("[user] fabricates a circuit and places it into [src]."), \
span_notice("You adapt a firelock circuit and slot it into the assembly."))
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/firealarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@

else if(istype(tool, /obj/item/electroadaptive_pseudocircuit))
var/obj/item/electroadaptive_pseudocircuit/pseudoc = tool
if(!pseudoc.adapt_circuit(user, circuit_cost = 15 KILO JOULES))
if(!pseudoc.adapt_circuit(user, circuit_cost = 0.015 * STANDARD_CELL_CHARGE))
return
user.visible_message(span_notice("[user] fabricates a circuit and places it into [src]."), \
span_notice("You adapt a fire alarm circuit and slot it into the assembly."))
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/rechargestation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
if(!occupant)
return

if(!use_energy(active_power_usage * seconds_per_tick))
if(!use_energy(active_power_usage * seconds_per_tick, force = FALSE))
return

SEND_SIGNAL(occupant, COMSIG_PROCESS_BORGCHARGER_OCCUPANT, charge_cell, seconds_per_tick, repairs, sendmats)
7 changes: 4 additions & 3 deletions code/game/machinery/suit_storage_unit.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// SUIT STORAGE UNIT /////////////////
/obj/machinery/suit_storage_unit
name = "suit storage unit"
Expand Down Expand Up @@ -55,9 +56,9 @@
/// How long it takes to break out of the SSU.
var/breakout_time = 30 SECONDS
/// Power contributed by this machine to charge the mod suits cell without any capacitors
var/base_charge_rate = 200 KILO WATTS
var/base_charge_rate = 0.2 * STANDARD_CELL_RATE
/// Final charge rate which is base_charge_rate + contribution by capacitors
var/final_charge_rate = 250 KILO WATTS
var/final_charge_rate = 0.25 * STANDARD_CELL_RATE
/// is the card reader installed in this machine
var/card_reader_installed = FALSE
/// physical reference of the players id card to check for PERSONAL access level
Expand Down Expand Up @@ -287,7 +288,7 @@
. = ..()

for(var/datum/stock_part/capacitor/capacitor in component_parts)
final_charge_rate = base_charge_rate + (capacitor.tier * 50 KILO WATTS)
final_charge_rate = base_charge_rate + (capacitor.tier * 0.05 * STANDARD_CELL_RATE)

set_access()

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/powersink.dm
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
if(istype(terminal.master, /obj/machinery/power/apc))
var/obj/machinery/power/apc/apc = terminal.master
if(apc.operating && apc.cell)
drained += 0.001 * apc.cell.use(50 KILO JOULES, force = TRUE)
drained += 0.001 * apc.cell.use(0.05 * STANDARD_CELL_CHARGE, force = TRUE)
internal_heat += drained

/obj/item/powersink/process()
Expand Down
14 changes: 8 additions & 6 deletions code/game/objects/items/inspector.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
///Energy used to say an error message.
#define ENERGY_TO_SPEAK (0.001 * STANDARD_CELL_CHARGE)

/**
* # N-spect scanner
*
Expand Down Expand Up @@ -28,8 +31,6 @@
var/cell_cover_open = FALSE
///Energy used per print.
var/energy_per_print = INSPECTOR_ENERGY_USAGE_NORMAL
///Energy used to say an error message.
var/energy_to_speak = 1 KILO JOULES

/obj/item/inspector/Initialize(mapload)
. = ..()
Expand Down Expand Up @@ -112,7 +113,7 @@
to_chat(user, "<span class='info'>\The [src] doesn't seem to be on... Perhaps it ran out of power?")
return
if(!cell.use(energy_per_print))
if(cell.use(energy_to_speak))
if(cell.use(ENERGY_TO_SPEAK))
say("ERROR! POWER CELL CHARGE LEVEL TOO LOW TO PRINT REPORT!")
return

Expand Down Expand Up @@ -258,7 +259,7 @@

/obj/item/inspector/clown/bananium/proc/check_settings_legality()
if(print_sound_mode == INSPECTOR_PRINT_SOUND_MODE_NORMAL && time_mode == INSPECTOR_TIME_MODE_HONK)
if(cell.use(energy_to_speak))
if(cell.use(ENERGY_TO_SPEAK))
say("Setting combination forbidden by Geneva convention revision CCXXIII selected, reverting to defaults")
time_mode = INSPECTOR_TIME_MODE_SLOW
print_sound_mode = INSPECTOR_PRINT_SOUND_MODE_NORMAL
Expand Down Expand Up @@ -296,7 +297,7 @@
if(time_mode != INSPECTOR_TIME_MODE_HONK)
return ..()
if(paper_charges == 0)
if(cell.use(energy_to_speak))
if(cell.use(ENERGY_TO_SPEAK))
say("ERROR! OUT OF PAPER! MAXIMUM PRINTING SPEED UNAVAIBLE! SWITCH TO A SLOWER SPEED TO OR PROVIDE PAPER!")
else
to_chat(user, "<span class='info'>\The [src] doesn't seem to be on... Perhaps it ran out of power?")
Expand Down Expand Up @@ -383,5 +384,6 @@
target.MakeSlippery(TURF_WET_WATER, min_wet_time = 10 SECONDS, wet_time_to_add = 5 SECONDS)
to_chat(user, span_notice("As you try to fold [src] into the shape of a plane, it disintegrates into water!"))
qdel(src)

return CLICK_ACTION_SUCCESS

#undef ENERGY_TO_SPEAK
2 changes: 1 addition & 1 deletion code/game/objects/items/maintenance_loot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
icon_state = "lead_battery"
throwforce = 10
maxcharge = STANDARD_CELL_CHARGE * 20 //decent max charge
chargerate = STANDARD_CELL_CHARGE * 0.7 //charging is about 30% less efficient than lithium batteries.
chargerate = STANDARD_CELL_RATE * 0.7 //charging is about 30% less efficient than lithium batteries.
charge_light_type = null
connector_type = "leadacid"
rating = 2 //Kind of a mid-tier battery
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/rcd/RCD.dm
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
desc = "A device used to rapidly build walls and floors."
banned_upgrades = RCD_UPGRADE_SILO_LINK
/// enery usage
var/energyfactor = 72 KILO JOULES
var/energyfactor = 0.072 * STANDARD_CELL_CHARGE

/obj/item/construction/rcd/borg/get_matter(mob/user)
if(!iscyborg(user))
Expand Down Expand Up @@ -470,7 +470,7 @@
desc = "A reverse-engineered RCD with black market upgrades that allow this device to deconstruct reinforced walls. Property of Donk Co."
icon_state = "ircd"
inhand_icon_state = "ircd"
energyfactor = 66 KILO JOULES
energyfactor = 0.066 * STANDARD_CELL_CHARGE
canRturf = TRUE

/obj/item/construction/rcd/loaded
Expand Down Expand Up @@ -522,7 +522,7 @@
upgrade = RCD_ALL_UPGRADES & ~RCD_UPGRADE_SILO_LINK

///How much charge is used up for each matter unit.
#define MASS_TO_ENERGY (16 KILO JOULES)
#define MASS_TO_ENERGY (0.016 * STANDARD_CELL_CHARGE)

/obj/item/construction/rcd/exosuit
name = "mounted RCD"
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/robot/items/food.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
check_amount()
if(iscyborg(user))
var/mob/living/silicon/robot/robot_user = user
if(!robot_user.cell.use(12 KILO JOULES))
if(!robot_user.cell.use(0.012 * STANDARD_CELL_CHARGE))
to_chat(user, span_warning("Not enough power."))
return AFTERATTACK_PROCESSED_ITEM
switch(mode)
Expand Down
8 changes: 4 additions & 4 deletions code/game/objects/items/robot/items/hypo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
*/
var/max_volume_per_reagent = 30
/// Cell cost for charging a reagent
var/charge_cost = 50 KILO JOULES
var/charge_cost = 0.05 * STANDARD_CELL_CHARGE
/// Counts up to the next time we charge
var/charge_timer = 0
/// Time it takes for shots to recharge (in seconds)
Expand Down Expand Up @@ -310,7 +310,7 @@ NOVA EDIT REMOVAL END */
Also metabolizes potassium iodide for radiation poisoning, inacusiate for ear damage and morphine for offense."
icon_state = "borghypo_s"
tgui_theme = "syndicate"
charge_cost = 20 KILO JOULES
charge_cost = 0.02 * STANDARD_CELL_CHARGE
recharge_time = 2
default_reagent_types = BASE_SYNDICATE_REAGENTS
bypass_protection = TRUE
Expand All @@ -323,7 +323,7 @@ NOVA EDIT REMOVAL END */
icon_state = "shaker"
possible_transfer_amounts = list(5,10,20,1)
// Lots of reagents all regenerating at once, so the charge cost is lower. They also regenerate faster.
charge_cost = 20 KILO JOULES
charge_cost = 0.02 * STANDARD_CELL_CHARGE
recharge_time = 3
dispensed_temperature = WATER_MATTERSTATE_CHANGE_TEMP //Water stays wet, ice stays ice
default_reagent_types = BASE_SERVICE_REAGENTS
Expand Down Expand Up @@ -395,7 +395,7 @@ NOVA EDIT REMOVAL END */
icon_state = "flour"
possible_transfer_amounts = list(5,10,20,1)
// Lots of reagents all regenerating at once, so the charge cost is lower. They also regenerate faster.
charge_cost = 40 KILO JOULES //Costs double the power of the borgshaker due to synthesizing solids
charge_cost = 0.04 * STANDARD_CELL_CHARGE //Costs double the power of the borgshaker due to synthesizing solids
recharge_time = 6 //Double the recharge time too, for the same reason.
dispensed_temperature = WATER_MATTERSTATE_CHANGE_TEMP
default_reagent_types = EXPANDED_SERVICE_REAGENTS
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/robot/items/tools.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define PKBORG_DAMPEN_CYCLE_DELAY (2 SECONDS)
#define POWER_RECHARGE_CYBORG_DRAIN_MULTIPLIER (0.4 KILO WATTS)
#define POWER_RECHARGE_CYBORG_DRAIN_MULTIPLIER (0.0004 * STANDARD_CELL_RATE)

/obj/item/cautery/prt //it's a subtype of cauteries so that it inherits the cautery sprites and behavior and stuff, because I'm too lazy to make sprites for this thing
name = "plating repair tool"
Expand Down
8 changes: 4 additions & 4 deletions code/game/objects/items/robot/robot_upgrades.dm
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
/// Minimum time between repairs in seconds
var/repair_cooldown = 4
var/on = FALSE
var/energy_cost = 10 KILO JOULES
var/energy_cost = 0.01 * STANDARD_CELL_CHARGE
var/datum/action/toggle_action

/obj/item/borg/upgrade/selfrepair/action(mob/living/silicon/robot/R, user = usr)
Expand Down Expand Up @@ -366,16 +366,16 @@
if(cyborg.health < cyborg.maxHealth)
if(cyborg.health < 0)
repair_amount = -2.5
energy_cost = 30 KILO JOULES
energy_cost = 0.03 * STANDARD_CELL_CHARGE
else
repair_amount = -1
energy_cost = 10 KILO JOULES
energy_cost = 0.01 * STANDARD_CELL_CHARGE
cyborg.adjustBruteLoss(repair_amount)
cyborg.adjustFireLoss(repair_amount)
cyborg.updatehealth()
cyborg.cell.use(energy_cost)
else
cyborg.cell.use(5 KILO JOULES)
cyborg.cell.use(0.005 * STANDARD_CELL_CHARGE)
next_repair = world.time + repair_cooldown * 10 // Multiply by 10 since world.time is in deciseconds

if(TIMER_COOLDOWN_FINISHED(src, COOLDOWN_BORG_SELF_REPAIR))
Expand Down
19 changes: 11 additions & 8 deletions code/game/objects/items/stacks/golem_food/golem_status_effects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,18 @@
owner.remove_traits(list(TRAIT_ANTIMAGIC, TRAIT_HOLY), TRAIT_STATUS_EFFECT(id))
return ..()

/// What do we multiply our damage by to convert it into power?
#define ENERGY_PER_DAMAGE (0.005 * STANDARD_CELL_CHARGE)
/// Multiplier to apply to burn damage, not 0 so that we can reverse it more easily
#define BURN_MULTIPLIER 0.05

/// Heat immunity, turns heat damage into local power
/datum/status_effect/golem/plasma
overlay_state_prefix = "plasma"
mineral_name = "plasma"
applied_fluff = "Plasma cooling rods sprout from your body. You can take the heat!"
alert_icon_state = "sheet-plasma"
alert_desc = "You are protected from high pressure and can convert heat damage into power."
/// What do we multiply our damage by to convert it into power?
var/energy_per_damage = 5 KILO JOULES
/// Multiplier to apply to burn damage, not 0 so that we can reverse it more easily
var/burn_multiplier = 0.05

/datum/status_effect/golem/plasma/on_apply()
. = ..()
Expand All @@ -179,14 +180,14 @@
owner.add_traits(list(TRAIT_RESISTHIGHPRESSURE, TRAIT_RESISTHEAT, TRAIT_ASHSTORM_IMMUNE), TRAIT_STATUS_EFFECT(id))
RegisterSignal(owner, COMSIG_MOB_APPLY_DAMAGE, PROC_REF(on_burned))
var/mob/living/carbon/human/human_owner = owner
human_owner.physiology.burn_mod *= burn_multiplier
human_owner.physiology.burn_mod *= BURN_MULTIPLIER
return TRUE

/datum/status_effect/golem/plasma/on_remove()
owner.remove_traits(list(TRAIT_RESISTHIGHPRESSURE, TRAIT_RESISTHEAT, TRAIT_ASHSTORM_IMMUNE), TRAIT_STATUS_EFFECT(id))
UnregisterSignal(owner, COMSIG_MOB_APPLY_DAMAGE)
var/mob/living/carbon/human/human_owner = owner
human_owner.physiology.burn_mod /= burn_multiplier
human_owner.physiology.burn_mod /= BURN_MULTIPLIER
return ..()

/// When we take fire damage (or... technically also cold damage, we don't differentiate), zap a nearby APC
Expand All @@ -195,7 +196,6 @@
if(damagetype != BURN)
return

var/power = damage * energy_per_damage
var/obj/machinery/power/energy_accumulator/ground = get_closest_atom(/obj/machinery/power/energy_accumulator, view(4, owner), owner)
if (ground)
zap_effect(ground)
Expand All @@ -206,7 +206,10 @@
if (!our_apc)
return
zap_effect(our_apc)
our_apc.cell?.give(power)
our_apc.cell?.give(damage * ENERGY_PER_DAMAGE)

#undef ENERGY_PER_DAMAGE
#undef BURN_MULTIPLIER

/// Shoot a beam at the target atom
/datum/status_effect/golem/plasma/proc/zap_effect(atom/target)
Expand Down
Loading
Loading