mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 12:29:46 +01:00
Various Delta Time Fixes (#21871)
Organs were being given ~3 seconds of DT per ~2 seconds of real time, because they were being hit by Process() TWICE, once during processing for the "Set of all objects", and again during processing for the "Set of all mobs". No species was hit harder than this but IPCs, who suffered from having wildly inconsistent temperature mechanics that seemingly never matched the expected numbers. I have actually tested this PR to verify that it works. I even went the extra mile to more extensively test IPC temperature mechanics to find a separate bug unrelated to DTs that was causing suit coolers to just straight up not work at all (space suit or otherwise) on a majority of all IPC subspecies. I then tested the numbers in the PR for IPC cooling to verify that things work as intended. <img width="969" height="623" alt="image" src="https://github.com/user-attachments/assets/01c3aca7-b436-4e52-86f7-aed847dcba5e" /> I also tweaked all the subsystems to have a small performance improvement. --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com>
This commit is contained in:
@@ -30,18 +30,6 @@
|
||||
for(var/obj/item/organ/external/Ex in organs)
|
||||
bad_external_organs |= Ex
|
||||
|
||||
//processing internal organs is pretty cheap, do that first.
|
||||
for(var/obj/item/organ/I in internal_organs)
|
||||
if (QDELETED(I))
|
||||
LOG_DEBUG("Organ [DEBUG_REF(src)] was not properly removed from its parent!")
|
||||
internal_organs -= I
|
||||
continue
|
||||
|
||||
if(I.status & ORGAN_DEAD)
|
||||
continue
|
||||
|
||||
I.process(seconds_per_tick)
|
||||
|
||||
handle_stance()
|
||||
handle_grasp()
|
||||
|
||||
@@ -55,7 +43,6 @@
|
||||
bad_external_organs -= E
|
||||
continue
|
||||
else
|
||||
E.process()
|
||||
number_wounds += E.number_wounds
|
||||
|
||||
if (!lying && !buckled_to && world.time - l_move_time < 15)
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
//Organs
|
||||
handle_organs(seconds_per_tick)
|
||||
stabilize_body_temperature() //Body temperature adjusts itself (self-regulation)
|
||||
stabilize_body_temperature(seconds_per_tick) //Body temperature adjusts itself (self-regulation)
|
||||
|
||||
//Random events (vomiting etc)
|
||||
handle_random_events()
|
||||
@@ -303,7 +303,7 @@
|
||||
|
||||
return breath
|
||||
|
||||
/mob/living/carbon/human/handle_environment(datum/gas_mixture/environment)
|
||||
/mob/living/carbon/human/handle_environment(datum/gas_mixture/environment, seconds_per_tick)
|
||||
..()
|
||||
|
||||
if(!environment)
|
||||
@@ -330,8 +330,10 @@
|
||||
if(bodytemperature > (0.1 * HUMAN_HEAT_CAPACITY/(HUMAN_EXPOSED_SURFACE_AREA*STEFAN_BOLTZMANN_CONSTANT))**(1/4) + COSMIC_RADIATION_TEMPERATURE)
|
||||
//Thermal radiation into space
|
||||
var/heat_loss = HUMAN_EXPOSED_SURFACE_AREA * STEFAN_BOLTZMANN_CONSTANT * ((bodytemperature - COSMIC_RADIATION_TEMPERATURE)**4)
|
||||
// Temperature loss in Watts (kgm^2/s^3)
|
||||
var/temperature_loss = heat_loss/HUMAN_HEAT_CAPACITY
|
||||
bodytemperature -= temperature_loss
|
||||
// Since body temperature is in Joules (kgm^2/s^2), we multiply temperature loss by DT (in seconds) to convert from Watts to Joules before subtracting.
|
||||
bodytemperature -= temperature_loss * seconds_per_tick
|
||||
else
|
||||
var/loc_temp = T0C
|
||||
if(istype(loc, /obj/machinery/atmospherics/unary/cryo_cell))
|
||||
@@ -437,9 +439,9 @@
|
||||
baseline += clothing.body_temperature_change
|
||||
return baseline
|
||||
|
||||
/mob/living/carbon/human/proc/stabilize_body_temperature()
|
||||
/mob/living/carbon/human/proc/stabilize_body_temperature(seconds_per_tick)
|
||||
if (species.passive_temp_gain) // We produce heat naturally.
|
||||
species.handle_temperature_regulation(src)
|
||||
species.handle_temperature_regulation(src, seconds_per_tick)
|
||||
|
||||
if (species.body_temperature == null)
|
||||
return //this species doesn't have metabolic thermoregulation
|
||||
@@ -453,19 +455,16 @@
|
||||
|
||||
if(bodytemperature < species.cold_level_1) //260.15 is 310.15 - 50, the temperature where you start to feel effects.
|
||||
if(nutrition >= 2) //If we are very, very cold we'll use up quite a bit of nutriment to heat us up.
|
||||
adjustNutritionLoss(2)
|
||||
var/recovery_amt = max((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), BODYTEMP_AUTORECOVERY_MINIMUM)
|
||||
bodytemperature += recovery_amt
|
||||
adjustNutritionLoss(seconds_per_tick)
|
||||
bodytemperature += max((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR * seconds_per_tick), BODYTEMP_AUTORECOVERY_MINIMUM * seconds_per_tick)
|
||||
else if(species.cold_level_1 <= bodytemperature && bodytemperature <= species.heat_level_1)
|
||||
var/recovery_amt = body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR
|
||||
bodytemperature += recovery_amt
|
||||
bodytemperature += body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR * seconds_per_tick
|
||||
else if(bodytemperature > species.heat_level_1) //360.15 is 310.15 + 50, the temperature where you start to feel effects.
|
||||
if(hydration >= 2)
|
||||
adjustHydrationLoss(2)
|
||||
adjustHydrationLoss(seconds_per_tick)
|
||||
if((species.flags & CAN_SWEAT) && fire_stacks == 0)
|
||||
fire_stacks = -1
|
||||
var/recovery_amt = min((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), -BODYTEMP_AUTORECOVERY_MINIMUM) //We're dealing with negative numbers
|
||||
bodytemperature += recovery_amt
|
||||
bodytemperature += min((body_temperature_difference * seconds_per_tick / BODYTEMP_AUTORECOVERY_DIVISOR), -BODYTEMP_AUTORECOVERY_MINIMUM * seconds_per_tick) //We're dealing with negative numbers
|
||||
|
||||
/**
|
||||
* Returns a bitflag for the body parts currently heat-protected. Called and used by get_heat_protection()
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
var/heat_level_2 = 400
|
||||
/// Heat damage level 3 above this point
|
||||
var/heat_level_3 = 1000
|
||||
/// Species will gain this much temperature every second
|
||||
/// Species will gain this much temperature (in degrees kelvin per second)
|
||||
var/passive_temp_gain = 0
|
||||
/// Dangerously high pressure
|
||||
var/hazard_high_pressure = HAZARD_HIGH_PRESSURE
|
||||
@@ -1080,5 +1080,5 @@
|
||||
* This proc handles the species temperature regulation. By default, it just adds `passive_temp_gain` to the human's bodytemperature.
|
||||
* Can be overridden for more complex calculations.
|
||||
*/
|
||||
/datum/species/proc/handle_temperature_regulation(mob/living/carbon/human/human)
|
||||
human.bodytemperature += passive_temp_gain
|
||||
/datum/species/proc/handle_temperature_regulation(mob/living/carbon/human/human, seconds_per_tick)
|
||||
human.bodytemperature += passive_temp_gain * seconds_per_tick
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
heat_level_3 = 2400
|
||||
|
||||
body_temperature = null
|
||||
passive_temp_gain = 10
|
||||
passive_temp_gain = 5 // Degrees kelvin per second
|
||||
|
||||
inherent_verbs = list(
|
||||
/mob/living/carbon/human/proc/change_monitor,
|
||||
@@ -171,11 +171,11 @@
|
||||
var/machine_ui_theme = "hackerman"
|
||||
|
||||
|
||||
/datum/species/machine/handle_temperature_regulation(mob/living/carbon/human/human)
|
||||
/datum/species/machine/handle_temperature_regulation(mob/living/carbon/human/human, seconds_per_tick)
|
||||
// No cooling unit = you're cooking. Broken cooling unit effects are handled by the organ itself.
|
||||
// Here we just want to check if it's been removed.
|
||||
// 500K is about 226 degrees. Spicy!
|
||||
var/base_heat_gain = passive_temp_gain
|
||||
var/base_heat_gain = passive_temp_gain * seconds_per_tick
|
||||
var/obj/item/organ/internal/machine/cooling_unit/cooling = human.internal_organs_by_name[BP_COOLING_UNIT]
|
||||
if(!cooling || (cooling?.status & ORGAN_DEAD))
|
||||
base_heat_gain *= 4 //uh oh
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
//Handle temperature/pressure differences between body and environment
|
||||
if(environment)
|
||||
handle_environment(environment)
|
||||
handle_environment(environment, seconds_per_tick)
|
||||
|
||||
blinded = 0 // Placing this here just show how out of place it is.
|
||||
|
||||
@@ -213,7 +213,7 @@
|
||||
if(!.) // If we're under or inside shelter, use the z-level rain (for ambience)
|
||||
. = SSweather.weather_by_z["[my_turf.z]"]
|
||||
|
||||
/mob/living/proc/handle_environment(var/datum/gas_mixture/environment)
|
||||
/mob/living/proc/handle_environment(var/datum/gas_mixture/environment, seconds_per_tick)
|
||||
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
|
||||
|
||||
@@ -22,8 +22,11 @@
|
||||
|
||||
/// The power consumed when we are cooling down.
|
||||
var/base_power_consumption = 8
|
||||
/// The passive temperature change. Basically, cooling units counteract an IPC's passive temperature gain. But the IPC's temperature goes to get itself fucked if the cooling unit dies.
|
||||
/// Remember, can be negative or positive. Depends on what we're trying to stabilize towards.
|
||||
/**
|
||||
* The passive temperature change in "Degrees Kelvin Per Second". This is reduced by a variety of conditions.
|
||||
* Basically, cooling units counteract an IPC's passive temperature gain. But the IPC's temperature goes to get itself fucked if the cooling unit dies.
|
||||
* Remember, can be negative or positive. Depends on what we're trying to stabilize towards.
|
||||
*/
|
||||
var/passive_temp_change = 2
|
||||
/// The temperature that this cooling unit tries to regulate towards.
|
||||
var/thermostat = T20C
|
||||
@@ -41,6 +44,8 @@
|
||||
var/safety_burnt = FALSE
|
||||
/// If the thermostat is locked and thus cannot be changed. Used for spooky effects, like the high integrity damage in the positronic brain.
|
||||
var/locked_thermostat = FALSE
|
||||
/// The amount of degrees kelvin (per second) of heat the cooling unit will generate if it is blocked by a space suit.
|
||||
var/spacesuited_heat_per_second = 5
|
||||
|
||||
/obj/item/organ/internal/machine/cooling_unit/Initialize()
|
||||
. = ..()
|
||||
@@ -138,13 +143,11 @@
|
||||
if(prob(owner.bodytemperature * 0.1))
|
||||
take_internal_damage(owner.bodytemperature * 0.01)
|
||||
|
||||
var/temperature_change = passive_temp_change
|
||||
var/temperature_change = passive_temp_change * seconds_per_tick
|
||||
if(owner.wear_suit)
|
||||
if(!spaceproof && istype(owner.wear_suit, /obj/item/clothing/suit/space))
|
||||
//cooling is going to SUCK if you have heat-regulating clothes
|
||||
if(owner.bodytemperature < species.heat_level_3)
|
||||
owner.bodytemperature = min(owner.bodytemperature + 5, owner.species.heat_level_2)
|
||||
temperature_change *= 0.5
|
||||
temperature_change *= 0.5
|
||||
|
||||
// Check if there is somehow no air, or if we are in an ambient without enough air to properly cool us.
|
||||
if((!ambient || (ambient && owner.calculate_affecting_pressure(XGM_PRESSURE(ambient)) < owner.species.warning_low_pressure)))
|
||||
|
||||
@@ -365,14 +365,14 @@
|
||||
else
|
||||
owner.robot_pain.icon_state = null
|
||||
|
||||
/obj/item/organ/internal/machine/posibrain/low_integrity_damage(integrity)
|
||||
/obj/item/organ/internal/machine/posibrain/low_integrity_damage(integrity, seconds_per_tick)
|
||||
var/damage_probability = get_integrity_damage_probability(integrity)
|
||||
if(prob(damage_probability))
|
||||
if(SPT_PROB(damage_probability, seconds_per_tick))
|
||||
to_chat(owner, SPAN_MACHINE_WARNING("Neural pathway error located at block 0x[generate_hex()]."))
|
||||
take_internal_damage(2)
|
||||
. = ..()
|
||||
|
||||
/obj/item/organ/internal/machine/posibrain/medium_integrity_damage(integrity)
|
||||
/obj/item/organ/internal/machine/posibrain/medium_integrity_damage(integrity, seconds_per_tick)
|
||||
var/damage_probability = get_integrity_damage_probability(integrity)
|
||||
var/list/static/medium_integrity_damage_messages = list(
|
||||
"Your neural subroutines' alarms are all going off at once.",
|
||||
@@ -381,14 +381,14 @@
|
||||
"Your software warns you of dangerously low neural coherence.",
|
||||
"Your self-preservation subroutines threaten to kick in. [SPAN_DANGER("WARNING. WARNING.")]"
|
||||
)
|
||||
if(prob(damage_probability))
|
||||
if(SPT_PROB(damage_probability, seconds_per_tick))
|
||||
to_chat(owner, SPAN_MACHINE_WARNING(pick(medium_integrity_damage_messages)))
|
||||
take_internal_damage(2)
|
||||
. = ..()
|
||||
|
||||
/obj/item/organ/internal/machine/posibrain/high_integrity_damage(integrity)
|
||||
/obj/item/organ/internal/machine/posibrain/high_integrity_damage(integrity, seconds_per_tick)
|
||||
var/damage_probability = get_integrity_damage_probability(integrity)
|
||||
if(prob(damage_probability))
|
||||
if(SPT_PROB(damage_probability, seconds_per_tick))
|
||||
var/damage_roll = rand(1, 50)
|
||||
switch(damage_roll)
|
||||
if(1 to 10)
|
||||
|
||||
Reference in New Issue
Block a user