Skip to content

Commit

Permalink
Temperature Feedback (#3358)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

Original code and new alert icons by Rylie, a few bug fixes and
modifications by me, and PRed on behalf of her.

The sweating alert icons specifically are from Citadel Station

Adds comfortable temperature ranges for species. Instead of the temp
indicator only showing up when you hit dangerous temps and start taking
damage, it will now show up once you exceed your comfortable range.

Being in temperature damage is now indicated by a sweating/fan overheat
alert for organics and IPCs respectively in the case of overheating, or
shivering if you're too cold.

Comfortable temp ranges are provisional, and Im open to changing them.

## Why It's Good For The Game

<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

Gives a bit more nuanced feedback on your temperature, and provides a
transition state between from "you're a bit warm" to "you are now dying
of heatstroke" instead of immediately going from fine to melting alive
with no HUD warning.
## Changelog

:cl: Rye-Rice, Gristlebee
add: Comfortable Temperature ranges
imageadd: Temperature HUD alerts
/:cl: 

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
Gristlebee authored Sep 18, 2024
1 parent 29177cb commit e08ed92
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 38 deletions.
33 changes: 29 additions & 4 deletions code/_onclick/hud/alert.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,40 @@ Override makes it so the alert is not replaced until cleared by a clear_alert wi
icon_state = "gross3"

/atom/movable/screen/alert/hot
name = "Too Hot"
desc = "You're flaming hot! Get somewhere cooler and take off any insulating clothing like a fire suit."
name = "Hot"
desc = "It's quite warm. Get somewhere cooler and take off any insulating clothing like a fire suit."
icon_state = "hot"

/atom/movable/screen/alert/warm
name = "Warm"
desc = "It's a bit warm, but not unbearably so."
icon_state = "hot"

/atom/movable/screen/alert/cold
name = "Too Cold"
desc = "You're freezing cold! Get somewhere warmer and take off any insulating clothing like a space suit."
name = "Cold"
desc = "It's quite cold. Get somewhere warmer and take off any insulating clothing like a space suit."
icon_state = "cold"

/atom/movable/screen/alert/chilly
name = "Chilly"
desc = "It's a bit chilly, but not unbearably so."
icon_state = "cold"

/atom/movable/screen/alert/sweat
name = "Sweating"
desc = "You're sweating and the heat is starting to hurt. Get somewhere cooler and take off any insulating clothing like a fire suit."
icon_state = "sweat"

/atom/movable/screen/alert/shiver
name = "Shivering"
desc = "You're shivering and the cold is starting to hurt. Get somewhere warmer and take off any insulating clothing like a space suit."
icon_state = "shiver"

/atom/movable/screen/alert/fans
name = "High Fan Speed"
desc = "Your fans are spinning quite fast, and your components are reaching a dangerous temperature! Get somewhere cooler and take off any insulating clothing like a fire suit."
icon_state = "fans"

/atom/movable/screen/alert/lowpressure
name = "Low Pressure"
desc = "The air around you is hazardously thin. A space suit would protect you."
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/turf_fire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define TURF_FIRE_VOLUME 150
#define TURF_FIRE_MAX_POWER 50

#define TURF_FIRE_ENERGY_PER_BURNED_OXY_MOL 12000
#define TURF_FIRE_ENERGY_PER_BURNED_OXY_MOL 30000
#define TURF_FIRE_BURN_RATE_BASE 0.12
#define TURF_FIRE_BURN_RATE_PER_POWER 0.02
#define TURF_FIRE_BURN_CARBON_DIOXIDE_MULTIPLIER 0.75
Expand Down
117 changes: 90 additions & 27 deletions code/modules/mob/living/carbon/human/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ GLOBAL_LIST_EMPTY(roundstart_races)
var/bodytemp_normal = HUMAN_BODYTEMP_NORMAL
/// Minimum amount of kelvin moved toward normal body temperature per tick.
var/bodytemp_autorecovery_min = HUMAN_BODYTEMP_AUTORECOVERY_MINIMUM
/// The maximum temperature the species is comfortable at. Going above this does not apply any effects, but warns players that the temperture is hot
var/max_temp_comfortable = (HUMAN_BODYTEMP_NORMAL + 7)
/// The minimum temperature the species is comfortable at. Going below this does not apply any effects, but warns players that the temperture is chilly
var/min_temp_comfortable = (HUMAN_BODYTEMP_NORMAL - 5)
/// This is the divisor which handles how much of the temperature difference between the current body temperature and 310.15K (optimal temperature) humans auto-regenerate each tick. The higher the number, the slower the recovery.
var/bodytemp_autorecovery_divisor = HUMAN_BODYTEMP_AUTORECOVERY_DIVISOR
///Similar to the autorecovery_divsor, but this is the divisor which is applied at the stage that follows autorecovery. This is the divisor which comes into play when the human's loc temperature is higher than their body temperature. Make it lower to lose bodytemp faster.
Expand All @@ -160,6 +164,10 @@ GLOBAL_LIST_EMPTY(roundstart_races)
var/bodytemp_cooling_rate_max = HUMAN_BODYTEMP_COOLING_MAX
/// The maximum rate at which a species can cool down per tick
var/bodytemp_heating_rate_max = HUMAN_BODYTEMP_HEATING_MAX
/// How much temp is our body stabilizing naturally?
var/bodytemp_natural_stabilization = 0
/// How much temp is the environment is causing us to charge?
var/bodytemp_environment_change = 0

///Does our species have colors for its' damage overlays?
var/use_damage_color = TRUE
Expand Down Expand Up @@ -1790,10 +1798,10 @@ GLOBAL_LIST_EMPTY(roundstart_races)
var/areatemp = H.get_temperature(environment)

if(H.stat != DEAD) // If you are dead your body does not stabilize naturally
natural_bodytemperature_stabilization(environment, H)
bodytemp_natural_stabilization = natural_bodytemperature_stabilization(environment, H)

if(!H.on_fire || areatemp > H.bodytemperature) // If we are not on fire or the area is hotter
H.adjust_bodytemperature((areatemp - H.bodytemperature), use_insulation=TRUE, use_steps=TRUE, hardsuit_fix=bodytemp_normal - H.bodytemperature)
bodytemp_environment_change = H.adjust_bodytemperature((areatemp - H.bodytemperature), use_insulation=TRUE, use_steps=TRUE, hardsuit_fix=bodytemp_normal - H.bodytemperature)

if(H.check_for_seal())
return
Expand Down Expand Up @@ -1853,32 +1861,77 @@ GLOBAL_LIST_EMPTY(roundstart_races)
/// Handle the body temperature status effects for the species
/// Traits for resitance to heat or cold are handled here.
/datum/species/proc/handle_body_temperature(mob/living/carbon/human/H)
var/body_temp = H.bodytemperature
var/total_change = bodytemp_natural_stabilization + bodytemp_environment_change

//tempature is no longer comfy, throw alert
if(body_temp > max_temp_comfortable && !HAS_TRAIT(H, TRAIT_RESISTHEAT))
SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "cold")
if(body_temp > bodytemp_heat_damage_limit)
var/burn_damage = calculate_burn_damage(H)
if(burn_damage < 2)
H.throw_alert("tempfeel", /atom/movable/screen/alert/hot, 3)
else
H.throw_alert("tempfeel", /atom/movable/screen/alert/hot, 2)
else
if(body_temp < (bodytemp_heat_damage_limit - 10))
// you are cooling down and exiting the danger zone
if(total_change < 0)
H.throw_alert("tempfeel", /atom/movable/screen/alert/warm)
else
H.throw_alert("tempfeel", /atom/movable/screen/alert/hot, 2)
else if(total_change > 1)
H.throw_alert("tempfeel", /atom/movable/screen/alert/warm)
else
H.clear_alert("tempfeel")
else if (body_temp < min_temp_comfortable && !HAS_TRAIT(H, TRAIT_RESISTCOLD))
SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "hot")
if(body_temp < 200)
H.throw_alert("tempfeel", /atom/movable/screen/alert/cold, 3)
else if(body_temp < bodytemp_cold_damage_limit)
H.throw_alert("tempfeel", /atom/movable/screen/alert/cold, 2)
else if(body_temp < (bodytemp_cold_damage_limit + 10))
// you are warming up and exiting the danger zone
if(total_change > 0)
H.throw_alert("tempfeel", /atom/movable/screen/alert/chilly)
else
H.throw_alert("tempfeel", /atom/movable/screen/alert/cold, 2)
else if(total_change < -1)
H.throw_alert("tempfeel", /atom/movable/screen/alert/chilly)
else
H.clear_alert("tempfeel")
else
H.clear_alert("tempfeel")

