From 28db4587f20a7baec26fc7723a6a2777a03007d9 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Mon, 26 Oct 2015 14:50:52 -0400 Subject: [PATCH 1/3] Fixes #11354 --- code/modules/mob/living/carbon/human/life.dm | 2 ++ code/modules/mob/living/carbon/human/species/station/station.dm | 1 + 2 files changed, 3 insertions(+) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 74844fd3b1..b5db5a83d9 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -687,6 +687,8 @@ /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 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 b63dd51963..47783470a4 100644 --- a/code/modules/mob/living/carbon/human/species/station/station.dm +++ b/code/modules/mob/living/carbon/human/species/station/station.dm @@ -270,6 +270,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 From 52deec9fde613d0ce5a976e47766b381d0dbdba1 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Tue, 10 Nov 2015 23:16:53 -0500 Subject: [PATCH 2/3] Adds thermal radiation into space for human mobs Main effect is that IPCs won't gain temperature infinitely anymore. --- code/__defines/atmos.dm | 1 + code/__defines/math_physics.dm | 1 + code/modules/mob/living/carbon/human/life.dm | 13 ++++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) 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 b5db5a83d9..a5f3fae6a6 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -580,7 +580,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 @@ -594,7 +601,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. @@ -695,7 +702,7 @@ 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. From 7e472af23832e3e6fad33990ddb74b4f8ccda5da Mon Sep 17 00:00:00 2001 From: mwerezak Date: Tue, 10 Nov 2015 23:36:58 -0500 Subject: [PATCH 3/3] Fixes temperature HUD being incorrect for species with null body_temperature. --- code/modules/mob/living/carbon/human/life.dm | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index a5f3fae6a6..97d9b786a0 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1322,31 +1322,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"