mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Body temperature fixes and updates
Body temperature regulation is now based on species, and environmental temperature now respects the air density when affecting living/humans. This also fixes some bugs with heat/cold protection handling and improves the way synthetic species body temperatures are handled to be much more logical. IPCs always gain temperature but cool down because of their environment. When the heat transfer to the environment is reduced because of the lack of air, this will cause IPCs to heat up. As well, having an infection will increase your body temperature, and body scanners now detect infections.
This commit is contained in:
@@ -674,20 +674,27 @@
|
||||
else
|
||||
loc_temp = environment.temperature
|
||||
|
||||
if(adjusted_pressure < species.warning_low_pressure && adjusted_pressure > species.warning_low_pressure && abs(loc_temp - 293.15) < 20 && abs(bodytemperature - 310.14) < 0.5 && environment.phoron < MOLES_PHORON_VISIBLE)
|
||||
if(adjusted_pressure < species.warning_high_pressure && adjusted_pressure > species.warning_low_pressure && abs(loc_temp - bodytemperature) < 20 && bodytemperature < species.heat_level_1 && bodytemperature > species.cold_level_1 && environment.phoron < MOLES_PHORON_VISIBLE)
|
||||
return // Temperatures are within normal ranges, fuck all this processing. ~Ccomp
|
||||
|
||||
//Body temperature adjusts depending on surrounding atmosphere based on your thermal protection
|
||||
if(loc_temp < species.cold_level_1) //Place is colder than we are
|
||||
var/temp_adj = 0
|
||||
if(loc_temp < bodytemperature) //Place is colder than we are
|
||||
var/thermal_protection = 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)
|
||||
var/amt = min((1-thermal_protection) * ((loc_temp - bodytemperature) / BODYTEMP_COLD_DIVISOR), BODYTEMP_COOLING_MAX)
|
||||
bodytemperature += amt
|
||||
else if (loc_temp > species.heat_level_1) //Place is hotter than we are
|
||||
temp_adj = (1-thermal_protection) * ((loc_temp - bodytemperature) / BODYTEMP_COLD_DIVISOR) //this will be negative
|
||||
else if (loc_temp > bodytemperature) //Place is hotter than we are
|
||||
var/thermal_protection = 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)
|
||||
var/amt = min((1-thermal_protection) * ((loc_temp - bodytemperature) / BODYTEMP_HEAT_DIVISOR), BODYTEMP_HEATING_MAX)
|
||||
bodytemperature += amt
|
||||
temp_adj = (1-thermal_protection) * ((loc_temp - bodytemperature) / BODYTEMP_HEAT_DIVISOR)
|
||||
|
||||
//Use heat transfer as proportional to the gas density. However, we only care about the relative density vs standard 101 kPa/20 C air. Therefore we can use mole ratios
|
||||
var/relative_density = environment.total_moles() / MOLES_CELLSTANDARD
|
||||
temp_adj *= relative_density
|
||||
|
||||
if (temp_adj > BODYTEMP_HEATING_MAX) temp_adj = BODYTEMP_HEATING_MAX
|
||||
if (temp_adj < BODYTEMP_COOLING_MAX) temp_adj = BODYTEMP_COOLING_MAX
|
||||
bodytemperature += temp_adj
|
||||
|
||||
// +/- 50 degrees from 310.15K is the 'safe' zone, where no damage is dealt.
|
||||
if(bodytemperature > species.heat_level_1)
|
||||
@@ -738,12 +745,8 @@
|
||||
bodytemperature += 0.5 * TEMPERATURE_DAMAGE_COEFFICIENT //Synthetics suffer overheating in a vaccuum. ~Z
|
||||
|
||||
else
|
||||
|
||||
if(species && species.flags & IS_SYNTHETIC)
|
||||
bodytemperature += 1 * TEMPERATURE_DAMAGE_COEFFICIENT
|
||||
|
||||
if( !(COLD_RESISTANCE in mutations))
|
||||
adjustBruteLoss( LOW_PRESSURE_DAMAGE )
|
||||
apply_damage(LOW_PRESSURE_DAMAGE, BRUTE, used_weapon = "Low Pressure")
|
||||
pressure_alert = -2
|
||||
else
|
||||
pressure_alert = -1
|
||||
@@ -770,23 +773,27 @@
|
||||
temp_change = (temperature - current)
|
||||
return temp_change
|
||||
*/
|
||||
|
||||
proc/stabilize_temperature_from_calories()
|
||||
var/body_temperature_difference = 310.15 - bodytemperature
|
||||
|
||||
proc/stabilize_body_temperature()
|
||||
if (species && species.flags & IS_SYNTHETIC)
|
||||
bodytemperature += species.synth_temp_gain //that CPU/posibrain just keeps putting out heat.
|
||||
return
|
||||
|
||||
var/body_temperature_difference = species.body_temperature - bodytemperature
|
||||
if (abs(body_temperature_difference) < 0.5)
|
||||
return //fuck this precision
|
||||
switch(bodytemperature)
|
||||
if(-INFINITY to 260.15) //260.15 is 310.15 - 50, the temperature where you start to feel effects.
|
||||
if(-INFINITY to 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.
|
||||
nutrition -= 2
|
||||
var/recovery_amt = max((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), BODYTEMP_AUTORECOVERY_MINIMUM)
|
||||
// log_debug("Cold. Difference = [body_temperature_difference]. Recovering [recovery_amt]")
|
||||
bodytemperature += recovery_amt
|
||||
if(260.15 to 360.15)
|
||||
if(species.cold_level_1 to species.heat_level_1)
|
||||
var/recovery_amt = body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR
|
||||
// log_debug("Norm. Difference = [body_temperature_difference]. Recovering [recovery_amt]")
|
||||
bodytemperature += recovery_amt
|
||||
if(360.15 to INFINITY) //360.15 is 310.15 + 50, the temperature where you start to feel effects.
|
||||
if(species.heat_level_1 to INFINITY) //360.15 is 310.15 + 50, the temperature where you start to feel effects.
|
||||
//We totally need a sweat system cause it totally makes sense...~
|
||||
var/recovery_amt = min((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), -BODYTEMP_AUTORECOVERY_MINIMUM) //We're dealing with negative numbers
|
||||
// log_debug("Hot. Difference = [body_temperature_difference]. Recovering [recovery_amt]")
|
||||
@@ -1087,7 +1094,7 @@
|
||||
else //ALIVE. LIGHTS ARE ON
|
||||
updatehealth() //TODO
|
||||
if(!in_stasis)
|
||||
stabilize_temperature_from_calories() //Body temperature adjusts itself
|
||||
stabilize_body_temperature() //Body temperature adjusts itself
|
||||
handle_organs() //Optimized.
|
||||
handle_blood()
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
var/heat_level_1 = 360 // Heat damage level 1 above this point.
|
||||
var/heat_level_2 = 400 // Heat damage level 2 above this point.
|
||||
var/heat_level_3 = 1000 // Heat damage level 2 above this point.
|
||||
|
||||
var/body_temperature = 310.15 //non-IS_SYNTHETIC species will try to stabilize at this temperature. (also affects temperature processing)
|
||||
var/synth_temp_gain = 0 //IS_SYNTHETIC species will gain this much temperature every second
|
||||
|
||||
var/darksight = 2
|
||||
var/hazard_high_pressure = HAZARD_HIGH_PRESSURE // Dangerously high pressure.
|
||||
@@ -279,6 +282,8 @@
|
||||
heat_level_2 = 3000
|
||||
heat_level_3 = 4000
|
||||
|
||||
body_temperature = T0C + 15 //make the plant people have a bit lower body temperature, why not
|
||||
|
||||
flags = IS_WHITELISTED | NO_BREATHE | REQUIRE_LIGHT | NO_SCAN | IS_PLANT | RAD_ABSORB | NO_BLOOD | IS_SLOW | NO_PAIN
|
||||
|
||||
blood_color = "#004400"
|
||||
@@ -326,6 +331,8 @@
|
||||
heat_level_1 = 2000
|
||||
heat_level_2 = 3000
|
||||
heat_level_3 = 4000
|
||||
|
||||
synth_temp_gain = 6.7 //round(40 / BODYTEMP_COLD_DIVISOR, 0.1) //this should cause IPCs to stabilize at ~60 C in a 20 C environment. Based on some CPU operating temperatures
|
||||
|
||||
flags = IS_WHITELISTED | NO_BREATHE | NO_SCAN | NO_BLOOD | NO_PAIN | IS_SYNTHETIC
|
||||
|
||||
|
||||
Reference in New Issue
Block a user