Skip to content

Commit

Permalink
Insulation now properly protects you from icebox snowstorms (+ partic…
Browse files Browse the repository at this point in the history
…le weather code improvements)
  • Loading branch information
Absolucy committed Oct 22, 2024
1 parent 006f66f commit 9847162
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,39 @@ SUBSYSTEM_DEF(particle_weather)

var/enabled = TRUE

//This has been mangled - currently only supports 1 weather effect serverwide so I can finish this
/datum/controller/subsystem/particle_weather/Initialize(start_timeofday)
if(CONFIG_GET(flag/disable_particle_weather))
disable()
return SS_INIT_NO_NEED
for(var/particle_weather_type in subtypesof(/datum/particle_weather))
var/datum/particle_weather/particle_weather = new particle_weather_type
if(particle_weather.target_trait in SSmapping.config.particle_weathers)
elligble_weathers[particle_weather_type] = particle_weather.probability

if(particle_weather.eclipse)
elligble_eclipse_weathers[particle_weather_type] = particle_weather.probability

return SS_INIT_SUCCESS

/datum/controller/subsystem/particle_weather/Recover()
running_weather = SSparticle_weather.running_weather
running_eclipse_weather = SSparticle_weather.running_eclipse_weather

next_hit = SSparticle_weather.next_hit
next_weather_start = SSparticle_weather.next_weather_start

next_hit_eclipse = SSparticle_weather.next_hit_eclipse
next_weather_start_eclipse = SSparticle_weather.next_weather_start_eclipse

particle_effect = SSparticle_weather.particle_effect
weather_special_effect = SSparticle_weather.weather_special_effect
weather_effect = SSparticle_weather.weather_effect

particle_effect_eclipse = SSparticle_weather.particle_effect_eclipse
weather_special_effect_eclipse = SSparticle_weather.weather_special_effect_eclipse
weather_effect_eclipse = SSparticle_weather.weather_effect_eclipse

/datum/controller/subsystem/particle_weather/stat_entry(msg)
if(enabled)
if(running_weather?.running)
Expand All @@ -47,54 +80,38 @@ SUBSYSTEM_DEF(particle_weather)

/datum/controller/subsystem/particle_weather/fire()
// process active weather
if(!running_weather && next_hit && COOLDOWN_FINISHED(src, next_weather_start))
if(QDELETED(running_weather) && next_hit && COOLDOWN_FINISHED(src, next_weather_start))
run_weather(next_hit)

if(!running_eclipse_weather && next_hit_eclipse && COOLDOWN_FINISHED(src, next_weather_start_eclipse))
if(QDELETED(running_eclipse_weather) && next_hit_eclipse && COOLDOWN_FINISHED(src, next_weather_start_eclipse))
run_weather(next_hit_eclipse, eclipse = TRUE)

if(!running_weather && !next_hit && length(elligble_weathers))
if(QDELETED(running_weather) && !next_hit && length(elligble_weathers))
for(var/our_event in elligble_weathers)
if(our_event && prob(elligble_weathers[our_event]))
next_hit = new our_event()
COOLDOWN_START(src, next_weather_start, rand(-3000, 3000) + initial(next_hit.weather_duration_upper) / 5)
break

if(!running_eclipse_weather && !next_hit_eclipse && length(elligble_eclipse_weathers))
if(QDELETED(running_eclipse_weather) && !next_hit_eclipse && length(elligble_eclipse_weathers))
for(var/our_event in elligble_eclipse_weathers)
if(our_event && prob(elligble_eclipse_weathers[our_event]))
next_hit_eclipse = new our_event("Eclipse")
COOLDOWN_START(src, next_weather_start_eclipse, rand(-3000, 3000) + initial(next_hit_eclipse.weather_duration_upper) / 5)
break

if(running_eclipse_weather)
if(!QDELETED(running_eclipse_weather))
running_eclipse_weather.tick()

if(weather_special_effect_eclipse)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_WEATHER_EFFECT, weather_special_effect_eclipse)

if(running_weather)
if(!QDELETED(running_weather))
running_weather.tick()

if(weather_special_effect)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_WEATHER_EFFECT, weather_special_effect)


