From c2bba3c630250c3e4314143a367958e2a168d06d Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+Steals-The-PRs@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:05:31 +0300 Subject: [PATCH] [MIRROR] Fixing cell power usage (Part 1) (#2598) * Fixing cell power usage (Part 1) * Conflicts * woops --------- Co-authored-by: NovaBot <154629622+NovaBot13@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: SomeRandomOwl <2568378+SomeRandomOwl@users.noreply.github.com> Co-authored-by: Iajret --- .../datums/components/riding/riding_vehicle.dm | 2 +- code/game/machinery/spaceheater.dm | 12 +++++++----- code/game/objects/items/rcd/RCD.dm | 18 +++++++++++------- .../components/electrolyzer/electrolyzer.dm | 2 +- .../machinery/portable/canister.dm | 8 ++++---- .../food_and_drinks/machinery/microwave.dm | 2 +- code/modules/hydroponics/plant_genes.dm | 2 +- code/modules/power/cell.dm | 5 ++++- code/modules/vehicles/mecha/mecha_helpers.dm | 2 +- code/modules/vehicles/motorized_wheelchair.dm | 6 +++--- 10 files changed, 34 insertions(+), 25 deletions(-) diff --git a/code/datums/components/riding/riding_vehicle.dm b/code/datums/components/riding/riding_vehicle.dm index 8935634cb42..45e16e9f910 100644 --- a/code/datums/components/riding/riding_vehicle.dm +++ b/code/datums/components/riding/riding_vehicle.dm @@ -349,4 +349,4 @@ . = ..() var/obj/vehicle/ridden/wheelchair/motorized/our_chair = parent if(istype(our_chair) && our_chair.power_cell) - our_chair.power_cell.use(our_chair.power_usage / max(our_chair.power_efficiency, 1) * 0.05) + our_chair.power_cell.use(our_chair.energy_usage / max(our_chair.power_efficiency, 1) * 0.05) diff --git a/code/game/machinery/spaceheater.dm b/code/game/machinery/spaceheater.dm index e07cbb593f2..523b4a5f8d9 100644 --- a/code/game/machinery/spaceheater.dm +++ b/code/game/machinery/spaceheater.dm @@ -7,7 +7,7 @@ anchored = FALSE density = TRUE interaction_flags_machine = INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN - icon = 'icons/obj/pipes_n_cables/atmos.dmi' // NOVA EDIT CHANGE - ICON OVERRIDEN IN SKYRAT AESTHETICS - SEE MODULE + icon = 'icons/obj/pipes_n_cables/atmos.dmi' // NOVA EDIT CHANGE - ICON OVERRIDEN IN SKYRAT AESTHETICS - SEE MODULE icon_state = "sheater-off" base_icon_state = "sheater" name = "space heater" @@ -30,7 +30,7 @@ ///How much heat/cold we can deliver var/heating_power = 40000 ///How efficiently we can deliver that heat/cold (higher indicates less cell consumption) - var/efficiency = 20 + var/efficiency = 20 / (1 KILO) ///The amount of degrees above and below the target temperature for us to change mode to heater or cooler var/temperature_tolerance = 1 ///What's the middle point of our settable temperature (30 °C) @@ -95,7 +95,7 @@ else . += "There is no power cell installed." if(in_range(user, src) || isobserver(user)) - . += span_notice("The status display reads: Temperature range at [settable_temperature_range]°C.
Heating power at [siunit(heating_power, "W", 1)].
Power consumption at [100 / efficiency]%.") //100%, 75%, 50%, 25% + . += span_notice("The status display reads: Temperature range at [settable_temperature_range]°C.
Heating power at [siunit(heating_power, "W", 1)].
Power consumption at [100 / efficiency KILO JOULES]%.") //100%, 75%, 50%, 25% . += span_notice("Right-click to toggle [on ? "off" : "on"].") /obj/machinery/space_heater/update_icon_state() @@ -173,7 +173,7 @@ heating_power = laser * 40000 settable_temperature_range = cap * 30 - efficiency = (cap + 1) * 10 + efficiency = ((cap + 1) * 10) / (1 KILO JOULES) target_temperature = clamp(target_temperature, max(settable_temperature_median - settable_temperature_range, TCMB), @@ -459,7 +459,9 @@ max(settable_temperature_median - settable_temperature_range, TCMB), settable_temperature_median + settable_temperature_range) - chem_heating_power = efficiency/20 + chem_heating_power = efficiency / 20 + + efficiency /= (1 KILO JOULES) #undef HEATER_MODE_STANDBY #undef HEATER_MODE_HEAT diff --git a/code/game/objects/items/rcd/RCD.dm b/code/game/objects/items/rcd/RCD.dm index 539821d1607..d050da4fa5e 100644 --- a/code/game/objects/items/rcd/RCD.dm +++ b/code/game/objects/items/rcd/RCD.dm @@ -422,7 +422,8 @@ /obj/item/construction/rcd/borg desc = "A device used to rapidly build walls and floors." banned_upgrades = RCD_UPGRADE_SILO_LINK - var/energyfactor = 72 + /// enery usage + var/energyfactor = 72 KILO JOULES /obj/item/construction/rcd/borg/get_matter(mob/user) if(!iscyborg(user)) @@ -464,7 +465,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 + energyfactor = 66 KILO JOULES canRturf = TRUE /obj/item/construction/rcd/loaded @@ -515,6 +516,9 @@ has_ammobar = FALSE 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) + /obj/item/construction/rcd/exosuit name = "mounted RCD" desc = "An exosuit-mounted Rapid Construction Device." @@ -525,8 +529,6 @@ resistance_flags = FIRE_PROOF | INDESTRUCTIBLE // should NOT be destroyed unless the equipment is destroyed item_flags = NO_MAT_REDEMPTION | NOBLUDGEON | DROPDEL // already qdeleted in the equipment's Destroy() but you can never be too sure delay_mod = 0.5 - ///How much charge is used up for each matter unit. - var/mass_to_energy = 16 /obj/item/construction/rcd/exosuit/ui_status(mob/user, datum/ui_state/state) if(ismecha(owner)) @@ -539,7 +541,7 @@ if(!ismecha(owner)) return 0 var/obj/vehicle/sealed/mecha/gundam = owner - return round(gundam.get_charge() / mass_to_energy) + return round(gundam.get_charge() / MASS_TO_ENERGY) /obj/item/construction/rcd/exosuit/useResource(amount, mob/user) if(silo_link) @@ -547,7 +549,7 @@ if(!ismecha(owner)) return 0 var/obj/vehicle/sealed/mecha/gundam = owner - if(!gundam.use_energy(amount * mass_to_energy)) + if(!gundam.use_energy(amount * MASS_TO_ENERGY)) gundam.balloon_alert(user, "insufficient charge!") return FALSE return TRUE @@ -558,11 +560,13 @@ if(!ismecha(owner)) return 0 var/obj/vehicle/sealed/mecha/gundam = owner - if(!gundam.has_charge(amount * mass_to_energy)) + if(!gundam.has_charge(amount * MASS_TO_ENERGY)) gundam.balloon_alert(user, "insufficient charge!") return FALSE return TRUE +#undef MASS_TO_ENERGY + #undef FREQUENT_USE_DEBUFF_MULTIPLIER /obj/item/rcd_ammo diff --git a/code/modules/atmospherics/machinery/components/electrolyzer/electrolyzer.dm b/code/modules/atmospherics/machinery/components/electrolyzer/electrolyzer.dm index 3be95de5605..0ab8427c0ae 100644 --- a/code/modules/atmospherics/machinery/components/electrolyzer/electrolyzer.dm +++ b/code/modules/atmospherics/machinery/components/electrolyzer/electrolyzer.dm @@ -127,7 +127,7 @@ if(anchored) use_energy(power_to_use) else - cell.use(power_to_use) + cell.use(power_to_use KILO JOULES) /obj/machinery/electrolyzer/proc/call_reactions(datum/gas_mixture/env) for(var/reaction in GLOB.electrolyzer_reactions) diff --git a/code/modules/atmospherics/machinery/portable/canister.dm b/code/modules/atmospherics/machinery/portable/canister.dm index dba4c5bff2f..75152798bba 100644 --- a/code/modules/atmospherics/machinery/portable/canister.dm +++ b/code/modules/atmospherics/machinery/portable/canister.dm @@ -479,11 +479,11 @@ var/our_temperature = air_contents.return_temperature() if(shielding_powered) - var/power_factor = round(log(10, max(our_pressure - pressure_limit, 1)) + log(10, max(our_temperature - temp_limit, 1))) - var/power_consumed = power_factor * 250 * seconds_per_tick + var/energy_factor = round(log(10, max(our_pressure - pressure_limit, 1)) + log(10, max(our_temperature - temp_limit, 1))) + var/energy_consumed = energy_factor * 250 * seconds_per_tick if(powered(AREA_USAGE_EQUIP, ignore_use_power = TRUE)) - use_energy(power_consumed, AREA_USAGE_EQUIP) - else if(!internal_cell?.use(power_consumed * 0.025)) + use_energy(energy_consumed, channel = AREA_USAGE_EQUIP) + else if(!internal_cell?.use(energy_consumed * 0.025 KILO JOULES)) shielding_powered = FALSE SSair.start_processing_machine(src) investigate_log("shielding turned off due to power loss") diff --git a/code/modules/food_and_drinks/machinery/microwave.dm b/code/modules/food_and_drinks/machinery/microwave.dm index 1834b23e563..dfb6ac9b2de 100644 --- a/code/modules/food_and_drinks/machinery/microwave.dm +++ b/code/modules/food_and_drinks/machinery/microwave.dm @@ -15,7 +15,7 @@ #define MAX_MICROWAVE_DIRTINESS 100 /// For the wireless version, and display fluff -#define TIER_1_CELL_CHARGE_RATE 250 +#define TIER_1_CELL_CHARGE_RATE (250 KILO JOULES) /obj/machinery/microwave name = "microwave oven" diff --git a/code/modules/hydroponics/plant_genes.dm b/code/modules/hydroponics/plant_genes.dm index 2ce685d0b7c..beb19687d87 100644 --- a/code/modules/hydroponics/plant_genes.dm +++ b/code/modules/hydroponics/plant_genes.dm @@ -586,7 +586,7 @@ var/obj/item/stock_parts/cell/potato/pocell = new /obj/item/stock_parts/cell/potato(user.loc) pocell.icon = our_plant.icon // Just in case the plant icons get spread out in different files eventually, this trait won't cause error sprites (also yay downstreams) pocell.icon_state = our_plant.icon_state - pocell.maxcharge = our_seed.potency * 20 + pocell.maxcharge = our_seed.potency * 20 KILO JOULES // The secret of potato supercells! var/datum/plant_gene/trait/cell_charge/electrical_gene = our_seed.get_gene(/datum/plant_gene/trait/cell_charge) diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index 2c4ea37881e..14497414a2c 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -426,7 +426,6 @@ desc = "A rechargeable starch based power cell." icon = 'icons/obj/service/hydroponics/harvest.dmi' icon_state = "potato" - charge = 100 maxcharge = STANDARD_CELL_CHARGE * 0.3 charge_light_type = null connector_type = null @@ -434,6 +433,10 @@ grown_battery = TRUE //it has the overlays for wires custom_premium_price = PAYCHECK_CREW +/obj/item/stock_parts/cell/potato/Initialize(mapload, override_maxcharge) + charge = maxcharge * 0.3 + . = ..() + /obj/item/stock_parts/cell/emproof name = "\improper EMP-proof cell" desc = "An EMP-proof cell." diff --git a/code/modules/vehicles/mecha/mecha_helpers.dm b/code/modules/vehicles/mecha/mecha_helpers.dm index 37757ac1f5c..03084c56957 100644 --- a/code/modules/vehicles/mecha/mecha_helpers.dm +++ b/code/modules/vehicles/mecha/mecha_helpers.dm @@ -8,7 +8,7 @@ return cell?.charge /obj/vehicle/sealed/mecha/proc/use_energy(amount) - var/output = get_charge() && cell.use(amount) + var/output = cell.use(amount) if (output) diag_hud_set_mechcell() return output diff --git a/code/modules/vehicles/motorized_wheelchair.dm b/code/modules/vehicles/motorized_wheelchair.dm index 973914a30c3..128530968e2 100644 --- a/code/modules/vehicles/motorized_wheelchair.dm +++ b/code/modules/vehicles/motorized_wheelchair.dm @@ -9,8 +9,8 @@ var/speed = 2 ///Self explanatory, ratio of how much power we use var/power_efficiency = 1 - ///How much power we use - var/power_usage = 100 + ///How much energy we use + var/energy_usage = 100 KILO JOULES ///whether the panel is open so a user can take out the cell var/panel_open = FALSE ///Parts used in building the wheelchair @@ -90,7 +90,7 @@ canmove = FALSE addtimer(VARSET_CALLBACK(src, canmove, TRUE), 2 SECONDS) return FALSE - if(power_cell.charge < power_usage / max(power_efficiency, 1)) + if(power_cell.charge < energy_usage / max(power_efficiency, 1)) to_chat(user, span_warning("The display on [src] blinks 'Out of Power'.")) canmove = FALSE addtimer(VARSET_CALLBACK(src, canmove, TRUE), 2 SECONDS)