Skip to content

Commit

Permalink
[MIRROR] Fixing cell power usage (Part 1) (#2598)
Browse files Browse the repository at this point in the history
* Fixing cell power usage (Part 1)

* Conflicts

* woops

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: SyncIt21 <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
Co-authored-by: Iajret <[email protected]>
  • Loading branch information
5 people authored Mar 28, 2024
1 parent 7817c37 commit c2bba3c
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion code/datums/components/riding/riding_vehicle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 7 additions & 5 deletions code/game/machinery/spaceheater.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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 <b>[settable_temperature_range]°C</b>.<br>Heating power at <b>[siunit(heating_power, "W", 1)]</b>.<br>Power consumption at <b>[100 / efficiency]%</b>.") //100%, 75%, 50%, 25%
. += span_notice("The status display reads: Temperature range at <b>[settable_temperature_range]°C</b>.<br>Heating power at <b>[siunit(heating_power, "W", 1)]</b>.<br>Power consumption at <b>[100 / efficiency KILO JOULES]%</b>.") //100%, 75%, 50%, 25%
. += span_notice("<b>Right-click</b> to toggle [on ? "off" : "on"].")

/obj/machinery/space_heater/update_icon_state()
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions code/game/objects/items/rcd/RCD.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand All @@ -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))
Expand All @@ -539,15 +541,15 @@
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)
return ..()
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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions code/modules/atmospherics/machinery/portable/canister.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion code/modules/food_and_drinks/machinery/microwave.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/plant_genes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion code/modules/power/cell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,17 @@
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
custom_materials = null
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."
Expand Down
2 changes: 1 addition & 1 deletion code/modules/vehicles/mecha/mecha_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions code/modules/vehicles/motorized_wheelchair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c2bba3c

Please sign in to comment.