// Body temperature is too hot, and we do not have resist traits
if(H.bodytemperature > bodytemp_heat_damage_limit && !HAS_TRAIT(H, TRAIT_RESISTHEAT))
if(body_temp > bodytemp_heat_damage_limit && !HAS_TRAIT(H, TRAIT_RESISTHEAT))
// Clear cold mood and apply hot mood
SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "cold")
SEND_SIGNAL(H, COMSIG_ADD_MOOD_EVENT, "hot", /datum/mood_event/hot)

//Remove any slowdown from the cold.
H.remove_movespeed_modifier(/datum/movespeed_modifier/cold)

var/burn_damage = 0
var/firemodifier = H.fire_stacks / 50
if (!H.on_fire) // We are not on fire, reduce the modifier
firemodifier = min(firemodifier, 0)

// this can go below 5 at log 2.5
burn_damage = max(log(2 - firemodifier, (H.bodytemperature - H.get_body_temp_normal(apply_change=FALSE))) - 5,0)

// Display alerts based on the amount of fire damage being taken
if (burn_damage)
switch(burn_damage)
if(1 to 2)
H.throw_alert("temp", /atom/movable/screen/alert/hot, 1)
if(2 to 4)
H.throw_alert("temp", /atom/movable/screen/alert/hot, 2)
else
H.throw_alert("temp", /atom/movable/screen/alert/hot, 3)
var/burn_damage = calculate_burn_damage(H)

