Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

data/spawn_rules/

A spawn rule: what spawns, how often relative to other rules, where, and under which conditions (grass under open sky, at least 24 blocks from every player). Spawners name the rules they use. A rule’s conditions are gameplay conditions in the spawn context, with the spawn atoms (manifold:surface_block, manifold:sky_light); the block a manifold:surface_block atom names must exist (DATA010). Loaded by the server only.

Registrymanifold-ai:spawn-rule
Filesdata/spawn_rules/*.ron, *.update.ron, *.final.ron
Sidesserver: only the server loads it
Readsnothing
ContractPopulation, data stage

Entry

A record, written SpawnRule(..); the name before the parentheses is optional.

FieldTypeRequiredDefaultDescription
idstringyesThe rule’s key, <mod-id>:<path>.
archetypestringyesThe archetype it spawns (manifold:archetype key).
categorystringyesIts category (manifold-ai:spawn-category key).
weightu32no1Its weight among a spawner’s rules, at least 1.
conditionscondition or NonenoalwaysA condition in the spawn context, also written Condition(..) or Some(..).
densityDensityno6 per region, 12 of its categoryDensity limits per region.
distanceSpawnDistanceno24 to 64 blocksHow far from players it spawns.
persistencePersistencePolicynoAmbientHow its creatures persist. Only Ambient is available.

Example

From game/flagship-game/data/spawn_rules/boar.ron:

SpawnRule(
    id: "flagship-game:spawn/boar_meadow",
    archetype: "flagship-game:boar",
    category: "flagship-game:cat/creature",
    weight: 10,
    conditions: All([
        Ext(atom: "manifold:surface_block", args: (block: "flagship:grass")),
        Ext(atom: "manifold:sky_light", args: (at_least: 8)),
    ]),
    density: (per_region: 6, category_per_region: 12),
    distance: (min: 24.0, max: 64.0),
    persistence: Ambient,
)

Types

Density

A rule’s density limits.

A record: Density(..) or (..).

FieldTypeRequiredDefaultDescription
per_regionu16no6The most creatures of this rule in one interest region.
category_per_regionu16no12The most creatures of its category in one region, for this rule.

SpawnDistance

How far from players a rule spawns, in blocks.

A record: SpawnDistance(..) or (..).

FieldTypeRequiredDefaultDescription
minf32no24.0At least this far from every player.
maxf32no64.0At most this far from some player.

PersistencePolicy

How a spawner’s creatures persist.

VariantWrittenDescription
AmbientAmbientNever saved: gone after a restart and spawned afresh; despawn by distance.
EncounterEncounterNot available yet (Talos E2): refused at load.
PersistentPersistentNot available yet (Talos E4): refused at load.

Value forms used here: condition.