From 7e472af23832e3e6fad33990ddb74b4f8ccda5da Mon Sep 17 00:00:00 2001 From: mwerezak Date: Tue, 10 Nov 2015 23:36:58 -0500 Subject: [PATCH] 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 a5f3fae6a6b..97d9b786a0c 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"