// sweats depending on burn damage, not actually a mechanic but a alternative to pinpoint when you are taking damage
if(burn_damage)
if(H.mob_biotypes & MOB_ROBOTIC) //robors have a alternative cooling fan graphic
switch(burn_damage)
if(0 to 2)
H.throw_alert("temp", /atom/movable/screen/alert/fans, 1)
if(2 to 4)
H.throw_alert("temp", /atom/movable/screen/alert/fans, 2)
else
H.throw_alert("temp", /atom/movable/screen/alert/fans, 3)
else
switch(burn_damage)
if(0 to 2)
H.throw_alert("temp", /atom/movable/screen/alert/sweat, 1)
if(2 to 4)
H.throw_alert("temp", /atom/movable/screen/alert/sweat, 2)
else
H.throw_alert("temp", /atom/movable/screen/alert/sweat, 3)

// Apply species and physiology modifiers to heat damage
burn_damage = burn_damage * heatmod * H.physiology.heat_mod
Expand All @@ -1891,7 +1944,7 @@ GLOBAL_LIST_EMPTY(roundstart_races)
H.apply_damage(burn_damage, BURN, spread_damage = TRUE)

// Body temperature is too cold, and we do not have resist traits
else if(H.bodytemperature < bodytemp_cold_damage_limit && !HAS_TRAIT(H, TRAIT_RESISTCOLD))
else if(body_temp < bodytemp_cold_damage_limit && !HAS_TRAIT(H, TRAIT_RESISTCOLD))
// clear any hot moods and apply cold mood
SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "hot")
SEND_SIGNAL(H, COMSIG_ADD_MOOD_EVENT, "cold", /datum/mood_event/cold)
Expand All @@ -1900,17 +1953,16 @@ GLOBAL_LIST_EMPTY(roundstart_races)
// Display alerts based on the amount of cold damage being taken
// Apply more damage based on how cold you are

