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] Fixing cell power usage (Part 3) #2600

Merged
merged 2 commits into from
Mar 28, 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.2
#define LIGHT_EMERGENCY_POWER_USE (0.1 KILO WATTS)
// status values shared between lighting fixtures and items
#define LIGHT_OK 0
#define LIGHT_EMPTY 1
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
var/charge_cost = 50 KILO JOULES
/// 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 @@ -311,7 +311,7 @@
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
charge_cost = 20 KILO JOULES
recharge_time = 2
default_reagent_types = BASE_SYNDICATE_REAGENTS
bypass_protection = TRUE
Expand All @@ -324,7 +324,7 @@
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
charge_cost = 20 KILO JOULES
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 @@ -396,7 +396,7 @@
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 //Costs double the power of the borgshaker due to synthesizing solids
charge_cost = 40 KILO JOULES //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
6 changes: 3 additions & 3 deletions code/game/objects/items/robot/items/tools.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#define PKBORG_DAMPEN_CYCLE_DELAY (2 SECONDS)
#define POWER_RECHARGE_CYBORG_DRAIN_MULTIPLIER (0.4 KILO WATTS)

/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 All @@ -24,8 +25,6 @@
var/energy = 1500
/// Recharging rate in energy per second
var/energy_recharge = 37.5
/// Charge draining right
var/energy_recharge_cyborg_drain_coefficient = 0.4
/// Critical power level percentage
var/cyborg_cell_critical_percentage = 0.05
/// The owner of the dampener
Expand Down Expand Up @@ -156,7 +155,7 @@
energy = clamp(energy + energy_recharge * seconds_per_tick, 0, maxenergy)
return
if(host.cell && (host.cell.charge >= (host.cell.maxcharge * cyborg_cell_critical_percentage)) && (energy < maxenergy))
host.cell.use(energy_recharge * seconds_per_tick * energy_recharge_cyborg_drain_coefficient)
host.cell.use(energy_recharge * seconds_per_tick * POWER_RECHARGE_CYBORG_DRAIN_MULTIPLIER)
energy += energy_recharge * seconds_per_tick

/obj/item/borg/projectile_dampen/proc/dampen_projectile(datum/source, obj/projectile/projectile)
Expand All @@ -176,3 +175,4 @@
projectile.cut_overlay(projectile_effect)

#undef PKBORG_DAMPEN_CYCLE_DELAY
#undef POWER_RECHARGE_CYBORG_DRAIN_MULTIPLIER
18 changes: 11 additions & 7 deletions code/modules/antagonists/nukeop/equipment/borgchameleon.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#define ACTIVATION_COST (300 KILO JOULES)
#define ACTIVATION_UP_KEEP (25 KILO WATTS)

/obj/item/borg_chameleon
name = "cyborg chameleon projector"
icon = 'icons/obj/devices/syndie_gadget.dmi'
Expand All @@ -11,8 +14,6 @@
var/friendlyName
var/savedName
var/active = FALSE
var/activationCost = 300
var/activationUpkeep = 50
var/disguise = "engineer"
var/mob/listeningTo
var/static/list/signalCache = list( // list here all signals that should break the camouflage
Expand Down Expand Up @@ -44,13 +45,13 @@
disrupt(user)

/obj/item/borg_chameleon/attack_self(mob/living/silicon/robot/user)
if (user && user.cell && user.cell.charge > activationCost)
if (user && user.cell && user.cell.charge > ACTIVATION_COST)
if (isturf(user.loc))
toggle(user)
else
to_chat(user, span_warning("You can't use [src] while inside something!"))
else
to_chat(user, span_warning("You need at least [activationCost] charge in your cell to use [src]!"))
to_chat(user, span_warning("You need at least [display_energy(ACTIVATION_COST)] of charge in your cell to use [src]!"))

/obj/item/borg_chameleon/proc/toggle(mob/living/silicon/robot/user)
if(active)
Expand All @@ -65,7 +66,7 @@
to_chat(user, span_notice("You activate \the [src]."))
playsound(src, 'sound/effects/seedling_chargeup.ogg', 100, TRUE, -6)
apply_wibbly_filters(user)
if (do_after(user, 50, target=user) && user.cell.use(activationCost))
if (do_after(user, 50, target=user) && user.cell.use(ACTIVATION_COST))
playsound(src, 'sound/effects/bamf.ogg', 100, TRUE, -6)
to_chat(user, span_notice("You are now disguised as the Nanotrasen engineering borg \"[friendlyName]\"."))
activate(user)
Expand All @@ -75,9 +76,9 @@
remove_wibbly_filters(user)
animation_playing = FALSE

/obj/item/borg_chameleon/process()
/obj/item/borg_chameleon/process(seconds_per_tick)
if (user)
if (!user.cell || !user.cell.use(activationUpkeep))
if (!user.cell || !user.cell.use(ACTIVATION_UP_KEEP * seconds_per_tick))
disrupt(user)
else
return PROCESS_KILL
Expand Down Expand Up @@ -119,3 +120,6 @@
if(active)
to_chat(user, span_danger("Your chameleon field deactivates."))
deactivate(user)

#undef ACTIVATION_COST
#undef ACTIVATION_UP_KEEP
3 changes: 1 addition & 2 deletions code/modules/explorer_drone/loot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ GLOBAL_LIST_INIT(adventure_loot_generator_index,generate_generator_index())
lefthand_file = 'icons/mob/inhands/items/firelance_lefthand.dmi'
var/windup_time = 10 SECONDS
var/melt_range = 3
var/charge_per_use = 200
var/obj/item/stock_parts/cell/cell

/obj/item/firelance/Initialize(mapload)
Expand All @@ -176,7 +175,7 @@ GLOBAL_LIST_INIT(adventure_loot_generator_index,generate_generator_index())
return
if(LAZYACCESS(user.do_afters, "firelance"))
return
if(!cell.use(charge_per_use))
if(!cell.use(200 KILO JOULES))
to_chat(user,span_warning("[src] battery ran dry!"))
return
ADD_TRAIT(user, TRAIT_IMMOBILIZED, REF(src))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mod/mod_link.dm
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
/obj/item/clothing/neck/link_scryer/process(seconds_per_tick)
if(!mod_link.link_call)
return
cell.use(min(20 * seconds_per_tick, cell.charge))
cell.use(20 KILO WATTS * seconds_per_tick, force = TRUE)

/obj/item/clothing/neck/link_scryer/attackby(obj/item/attacked_by, mob/user, params)
. = ..()
Expand Down
4 changes: 2 additions & 2 deletions code/modules/power/lighting/light.dm
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@
if(cell)
if(cell.charge == cell.maxcharge && !reagents) //If the cell is done mooching station power, and reagents don't need processing, stop processing
return PROCESS_KILL
cell.charge = min(cell.maxcharge, cell.charge + LIGHT_EMERGENCY_POWER_USE) //Recharge emergency power automatically while not using it
charge_cell(LIGHT_EMERGENCY_POWER_USE * seconds_per_tick, cell = cell) //Recharge emergency power automatically while not using it
if(reagents) //with most reagents coming out at 300, and with most meaningful reactions coming at 370+, this rate gives a few seconds of time to place it in and get out of dodge regardless of input.
reagents.adjust_thermal_energy(8 * reagents.total_volume * SPECIFIC_HEAT_DEFAULT * seconds_per_tick)
reagents.handle_reactions()
if(low_power_mode && !use_emergency_power(LIGHT_EMERGENCY_POWER_USE))
if(low_power_mode && !use_emergency_power(LIGHT_EMERGENCY_POWER_USE * seconds_per_tick))
update(FALSE) //Disables emergency mode and sets the color to normal

/obj/machinery/light/proc/burn_out()
Expand Down
Loading