Skip to content

Commit ea6c23c

Browse files
[NO GBP]Fixes space heaters. Makes their effectiveness independant of cell defines. (tgstation#84962)
## About The Pull Request Makes BASE_HEATING_ENERGY be 40 KILO JOULES. It shouldn't have any scaling with the cell defines because it impacts how powerful the space heater interacts with the air, and doesn't impact how much energy is actually used per energy it changed in the air. Makes the efficiency variable inversely scale with STANDARD_CELL_CHARGE. This makes the consumption relative to the standard cell charge, so changing the defines won't impact how long the space heater lasts. Makes the heating_energy var use initial() instead of the defines, so they respect subtypes better. Makes the improvised chemical heater also scale their variables based on the initial one. Also sets the improvised chemical heater's settable_temperature_range to what it would be set to with tier 1 parts in RefreshParts(). Renames chem_heating_power to beaker_conduction_power to more accurately describe its effect of scaling how fast it heats or cools things. Removes the pointless multiplication that is done to it in every instance of using it, and instead just scale the variable down. Gives a more accurate description of the improvised chemical heater's heating power in its heating_examine(). Gives better feedback with balloon alerts when attempting to turn on a space heater while it is lacking a cell, has no charge or is broken. ## Why It's Good For The Game Closes tgstation#84892 This will make their relative energy usage behave identical to before the power changes. It will make their effectiveness independant of the cell scale. Also the improvised chemical heater's heating power description was misleading and nonsensical. Gives a more accurate one. Space heaters give better feedback when attempting to turn it on while it's missing a cell, has no charge or is broken. ## Changelog :cl: fix: Fixes space heater cell relative consumption inadvertently being changed from the introduction of megacells. qol: The improvised chemical heater gives a more accurate description of its heating power on examine. qol: Improved feedback when attempting to turn on a space heater that is lacking a cell, has no charge or is broken. code: Space heater relative cell consumption is consistent regardless of the cell charge scale. /:cl: --------- Co-authored-by: SyncIt21 <[email protected]>
1 parent aefea93 commit ea6c23c

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

code/game/machinery/spaceheater.dm

+33-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define HEATER_MODE_HEAT "heat"
33
#define HEATER_MODE_COOL "cool"
44
#define HEATER_MODE_AUTO "auto"
5-
#define BASE_HEATING_ENERGY (STANDARD_CELL_RATE * 4)
5+
#define BASE_HEATING_ENERGY (40 KILO JOULES)
66

77
/obj/machinery/space_heater
88
anchored = FALSE
@@ -32,7 +32,7 @@
3232
///How much heat/cold we can deliver
3333
var/heating_energy = BASE_HEATING_ENERGY
3434
///How efficiently we can deliver that heat/cold (higher indicates less cell consumption)
35-
var/efficiency = 200
35+
var/efficiency = 20 MEGA JOULES / STANDARD_CELL_CHARGE
3636
///The amount of degrees above and below the target temperature for us to change mode to heater or cooler
3737
var/temperature_tolerance = 1
3838
///What's the middle point of our settable temperature (30 °C)
@@ -176,7 +176,7 @@
176176
for(var/datum/stock_part/capacitor/capacitor in component_parts)
177177
cap += capacitor.tier
178178

179-
heating_energy = laser * BASE_HEATING_ENERGY
179+
heating_energy = laser * initial(heating_energy)
180180

181181
settable_temperature_range = cap * initial(settable_temperature_range)
182182
efficiency = (cap + 1) * initial(efficiency) * 0.5
@@ -295,7 +295,14 @@
295295
on = !on
296296
mode = HEATER_MODE_STANDBY
297297
if(!isnull(user))
298-
balloon_alert(user, "turned [on ? "on" : "off"]")
298+
if(QDELETED(cell))
299+
balloon_alert(user, "no cell!")
300+
else if(!cell.charge())
301+
balloon_alert(user, "no charge!")
302+
else if(!is_operational)
303+
balloon_alert(user, "not operational!")
304+
else
305+
balloon_alert(user, "turned [on ? "on" : "off"]")
299306
update_appearance()
300307
if(on)
301308
SSair.start_processing_machine(src)
@@ -310,23 +317,29 @@
310317
//We inherit the cell from the heater prior
311318
cell = null
312319
interaction_flags_click = FORBID_TELEKINESIS_REACH
320+
display_panel = FALSE
321+
settable_temperature_range = 50
313322
///The beaker within the heater
314323
var/obj/item/reagent_containers/beaker = null
315-
///How powerful the heating is, upgrades with parts. (ala chem_heater.dm's method, basically the same level of heating, but this is restricted)
316-
var/chem_heating_power = 1
317-
display_panel = FALSE
324+
/// How quickly it delivers heat to the reagents. In watts per joule of the thermal energy difference of the reagent from the temperature difference of the current and target temperatures.
325+
var/beaker_conduction_power = 0.1
326+
/// The subsystem we're being processed by.
327+
var/datum/controller/subsystem/processing/our_subsystem
328+
329+
/obj/machinery/space_heater/improvised_chem_heater/Initialize(mapload)
330+
our_subsystem = locate(subsystem_type) in Master.subsystems
331+
. = ..()
318332

319333
/obj/machinery/space_heater/improvised_chem_heater/Destroy()
320334
. = ..()
321335
QDEL_NULL(beaker)
322336

323337
/obj/machinery/space_heater/improvised_chem_heater/heating_examine()
324338
. = ..()
325-
326-
var/power_mod = 0.1 * chem_heating_power
327-
if(set_mode == HEATER_MODE_AUTO)
328-
power_mod *= 0.5
329-
. += span_notice("Heating power for beaker: <b>[display_power(heating_energy * power_mod, convert = TRUE)]</b>")
339+
// Conducted energy per joule of thermal energy difference in a tick.
340+
var/conduction_energy = beaker_conduction_power * (set_mode == HEATER_MODE_AUTO ? 0.5 : 1) * our_subsystem.wait / (1 SECONDS)
341+
// This accounts for the timestep inaccuracy.
342+
. += span_notice("Reagent conduction power: <b>[conduction_energy < 1 ? display_power(-log(1 - conduction_energy) SECONDS / our_subsystem.wait, convert = FALSE) : "∞W"]/J</b>")
330343

331344
/obj/machinery/space_heater/improvised_chem_heater/toggle_power(user)
332345
. = ..()
@@ -341,18 +354,18 @@
341354
return PROCESS_KILL
342355

343356
if(beaker.reagents.total_volume)
344-
var/power_mod = 0.1 * chem_heating_power
357+
var/conduction_modifier = beaker_conduction_power
345358
switch(set_mode)
346359
if(HEATER_MODE_AUTO)
347-
power_mod *= 0.5
360+
conduction_modifier *= 0.5
348361
if(HEATER_MODE_HEAT)
349362
if(target_temperature < beaker.reagents.chem_temp)
350363
return
351364
if(HEATER_MODE_COOL)
352365
if(target_temperature > beaker.reagents.chem_temp)
353366
return
354367

355-
var/required_energy = abs(target_temperature - beaker.reagents.chem_temp) * power_mod * seconds_per_tick * beaker.reagents.heat_capacity()
368+
var/required_energy = abs(target_temperature - beaker.reagents.chem_temp) * conduction_modifier * seconds_per_tick * beaker.reagents.heat_capacity()
356369
required_energy = min(required_energy, heating_energy, cell.charge * efficiency)
357370
if(required_energy < 1)
358371
return
@@ -468,16 +481,17 @@
468481
for(var/datum/stock_part/capacitor/capacitor in component_parts)
469482
capacitors_rating += capacitor.tier
470483

471-
heating_energy = lasers_rating * BASE_HEATING_ENERGY
484+
heating_energy = lasers_rating * initial(heating_energy)
472485

473-
settable_temperature_range = capacitors_rating * 50 //-20 - 80 at base
474-
efficiency = (capacitors_rating + 1) * 10
486+
settable_temperature_range = capacitors_rating * initial(settable_temperature_range) //-20 - 80 at base
487+
efficiency = (capacitors_rating + 1) * initial(efficiency) * 0.5
475488

476489
target_temperature = clamp(target_temperature,
477490
max(settable_temperature_median - settable_temperature_range, TCMB),
478491
settable_temperature_median + settable_temperature_range)
479492

480-
chem_heating_power = efficiency / 20
493+
// No time integration is used, so we should clamp this to prevent being able to overshoot if there was a subtype with a high initial value.
494+
beaker_conduction_power = min((capacitors_rating + 1) * 0.5 * initial(beaker_conduction_power), 1 SECONDS / our_subsystem.wait)
481495

482496
#undef HEATER_MODE_STANDBY
483497
#undef HEATER_MODE_HEAT

0 commit comments

Comments
 (0)