var/bodytemp = H.bodytemperature
if(bodytemp < 120)
H.throw_alert("temp", /atom/movable/screen/alert/cold, 3)
if(body_temp < 120)
H.throw_alert("temp", /atom/movable/screen/alert/shiver, 3)
H.apply_damage(COLD_DAMAGE_LEVEL_3 * coldmod * H.physiology.cold_mod, BURN)

else if(bodytemp < 200)
H.throw_alert("temp", /atom/movable/screen/alert/cold, 2)
else if(body_temp < 200)
H.throw_alert("temp", /atom/movable/screen/alert/shiver, 2)
H.apply_damage(COLD_DAMAGE_LEVEL_2 * coldmod * H.physiology.cold_mod, BURN)

else
H.throw_alert("temp", /atom/movable/screen/alert/cold, 1)
H.throw_alert("temp", /atom/movable/screen/alert/shiver, 1)
H.apply_damage(COLD_DAMAGE_LEVEL_1 * coldmod * H.physiology.cold_mod, BURN)

// We are not to hot or cold, remove status and moods
Expand All @@ -1920,6 +1972,16 @@ GLOBAL_LIST_EMPTY(roundstart_races)
SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "cold")
SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "hot")

/datum/species/proc/calculate_burn_damage(mob/living/carbon/human/current_human)
var/burn_damage = 0
var/firemodifier = current_human.fire_stacks / 50
if (!current_human.on_fire) // We are not on fire, reduce the modifier
firemodifier = min(firemodifier, 0)

// this can go below 5 at log 2.5
burn_damage = max(log(2 - firemodifier, (current_human.bodytemperature - current_human.get_body_temp_normal(apply_change=FALSE))) - 5,0)
return burn_damage

/// Handle the air pressure of the environment
/datum/species/proc/handle_environment_pressure(datum/gas_mixture/environment, mob/living/carbon/human/H)
var/pressure = environment.return_pressure()
Expand Down Expand Up @@ -2017,6 +2079,7 @@ GLOBAL_LIST_EMPTY(roundstart_races)

// Apply the natural stabilization changes
H.adjust_bodytemperature(natural_change)
return natural_change

//////////
// FIRE //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
bodytemp_heat_damage_limit = FIRE_MINIMUM_TEMPERATURE_TO_SPREAD // about 150C
// Cold temperatures hurt faster as it is harder to move with out the heat energy
bodytemp_cold_damage_limit = (T20C - 10) // about 10c

max_temp_comfortable = HUMAN_BODYTEMP_NORMAL + 100

hair_color = "fixedmutcolor"
hair_alpha = 140
mutant_bodyparts = list("elzu_horns", "tail_elzu")
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/living/carbon/human/species_types/kepori.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
bodytemp_normal = HUMAN_BODYTEMP_NORMAL + 30
bodytemp_heat_damage_limit = HUMAN_BODYTEMP_HEAT_DAMAGE_LIMIT + 30
bodytemp_cold_damage_limit = HUMAN_BODYTEMP_COLD_DAMAGE_LIMIT + 30
max_temp_comfortable = HUMAN_BODYTEMP_NORMAL + 40
min_temp_comfortable = HUMAN_BODYTEMP_NORMAL - 3
mutanttongue = /obj/item/organ/tongue/kepori
species_language_holder = /datum/language_holder/kepori
var/datum/action/innate/keptackle/keptackle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
// Lizards are coldblooded and can stand a greater temperature range than humans
bodytemp_heat_damage_limit = HUMAN_BODYTEMP_HEAT_DAMAGE_LIMIT + 20 // This puts lizards 10 above lavaland max heat for ash lizards.
bodytemp_cold_damage_limit = HUMAN_BODYTEMP_COLD_DAMAGE_LIMIT - 10