//This has been mangled - currently only supports 1 weather effect serverwide so I can finish this
/datum/controller/subsystem/particle_weather/Initialize(start_timeofday)
if(CONFIG_GET(flag/disable_particle_weather))
disable()
return SS_INIT_NO_NEED
for(var/i in subtypesof(/datum/particle_weather))
var/datum/particle_weather/particle_weather = new i
if(particle_weather.target_trait in SSmapping.config.particle_weathers)
elligble_weathers[i] = particle_weather.probability

if(particle_weather.eclipse)
elligble_eclipse_weathers[i] = particle_weather.probability

return SS_INIT_SUCCESS

/datum/controller/subsystem/particle_weather/proc/disable()
flags |= SS_NO_FIRE
enabled = FALSE
Expand Down Expand Up @@ -133,44 +150,49 @@ SUBSYSTEM_DEF(particle_weather)
/datum/controller/subsystem/particle_weather/proc/make_eligible(datum/particle_weather/possible_weather, probability = 10)
elligble_weathers[possible_weather] = probability

/datum/controller/subsystem/particle_weather/proc/get_weather_effect(atom/movable/screen/plane_master/weather_effect/W)
if(W.z_type == "Default")
if(!weather_effect)
weather_effect = new /obj()
/datum/controller/subsystem/particle_weather/proc/get_weather_effect(atom/movable/screen/plane_master/weather_effect/weather_plane_master)
switch(weather_plane_master.z_type)
if("Default")
if(QDELETED(weather_effect))
weather_effect = new /obj()
weather_effect.particles = particle_effect
weather_effect.filters += filter(type="alpha", render_source="[WEATHER_RENDER_TARGET] #[weather_plane_master.offset]")
weather_effect.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
return weather_effect
if("Eclipse")
if(QDELETED(weather_effect_eclipse))
weather_effect_eclipse = new /obj()
weather_effect_eclipse.filters += filter(type="alpha", render_source="[WEATHER_ECLIPSE_RENDER_TARGET] #[weather_plane_master.offset]")
weather_effect_eclipse.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
return weather_effect_eclipse

/datum/controller/subsystem/particle_weather/proc/set_particle_effect(particles/particle, z_type)
if(!particle)
return
switch(z_type)
if("Default")
if(QDELETED(weather_effect))
return
particle_effect = particle
weather_effect.particles = particle_effect
weather_effect.filters += filter(type="alpha", render_source="[WEATHER_RENDER_TARGET] #[W.offset]")
weather_effect.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
return weather_effect
else if(W.z_type == "Eclipse")
if(!weather_effect_eclipse)
weather_effect_eclipse = new /obj()
weather_effect_eclipse.filters += filter(type="alpha", render_source="[WEATHER_ECLIPSE_RENDER_TARGET] #[W.offset]")
weather_effect_eclipse.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
return weather_effect_eclipse

/datum/controller/subsystem/particle_weather/proc/set_particle_effect(particles/P, z_type)
if(z_type == "Default")
if(!P || !weather_effect)
return
particle_effect = P
weather_effect.particles = particle_effect
else if(z_type == "Eclipse")
if(!P || !weather_effect_eclipse)
return
particle_effect_eclipse = P
weather_effect_eclipse.particles = particle_effect_eclipse
if("Eclipse")
if(QDELETED(weather_effect_eclipse))
return
particle_effect_eclipse = particle
weather_effect_eclipse.particles = particle_effect_eclipse

/datum/controller/subsystem/particle_weather/proc/stop_weather(z_type)
if(z_type == "Default")
QDEL_NULL(running_weather)
QDEL_NULL(particle_effect)
//QDEL_NULL(weather_effect)
QDEL_NULL(weather_special_effect)
else if(z_type == "Eclipse")
QDEL_NULL(running_eclipse_weather)
QDEL_NULL(particle_effect_eclipse)
//QDEL_NULL(weather_effect_eclipse)
QDEL_NULL(weather_special_effect_eclipse)
switch(z_type)
if("Default")
QDEL_NULL(running_weather)
QDEL_NULL(particle_effect)
//QDEL_NULL(weather_effect)
QDEL_NULL(weather_special_effect)
if("Eclipse")
QDEL_NULL(running_eclipse_weather)
QDEL_NULL(particle_effect_eclipse)
//QDEL_NULL(weather_effect_eclipse)
QDEL_NULL(weather_special_effect_eclipse)

/obj/weather_effect
plane = LIGHTING_PLANE
Loading

0 comments on commit 9847162

Please sign in to comment.