# stalkerKit 1.0.2
Horror monsters that hunt the player. Put a `Stalker` on a character, pick a **kind** with one field, and it listens, follows your torch light, stalks you out of sight, hunts where it heard you, searches where it lost you, chases, attacks, and slips back into a vent when it is hurt or caught in your light too long, to come back later. Five kinds ship (pursuer, shambler, lurker, light-shy, blind hunter); each is plain data a designer tunes without code.
stalkerKit is built on **aiKit** (brains, senses, memory), **navKit** (movement) and **SecondWind** (health and damage). That means **weaponsKit** weapons hurt the monsters with no extra wiring, and every aiKit character hears the same noises.
## Install
Install `stalkerKit.package` from ZeroMind (search "stalkerKit" or "monster that hunts the player by sound and light"). It needs aiKit 1.4.0 or later in the world (aiKit brings navKit, SecondWind, Lifeline and MatchFlow); 1.4.0 is the release that adds carried lights (`AI.setCarriedLight`), which is how a torch gives the player away.
## First example
In code that runs in play on the host, once the level's colliders exist, with a navKit map baked over the floor (`require("~navKit.api").bake({ kind = "grid" })`, a frame or more after the walls are spawned; see Known limits):
```lua
local Stalkers = require("stalkerKit.api")
-- a vent the pursuer can slip into (stand it on the floor in front of the opening)
Stalkers.addLair({ -56, 0, -404 })
Stalkers.addLair({ -4, 0, -456 })
-- the hunter and a drowned diver
local pursuer = Stalkers.spawn("pursuer", { -25, 0, -412 })
local diver = Stalkers.spawn("shambler", { -20, 0, -430 })
-- your game hands over its own: here a stand-in player body, its camera's forward and a shot
local playerBody = entity.spawn("playerBody"); playerBody.position = vector.create(-25, 0, -420)
local cameraForward = vector.create(0, 0, -1)
local shooterBody, shotPosition = playerBody, vector.create(-25, 1.5, -420)
-- weapon fire, doors and torch clicks give the player away
Stalkers.hearNoise(shotPosition, "gunshot", shooterBody)
-- a torch kit says how visible a player is (0 dark .. 1 torch on) and where the beam points
Stalkers.setPlayerLight(playerBody, 1, cameraForward)
-- a tension director reads how close the danger is
local danger = Stalkers.threatFor(playerBody) -- 0..1
Stalkers.on("noticed", function(e) print(e.entity.name, "is after", e.target.name) end)
```
Or place it by hand: a synced entity with `stalkerKit.Stalker { kind = "pursuer" }` (it adds the aiKit `Brain` itself), and `stalkerKit.StalkerLair` on the entities in front of your vents.
## Kinds
| kind | look | senses | what it does | dies? |
|---|---|---|---|---|
| `pursuer` | tall, gaunt, too-long limbs and claws, pale wet skin, barnacle crusts, an eyeless elongated skull with a slit of needle teeth | sees only lit things (beyond 4.5 m), 24 m, 140°; hears 1.7× as far; notices a torch beam in its face from 16 m and a lit torch inside its cone from 36 m | the main hunter: hears shots, running, doors, torch clicks and thrown things; stalks out of sight at 8-14 m for up to 9 s, commits when you come close, shine your torch on it or it has watched long enough; chases, attacks (28 dmg); hunts and searches the last-known spot; after 5 s lit, 22% health lost in 6 s or 22 s of chasing it screeches and runs to the nearest vent, crawls in, heals for 16-30 s and crawls out of the vent nearest a player | no: at 20% health it retreats and heals |
| `shambler` | a drowned diver: bloated, in a rotting canvas suit, cracked brass helmet with a swollen face behind the porthole, lead boots, kelp | 9 m sight, poor hearing (0.8×), remembers for 40 s | slow (0.85 / 1.55 m/s), relentless (gives up after 12 s unseen), grabs and bites (34 dmg, slow), 360 HP, shrugs off small hits | yes |
| `lurker` | a darker, crouched pursuer thick with barnacles | 16 m, all round | waits motionless where you put it; moves only while no player is looking at it (freezes in your view); lunges from 3 m with a hiss; after a short chase melts back into a lair or the dark | yes |
| `lightshy` | pale pink skin with glowing blue spots on its skull | 18 m, notices beams | circles at 5-9 m at the edge of your light; a beam or strong light on it for 1.2 s makes it recoil to the nearest dark; strikes the moment you stand in darkness | yes |
| `blind` | grey-green, eyeless, a huge barnacle-crowned skull | hearing only, 2.2× (a walking footstep from 11 m) | goes where it heard; walk slowly (silent), throw something, or stand still | yes |
### Body styles (`stalker.body`, one field)
Every kind's look is its `stalker.body` knob, so any kind can wear any body: `pursuer`, `shambler`, `lurker`, `lightshy`, `blind`, and `drowned`.
`drowned` (new in 1.0.9): a tall (2.55 m), gaunt, long-limbed, hunched figure draped in river weed and dripping silt. Dark olive-brown silt skin that stays matte under a torch (roughness 0.88, metallic 0, almost no clearcoat), a dark elongated skull, long dark claws, no barnacles and nothing that glows. About 40 strands of weed hang from the head, shoulders, elbows, hands, back, hips and thighs; each hangs from gravity whatever the pose, bends in two segments and sways in `Body.update` (more while it moves), and a pool of 10 silt drops falls from the strand tips and is reused (parked while the body is hidden). Use it on any kind:
```lua
Stalkers.tuneKind("pursuer", { stalker = { body = "drowned" } }) -- every pursuer
Stalkers.defineKind("riverman", { base = "pursuer", stalker = { body = "drowned", sounds = "shambler" } })
```
Every kind is an aiKit preset (`stalker.<kind>`) plus a `stalker` table of knobs. Change them for the whole game:
```lua
local Stalkers = require("stalkerKit.api")
Stalkers.tuneKind("pursuer", { stalker = { stalkTime = 15, hideTime = { 40, 60 } }, preset = { move = { run = 5.6 } } })
Stalkers.defineKind("hound", { base = "pursuer", label = "Hound", preset = { move = { run = 7 } }, stalker = { stalk = false } })
```
### Knobs (`stalker` table)
| knob | pursuer | meaning |
|---|---|---|
| `drawnToLight` | 1 | 0..1: a lit torch inside its eyes' cone is a lead out to 36 m × this |
| `lightShy` | 0 | light level where it stands that it cannot bear (0 = never) |
| `litTolerance` | 5 | seconds in a beam / strong light before it breaks off (0 = never) |
| `attackOnlyInDark` | false | will not close in while the prey stands in light |
| `stalk`, `stalkRange`, `stalkTime`, `commitRange` | true, {8,14}, 9, 5 | keep its distance out of sight before committing |
| `huntRun` | true | runs to loud leads (gunshot, door, shout) |
| `chaseTimeout` | 22 | seconds of chase before it slips away (0 = never) |
| `searchTime`, `vanishAfterSearch` | 14, 0.5 | how long it searches; the chance it then slips into a lair |
| `retreats`, `hurtRetreat` | true, 0.22 | breaks off after losing this share of health within 6 s |
| `dies`, `floor` | false, 0.2 | false: never drops under `floor` health; retreats and heals instead |
| `hideTime`, `returnNear` | {16,30}, true | seconds in the lair; come out of the lair nearest a player |
| `lurk`, `freezeWhenWatched`, `springRange` | false, false, 3 | ambusher behaviour |
| `flinch`, `staggerAt` | 0.3, 30 | seconds a hit stops it; damage in one hit that staggers it twice as long |
| `grab` | false | slow grab-and-bite attack |
| `breathEvery`, `screechOnNotice` | {4,7}, true | feel |
| `body`, `sounds` | pursuer | which body and sound set it uses |
## API (`local Stalkers = require("stalkerKit.api")`)
| call | what it does |
|---|---|
| `Stalkers.spawn(kind, at, opts?) -> entity` | Spawn a synced stalker (`opts`: name, yaw, lairGroup, route, active). |
| `Stalkers.addLair(at, opts?) -> entity` | A vent / dark hole at a position, or on an entity (`opts`: group, kind = "vent" or "dark", yaw). |
| `Stalkers.sendTo(e, pos, { run })` | Send it to look at a spot. |
| `Stalkers.retreat(e)` | Break off now and slip into a lair. |
| `Stalkers.appearAt(e, pos, { face })` | It crawls out at a spot, then hunts toward the nearest player. Cancels a retreat still under way and releases a `holdHidden`. Orders sent in the same moment are all seen, in order; the last that changes what it does wins. |
| `Stalkers.holdHidden(e, on)` | Keep it in its lair until released. |
| `Stalkers.setKind(e, kind)`, `Stalkers.setActive(e, on)` | Switch kind; switch its brain off/on. |
| `Stalkers.hearNoise(pos, loudness, source?, kind?)` | A noise: metres or a name (`gunshot` 35, `slam` 22, `throw` 16, `door` 14, `run` 11, `impact` 10, `click`/`torch` 6, `footstep` 5). `source` = who gives themselves away. Goes through aiKit's noise bus. |
| `Stalkers.setPlayerLight(player, level, beamDir?, { range, cone })` | A torch kit reports a player's light (0..1) and beam; call it on the player's own peer. |
| `Stalkers.playerLight(player)` | The light as the monsters know it. |
| `Stalkers.threatFor(player) -> 0..1` | Danger for a tension director: nearest stalkers, what they do, whether they are after this player. Every peer. |
| `Stalkers.list()`, `Stalkers.info(e)`, `Stalkers.nearest(pos, { visible })` | What is out there. |
| `Stalkers.kindNames()`, `kind(name)`, `defineKind`, `tuneKind` | The kinds as data. |
| `Stalkers.on(event, fn) -> connection` | Events (below); call the connection or `:Disconnect()` to stop. |
## Events
| event | payload | fires on |
|---|---|---|
| `state` | `entity, state, from, detail`, state is `idle`, `stalk`, `hunt`, `search`, `chase`, `retreat` or `attack`; `detail` is the brain's own state (lurk, creep, recoil, vent, hidden, appear...) | every peer |
| `noticed` | `entity, target` | every peer |
| `lost` | `entity, target` | every peer |
| `attacked` | `entity, target, kind` (attack, grab) | every peer |
| `hurt` | `entity, amount, by` | the peer running it |
| `retreated` | `entity, lair` | the peer running it |
| `appeared` | `entity` | the peer running it |
| `died` | `entity, by` | the peer running it |
| `noise` | `position, radius, kind, source` | the peer that called hearNoise |
| `*` | `{ event, data }` | all of the above |
## Fighting them
Their health is SecondWind's, so weaponsKit's hitscan, projectiles and melee hit them (weaponsKit hits collider-less characters as a capsule; the Stalker sizes it to the creature: 2.3 m for the pursuer, 0.5 m wide for the shambler). A hit flinches them; one of 30+ damage staggers. The pursuer cannot be killed by default (`dies = false`): it screeches and retreats to heal, so ammo buys time, not safety. The shambler dies after about 360 damage. **Ammo is the level's job**: keep it scarce (a handful of rounds per encounter) so running, hiding in the dark and turning the torch off stay the better answer.
## Multiplayer
The host (or the entity's owner) runs the brains through aiKit; every peer builds the same body from the synced `kind` and animates it from the synced pose and one-shot counter, and plays the sounds locally, so nothing but a few fields crosses the network. Any player can be hunted. Torch reports go from each player's peer to the host through aiKit's carried-light channel. Scripted orders (`sendTo`, `retreat`, `appearAt`, `holdHidden`) work from any peer.
## Performance
Each stalker is one aiKit brain (senses 10×/s, thinks 15×/s) plus a skinned body with ~60-110 small parts and an AnimGraph ticked in script. A pursuer is roughly one aiKit character plus one animated body; two or three on screen are fine on a tablet. Parts cast no shadows where they are small. Lower `AI.config.senseRate` / `thinkRate` for weaker devices.
## Known limits
- **Nothing reports your torch to the monsters unless something calls `setPlayerLight`.** horrorKit does it for flashlightKit's torch; with flashlightKit alone, call `Stalkers.setPlayerLight(body, Torch.visibility(nil))` on the player's own peer a few times a second.
- **Switching the torch off does not shake a pursuer that already has you.** Measured in an empty world, twice: standing still in the dark with no lead, it never found the player (idle at 18 to 21 m for 20 s); with the torch on it noticed at about 14 m, stalked and caught the player within about 10 s; switching the torch off then (during the chase, or after sending it to a lair) did not lose it: it went to where it last knew the player and, since it sees an unlit player inside `darkRange` (4.5 m), found them and kept attacking. Put distance, a door or a hiding place between you before you go dark.
- **Bodies are a re-proportioned stock rig.** Mesh generation was out of quota when this was built, so every creature is the engine's rigged humanoid stretched, re-skinned and dressed with procedural parts. A generated or imported rigged creature can replace it in `stalkerKit.body` (`Body.STYLES`).
- **A hidden stalker keeps its hit volume at its lair.** Shots into an empty vent can still hit it.
- **Lurker "watched" check uses where each player faces** (the torch report's beam when there is one, else the avatar's turn), not the exact camera.
- **Bake the navKit map after the level's colliders exist**: a grid map baked in the same frame the walls were spawned has no walkable cells and every stalker stands still ("unreachable").
- **Vents are entry points, not paths**: a stalker vanishes into one and comes out of another; it does not crawl through ducts.
## Tests
`tools.use("tests", "run", { suite = "stalkerKit" })` (edit mode): kinds and presets, the API, hearNoise reaching aiKit's bus, events, threatFor, and a play test where a pursuer hears a gunshot and goes to it.
## Version history
- **1.0.0**: First release: five kinds, the stalker brain, the Stalker and StalkerLair components, bodies, generated animations and sounds, the api with noise, light, threat and scripting hooks, a guide and a test suite.
## 1.0.2
README only: how to bake the navKit map in the first example; that the torch reaches the monsters only through `setPlayerLight` (horrorKit or your own code); what a pursuer does when you go dark mid-chase.
## 1.0.1
Bodies use lit materials, so a monster in a dark room is invisible until a light finds it. Overhead health bars are off by default (`healthBar` field). `setActive` reliably wakes and stills a monster. Declares aiKit 1.4.0 and its other dependencies with versions.
## 1.0.10
A Stalker whose kind the game defines after it woke now waits for that kind instead of failing. A joining player's engine receives the creature before the game's start code defines its own kinds, and the Stalker used to hand aiKit the unknown preset at once, which threw ("aiKit.addBrain: unknown preset 'stalker.<kind>'") and disabled the component for good on that player's side. Now its brain and body are built as soon as the kind exists (`Kinds.has(kind)` is new). New test: "waits for a kind defined after it woke". Found in Low Water's co-op.
## 1.0.9 (`stalker.body = "drowned"`): tall, gaunt, long-limbed and hunched, draped in swaying river weed, dripping silt, matte dark silt skin, nothing glows. `appearAt` now always cancels a retreat in progress: orders queue until the brain next thinks instead of the later one overwriting the earlier, a non-retreat order clears the retreat and frees the lair it was heading for, and `appearAt` releases a `holdHidden` (a game no longer needs to switch the brain off and on to bring it out). New test "appearAt cancels a retreat in progress".
## 1.0.8
Correction to 1.0.7: its wait for the sky light does not prevent the occasional 6 "camera texture not found" errors during the in-play test, so it is removed. Those errors come from the engine, not this kit: switching into play makes the sky light build six internal capture cameras, the test runner's leftover sweep removes them when the test ends, and the sky light later draws through the removed cameras (reported to ZeroMind). The tests pass either way; a plain install and play logs none. No changes outside the tests and README.
## 1.0.7
The tests leave no camera errors: the play test restarts the sky light, and each test now ends only once the sky light has finished its capture, so the runner's cleanup never removes capture cameras with a picture still queued. No changes outside the tests.
## 1.0.6
The tests remove everything each test (and the monsters it spawned) left behind and wait for previews a fresh install is drawing, so a passing run leaves no errors. The second README example requires the API itself and runs on its own. No changes outside the tests and README.
## 1.0.5
Declares SecondWind 1.4.8, the version stealthKit 1.0.22 brings, so a world with both kits runs one SecondWind. No code changes; stalkerKitTests 7/7 on 1.4.8.
## 1.0.4
Declares SecondWind 1.4.7, the newest SecondWind release, which is what an install beside stealthKit 1.0.20 places (it stated 1.4.8). No code changes; stalkerKitTests 7/7 on 1.4.7.
## 1.0.3
Bodies keep their surfaces again on the current engine: each part's roughness, clearcoat and glow (the pursuer's eyes and spots, the diver's porthole) went to `Model:setMaterialProperties`, which now writes the shared material and failed on the kit's runtime materials (hundreds of warnings, flat parts). Parts and skins now get materials of their own with those values, made once per look; no shared material is ever repainted. README: the first example defines the player body, camera forward and shot it uses.
# scriptedEventsKit
Named **scriptedEventsKit** since 1.0.1 (it was published as cueKit in 1.0.0). Search for either name.
**Scripted events for level designers: a trigger in the world plays an ordered list of beats.** Walk into the hall and the lights short out, a door swings shut two seconds later, a whisper, a flash, a subtitle. Write it as data, place it as a component, and it works the same for every player in a multiplayer world.
Version **1.0.4** (`Cues.VERSION`). The version, this README and `package.yaml` move together.
## Install
1. Install `scriptedEventsKit.package` from ZeroMind (search **scriptedEventsKit**), or copy the folder into `/source`. It depends on nothing, so the install brings no other kit. The optional kits it works with (interactKit, inventoryKit, tensionKit, saveKit, pickupsKit, soundstage, juiceKit) are handed over by the game through `scriptedEventsKit.links`, by their dotted module names: `require("~scriptedEventsKit.links").link("interactKit.api", require("~interactKit.api"))`. `require("~horrorKit.api")` links every one it installs. A trigger or beat whose kit is not linked does nothing. eerieLightsKit lights are found by entity name and group tag, with no link.
2. `local Cues = require("~scriptedEventsKit.api")` from any component, module or scene entrypoint.
3. Define cues when play starts (a scene `entrypoint.luau`, or a component's `start`), or place a **Cue** component on an entity.
## First example
```lua
local Cues = require("~scriptedEventsKit.api")
Cues.define("lightsOut", {
trigger = { kind = "area", entity = "hallTrigger", size = { 4, 3, 2 } },
once = true,
beats = {
{ "light", "hallLight*", "short" }, -- every light named hallLight...
{ "wait", 2 },
{ "show", "shape" },
{ "sound", "sk_sting", at = "shape" }, -- heard by everyone near it (a name scaresKit registers; without scaresKit pass a soundClip ref)
{ "flash", "red", alpha = 0.4 }, -- only the player who walked in
{ "message", "It is in here with you.", style = "whisper" },
{ "wait", 1.5 },
{ "hide", "shape" },
{ "light", "hallLight*", "restore" },
},
})
```
Or with no code: add `scriptedEventsKit.Cue` to an empty entity, set `size`, and fill `beats` with the same list. The editor draws its trigger box.
## Triggers
A cue takes one trigger or a list of them (any one fires it). `local` triggers are watched by each player's own engine for that player; `host` triggers by the host. Either way the host decides.
| kind | where | fields | fires when |
|---|---|---|---|
| `area` | local | `entity` or `at`, `size = {x,y,z}`, `shape = box/sphere`, `radius`, `on = enter/exit/inside`, `seconds` | a player enters / leaves / stays inside a box or sphere (uses an interactKit TriggerVolume's size if the entity has one) |
| `proximity` | local | `entity`, `radius = 3`, `on` | a player gets within `radius` of an entity, which may move |
| `look` | local | `entity` or `at`, `angle = 12`, `range = 25`, `seconds = 0.4`, `los = true` | the player keeps it inside a view cone for N seconds, with line of sight |
| `timer` | host | `after`, `from = "start"` or a cue id, `every` | N seconds after level start or after another cue fired; `every` repeats |
| `cue` | host | `after = "cueA"`, `delay` | chain: right after (or `delay` s after) cue A fires |
| `pickup` | host | `item`, `entity` | an item is picked up (interactKit Item collect, pickupsKit, or `Cues.notify("pickup", {item, peer})`) |
| `interact` / `door` | host | `entity`, `event = use/open/close/on/off/unlock/...` | an interactKit device is used, a door opens |
| `dread` | local | `above = 0.7` | the player's dread (tensionKit) rises past a level; nothing happens without tensionKit |
| `event` | host | `name` | your code calls `Cues.notify(name, { peer, at })` |
| `manual` | host | | only `Cues.fire(id)` |
Add your own with `Cues.registerTrigger(kind, { where, setup, tick })`.
## Beats
Beats run in order; only `wait` (and any beat with `wait = true` or `wait = seconds`) holds the timeline. `{"kind", main, second, field = ...}`: the first entry after the kind fills the main field.
| beat | scope | main, second | other fields |
|---|---|---|---|
| `wait` | time | seconds (or `{min,max}`) | |
| `sound` | world | clip | `at` (point/entity: 3D for everyone; none: 2D for the targeted players), `volume`, `maxDistance`, `pitch`, `loop`, `duration`. Clip = a soundClip ref, a name registered with `Cues.registerSound`, or a soundstage `"bank.sound"` |
| `light` | world | target, state | `on / off / flicker / short / restore / dim`; eerieLightsKit `LightBehavior.state` when present, else `Light.intensity`; `duration`, `level`, `intensity`, `style` |
| `animate` | world | target | `to = {pos, rot, scale}` or `by = {...}`, `duration`, `ease` (linear, inQuad, outQuad, inOutQuad, inCubic, outCubic, inOutSine, outBack, outBounce, slam, snap), `space = local/world` |
| `move` | world | target | `to` (point/entity), `rot` |
| `show` / `hide` | world | target | entity and all its children (models and lights) |
| `spawn` | host | model | `at`, `rot`, `scale`, `material`, `asset`, `physics = dynamic`, `mass`, `collider`, `light`, `lifetime`, `name` |
| `despawn` | world | target | |
| `impulse` | world | target | `force = {x,y,z}` or `from` + `strength` (+ `up`) |
| `shake` | personal | preset | juiceKit preset (`shakeLight`, `shakeHeavy`, `shakeRumble`, `shakeKick`, ...), `intensity` |
| `nudge` | personal | from | a small kick of the view away from a point |
| `look` | personal | at | eases the view toward a point, holds, hands it back: `turn`, `hold`, `release`, `strength` |
| `flash` | personal | color | `white / red / black / {r,g,b}`, `alpha`, `attack`, `hold`, `fade` |
| `fade` | personal | color | `duration`, `hold`, `back` (seconds, or `false` to stay dark) |
| `message` | personal | text | `style = subtitle / whisper / title / objective`, `speaker`, `duration` |
| `cutscene` | personal | def | an engine `cutscene.play` definition |
| `flag` | host | name, value | sets a world flag |
| `fire` | host | cue | fires another cue (its rules apply unless `force`), `delay` |
| `reset` | host | cue | forget that a cue fired |
| `enable` | time | cue | `on = false` turns it off |
| `call` | world | name | runs `Cues.register(name, fn)` on every peer: `fn(ctx, beat)`. The function's name is the beat's `name` field (where its main value lands), so a beat field called `name` REPLACES the function name: `{ "call", "spawnCorpse", name = "Ada" }` calls a function named `Ada`. Name it with `fn` instead to keep `name` for your data: `{ "call", fn = "spawnCorpse", name = "Ada" }` (`fn` wins when both are given) |
Every beat takes `chance = 0..1` and `only = "host"`. `Cues.registerBeat(kind, fn, { scope, main, second })` adds a beat; `fn(beat, ctx)` may return its length in seconds.
Scopes: **world** beats run on every peer and each entity is written by the one peer allowed to (its owner, or each peer for its own unshared copy), so every player sees the same door; **personal** beats run only for the cue's targeted players; **host** beats only on the host; **time** beats on everyone.
## Rules and conditions
| field | meaning |
|---|---|
| `once = true` | default: fires once per session (and per save with a state store) |
| `times = n` | fires at most n times |
| `["repeat"] = true`, `cooldown = s` | fires again after a cooldown |
| `when = { flags, notFlags, after, notAfter, item, test }` | needs flags set / unset, other cues fired / not fired, the triggering player holding an item (interactKit or inventoryKit), or your test |
| `players = "trigger" / "all" / "near"`, `near = 12` | who gets personal beats |
| `gate = fn(cue, ctx)` / `Cues.setGate(fn)` | a director may veto any fire |
| `enabled`, `label`, `data`, `save = false` | |
## API
| call | what it does |
|---|---|
| `Cues.define(id, spec)` / `undefine(id)` / `get(id)` / `list()` | author cues |
| `Cues.fire(id, { force, by, at })` | ask the host to fire it (manual trigger) |
| `Cues.fired(id)` / `hasFired(id)` / `isRunning(id)` / `whyNot(id)` | the ledger |
| `Cues.reset(id)` / `resetAll()` / `stop(id)` / `setEnabled(id, on)` | testing and control |
| `Cues.setFlag(name, v)` / `flag(name)` / `flags()` | world flags |
| `Cues.on(event, fn)` | events, returns a disconnect |
| `Cues.notify(name, data)` | feed `event` / `pickup` / `door` triggers from your code |
| `Cues.registerBeat` / `registerTrigger` / `register` / `registerSound` / `registerMaterial` | extend |
| `Cues.playBeats(list, opts)` | play a beat list on this peer only (directors, previews) |
| `Cues.setStateStore({get,set})` / `useSaveKit()` | keep the ledger between sessions |
| `Cues.setGate(fn)` / `setDebug(on)` | director veto; draw trigger volumes in play |
| `Cues.beatKinds()` / `triggerKinds()` | what is registered |
## Events
| event | data |
|---|---|
| `cueFired` | `{ id, by, count, origin }` (every peer) |
| `beat` | `{ id, index, kind, ran }` (every peer; `ran` false where a personal beat was not for this player) |
| `cueDone` | `{ id, by }` |
| `denied` | `{ id, by, reason }` (on the deciding peer) |
| `flag` | `{ name, value }` |
| `reset` | `{ id }` |
## Multiplayer
- The host decides every fire against one ledger (fired counts, last fire times, flags) that every peer mirrors; a cue fires once for the world even when two players walk in on the same frame.
- The host broadcasts `cue:run` with a start time on the session clock; every peer plays the beats from it, so doors, lights, props and positional sounds line up on every screen.
- Personal beats (flash, fade, shake, look, message, 2D sound) reach only the players the cue targets.
- A player who dies, respawns or rejoins keeps the world's ledger: a late joiner asks the host for a snapshot; a new host already has the mirror.
- With `Cues.setStateStore` (or `useSaveKit()`) the host writes the ledger so fired-once cues stay fired between sessions.
## Components
- **Cue**: a cue as fields (quick trigger + beats list, or a full `spec`); draws its area in the editor.
- **CueRunner**: spawned by the kit, one per peer in play; never added by hand.
## Known limits
- A cue defined with `Cues.define` lives in the kit's module state: it stays defined across play sessions in the same engine and fires again in the next session. Define cues where play starts (entrypoint `onLoad`, a component's `start`), not from a one-off script, or `undefine` them.
- The forced `look` is a glance: the builtin first-person controller keeps its own yaw and pitch, so the view eases toward the point and back rather than staying turned.
- Entities are addressed by name, glob or parent (the engine has no tag API); a light group is a parent entity or a name pattern.
- Beat sound and material names must be registered refs (`Cues.registerSound`); a world cannot resolve asset names computed at runtime and still publish.
- A cue's own beats are not replayed for a player who joins after it ran; state that must persist (an opened door, a spawned prop) should live on synced entities or flags.
## 1.0.4
The `call` beat also takes its function name from `fn`, so a beat can carry a data field called `name` (before, `name` is where the beat's main value lands, so a `name` field silently replaced the function name). README documents the clash. The package test reads the package.yaml and README beside the install, so it passes under deps/ and showcase/ too. New test.
## 1.0.3
The tests wait for the preview pictures a fresh install is still drawing before each test, so their first run no longer logs "camera texture not found" errors. No changes outside the tests.
## 1.0.2
README only: the install brings the packages `package.yaml` declares (it said it needed none); the first example's `sk_sting` sound is a name scaresKit registers; a cue defined from code stays defined in that engine across play sessions, so define it once (an entrypoint or a component's `start`).
## 1.0.2 (links)
Depends on nothing: tensionKit, interactKit, inventoryKit and saveKit are no longer declared, and no optional kit (pickupsKit, soundstage, juiceKit included) is required by name any more. They are linked by the game through `scriptedEventsKit.links`; `require("~horrorKit.api")` links them.
## 1.0.1
Renamed from cueKit. Declares its dependencies with versions. Test suite renamed scriptedEventsKitTests.