max_temp_comfortable = HUMAN_BODYTEMP_NORMAL + 25
min_temp_comfortable = HUMAN_BODYTEMP_NORMAL - 3
loreblurb = "The Sarathi are a cold-blooded reptilian species originating from the planet Kalixcis, where they evolved alongside the Elzuosa. Kalixcian culture places no importance on blood-bonds, and those from it tend to consider their family anyone they are sufficiently close to, and choose their own names."

ass_image = 'icons/ass/asslizard.png'
Expand Down Expand Up @@ -91,7 +94,7 @@

/// Lizards are cold blooded and do not stabilize body temperature naturally
/datum/species/lizard/natural_bodytemperature_stabilization(datum/gas_mixture/environment, mob/living/carbon/human/H)
return
return 0

/datum/species/lizard/random_name(gender,unique,lastname)
if(unique)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/human/species_types/vox.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
bodytemp_cold_divisor = VOX_BODYTEMP_COLD_DIVISOR
bodytemp_autorecovery_min = VOX_BODYTEMP_AUTORECOVERY_MIN

max_temp_comfortable = HUMAN_BODYTEMP_NORMAL + 20
min_temp_comfortable = HUMAN_BODYTEMP_NORMAL - 20

bodytype = BODYTYPE_VOX

species_chest = /obj/item/bodypart/chest/vox
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ All effects don't start immediately, but rather get worse over time; the rate is

if(bodytemperature >= min_temp && bodytemperature <= max_temp)
bodytemperature = clamp(bodytemperature + amount,min_temp,max_temp)
return amount


/////////
Expand Down
Binary file modified icons/hud/screen_alert.dmi
Binary file not shown.
10 changes: 5 additions & 5 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@
#include "code\__DEFINES\wires.dm"
#include "code\__DEFINES\dcs\flags.dm"
#include "code\__DEFINES\dcs\helpers.dm"
#include "code\__DEFINES\dcs\signals\signals.dm"
#include "code\__DEFINES\dcs\signals\signals_mod.dm"
#include "code\__DEFINES\dcs\signals\signals_storage.dm"
#include "code\__DEFINES\dcs\signals\signals_mob\signals_mob_carbon.dm"
#include "code\__DEFINES\dcs\signals\signals.dm"
#include "code\__DEFINES\dcs\signals\signals_obj\signals_object.dm"
#include "code\__DEFINES\dcs\signals\signals_obj\signals_item\signals_clothing.dm"
#include "code\__DEFINES\dcs\signals\signals_obj\signals_item\signals_food.dm"
Expand Down Expand Up @@ -2811,6 +2811,10 @@
#include "code\modules\mob\living\simple_animal\slime\slime.dm"
#include "code\modules\mob\living\simple_animal\slime\slime_say.dm"
#include "code\modules\mob\living\simple_animal\slime\subtypes.dm"
#include "code\modules\mob_spawner\burrow.dm"
#include "code\modules\mob_spawner\hivebot.dm"
#include "code\modules\mob_spawner\spawner.dm"
#include "code\modules\mob_spawner\spawner_componet.dm"
#include "code\modules\mod\mod_actions.dm"
#include "code\modules\mod\mod_activation.dm"
#include "code\modules\mod\mod_ai.dm"
Expand All @@ -2835,10 +2839,6 @@
#include "code\modules\mod\modules\modules_storage.dm"
#include "code\modules\mod\modules\modules_supply.dm"
#include "code\modules\mod\modules\modules_visor.dm"
#include "code\modules\mob_spawner\burrow.dm"
#include "code\modules\mob_spawner\hivebot.dm"
#include "code\modules\mob_spawner\spawner.dm"
#include "code\modules\mob_spawner\spawner_componet.dm"
#include "code\modules\modular_computers\laptop_vendor.dm"
#include "code\modules\modular_computers\computers\_modular_computer_shared.dm"
#include "code\modules\modular_computers\computers\item\computer.dm"
Expand Down

0 comments on commit e08ed92

Please sign in to comment.