Skip to content

Commit

Permalink
[MIRROR] Adds a visual effect to breathing in cold environments (#2734)
Browse files Browse the repository at this point in the history
* Adds a visual effect to breathing in cold environments (#82336)

## About The Pull Request

Humans (who breathe) (with lungs) now has a particle associated when
breathing in cold air. The colder the air, the more likely the particle
to occur per breath.


https://github.com/tgstation/tgstation/assets/51863163/f375dd1b-87f6-4124-9329-4714fe988c16

Other changes:

- Adjusts the probability of getting "your lungs feel cold/hot" when
breathing cold/hot air depending on how cold/hot the air is.
- Very cold air now has a chance of causing humans to shiver when they
breathe it in.

## Why It's Good For The Game

Some nice VFX to breathe some style into the game. 

## Changelog

:cl: Melbert
qol: Breathing cold air now has a particle effect associated, careful
not to let your glasses fog up.
qol: Breathing cold air will now occasionally make your spaceman shiver.
Brrr.
/:cl:

* Adds a visual effect to breathing in cold environments

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: MrMelbert <[email protected]>
  • Loading branch information
3 people authored Apr 4, 2024
1 parent a96515d commit dac5b2d
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 8 deletions.
13 changes: 13 additions & 0 deletions code/game/objects/effects/particles/smoke.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,16 @@
fadein = 0.7 SECONDS
position = generator(GEN_VECTOR, list(-3, 5, 0), list(3, 6.5, 0), NORMAL_RAND)
velocity = generator(GEN_VECTOR, list(-0.1, 0.4, 0), list(0.1, 0.5, 0), NORMAL_RAND)

/particles/fog
icon = 'icons/effects/particles/smoke.dmi'
icon_state = list("chill_1" = 2, "chill_2" = 2, "chill_3" = 1)

/particles/fog/breath
count = 1
spawning = 1
lifespan = 1 SECONDS
fade = 0.5 SECONDS
grow = 0.05
spin = 2
color = "#fcffff77"
70 changes: 62 additions & 8 deletions code/modules/surgery/organs/internal/lungs/_lungs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -754,31 +754,85 @@

if(!HAS_TRAIT(breather, TRAIT_RESISTCOLD)) // COLD DAMAGE
var/cold_modifier = breather.dna.species.coldmod
var/breath_effect_prob = 0
if(breath_temperature < cold_level_3_threshold)
breather.apply_damage(cold_level_3_damage*cold_modifier, cold_damage_type, spread_damage = TRUE)
breather.apply_damage(cold_level_3_damage * cold_modifier, cold_damage_type, spread_damage = TRUE)
breath_effect_prob = 100
if(breath_temperature > cold_level_3_threshold && breath_temperature < cold_level_2_threshold)
breather.apply_damage(cold_level_2_damage*cold_modifier, cold_damage_type, spread_damage = TRUE)
breather.apply_damage(cold_level_2_damage * cold_modifier, cold_damage_type, spread_damage = TRUE)
breath_effect_prob = 50
if(breath_temperature > cold_level_2_threshold && breath_temperature < cold_level_1_threshold)
breather.apply_damage(cold_level_1_damage*cold_modifier, cold_damage_type, spread_damage = TRUE)
breather.apply_damage(cold_level_1_damage * cold_modifier, cold_damage_type, spread_damage = TRUE)
breath_effect_prob = 25
if(breath_temperature < cold_level_1_threshold)
if(prob(20))
if(prob(sqrt(breath_effect_prob) * 4))
to_chat(breather, span_warning("You feel [cold_message] in your [name]!"))
if(prob(50))
breather.emote("shiver")
if(prob(breath_effect_prob))
// Breathing into your mask, no particle. We can add fogged up glasses later
if(breather.is_mouth_covered())
return
// Even though breathing via internals TECHNICALLY exhales into the environment, we'll still block it
if(breather.internal || breather.external)
return
emit_breath_particle(breather, /particles/fog/breath)

if(!HAS_TRAIT(breather, TRAIT_RESISTHEAT)) // HEAT DAMAGE
var/heat_modifier = breather.dna.species.heatmod
var/heat_message_prob = 0
if(breath_temperature > heat_level_1_threshold && breath_temperature < heat_level_2_threshold)
breather.apply_damage(heat_level_1_damage*heat_modifier, heat_damage_type, spread_damage = TRUE)
breather.apply_damage(heat_level_1_damage * heat_modifier, heat_damage_type, spread_damage = TRUE)
heat_message_prob = 100
if(breath_temperature > heat_level_2_threshold && breath_temperature < heat_level_3_threshold)
breather.apply_damage(heat_level_2_damage*heat_modifier, heat_damage_type, spread_damage = TRUE)
breather.apply_damage(heat_level_2_damage * heat_modifier, heat_damage_type, spread_damage = TRUE)
heat_message_prob = 50
if(breath_temperature > heat_level_3_threshold)
breather.apply_damage(heat_level_3_damage*heat_modifier, heat_damage_type, spread_damage = TRUE)
breather.apply_damage(heat_level_3_damage * heat_modifier, heat_damage_type, spread_damage = TRUE)
heat_message_prob = 25
if(breath_temperature > heat_level_1_threshold)
if(prob(20))
if(prob(sqrt(heat_message_prob) * 4))
to_chat(breather, span_warning("You feel [hot_message] in your [name]!"))

// The air you breathe out should match your body temperature
breath.temperature = breather.bodytemperature

/// Creates a particle effect off the mouth of the passed mob.
/obj/item/organ/internal/lungs/proc/emit_breath_particle(mob/living/carbon/human/breather, particle_type)
ASSERT(ispath(particle_type, /particles))

var/obj/effect/abstract/particle_holder/holder = new(breather, particle_type)
var/particles/breath_particle = holder.particles
var/breath_dir = breather.dir

var/list/particle_grav = list(0, 0.1, 0)
var/list/particle_pos = list(0, breather.get_mob_height() + 2, 0)
if(breath_dir & NORTH)
particle_grav[2] = 0.2
breath_particle.rotation = pick(-45, 45)
// Layer it behind the mob since we're facing away from the camera
holder.pixel_w -= 4
holder.pixel_y += 4
if(breath_dir & WEST)
particle_grav[1] = -0.2
particle_pos[1] = -5
breath_particle.rotation = -45
if(breath_dir & EAST)
particle_grav[1] = 0.2
particle_pos[1] = 5
breath_particle.rotation = 45
if(breath_dir & SOUTH)
particle_grav[2] = 0.2
breath_particle.rotation = pick(-45, 45)
// Shouldn't be necessary but just for parity
holder.pixel_w += 4
holder.pixel_y -= 4

breath_particle.gravity = particle_grav
breath_particle.position = particle_pos

QDEL_IN(holder, breath_particle.lifespan)

/obj/item/organ/internal/lungs/on_life(seconds_per_tick, times_fired)
. = ..()
if(failed && !(organ_flags & ORGAN_FAILING))
Expand Down
Binary file modified icons/effects/particles/smoke.dmi
Binary file not shown.

0 comments on commit dac5b2d

Please sign in to comment.