diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm index 0c735844f8..6f4aa69277 100644 --- a/code/__DEFINES/atmospherics.dm +++ b/code/__DEFINES/atmospherics.dm @@ -86,16 +86,18 @@ #define HAZARD_LOW_PRESSURE 20 //This is when the black ultra-low pressure icon is displayed. (This one is set as a constant) #define TEMPERATURE_DAMAGE_COEFFICIENT 1.5 //This is used in handle_temperature_damage() for humans, and in reagents that affect body temperature. Temperature damage is multiplied by this amount. -#define BODYTEMP_AUTORECOVERY_DIVISOR 12 //This is the divisor which handles how much of the temperature difference between the current body temperature and 310.15K (optimal temperature) humans auto-regenerate each tick. The higher the number, the slower the recovery. This is applied each tick, so long as the mob is alive. -#define BODYTEMP_AUTORECOVERY_MINIMUM 10 //Minimum amount of kelvin moved toward 310.15K per tick. So long as abs(310.15 - bodytemp) is more than 50. -#define BODYTEMP_NORMAL 310.15 //98.6F, or 37C, the normal temprature of the human body. -#define BODYTEMP_COLD_DIVISOR 6 //Similar to the BODYTEMP_AUTORECOVERY_DIVISOR, but this is the divisor which is applied at the stage that follows autorecovery. This is the divisor which comes into play when the human's loc temperature is lower than their body temperature. Make it lower to lose bodytemp faster. -#define BODYTEMP_HEAT_DIVISOR 6 //Similar to the BODYTEMP_AUTORECOVERY_DIVISOR, but this is the divisor which is applied at the stage that follows autorecovery. This is the divisor which comes into play when the human's loc temperature is higher than their body temperature. Make it lower to gain bodytemp faster. -#define BODYTEMP_COOLING_MAX 30 //The maximum number of degrees that your body can cool in 1 tick, when in a cold area. -#define BODYTEMP_HEATING_MAX 30 //The maximum number of degrees that your body can heat up in 1 tick, when in a hot area. -#define BODYTEMP_HEAT_DAMAGE_LIMIT 360.15 // The limit the human body can take before it starts taking damage from heat. -#define BODYTEMP_COLD_DAMAGE_LIMIT 260.15 // The limit the human body can take before it starts taking damage from coldness. +#define BODYTEMP_NORMAL 310.15 //The natural temperature for a body +#define BODYTEMP_AUTORECOVERY_DIVISOR 11 //This is the divisor which handles how much of the temperature difference between the current body temperature and 310.15K (optimal temperature) humans auto-regenerate each tick. The higher the number, the slower the recovery. This is applied each tick, so long as the mob is alive. +#define BODYTEMP_AUTORECOVERY_MINIMUM 12 //Minimum amount of kelvin moved toward 310K per tick. So long as abs(310.15 - bodytemp) is more than 50. +#define BODYTEMP_COLD_DIVISOR 6 //Similar to the BODYTEMP_AUTORECOVERY_DIVISOR, but this is the divisor which is applied at the stage that follows autorecovery. This is the divisor which comes into play when the human's loc temperature is lower than their body temperature. Make it lower to lose bodytemp faster. +#define BODYTEMP_HEAT_DIVISOR 15 //Similar to the BODYTEMP_AUTORECOVERY_DIVISOR, but this is the divisor which is applied at the stage that follows autorecovery. This is the divisor which comes into play when the human's loc temperature is higher than their body temperature. Make it lower to gain bodytemp faster. +#define BODYTEMP_COOLING_MAX -100 //The maximum number of degrees that your body can cool in 1 tick, due to the environment, when in a cold area. +#define BODYTEMP_HEATING_MAX 30 //The maximum number of degrees that your body can heat up in 1 tick, due to the environment, when in a hot area. + +#define BODYTEMP_HEAT_DAMAGE_LIMIT (BODYTEMP_NORMAL + 50) // The limit the human body can take before it starts taking damage from heat. +#define BODYTEMP_COLD_DAMAGE_LIMIT (BODYTEMP_NORMAL - 50) // The limit the human body can take before it starts taking damage from coldness. + #define SPACE_HELM_MIN_TEMP_PROTECT 2.0 //what min_cold_protection_temperature is set to for space-helmet quality headwear. MUST NOT BE 0. #define SPACE_HELM_MAX_TEMP_PROTECT 1500 //Thermal insulation works both ways /Malkevin diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 05cb67cdaa..987484bc8f 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -1623,24 +1623,29 @@ GLOBAL_LIST_EMPTY(roundstart_races) var/loc_temp = H.get_temperature(environment) - //Body temperature is adjusted in two steps. First, your body tries to stabilize itself a bit. - if(H.stat != DEAD) - H.natural_bodytemperature_stabilization() - - //Then, it reacts to the surrounding atmosphere based on your thermal protection + //Body temperature is adjusted in two parts: first there your body tries to naturally preserve homeostasis (shivering/sweating), then it reacts to the surrounding environment + //Thermal protection (insulation) has mixed benefits in two situations (hot in hot places, cold in hot places) if(!H.on_fire) //If you're on fire, you do not heat up or cool down based on surrounding gases - if(loc_temp < H.bodytemperature) - //Place is colder than we are - var/thermal_protection = H.get_cold_protection(loc_temp) //This returns a 0 - 1 value, which corresponds to the percentage of protection based on what you're wearing and what you're exposed to. - if(thermal_protection < 1) - H.bodytemperature += min((1-thermal_protection) * ((loc_temp - H.bodytemperature) / BODYTEMP_COLD_DIVISOR), BODYTEMP_COOLING_MAX) - else - //Place is hotter than we are - var/thermal_protection = H.get_heat_protection(loc_temp) //This returns a 0 - 1 value, which corresponds to the percentage of protection based on what you're wearing and what you're exposed to. - if(thermal_protection < 1) - H.bodytemperature += min((1-thermal_protection) * ((loc_temp - H.bodytemperature) / BODYTEMP_HEAT_DIVISOR), BODYTEMP_HEATING_MAX) + if((abs(BODYTEMP_NORMAL - H.bodytemperature) <= 5) && (abs(BODYTEMP_NORMAL - loc_temp) <= 25)) + return //Performance saver + var/natural = 0 + if(H.stat != DEAD) + natural = H.natural_bodytemperature_stabilization() + var/thermal_protection = 1 + if(loc_temp < H.bodytemperature) //Place is colder than we are + thermal_protection -= H.get_cold_protection(loc_temp) //This returns a 0 - 1 value, which corresponds to the percentage of protection based on what you're wearing and what you're exposed to. + if(H.bodytemperature < BODYTEMP_NORMAL) //we're cold, insulation helps us retain body heat and will reduce the heat we lose to the environment + H.bodytemperature += (thermal_protection+1)*natural + max(thermal_protection * (loc_temp - H.bodytemperature) / BODYTEMP_COLD_DIVISOR, BODYTEMP_COOLING_MAX) + else //we're sweating, insulation hinders our ability to reduce heat - and it will reduce the amount of cooling you get from the environment + H.bodytemperature += natural*(1/(thermal_protection+1)) + max((thermal_protection * (loc_temp - H.bodytemperature) + BODYTEMP_NORMAL - H.bodytemperature) / BODYTEMP_COLD_DIVISOR , BODYTEMP_COOLING_MAX) //Extra calculation for hardsuits to bleed off heat + else //Place is hotter than we are + thermal_protection -= H.get_heat_protection(loc_temp) //This returns a 0 - 1 value, which corresponds to the percentage of protection based on what you're wearing and what you're exposed to. + if(H.bodytemperature < BODYTEMP_NORMAL) //and we're cold, insulation enhances our ability to retain body heat but reduces the heat we get from the environment + H.bodytemperature += (thermal_protection+1)*natural + min(thermal_protection * (loc_temp - H.bodytemperature) / BODYTEMP_HEAT_DIVISOR, BODYTEMP_HEATING_MAX) + else //we're sweating, insulation hinders out ability to reduce heat - but will reduce the amount of heat we get from the environment + H.bodytemperature += natural*(1/(thermal_protection+1)) + min(thermal_protection * (loc_temp - H.bodytemperature) / BODYTEMP_HEAT_DIVISOR, BODYTEMP_HEATING_MAX) - // +/- 50 degrees from 310.15K is the 'safe' zone, where no damage is dealt. + // +/- 50 degrees from 310K is the 'safe' zone, where no damage is dealt. if(H.bodytemperature > BODYTEMP_HEAT_DAMAGE_LIMIT && !(RESISTHOT in species_traits)) //Body temperature is too hot. var/burn_damage diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index 0ac97fba5a..7595b5276b 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -396,15 +396,14 @@ /mob/living/carbon/proc/natural_bodytemperature_stabilization() var/body_temperature_difference = BODYTEMP_NORMAL - bodytemperature switch(bodytemperature) - if(-INFINITY to BODYTEMP_COLD_DAMAGE_LIMIT) //BODYTEMP_COLD_DAMAGE_LIMIT is BODYTEMP_NORMAL(310.15) - 50, the temperature where you start to feel effects. - bodytemperature += max((body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR), BODYTEMP_AUTORECOVERY_MINIMUM) + if(-INFINITY to BODYTEMP_COLD_DAMAGE_LIMIT) //Cold damage limit is 50 below the default, the temperature where you start to feel effects. + return max((body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR), BODYTEMP_AUTORECOVERY_MINIMUM) if(BODYTEMP_COLD_DAMAGE_LIMIT to BODYTEMP_NORMAL) - bodytemperature += max(body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR, min(body_temperature_difference, BODYTEMP_AUTORECOVERY_MINIMUM/4)) - if(BODYTEMP_NORMAL to BODYTEMP_HEAT_DAMAGE_LIMIT) - bodytemperature += min(body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR, max(body_temperature_difference, -BODYTEMP_AUTORECOVERY_MINIMUM/4)) - if(BODYTEMP_HEAT_DAMAGE_LIMIT to INFINITY) //BODYTEMP_HEAT_DAMAGE_LIMIT is BODYTEMP_NORMAL(310.15) + 50, the temperature where you start to feel effects. - //We totally need a sweat system cause it totally makes sense...~ - bodytemperature += min((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), -BODYTEMP_AUTORECOVERY_MINIMUM) //We're dealing with negative numbers + return max(body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR, min(body_temperature_difference, BODYTEMP_AUTORECOVERY_MINIMUM/4)) + if(BODYTEMP_NORMAL to BODYTEMP_HEAT_DAMAGE_LIMIT) // Heat damage limit is 50 above the default, the temperature where you start to feel effects. + return min(body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR, max(body_temperature_difference, -BODYTEMP_AUTORECOVERY_MINIMUM/4)) + if(BODYTEMP_HEAT_DAMAGE_LIMIT to INFINITY) + return min((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), -BODYTEMP_AUTORECOVERY_MINIMUM) //We're dealing with negative numbers ///////// //LIVER// ///////// @@ -460,4 +459,8 @@ death() var/obj/item/organ/brain/B = getorganslot(ORGAN_SLOT_BRAIN) if(B) +<<<<<<< HEAD B.damaged_brain = TRUE +======= + B.damaged_brain = TRUE +>>>>>>> 15864dc... Temperature Refactor and Fixes (#34133) diff --git a/code/modules/mob/living/carbon/monkey/life.dm b/code/modules/mob/living/carbon/monkey/life.dm index ca78e165c2..2b1f49cb7e 100644 --- a/code/modules/mob/living/carbon/monkey/life.dm +++ b/code/modules/mob/living/carbon/monkey/life.dm @@ -66,13 +66,13 @@ var/loc_temp = get_temperature(environment) if(stat != DEAD) - natural_bodytemperature_stabilization() + bodytemperature += natural_bodytemperature_stabilization() if(!on_fire) //If you're on fire, you do not heat up or cool down based on surrounding gases if(loc_temp < bodytemperature) bodytemperature += min(((loc_temp - bodytemperature) / BODYTEMP_COLD_DIVISOR), BODYTEMP_COOLING_MAX) else - bodytemperature += min(((loc_temp - bodytemperature) / BODYTEMP_HEAT_DIVISOR), BODYTEMP_HEATING_MAX) + bodytemperature += max(((loc_temp - bodytemperature) / BODYTEMP_HEAT_DIVISOR), BODYTEMP_HEATING_MAX) if(bodytemperature > BODYTEMP_HEAT_DAMAGE_LIMIT) switch(bodytemperature) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 634c1ebb5f..371f19f033 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -231,7 +231,7 @@ var/atom/A = src.loc if(isturf(A)) var/areatemp = get_temperature(environment) - if( abs(areatemp - bodytemperature) > 40 ) + if( abs(areatemp - bodytemperature) > 5) var/diff = areatemp - bodytemperature diff = diff / 5 bodytemperature += diff diff --git a/code/modules/reagents/chemistry/reagents/food_reagents.dm b/code/modules/reagents/chemistry/reagents/food_reagents.dm index 835bcaaad7..e0ea5de450 100644 --- a/code/modules/reagents/chemistry/reagents/food_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/food_reagents.dm @@ -213,29 +213,31 @@ taste_description = "mint" /datum/reagent/consumable/frostoil/on_mob_life(mob/living/M) - switch(current_cycle) - if(1 to 15) - M.bodytemperature -= 10 * TEMPERATURE_DAMAGE_COEFFICIENT - if(holder.has_reagent("capsaicin")) - holder.remove_reagent("capsaicin", 5) - if(isslime(M)) - M.bodytemperature -= rand(5,20) - if(15 to 25) - M.bodytemperature -= 20 * TEMPERATURE_DAMAGE_COEFFICIENT - if(isslime(M)) - M.bodytemperature -= rand(10,20) - if(25 to 35) - M.bodytemperature -= 30 * TEMPERATURE_DAMAGE_COEFFICIENT - if(prob(1)) - M.emote("shiver") - if(isslime(M)) - M.bodytemperature -= rand(15,20) - if(35 to INFINITY) - M.bodytemperature -= 40 * TEMPERATURE_DAMAGE_COEFFICIENT - if(prob(5)) - M.emote("shiver") - if(isslime(M)) - M.bodytemperature -= rand(20,25) + if(M.bodytemperature > 50) + switch(current_cycle) + if(1 to 15) + M.bodytemperature -= 10 * TEMPERATURE_DAMAGE_COEFFICIENT + if(holder.has_reagent("capsaicin")) + holder.remove_reagent("capsaicin", 5) + if(isslime(M)) + M.bodytemperature -= rand(5,20) + if(15 to 25) + M.bodytemperature -= 20 * TEMPERATURE_DAMAGE_COEFFICIENT + if(isslime(M)) + M.bodytemperature -= rand(10,20) + if(25 to 35) + M.bodytemperature -= 30 * TEMPERATURE_DAMAGE_COEFFICIENT + if(prob(1)) + M.emote("shiver") + if(isslime(M)) + M.bodytemperature -= rand(15,20) + if(35 to INFINITY) + M.bodytemperature -= 40 * TEMPERATURE_DAMAGE_COEFFICIENT + if(prob(5)) + M.emote("shiver") + if(isslime(M)) + M.bodytemperature -= rand(20,25) + M.bodytemperature = max(50, M.bodytemperature) ..() /datum/reagent/consumable/frostoil/reaction_turf(turf/T, reac_volume)