Files
Paradise/code/controllers/subsystem/SSweather.dm
warriorstar-orion 07a22cdb64 Enable multi-sector lavaland. (#28358)
* Enable multi-sector lavaland.

* fix exclude ci paths

* remove old lavaland

* Lewc review and other cleanups, add GPS stuff

* rebuild tgui

* fix ash storm no eligible areas

* update test config, don't skip out on test level creation

* unfuck example config

* whoops

* add north entrances to legion arena for easier traversal

* TM config -- REVERT BEFORE MERGE

* Make SSweather work on traits directly

* flip order of procgen/ruin placement

* fix GPS

* fix budget in code

* clobber prod config for lavaland ruin budget for TM

* add relay to gulag

* some more guards for procgen

* separate relays

* make gulag and base one ruin

* bridge improvements

* actually remove gulag map

* make linter happy

* harden ruin placement against failing

Config changes made. Bypassing code ownership.
2025-04-08 06:18:46 -07:00

85 lines
2.9 KiB
Plaintext

//Used for all kinds of weather, ex. lavaland ash storms.
SUBSYSTEM_DEF(weather)
name = "Weather"
flags = SS_BACKGROUND
wait = 10
runlevels = RUNLEVEL_GAME
offline_implications = "Ash storms will no longer trigger. No immediate action is needed."
var/list/processing = list()
var/list/eligible_traits = list()
var/list/next_hit_by_zlevel = list() //Used by barometers to know when the next storm is coming
cpu_display = SS_CPUDISPLAY_LOW
/datum/controller/subsystem/weather/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing)
.["custom"] = cust
/datum/controller/subsystem/weather/fire()
// process active weather
for(var/V in processing)
var/datum/weather/W = V
if(W.aesthetic || W.stage != WEATHER_MAIN_STAGE)
continue
for(var/i in GLOB.mob_living_list)
var/mob/living/L = i
if(W.can_weather_act(L))
W.weather_act(L)
// start random weather on relevant levels
while(length(eligible_traits))
var/trait = eligible_traits[length(eligible_traits)]
var/possible_weathers = eligible_traits[trait]
var/datum/weather/W = pickweight(possible_weathers)
var/randTime = rand(3000, 6000)
var/list/zlevels = levels_by_trait(trait)
for(var/z in zlevels)
addtimer(CALLBACK(src, PROC_REF(make_eligible), trait, possible_weathers), randTime + initial(W.weather_duration_upper), TIMER_UNIQUE) //Around 5-10 minutes between weathers
next_hit_by_zlevel["[z]"] = world.time + randTime + initial(W.telegraph_duration)
run_weather(W, zlevels)
eligible_traits.len--
/datum/controller/subsystem/weather/Initialize()
if(!GLOB.configuration.general.enable_default_weather_events)
log_debug("disabling default weather events due to configuration")
return
for(var/V in subtypesof(/datum/weather))
var/datum/weather/W = V
// any weather with a probability set may occur at random
if(W::probability)
LAZYINITLIST(eligible_traits[W::target_trait])
eligible_traits[W::target_trait][W] = W::probability
/datum/controller/subsystem/weather/proc/run_weather(datum/weather/weather_datum_type)
if(istext(weather_datum_type))
for(var/V in subtypesof(/datum/weather))
var/datum/weather/W = V
if(initial(W.name) == weather_datum_type)
weather_datum_type = V
break
if(!ispath(weather_datum_type, /datum/weather))
CRASH("run_weather called with invalid weather_datum_type: [weather_datum_type || "null"]")
var/list/zlevels = levels_by_trait(weather_datum_type::target_trait)
var/datum/weather/W = new weather_datum_type(zlevels)
W.telegraph()
/datum/controller/subsystem/weather/proc/make_eligible(trait, list/possible_weathers)
eligible_traits[trait] = possible_weathers
for(var/zlevel in levels_by_trait(trait))
next_hit_by_zlevel["[zlevel]"] = null
/datum/controller/subsystem/weather/proc/get_weather(z, area/active_area)
var/datum/weather/A
for(var/V in processing)
var/datum/weather/W = V
if((z in W.impacted_z_levels) && W.area_type == active_area)
A = W
break
return A