Spawners, turrets and waypoints

System entities: spawners that bring in waves, turrets, tower defense waypoints, flags and bases, spatialised sounds and point lights.

Some entities are not scenery but systems: they create other entities, shoot, mark out a path, play a sound or cast light. They are placed like any other entity, often without an asset: spawners have their own group on the Cast step, the others are placed on the Build step.

Spawners

A spawner brings in an asset at a regular interval, within a disc around it, while the game is running. It works in every mode. Spawned entities rest on the ground and inherit the spawner’s tag, so a rule can count them.

assetstringrequired
Id of the asset to spawn (must exist in the document).
roleEntityRolerequired
Role of the created entities: enemy, coin, prop…
everynumberrequired
Seconds between two spawns. The first one comes right at the start.
maxnumberrequired
Maximum number of this spawner’s entities alive at once.
totalnumberrequired
Total number of spawns; 0 = unlimited.
radiusnumberrequired
Half-size of the spawn area around the spawner.
behavior'patrol' | 'chase'Default 'chase'
Behaviour of spawned enemies (speed 2.4, 1 HP).
raptor-nest.jsonJSON
{
  "role": "spawner",
  "assetId": null,
  "pos": [12, 1, -10],
  "params": {
    "tag": "nest",
    "spawner": { "asset": "a_raptor", "role": "enemy", "every": 7, "max": 4, "total": 12, "radius": 3, "behavior": "chase" }
  }
}
One of the two nests of “Fern Valley Hunt”: a raptor every 7 s, at most 4 alive, 12 in total.

Caps

SourceLimit
Spawnermax alive, total over the game.
spawn / spawnAt actions20 entities per action.
sandbox.spawn()20 per frame and 400 actors in total, see Sandbox and limits.
Document3,000 placed entities, 96 assets.

Turrets

A turret turns toward the nearest living enemy in range and removes 1 HP per shot. It is solid. Outside tower defense, each enemy a turret kills is worth 10 points and emits the kill event.

rangenumberDefault 7 (6 in tower defense)
Firing range in units.
fireRatenumberDefault 1.2 (1.6 in tower defense)
Shots per second.

Waypoints and tower defense

Waypoint road of the Last Gate template
“Last Gate”: one spawn, ten numbered waypoints and the gate to defend.

In tower defense, enemies appear at the spawn points (or the first waypoint when there are none), follow the waypoint entities in params.order order, then hit the base. The first placed enemy is the template and is hidden at start.

  1. Draw the road

    Place waypoints and number them with order (1, 2, 3…).
  2. Place the base and the spawn

    The base at the end of the road, a spawn point at the start.
  3. Give an enemy template

    One enemy placed anywhere: its asset is used for every wave.
  4. Provide a turret

    A placed turret (or an asset whose name contains turret, tower or cannon): that is what the player builds by clicking the ground.
QuantityValue
Wavesrules.waves, 8 by default.
Base healthrules.lives, 10 by default; each enemy that arrives removes 1.
Enemies per wave4 + 3 × n
HP and speed2 + ⌊1,2 × n⌋ PV, 2,2 + 0,15 × n u/s
Gold120 at start, 10 + 2 × n per enemy, +40 per wave held.
Turret cost60, then +15 % with each build.
PlacementNot within 1.6 of a turret or 1.8 of a waypoint.
Waypoints are only used by tower defense. In race, checkpoint entities (with the same order field) lay out the circuit the bots follow.

Flags, bases and teams

Capture the flag needs exactly one flag and one base per team, each with params.team set to red or blue. If one is missing the game stops with a message. The player is always on the red team; placed enemies are blue bots.

EntityteamRole in the game
flagredYour flag: the bots try to steal it. If dropped in the field, touch it to send it home.
flagblueThe flag to steal.
baseredBring the blue flag here, with yours at home, to score.
baseblueWhere the bots score.

The number of captures to win comes from settings.win when its type is flags (3 otherwise). Details in Game modes.

Spatial sounds

A sound entity plays an audio file positioned in the world: the further the player, the quieter, down to silence past the radius. The sound starts when the game begins. For non-spatial background music use rules.music; for a one-shot sound, the sound rule action.

urlstringrequired
URL of the audio file.
radiusnumberrequired
Maximum hearing distance; volume starts dropping at 40 % of this radius.
loopbooleanrequired
Play in a loop.
volumenumberrequired
Volume from 0 to 1.

Lights

A light entity adds a point light 1 unit above it. With an asset (a lantern) the object is visible; without one only the light exists. Hiding the entity switches the light off, showing it switches it back on: handy for a switch driven by a rule.

tintstringDefault '#ffd58a'
Light colour.
strengthnumberDefault 1
Intensity (multiplied by 8 internally).
radiusnumberDefault 8
Range, multiplied by the entity’s scale.
lantern.jsonJSON
{ "role": "light", "assetId": "a_lantern", "params": { "tint": "#ffb547", "strength": 1.2, "radius": 8 } }

See also