Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Adds a visual effect to breathing in cold environments #2734

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading