-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3235 from MistakeNot4892/bodytemp
Condensing some bodytemp handling on /mob/living.
- Loading branch information
Showing
4 changed files
with
53 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/mob/living/proc/has_metabolic_thermoregulation() | ||
if(isSynthetic()) | ||
return FALSE | ||
var/decl/species/my_species = get_species() | ||
if(my_species?.body_temperature == null) | ||
return FALSE | ||
return TRUE | ||
|
||
/mob/living/proc/get_bodytemperature_difference() | ||
var/decl/species/my_species = get_species() | ||
if(my_species) | ||
return (my_species.body_temperature - bodytemperature) | ||
return 0 | ||
|
||
/mob/living/proc/stabilize_body_temperature() | ||
|
||
// This species doesn't have metabolic thermoregulation and can't adjust towards a baseline. | ||
if(!has_metabolic_thermoregulation()) | ||
return | ||
|
||
// We may produce heat naturally. | ||
var/decl/species/my_species = get_species() | ||
if(my_species?.passive_temp_gain) | ||
bodytemperature += my_species.passive_temp_gain | ||
|
||
var/body_temperature_difference = get_bodytemperature_difference() | ||
if (abs(body_temperature_difference) < 0.5) | ||
return //fuck this precision | ||
|
||
var/cold_1 = get_temperature_threshold(COLD_LEVEL_1) | ||
var/heat_1 = get_temperature_threshold(HEAT_LEVEL_1) | ||
if(bodytemperature < cold_1) //260.15 is 310.15 - 50, the temperature where you start to feel effects. | ||
var/nut_remove = 10 * DEFAULT_HUNGER_FACTOR | ||
if(get_nutrition() >= nut_remove) //If we are very, very cold we'll use up quite a bit of nutriment to heat us up. | ||
adjust_nutrition(-nut_remove) | ||
bodytemperature += max((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), BODYTEMP_AUTORECOVERY_MINIMUM) | ||
else if(cold_1 <= bodytemperature && bodytemperature <= heat_1) | ||
bodytemperature += body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR | ||
else if(bodytemperature > heat_1) //360.15 is 310.15 + 50, the temperature where you start to feel effects. | ||
var/hyd_remove = 10 * DEFAULT_THIRST_FACTOR | ||
if(get_hydration() >= hyd_remove) | ||
adjust_hydration(-hyd_remove) | ||
bodytemperature += min((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), -BODYTEMP_AUTORECOVERY_MINIMUM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters