Skip to content

Commit

Permalink
[MIRROR] Adds support for cold mist effect for low temperatures (#1472)
Browse files Browse the repository at this point in the history
Co-authored-by: CrimsonShrike <[email protected]>
  • Loading branch information
SierraHelper and CrimsonShrike authored Nov 18, 2023
1 parent 990a036 commit b4001c8
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 6 deletions.
2 changes: 2 additions & 0 deletions code/__defines/__renderer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

#define HEAT_EFFECT_PLANE -4
#define HEAT_EFFECT_TARGET "*heat"
#define COLD_EFFECT_TARGET "*cold"
#define COLD_EFFECT_BACK_TARGET "*coldb"
#define HEAT_COMPOSITE_TARGET "*heatc"
#define WARP_EFFECT_PLANE -3

Expand Down
12 changes: 11 additions & 1 deletion code/__defines/_renderer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ GLOBAL_LIST_EMPTY(zmimic_renderers)
group = RENDER_GROUP_FINAL
plane = RENDER_GROUP_SCENE


/// Render group for stuff OUTSIDE the typical game context - UI, full screen effects, etc.
/atom/movable/renderer/screen_group
name = "Screen Group"
Expand Down Expand Up @@ -279,6 +278,7 @@ GLOBAL_LIST_EMPTY(zmimic_renderers)
mouse_opacity = MOUSE_OPACITY_UNCLICKABLE

var/obj/gas_heat_object = null
var/obj/gas_cold_object = null // Not strictly a heat effect but similar setup so may as well

/atom/movable/renderer/heat/proc/Setup()
var/mob/M = owner
Expand All @@ -289,17 +289,27 @@ GLOBAL_LIST_EMPTY(zmimic_renderers)
if(gas_heat_object)
vis_contents -= gas_heat_object

if(gas_cold_object)
vis_contents -= gas_cold_object

if (quality == GLOB.PREF_LOW)
QDEL_NULL(gas_heat_object)
gas_heat_object = new /obj/heat(null)

QDEL_NULL(gas_cold_object)
gas_cold_object = new /obj/effect/cold_mist_gas(null)
else
QDEL_NULL(gas_heat_object)
QDEL_NULL(gas_cold_object)
gas_cold_object = new /obj/particle_emitter/mist/gas(null)
if (quality == GLOB.PREF_MED)
gas_heat_object = new /obj/particle_emitter/heat(null)
else if (quality == GLOB.PREF_HIGH)
gas_heat_object = new /obj/particle_emitter/heat/high(null)

vis_contents += gas_heat_object
if(config.enable_cold_mist)
vis_contents += gas_cold_object


/atom/movable/renderer/heat/Initialize()
Expand Down
4 changes: 4 additions & 0 deletions code/__defines/atmos.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
#define CARBON_LIFEFORM_FIRE_RESISTANCE (T0C + 200)
#define CARBON_LIFEFORM_FIRE_DAMAGE 4

#define FOGGING_TEMPERATURE (T0C + 5)
#define MAX_FOG_TEMPERATURE (T0C - 50)

// Phoron fire properties.
#define PHORON_MINIMUM_BURN_TEMPERATURE (T0C + 126) //400 K - autoignite temperature in tanks and canisters - enclosed environments I guess
#define PHORON_FLASHPOINT (T0C + 246) //519 K - autoignite temperature in air if that ever gets implemented.
Expand Down Expand Up @@ -126,3 +129,4 @@
#define GAS_PHORON "phoron"
#define GAS_BORON "boron"
#define GAS_HEAT "heat" //Not a real gas, used for visual effects
#define GAS_COLD "cold" //Not a real gas, used for visual effects
4 changes: 4 additions & 0 deletions code/controllers/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@
var/static/shutdown_on_reboot = FALSE
// [/SIERRA-ADD]

var/static/enable_cold_mist = FALSE


/datum/configuration/New()
load_config()
Expand Down Expand Up @@ -861,6 +863,8 @@
if("minimum_byondacc_age")
minimum_byondacc_age = text2num(value)
// [/SIERRA-ADD]
if ("enable_cold_mist")
enable_cold_mist = TRUE
else
log_misc("Unknown setting in config/config.txt: '[name]'")

Expand Down
30 changes: 30 additions & 0 deletions code/game/objects/effects/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,33 @@
pixel_x = -176
pixel_y = -176
z_flags = ZMM_IGNORE

/obj/effect/cold_mist
icon = 'icons/effects/tile_effects.dmi'
icon_state = "frontfog"
layer = FIRE_LAYER
alpha = 170

/obj/effect/cold_mist/Initialize()
. = ..()
AddOverlays(image(icon = 'icons/effects/tile_effects.dmi', icon_state = "backfog", layer = BELOW_OBJ_LAYER))

//Handling it as an overlay is not layering properly with render targets
/obj/effect/cold_mist_gas_back
icon = 'icons/effects/tile_effects.dmi'
icon_state = "backfog"
layer = BELOW_OBJ_LAYER
render_target = COLD_EFFECT_BACK_TARGET

/obj/effect/cold_mist_gas
icon = 'icons/effects/tile_effects.dmi'
icon_state = "frontfog"
render_target = COLD_EFFECT_TARGET
layer = FIRE_LAYER
appearance_flags = DEFAULT_APPEARANCE_FLAGS | KEEP_TOGETHER
var/obj/effect/cold_mist_gas_back/b = null

/obj/effect/cold_mist_gas/Initialize()
. = ..()
b = new()
vis_contents += b
50 changes: 50 additions & 0 deletions code/game/objects/effects/particles/particles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@
color = "white"


/particles/mist
name = "mist"
icon = 'icons/effects/particles.dmi'
icon_state = list("steam_1" = 1, "steam_2" = 1, "steam_3" = 1)
count = 500
spawning = 4
lifespan = 5 SECONDS
fade = 1 SECOND
fadein = 1 SECOND
velocity = generator("box", list(-0.5, -0.25, 0), list(0.5, 0.25, 0), NORMAL_RAND)
position = generator("box", list(-20, -16), list(20, -2), UNIFORM_RAND)
friction = 0.2
grow = 0.0015


/particles/mist/back
name = "mist_back"
spawning = 7
position = generator("box", list(-20, -1), list(20, 20), UNIFORM_RAND)
lifespan = 6 SECONDS
fadein = 1.5 SECONDS

/particles/fire_sparks
name = "fire sparks"
width = 500
Expand Down Expand Up @@ -333,3 +355,31 @@

/obj/particle_emitter/heat/high
particle_type = "high heat"


/obj/particle_emitter/mist
particle_type = "mist"
layer = FIRE_LAYER

/obj/particle_emitter/mist/back
particle_type = "mist_back"
layer = BELOW_OBJ_LAYER


/obj/particle_emitter/mist/back/gas
render_target = COLD_EFFECT_BACK_TARGET

/obj/particle_emitter/mist/back/gas/Initialize(mapload, time, _color)
. = ..()
filters += filter(type="alpha", render_source = COLD_EFFECT_TARGET, flags = MASK_INVERSE)


//for cold gas effect
/obj/particle_emitter/mist/gas
render_target = COLD_EFFECT_TARGET
var/obj/particle_emitter/mist/back/b = /obj/particle_emitter/mist/back/gas

/obj/particle_emitter/mist/gas/Initialize(mapload, time, _color)
. = ..()
b = new b(null)
vis_contents += b
19 changes: 19 additions & 0 deletions code/modules/xgm/xgm_gas_data.dm
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,22 @@ var/global/datum/xgm_gas_data/gas_data
. = ..()
icon = null
icon_state = null

/obj/effect/gas_cold_back
render_source = COLD_EFFECT_BACK_TARGET
plane = DEFAULT_PLANE
layer = BELOW_OBJ_LAYER

/obj/gas_overlay/cold
name = "gas"
desc = "You shouldn't be clicking this."
gas_id = GAS_COLD
render_source = COLD_EFFECT_TARGET
var/obj/effect/gas_cold_back/b = null

/obj/gas_overlay/cold/Initialize(mapload, gas)
. = ..()
icon = null
icon_state = null
b = new()
vis_contents += b
26 changes: 21 additions & 5 deletions code/modules/xgm/xgm_gas_mixture.dm
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@
for(var/obj/gas_overlay/O in graphic)
if(istype(O, /obj/gas_overlay/heat))
continue
if(istype(O, /obj/gas_overlay/cold))
continue
if(gas[O.gas_id] <= gas_data.overlay_limit[O.gas_id])
LAZYADD(graphic_remove, O)
for(var/g in gas_data.overlay_limit)
Expand All @@ -359,13 +361,20 @@
LAZYADD(graphic_add, tile_overlay)
. = 0

var/tile_overlay = get_tile_overlay(GAS_HEAT)
var/heat_overlay = get_tile_overlay(GAS_HEAT)
//If it's hot add something
if(temperature >= CARBON_LIFEFORM_FIRE_RESISTANCE)
if(!(tile_overlay in graphic))
LAZYADD(graphic_add, tile_overlay)
else if (tile_overlay in graphic)
LAZYADD(graphic_remove, tile_overlay)
if(!(heat_overlay in graphic))
LAZYADD(graphic_add, heat_overlay)
else if (heat_overlay in graphic)
LAZYADD(graphic_remove, heat_overlay)

var/cold_overlay = get_tile_overlay(GAS_COLD)
if(temperature <= FOGGING_TEMPERATURE && (return_pressure() >= (ONE_ATMOSPHERE / 4)))
if(!(cold_overlay in graphic))
LAZYADD(graphic_add, cold_overlay)
else if (cold_overlay in graphic)
LAZYADD(graphic_remove, cold_overlay)

//Apply changes
if(graphic_add && length(graphic_add))
Expand All @@ -382,6 +391,11 @@
if(new_alpha != O.alpha)
O.update_alpha_animation(new_alpha)
continue
if(istype(O, /obj/gas_overlay/cold))
var/new_alpha = clamp(max(125, 200 * (1 - ((temperature - MAX_FOG_TEMPERATURE) / (FOGGING_TEMPERATURE - MAX_FOG_TEMPERATURE)))), 125, 200)
if(new_alpha != O.alpha)
O.update_alpha_animation(new_alpha)
continue
var/concentration_mod = clamp(gas[O.gas_id] / total_moles, 0.1, 1)
var/new_alpha = min(230, round(pressure_mod * concentration_mod * 180, 5))
if(new_alpha != O.alpha)
Expand All @@ -391,6 +405,8 @@
if(!LAZYACCESS(tile_overlay_cache, gas_id))
if(gas_id == GAS_HEAT) //Not a real gas but functionally same thing
LAZYSET(tile_overlay_cache, gas_id, new/obj/gas_overlay/heat(null, GAS_HEAT))
if(gas_id == GAS_COLD) //Not a real gas but functionally same thing
LAZYSET(tile_overlay_cache, gas_id, new/obj/gas_overlay/cold(null, GAS_COLD))
else
LAZYSET(tile_overlay_cache, gas_id, new/obj/gas_overlay(null, gas_id))
return tile_overlay_cache[gas_id]
Expand Down
Binary file modified icons/effects/particles.dmi
Binary file not shown.
Binary file modified icons/effects/tile_effects.dmi
Binary file not shown.

0 comments on commit b4001c8

Please sign in to comment.