Files
Paradise/code/game/objects/effects/spawners/random/pool/spawn_pool.dm
warriorstar-orion 5b516c3166 Scatter depot loot to the solar winds. (#27954)
* Scatter depot loot to the solar winds.

* make zoo spawners guaranteed

* INFINITY also used for spawn_all_loot, whoops

* move abandoned sec shuttle spawner to locked crate

* Can't use spawn_all_loot and nested lists together

* Reduce pixel offset on mech transport spawn scatter

* set updatepaths script number

* incorporate changes from #27398 and remove old spawners

* some numbers tweaking

* pct -> %

* move briefcase from common to rare for ruins

* lower loot budget from 1800 -> 1700
2025-01-23 07:41:04 +00:00

61 lines
2.1 KiB
Plaintext

/// Keeps track of the available points for a given pool, as well as any
/// spawners that need to keep track globally of the number of any specific item
/// that they spawn.
/datum/spawn_pool
/// The ID of the spawn pool. All spawners registered to this pool must use this ID.
var/id
/// The number of points left for the spawner to use. Starts at its initial value.
var/available_points = 0
/// A list of all spawners registered to this pool.
var/list/known_spawners = list()
/// A key-value list of spawners with TRUE `unique_picks` to a shared copy of their
/// loot pool. When items from one of these spawners are spawned, it is removed
/// from the shared loot pool so it never spawns again.
var/list/unique_spawners = list()
/// A list of spawners whose `guaranteed` is `TRUE`. These spawners will
/// always spawn, and always before anything else,
var/list/guaranteed_spawners = list()
/datum/spawn_pool/proc/can_afford(points)
if(available_points >= points)
return TRUE
return FALSE
/datum/spawn_pool/proc/consume(points)
available_points -= points
/datum/spawn_pool/proc/process_guaranteed_spawners()
while(length(guaranteed_spawners))
var/obj/effect/spawner/random/pool/spawner = guaranteed_spawners[length(guaranteed_spawners)]
guaranteed_spawners.len--
spawner.spawn_loot()
qdel(spawner)
QDEL_LIST_CONTENTS(guaranteed_spawners)
/datum/spawn_pool/proc/process_spawners()
process_guaranteed_spawners()
shuffle_inplace(known_spawners)
while(length(known_spawners))
if(available_points <= 0)
break
var/obj/effect/spawner/random/pool/spawner = known_spawners[length(known_spawners)]
known_spawners.len--
if(spawner.point_value != INFINITY && available_points < spawner.point_value)
qdel(spawner)
continue
spawner.spawn_loot()
if(length(guaranteed_spawners))
WARNING("non-guaranteed spawner [spawner.type] spawned a guaranteed spawner, this should be avoided")
process_guaranteed_spawners()
qdel(spawner)
log_game("finished spawner [id] with [length(known_spawners)] remaining spawners and [available_points] points remaining.")
QDEL_LIST_CONTENTS(known_spawners)