diff --git a/code/__defines/atmos.dm b/code/__defines/atmos.dm index 8212e4c911..5f852954dd 100644 --- a/code/__defines/atmos.dm +++ b/code/__defines/atmos.dm @@ -17,6 +17,7 @@ #define BREATH_MOLES (ONE_ATMOSPHERE * BREATH_VOLUME / (T20C * R_IDEAL_GAS_EQUATION)) // Amount of air to take a from a tile #define BREATH_PERCENTAGE (BREATH_VOLUME / CELL_VOLUME) // Amount of air needed before pass out/suffocation commences. #define HUMAN_NEEDED_OXYGEN (MOLES_CELLSTANDARD * BREATH_PERCENTAGE * 0.16) +#define HUMAN_HEAT_CAPACITY 280000 //J/K For 80kg person #define SOUND_MINIMUM_PRESSURE 10 diff --git a/code/__defines/math_physics.dm b/code/__defines/math_physics.dm index 7c7c6d0d85..987cb1ba9d 100644 --- a/code/__defines/math_physics.dm +++ b/code/__defines/math_physics.dm @@ -13,6 +13,7 @@ #define GAS_CRITICAL_TEMPERATURE 132.65 // K. The critical point temperature for air. #define RADIATOR_EXPOSED_SURFACE_AREA_RATIO 0.04 // (3 cm + 100 cm * sin(3deg))/(2*(3+100 cm)). Unitless ratio. +#define HUMAN_EXPOSED_SURFACE_AREA 5.2 //m^2, surface area of 1.7m (H) x 0.46m (D) cylinder #define T0C 273.15 // 0.0 degrees celcius #define T20C 293.15 // 20.0 degrees celcius diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index afce6b0065..c701296a26 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -591,7 +591,14 @@ pl_effects() break - if(!istype(get_turf(src), /turf/space)) //space is not meant to change your body temperature. + if(istype(get_turf(src), /turf/space)) + //Don't bother if the temperature drop is less than 0.1 anyways. Hopefully BYOND is smart enough to turn this constant expression into a constant + 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) + var/temperature_loss = heat_loss/HUMAN_HEAT_CAPACITY + bodytemperature -= temperature_loss + else var/loc_temp = T0C if(istype(loc, /obj/mecha)) var/obj/mecha/M = loc @@ -605,7 +612,7 @@ pressure_alert = 0 return // Temperatures are within normal ranges, fuck all this processing. ~Ccomp - //Body temperature adjusts depending on surrounding atmosphere based on your thermal protection + //Body temperature adjusts depending on surrounding atmosphere based on your thermal protection (convection) 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. @@ -698,13 +705,15 @@ /mob/living/carbon/human/proc/stabilize_body_temperature() if (species.passive_temp_gain) // We produce heat naturally. bodytemperature += species.passive_temp_gain + if (species.body_temperature == null) + return //this species doesn't have metabolic thermoregulation var/body_temperature_difference = species.body_temperature - bodytemperature if (abs(body_temperature_difference) < 0.5) return //fuck this precision if (on_fire) - return //too busy for pesky convection + return //too busy for pesky metabolic regulation 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. @@ -1324,31 +1333,36 @@ if(260 to 280) bodytemp.icon_state = "temp-3" else bodytemp.icon_state = "temp-4" else + //TODO: precalculate all of this stuff when the species datum is created + var/base_temperature = species.body_temperature + if(base_temperature == null) //some species don't have a set metabolic temperature + base_temperature = (species.heat_level_1 + species.cold_level_1)/2 + var/temp_step - if (bodytemperature >= species.body_temperature) - temp_step = (species.heat_level_1 - species.body_temperature)/4 + if (bodytemperature >= base_temperature) + temp_step = (species.heat_level_1 - base_temperature)/4 if (bodytemperature >= species.heat_level_1) bodytemp.icon_state = "temp4" - else if (bodytemperature >= species.body_temperature + temp_step*3) + else if (bodytemperature >= base_temperature + temp_step*3) bodytemp.icon_state = "temp3" - else if (bodytemperature >= species.body_temperature + temp_step*2) + else if (bodytemperature >= base_temperature + temp_step*2) bodytemp.icon_state = "temp2" - else if (bodytemperature >= species.body_temperature + temp_step*1) + else if (bodytemperature >= base_temperature + temp_step*1) bodytemp.icon_state = "temp1" else bodytemp.icon_state = "temp0" - else if (bodytemperature < species.body_temperature) - temp_step = (species.body_temperature - species.cold_level_1)/4 + else if (bodytemperature < base_temperature) + temp_step = (base_temperature - species.cold_level_1)/4 if (bodytemperature <= species.cold_level_1) bodytemp.icon_state = "temp-4" - else if (bodytemperature <= species.body_temperature - temp_step*3) + else if (bodytemperature <= base_temperature - temp_step*3) bodytemp.icon_state = "temp-3" - else if (bodytemperature <= species.body_temperature - temp_step*2) + else if (bodytemperature <= base_temperature - temp_step*2) bodytemp.icon_state = "temp-2" - else if (bodytemperature <= species.body_temperature - temp_step*1) + else if (bodytemperature <= base_temperature - temp_step*1) bodytemp.icon_state = "temp-1" else bodytemp.icon_state = "temp0" diff --git a/code/modules/mob/living/carbon/human/species/station/station.dm b/code/modules/mob/living/carbon/human/species/station/station.dm index 444a808619..77f40ad0c4 100644 --- a/code/modules/mob/living/carbon/human/species/station/station.dm +++ b/code/modules/mob/living/carbon/human/species/station/station.dm @@ -260,6 +260,7 @@ heat_level_2 = 1000 heat_level_3 = 2000 + body_temperature = null passive_temp_gain = 10 // This should cause IPCs to stabilize at ~80 C in a 20 C environment. flags = CAN_JOIN | IS_WHITELISTED | NO_BREATHE | NO_SCAN | NO_BLOOD | NO_PAIN | NO_POISON