# board
The activity board: which replayable jobs a district offers today, running one,
```
and remembering what was done so the board changes.
An activity TYPE (content.activities.types) says what unlocks it and how many of its variants a district shows
a day. A VARIANT is a small authored job in the mission runner's shape (steps, a decision, bonus objectives,
rewards by choice, fail rewards): written, not generated. The board deals the day's offers from the variants
that are unlocked and rested, by a shuffle seeded from the day, the type and the district, so the same day
always offers the same jobs and tomorrow offers others. Finishing or failing a variant rests it for its type's
`rest` days; a variant marked `once` (a collectible) never comes back once done.
local Board = require("metropolisGame.logic.board")
local board = Board.new(Activities, hub?, seed) -- content.activities
board:offers(day, progress, "old_quay") -- { { id, type, district, giver } } today's jobs there (all districts when nil)
board:open(typeId, progress) -- whether a type is unlocked
board:start(id, day) -- ok, why ("unknown" | "busy" | "resting" | "done" | "locked")
board.runner -- the mission runner running the active variant (tick / event / choose)
board:active() -- the running variant's id, or nil
board:count(id) board:countType("getaway") -- times completed
board:view(day, progress, district) -- { { id, type, district, giver, state = "offered" | "active" } }
board:serialise() board:restore(data)
`progress` is the mission runner's progress summary (Runner.meets). Hub events are the runner's with the name
"activity" ("activityStarted", "activityStep", "activityChose", "activityDone", "activityFailed", ...); the board
records the day itself by listening to them.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# fleet
The vehicles in Wren's life: her own van, whatever she has borrowed, and what
```
stands in the garages.
Any vehicle in the city can be borrowed; only the van is hers and only the van keeps upgrades. A garage opens
in a district once its colour reaches Economy.garages.opensAt and holds ONE borrowed vehicle, with the paint
that was on it. This module is the bookkeeping: what she is driving, what is stored where, what each vehicle
looks like to a Warden (type, colour, plate), and what its type lets her do (content.vehicles).
local Fleet = require("metropolisGame.logic.fleet")
local fleet = Fleet.new(Vehicles, Economy.garages, hub?) -- content.vehicles, content.economy.garages
fleet:grantVan({ colour = "ochre", plate = "VR 0417" }) -- the van becomes hers (Borrowed Wheels)
fleet:hasVan()
fleet:board("car7", { type = "finch", colour = "blue", plate = "VR 1123", state = "parked" })
-- she took the wheel of a vehicle: returns its record { id, type, colour, plate, owned, def }
fleet:alight() -- she got out (the vehicle stays known as `last`)
fleet:driving() -- the record she is at the wheel of, or nil
fleet:type("car7") fleet:def("finch") -- a known vehicle's type; a type's content entry
fleet:appearance() -- { ["vehicle.kind"], ["vehicle.colour"], ["vehicle.plate"] } while driving, else {}
fleet:repaint("car7", "white") fleet:replate("car7", "VR 9001")
fleet:garages(colourOf) -- { { district, open, vehicle = record | nil } } district order
fleet:store("old_quay", "car7", colourOf) -- ok, why ("closed" | "full" | "own" | "unknown" | "driving")
fleet:retrieve("old_quay") -- the record, out of the garage (the host spawns it), or nil
fleet:forget("car7") -- abandoned for good, impounded or wrecked
fleet:serialise() fleet:restore(data)
Hub events: "boarded" { vehicle, type, owned }, "alighted" { vehicle }, "stored" { district, vehicle },
"retrieved" { district, vehicle }, "vanGranted" {}.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# chronicle
What the city remembers of Wren, and what its newspaper prints.
```
MEMORIES fire once each, the first time their condition holds over the player's tallies and state
(logic.chronicle). Each is a moment with a line that stays in the journal (`pm_street.memories.<id>.title`,
`.line`) and may pay something. HEADLINES are the day's front page of the Verrane Courier: the matching rule
with the highest priority wins, equals rotate by the day (`pm_street.headlines.<id>`).
Tallies the game keeps (logic.session counts them): walls_signed, signed_rough / _clean / _masterwork,
signed_tag / _piece / _wall / _landmark, tins_painted, shots_fired, painted_out_<kind>, escapes,
best_escape_level, arrests, ejections, days_since_arrest, days, grabs_broken, times_washed, washed_out,
vehicles_borrowed, borrowed_<type>, vehicles_fenced, arrangements, missions_done, activities_done,
activity_<type>, entered_<district>, commissions, studies, roof_lines, paint_runs, box_rounds, getaways,
trams_tagged, colour_wars, impound_breaks, ferries, sketches, warden_shifts.
Facts beside them: everything missions see (rank, level, strikes, sous, colour:<district>, trust:<contact>,
flag:<name>, washed_out ...), painted (districts painted), painted_recent (one was painted today or yesterday),
districts_half (districts at colour 50 or more), districts_entered, and remembers:<memory id>.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# arrest
Being caught, as a staged sequence with hooks, and its bill as an itemised list.
```
The stages are data (cfg.arrest.stages), each with a name, a duration and what the suspect may do in it:
breakable + breakHold the suspect can get free by holding the break input that long, if it has a charge
skippableAfter the stage can be ended early by the skip input after that many seconds
control a name for the host's input layer ("break", "skip", "none")
The sequence moves nobody and draws nothing. It calls hooks at every boundary so animation, camera and UI stay
in step with it:
local Arrest = require("~.modules.arrest")
local seq = Arrest.new(cfg.arrest, {
onStage = function(stage, ctx) end, -- a stage begins: play the animation, cut the camera, show UI
onStageEnd = function(stage, ctx) end,
onBreak = function(ctx) end, -- the suspect got free
onDone = function(ctx) end, -- the last stage ended
})
seq:begin({ charges = 1, by = "w3", level = 2, bill = bill }) -- ctx is passed to every hook
local status = seq:tick(dt, { breakHeld = false, skip = false }) -- "running" | "broke" | "done" | "idle"
seq:view() -- { stage, index, count, time, duration, progress, breakable, breakProgress, canSkip, charges }
The bill is computed by a pure function from rules the game supplies, so the UI shows exactly what is taken:
local bill = Arrest.bill({
fine = { base = 40, perLevel = 35, walletShare = 0.5 }, -- min(wallet * share, base + perLevel * level)
confiscate = { carried = true, vehicle = true, vehicleWithin = 30 },
strikes = 1, maxStrikes = 3, hours = 2,
}, { wallet = 180, level = 2, carried = 9, vehicleStock = 40, vehicleDistance = 12, vehicleProtected = false,
strikes = 0, work = "fish-market wall" })
-- { lines = { { key = "fine", amount = 90 }, { key = "carried", amount = 9 }, { key = "vehicle", amount = 40 },
-- { key = "work", name = "fish-market wall" }, { key = "strike", amount = 1, total = 1 },
-- { key = "hours", amount = 2 } },
-- fine = 90, carried = 9, vehicle = 40, strikes = 1, hours = 2, work = "fish-market wall" }
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# hub
A small event hub: named events, plain payload tables, no engine.
```
Every pursuitKit system reports what happened through a hub the host passes in, so animation, camera, sound and
UI subscribe to moments instead of polling state.
local Hub = require("~.modules.hub")
local hub = Hub.new()
local off = hub:on("state", function(e) print(e.from, e.to) end)
hub:emit("state", { from = "clear", to = "noticed" })
off() -- disconnect
hub:onAny(function(name, e) ... end) -- every event (a log, a recorder, a test)
A handler that errors does not stop the others; its message is kept in hub.lastError.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# murals
The city's murals: one canvas per site, who painted it, how good it is, and the
```
scrub crews that come for them. This is WORLD state: every player sees and paints the same walls.
local Murals = require("metropolisGame.logic.murals")
local murals = Murals.new({ paintCfg, sites, sizes = PaintContent.sizes, designs = PaintContent,
economy = Economy, hub })
murals:canvas(siteId) -- the site's canvas (made on first use), or nil for an unknown site
local r = murals:paint(painter, siteId, dt, { u, v, distance, stand, stencil }) -- paintKit painter.paint's result
local s = murals:sign(siteId, author) -- { tier, rank, site } or nil when it is below the lowest tier / signed
murals:quality(siteId) -- the canvas's quality (coverage, accuracy, overspray, tier ...) or nil
murals:author(siteId) -- the player id that signed it
murals:signedCount(author?) -- signed walls (of one author)
murals:queueScrub(siteId, seconds, { unstoppable = false, crew = "crew1" })
murals:stopScrub(siteId, "block" | "windscreen" | "foul") -- true if a crew was stopped or delayed
murals:tick(dt) -- crews arrive and work; emits what happens
murals:scrubs() -- { { site, state = "coming" | "working", startsIn, left } }
murals:serialise() murals:restore(data) -- canvases (text per site), authors, the crews' queue
Hub events: "scrubComing" { site, seconds }, "scrubStarted" { site }, "scrubbed" { site, district, author },
"scrubStopped" { site, how }, "scrubDelayed" { site, seconds }.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# missionRunner
Runs authored work from data: steps with goals, fails, limits and
```
checkpoints, a twist, CHOICES that branch what follows, bonus objectives, and the rewards all of that adds up to.
One runner runs story missions; a second runs activities (the same data shape, see content.missions and
content.activities). It evaluates conditions against facts the game supplies each tick and events the game
reports as they happen. It applies nothing itself: every moment goes out on the hub with the step's or twist's
`stage` directions for the host to act on, and the finished job's rewards for the game to pay.
local Runner = require("metropolisGame.logic.missionRunner")
local r = Runner.new(Missions.list, hub, { name = "mission" }) -- name prefixes the hub events
r:available({ done = {...}, rank = 1, colour = { old_quay = 12 }, upgrades = {}, painted = 0, flags = {}, trust = {} })
r:start("proper_piece")
r:event("bought", { tins = 6 })
r:choose("bargain") -- answers a `choose` step (false when no such option is on offer)
local status = r:tick(dt, facts) -- "idle" | "running" | "done" | "failed"
r:retry() -- back to the last checkpoint step (after "failed")
r:abandon()
r:view() -- { id, step, count, limit = { left, duration }?, twisted, failed, options = { id }?, chosen = {} } or nil
r:serialise() r:restore(data) -- the active job, its checkpoint and choices, and what is done
r.done -- { [id] = true } r.chosen -- { [id] = { choice, ... } } what was chosen in finished jobs
A step: { goal, fail?, limit?, checkpoint?, stage?, teach?, vars?, when = { chose = "x" }?, choose = { "x", "y" }? }
when.chose the step only exists on the branch where that option was chosen (otherwise it is skipped)
choose the step is a decision: it completes when `r:choose(option)` is called (goal is ignored)
A job: { id, steps, twist?, requires?, rewards?, rewardsBy = { [choice] = rewards }?,
bonus = { { id, goal, rewards } }? (checked every tick; each can be earned once),
failRewards? (applied when an activity fails: consequences are part of the design) }
Hub events ("<name>" = the runner's name): "<name>Started" { id }, "<name>Step" { id, step, stage, teach, vars,
options }, "<name>Twist" { id, stage, teach }, "<name>StepDone" { id, step }, "<name>Chose" { id, step, choice },
"<name>Bonus" { id, bonus }, "<name>Done" { id, rewards = { rewards, ... }, choices, bonuses },
"<name>Failed" { id, step, why, rewards }.
Runner.test(cond, facts, events, time) is the condition evaluator (see content.missions for the vocabulary).
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# vehicles
Every kind of vehicle in Verrane as the GAME sees it: what it carries, where
```
it fits, how the street reads Wren at its wheel, and what taking it means. Handling (mass, gears, grip) belongs
to the vehicle layer (vehiclesKit presets); `preset` names the body and tuning the host spawns for a type.
local Vehicles = require("metropolisGame.content.vehicles")
Vehicles.list Vehicles.byId("finch") Vehicles.borrowable() -- ids a player can take the wheel of
Entry fields (text in catalog `pm_world`: `vehicles.<id>.name`, `.line`, `.card`):
id, preset the type and the host's preset for it
class "car" | "van" | "bus" | "bike" | "rail" | "boat"
seats people it carries, driver included
tins paint it can carry (0: none; the satchel is all she has)
roof metres above the road a person on its roof stands (nil: no roof to stand on)
speeds = { street, avenue } what it can do, metres a second (a Warden car does 14 / 22)
fits = { lane, alley, stairs } where it can go that a saloon cannot
take the state taking it counts as when it is not parked (pursuitKit theft `takes`):
"occupied" for anything with a driver; "service" for the Wardens' own
concealment a concealment tag that applies while she drives it lawfully (content.pursuit)
witnesses people aboard who watch what she does (a bus's passengers)
blocks = true wide enough to shut a street when left across it
siren = true traffic clears for it
rails = true it runs on rails to a timetable; it is ridden, not driven
storable whether a garage takes it
fence sous a fence gives for it (nil: nobody will touch it)
mount the paint arm mount it gives (content.paint arms[..].mount)
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# progression
What the player has: sous, renown and rank, upgrades, and the loadout those
```
add up to (tools, paint arms, what the satchel and the van carry). Strikes live in pursuitKit's record.
local Progression = require("metropolisGame.logic.progression")
local p = Progression.new(Economy, hub?) -- Economy: content.economy
p:earn(40) p:spend(12) -> boolean p.sous
p:gain(25) p.renown p:rank() -> 0-based p:rankView() -> { rank, at, next, fraction, toNext }
p:setVan(true) -- upgrades marked needsVan can only be bought with the van
p:canBuy("roller") -> boolean, why ("owned" | "rank" | "needs" | "van" | "sous" | "unknown")
p:buy("roller") -> boolean, why p:grant("stencilKnife") (a reward: no price, no rank)
p:has("roller") p:flag("jacket") -> boolean
p:loadout() -> { satchel, slots, slips, tools = { "spray", ... }, arms = { "spray", ... }, flags = { jacket = true },
van, stencils }
p:shop() -> { { id, track, sous, rank, needs, owned, canBuy, why } } for the shop screen
p:serialise() p:restore(data)
Hub events: "sous" { value, delta }, "renown" { value, delta }, "rank" { from, to }, "upgrade" { id }.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# chronicle
What the city remembers about this player, and what the paper says about it.
```
It keeps TALLIES of things that happened (walls signed by tier, Wardens painted out, escapes by level, cars
borrowed, nights without an arrest...), fires each authored MEMORY once when its condition first holds (a
"the city remembers" moment with lasting text and optional rewards), and picks the day's HEADLINE: the
highest-priority authored rule whose condition matches the player's present state, so the newspaper reacts to
what she has been doing. All three are data (content.chronicle); conditions use the mission runner's evaluator
over the tallies and whatever facts the game adds.
local Chronicle = require("metropolisGame.logic.chronicle")
local ch = Chronicle.new(ChronicleContent, hub?)
ch:count("walls_signed") ch:count("tins_fired", 3) ch:set("best_escape_level", 3) ch:max("streak", n)
ch:tally("walls_signed") -- 0 when never counted
local fired = ch:tick({ rank = 2, ["colour:old_quay"] = 55 }) -- { memoryId, ... } newly remembered (also on the hub)
ch:remembers("first_masterwork")
local h = ch:headline(day, facts) -- { id, key = "pm_street.headlines.<id>", priority } or nil
ch:memories() -- { { id, day } } in the order they happened (for a journal)
ch:serialise() ch:restore(data)
Hub events: "remembered" { id, rewards }.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# pursuit
This game's configuration of pursuitKit: Verrane's Wardens and New Tide's
```
private security, the people and lenses that watch, what counts as an offence, how the Wardens escalate
(greywash, cars, road blocks), what taking a vehicle costs, and what an arrest takes away.
local PursuitContent = require("metropolisGame.content.pursuit")
local cfg = PursuitConfig.merge(PursuitConfig.DEFAULTS, PursuitContent.config) -- pursuitKit.modules.config
PursuitContent.bill -- rules for pursuitKit's Arrest.bill (the Wardens' bill)
PursuitContent.eject -- the bill when security throws Wren off New Tide
PursuitContent.escapeRenown -- renown per heat level for getting away
PursuitContent.breakFree -- { tins } paint spent spraying a way out of a grab
PursuitContent.units -- response unit kinds: actor / vehicle the host spawns, pursuer profile, observer kind
PursuitContent.actFor(tool, permitted, tolerated) -- the act name for painting with a tool
PursuitContent.fireAct -- the act while a paint arm is being fired
Numbers follow GAME_DESIGN.md §4.2 and s3/design/game_direction.md §1-2. Offence names are catalog key parts
(`pm_ui.offence.<name>`), so they are snake_case.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# arms
Paint arms: weapons that fire pigment out of the same tins the murals use.
```
An arm is data (cfg.arms[name], see modules/config): how many projectiles a shot throws and how they scatter,
how fast and far they fly, what a hit adds, how many shots a tin gives, how loud it is. This module is the
hands: which arms are owned, which is up, the cadence between shots, the paint each shot costs. It builds the
projectiles of a shot (origin and velocity, scatter from a seeded generator) and hands them back; flight and
hits are modules/ballistics, what a hit does is modules/impact.
local Arms = require("~.modules.arms")
local arms = Arms.new(cfg, supply, { arms = { "pistol" }, rng = rng }) -- rng() -> [0, 1), seeded by the host
arms:own("lob") arms:owns("lob") arms:select("lob") arms:cycle(1) arms.arm
arms:selectPigment("ochre") arms:cyclePigment(1) arms.pigment
arms:tick(dt) -- cools the cadence
local r = arms:fire({ origin = { x, y, z }, dir = { x, y, z }, mount = nil, owner = "player" })
-- { ok = false, reason = "no arm" | "cooling" | "empty" | "no pigment" | "not mounted" | "blocked" }
-- { ok = true, arm, pigment, used = tins, loudness, heard,
-- shots = { { arm, pigment, owner, x, y, z, vx, vy, vz, gravity, range, radius, cover, splash } }, pellet / lob / stream
-- cone = { arm, pigment, owner, x, y, z, dx, dy, dz, range, halfAngle, cover, radius } } cone (cover = this pulse's)
arms:block("washed") arms:block(nil) -- the host forbids firing (and why); nil lifts it
arms:ammo() -- { shots, tins, pigment } with the pigment that is up
arms:view() -- { { id, mode, selected, shots, perTin, cooling (0..1), mount, usable, reason } } for a wheel
arms:serialise() arms:restore(data) -- owned arms and what is selected
A stream or cone arm is fired every tick while the trigger is held: `fire` answers "cooling" between pulses, so
the caller needs no cadence of its own. A shot costs 1 / shotsPerTin of a tin of the pigment that is up; when
less than a shot is left of it the arm falls to another pigment the supply still holds.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# economy
Prices, payouts, ranks, and everything that can be bought: tools, paint arms,
```
what the van carries, what the crew does for trust rather than sous.
local Economy = require("metropolisGame.content.economy")
Economy.paint -- { tin, nightTin, shopOpens, shopShuts, stencil }
Economy.carry -- { satchel, slots, van, stash = { max, tins }, slips, stencils } what a new player has
Economy.tiers -- [tier] = { renown, colour, sous } multipliers on a size's base awards
Economy.audience -- { each, max } renown share per friend watching, and its cap
Economy.underNoses -- { level, factor } signing while this hunted multiplies renown
Economy.ranks -- renown thresholds; rank r (0-based) is reached at ranks[r + 1]
Economy.upgrades -- { { id, track, sous, rank, needs?, grants = { ... } } } in shop order
Economy.upgrade(id)
Economy.commission -- sous for legal work by size, before the tier multiplier
Economy.stipend -- { sous, everyDays } what a painted district sends
Economy.garages -- { opensAt, districts } colour at which a district's garage opens; which have one
Economy.safehouse -- { locker } tins a safehouse locker holds
Economy.services -- prices of things done for sous: { respray, plates, doctor, fence = { share }, bribeTip }
Economy.clock -- { dayMinutes, start, dawn, dusk, blend }
Economy.scrub -- how the scrub crews work
Economy.signHold -- seconds the sign control is held to sign a wall
Economy.near -- metres within which a named place or site counts as "here"
`track` is the progression track an upgrade belongs to, for the shop's tabs: "tools" (what paints walls),
"arms" (what fires paint), "carry" (satchel, slots, slips), "van" (the only vehicle that keeps upgrades),
"craft" (things that change how a job is done).
`grants` is read by logic.progression: satchel (capacity), slots (pigments loaded), slips (grabs broken per
incident), tool (a paintKit tool name), arm (a paintKit arm name), van (tins the van carries), flags (named
abilities a system checks: "jacket", "ladder", "roof_rack", "compartment", "plates", "stencils", "scope").
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# colour
The painter's own colour: what solvent takes, and how it comes back.
```
This is the stake in a fight where nobody is hurt. Solvent that hits the painter strips colour (1 = whole,
0 = none). At zero the painter is WASHED OUT: slowed, unable to paint or fire, easier to hold, until colour has
returned to cfg.colour.washedOut.reviveAt. Colour only returns while nobody is looking, after a delay, and
faster on friendly ground.
local Colour = require("~.modules.colour")
local colour = Colour.new(cfg.colour)
local e = colour:wash(0.2) -- solvent landed: { value, delta, washedOut = true when this hit did it }
local events = colour:tick(dt, { seen = false, friendly = 0.6 })
-- friendly 0..1: how much this ground is on the painter's side; events: { type = "revived" } when washed out ends
colour.value colour:isWashedOut()
colour:restore(0.5) -- given back at once (a doctor, a safehouse); may end a wash-out
colour:effects() -- { speed, canPaint, canFire, grabWindow, drain } drain 0..1: how grey the picture is
colour:serialise() colour:load(data)
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# wardens
Wardens with names: the roster pursuitKit's `roster` runs. Each walks one
```
beat of one post on some weekdays between two hours; some have a price, some have something in Teo's files.
local Wardens = require("metropolisGame.content.wardens")
Wardens.list Wardens.byId("w_brandt") Wardens.ofPost("lowmarket")
Entry fields (text in catalog `pm_story`: `wardens.<id>.name`, `.about`, and with leverage `.file`):
id, post, beat the post is a district id; the beat a place id of content.places (the street they watch)
days = { 1..7 }, from, to weekdays on duty (1 = the game's first day) and the shift (to < from wraps midnight)
bribe sous he takes to be elsewhere one weekday (nil: not for sale)
leverage a file id: she can lean on him if she holds it (Teo's `files` service, or a mission)
temper "steady" | "keen" | "tired": how the host plays him (patrol pace, how soon he fires)
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# contacts
The people Wren works with and the one she works against: where each is
```
found, how far each trusts her at the start, and what their trust opens.
local Contacts = require("metropolisGame.content.contacts")
Contacts.list Contacts.byId("pim") Contacts.services -- [serviceId] = what a system does with it
Entry fields (text in catalog `pm_story`: `people.<id>.name`, `.role`, `.about`; their lines under `lines.<id>.*`):
id, role who, and what they are to her ("craft", "wheels", "heights", "files", ...)
district, place where they are found (a place id of content.places)
known = true met before the game starts
trust trust at the start (-100..100)
services = { { id, at } } what they do for her, and the trust it takes (logic.crew)
Services (read by the system in brackets):
stencils cuts stencils at the studio [session]
cheap_paint tins at a discount at any shop [scoring]
garage_key the Ironside yard takes the van for repairs and a respray [fleet]
driver a driver who brings the van to a corner she names [driver]
fence takes borrowed vehicles for sous [fleet]
routes rooftop routes shown on the map [map]
cradle window-cleaner cradles left unlocked [missions]
beats Wardens' beats and shifts shown on the map [map, roster]
files leverage on named Wardens (blackmail) [roster]
lookout posts herself at a corner and whistles when a Warden nears [session]
decoy a false report that pulls a district's patrols away, once a day [response]
doctor restores colour at once, for sous [session]
safe_door a back door in her district that hides Wren during a search [session]
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# painter
A painter's hands: the tool and pigment in use, and what one tick of painting does.
```
It joins a supply, the tool table and a canvas (paint thrown at things is modules/arms). It knows nothing about input, cameras or characters: the host
says where on the canvas the tool points and how far away the painter stands.
local Painter = require("~.modules.painter")
local p = Painter.new(cfg, supply, { tools = { "spray" } }) -- the tools owned (names in cfg.tools)
p:own("roller") p:selectTool("roller") p:cycleTool(1)
p:selectPigment("ochre") p:cyclePigment(1) -- among pigments the supply holds
local r = p:paint(canvas, dt, { u = 1.2, v = 0.9, distance = 1.4, stand = 0, stencil = nil })
-- call every tick while the trigger is held
-- r = { ok = true, used = tins, added = cells, touched = cells, loudness = n }
-- | { ok = false, reason = "no tool" | "no pigment" | "empty" | "too far" | "out of reach" | "signed" }
-- `stand` is how high the painter's feet are above the canvas's foot (a ladder, a van roof).
-- `stencil = "teal"` with a tool whose config says masked = true paints only the teal region.
p:loudness() -- the selected tool's loudness (0 with no tool), for whatever is watching
p.tool, p.pigment
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# districts
The thirteen districts of Verrane as game boards: who watches, who polices,
```
what the roads allow, what the walls are, and the one rule that makes each a different problem.
Geography (where each district is, its street grain, its landmarks) belongs to the city template
(`s3/design/verrane_geography.md`, the cityGen plan); the ids here are the ids the city must report from
`city.districtAt`. Everything below is rules, read by the systems named in brackets. Text for a district is in
the catalog `pm_world`: `districts.<id>.name`, `.rule` (one line), `.line` (a voice), `.card.<part>` for each
part named in `card` (the district rule card).
local Districts = require("metropolisGame.content.districts")
Districts.list Districts.byId("old_quay") Districts.order Districts.thresholds Districts.colourTarget
Entry fields:
id, contact the district's id and the contact who works it
act the story act it opens in (1..3)
risk multiplies renown earned here [scoring]
police = { faction, foot, cars, beat } who patrols at heat 0: faction "wardens" | "security"; counts; beat =
"wander" | "clockwork" | "watchman" | "posts" | "none" [response, host]
citizens = { informer, sympathiser } shares of passers-by who report / who cheer at colour 0 [districtState]
turn = { at, informer } at this colour the informer share has fallen to this (linear from 0)
crowd = { day, night } 0..1 how full the streets are (cover and witnesses both) [host population]
eyes = { camera, curtain, doorman, lamp } fixed observers per 100 m of street front [host population]
witness = { day, night } the observer kind a reporting passer-by is, by time of day [session]
cars = { [roadClass] = m/s } Warden car speeds here by class of road (others: the kit's) [response]
noCars = { [roadClass] = true } classes no car fits here (the crew dismounts) [response]
sites = { tag, piece, wall } mural sites to deal (logic.sites)
rules = { ... } flags a system reads (each is explained on the district's card):
renownAudience cheering sympathisers raise renown here [scoring]
reportsFade = { share } that share of night reports is forgotten before it lands [session]
beat = { period, gap } clockwork beats: seconds a round, seconds between passes [host]
curtainsSleep = { from, to } window observers only watch outside these hours [host]
freight = { every, lasts } a train passes: full concealment behind it while it does [host]
paintTolerated = factor painting here is this much quieter to observers [session]
checkpointAt = level from this heat level the ways out are checked [response]
noWitnesses nobody lives here: only patrols see [host population]
detainOnly its police detain and call; they cannot arrest [content.pursuit]
impound / scrubDepot / hall / colourworks the place of that name stands here [missions, activities]
tramPass = colour the colour at which the district's tram pass is given [districtState]
shop = { discount } paint is cheaper here by this share [scoring]
card = { "eyes", "roads", ... } the parts of its rule card, in order (catalog keys)
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# missions
The eighteen story missions, as data the mission runner runs.
```
A mission is a list of steps. A step has a goal (a condition), may have a fail condition and a time limit, may
be a checkpoint (where a retry returns to), may be a DECISION (`choose`) and may exist only on the branch one
option opened (`when = { chose = "x" }`). One step carries the twist: a condition that, the first time it holds,
fires the mission's "twist" moment. `bonus` objectives pay extra. `rewards` are paid on completion,
`rewardsBy[choice]` on top for each choice made. Every word is in the catalog `pm_story`:
`missions.<id>.title`, `.giver_line`, `.brief`, `.twist`, `.done`, `.failed`, `.steps.s<n>`, `.options.<choice>`.
Conditions (logic.missionRunner):
{ fact = "near:studio" } { fact = "level", atLeast = 3 } { fact = "tins", atMost = 0 } { fact = "state", is = "clear" }
{ event = "signed", match = { site = "fishmarket" }, min = { rank = 2 }, count = 1 }
{ after = 30 } { all = { ... } } { any = { ... } } { never = cond }
Facts (logic.session supplies them every tick; the host adds its own through the frame's `facts`):
near:<place or named site> in:<district> colour:<district> trust:<contact> flag:<name> has:<upgrade>
driving:<vehicle type> state level heat hour night weekday day in_vehicle hot speed
tins van_tins painting firing colour (0..1, Wren's own) washed_out strikes rank sous blocks
hidden on_ground painted:<site> (0..1) tier:<site> (0 none, 1 rough, 2 clean, 3 masterwork)
host: load (0..1 of a carried load left) aboard:<tram | ferry | cradle> on_roof height (m above the street)
Events (the game reports the first group; the host reports the second with session:event):
signed { site, tier, rank, district, size } bought { tins, pigment } upgraded { id } escaped { level }
arrested ejected reported noticed scrubbed { site } scrub_stopped { site, how } jammed { id }
blinded { id } fouled { id } painted_out { kind } washed_out fired { arm } boarded { type, owned }
alighted stored retrieved fenced shed { what }
talked { who } delivered { to } arrived { at } patrol_passed { at } freight_gone inspector_returned
panels_filled picked_up { what } float_painted convoy_stalled convoy_passed cut_loose file_burnt map_copied
`stage` directions (a list on a step or a twist). GAME verbs are applied by logic.session; HOST verbs by the
driver's stage director through actors, vehicles, camera and audio (Missions.VERBS lists both):
game: { give = "tins", pigment, n } { set_hour = h } { scrub = site, in_seconds, unstoppable } { heat = level }
{ van_tins = n, pigment } { flag = name } { grant = upgrade } { scrub_call = district, in_seconds, crew }
host: { spawn = kind, at = place, id, count, walks_to, leaves, stays, returns_in } { despawn = id }
{ crowd = name, at } { patrol = "reverse" | "double", at } { shut = "bridges" | "roads", district }
{ vehicle = type, at, id, state } { convoy = name, from, to } { load = name } { trail = true }
{ show = name, district } { say = line, who } { shot = name } { freight = "pass" }
{ searchlights = pattern } { winch = true } { doors = "open", held_by } { marker = place }
{ item = what, at = place } something to pick up there (reports picked_up { what })
{ handover = to, at = place } someone to hand a thing to there (reports delivered { to })
{ sketch = place } a place to draw from (reports sketched { at })
local Missions = require("metropolisGame.content.missions")
Missions.list Missions.byId("first_coat") Missions.order Missions.sites Missions.VERBS
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# activities
The replayable work of the city: thirteen activity TYPES, each a small
```
authored job shape with a real decision in it and a consequence that lasts, and the written VARIANTS of each
(content.activityRows: one row per variant, where it is, for whom, with what numbers).
A type is a template: given a variant's row it builds a job in the mission runner's shape (steps, a `choose`
step, bonus objectives, rewards by choice, fail rewards). The board (logic.board) deals a district's variants
by the day. Text is in the catalog `pm_work`: per type `types.<type>.name`, `.pitch`, `.steps.s<n>`,
`.options.<choice>`, `.done`, `.failed`; per variant `<type>.<district>.<key>.title` and `.brief`.
local Activities = require("metropolisGame.content.activities")
Activities.types -- { { id, unlock, perDay, rest, once? } } in board order
Activities.variants -- { variant } built from the rows; each is a job for logic.missionRunner
Activities.byId(id) -- a variant by id ("<type>_<district>_<key>")
Activities.sites -- named mural sites the variants need ({ [name] = { district, size, design, near, permit, carrier } })
Activities.ofType("getaway") Activities.count() -- { [type] = { [district] = n } }
Type fields: unlock (Runner.meets requirements), perDay (variants a district shows a day), rest (days a variant
rests after it is done or failed), once (a collectible: never again once done).
Row fields (content.activityRows): { type, district, key, ...numbers and places the type's template reads }.
Every type's template is documented where it is defined below: what the row may carry, the decision, and what
each outcome changes for good.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# paint
This game's configuration of paintKit: the tools that paint walls, the paint
```
ARMS that fire the same tins, the eight pigments and what each does in a fight, cover for everything that can
be painted out, Wren's own colour, the mural sizes and the designs that go on the walls.
local PaintContent = require("metropolisGame.content.paint")
PaintContent.config -- overrides for paintKit.modules.config
PaintContent.pigments -- { { id, hex, safe, pattern } } in shop order (safe: colour-blind safe hex)
PaintContent.pigment("ochre") -- one of them
PaintContent.arms -- { id, ... } arm ids in wheel order
PaintContent.sizes.piece -- { scale, cols, rows, renown, colour, width, height } (width/height in metres)
PaintContent.designs.piece -- { { id, rows }, ... } authored pictures for that size
PaintContent.design("piece", 2) -- a paintKit design built from the nth picture (wraps round)
PaintContent.designById("piece", "fish")
Numbers follow s3/design/game_direction.md §1 (arms) and GAME_DESIGN.md §4.1 (tools); every one is here, none
in code. Designs are text: one character per block of `scale` x `scale` cells; a cell is 0.25 m. Letters:
o ochre v viridian m vermilion c ultramarine k white b lampblack s saffron h heather . bare wall
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# crew
The people Wren knows: how far each trusts her, and what that trust opens.
```
A contact (content.contacts) has a trust from -100 (they cross the street) to 100. Trust moves when jobs go
well or badly and when choices favour or betray them; every change carries a reason the UI can show. At
thresholds a contact offers SERVICES (a lookout at a corner, a driver, a decoy, a doctor who restores colour,
a fence who takes borrowed cars, cheaper paint): `crew:has("lookout")` is what the rest of the game asks.
Below zero a contact gives no work and no service until trust is rebuilt.
local Crew = require("metropolisGame.logic.crew")
local crew = Crew.new(Contacts, hub?) -- Contacts: content.contacts
crew:meet("pim") -- first met (appears in the list); returns false if known
crew:trust("pim") -- number (the contact's start value before any change)
crew:change("pim", 10, "job_clean") -- returns the new trust; emits "trust", and "service" for
-- each service the change opened or closed
crew:has("lookout") crew:provider("lookout") -- is the service open, and who gives it
crew:gives("pim") -- false while trust is below zero
crew:view() -- { { id, met, trust, band = "wary" | "cool" | "warm" | "close" | "sworn", services = { { id, at, open } } } }
crew:serialise() crew:restore(data)
Hub events: "trust" { contact, value, delta, why }, "service" { contact, service, open }, "met" { contact }.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# scoring
What a signed wall is worth, and what paint costs at this hour.
```
local Scoring = require("metropolisGame.logic.scoring")
local award = Scoring.mural(Economy, PaintContent.sizes, {
size = "piece", tier = "clean", risk = 1.25, audience = 3, heatLevel = 0, permit = false })
-- { renown, colour, sous, parts = { base, tier, risk, audience, underNoses } }
-- a permitted (commissioned) wall pays sous and no renown; an unlicensed one pays renown and no sous
Scoring.tinPrice(Economy, hour) -> sous, open (the day shops shut at night; the night stall charges double)
Scoring.escape(PursuitContent.escapeRenown, level) -> renown
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# response
The Wardens' side of one player's incident, assembled from pursuitKit: who
```
has seen her, how hot it is, which units are sent and what each should do this tick, who fires greywash,
which roads are closing, which borrowed car has been called in, who on the roster knows her face.
It owns no body. The host (logic.driver) tells it where the response units ARE (people and cars it spawned for
this purpose) and where the other observers are; it answers with an intent per unit, the shots to put in the
air, the road blocks to stand, and how many units it wants in the world.
local Response = require("metropolisGame.logic.response")
local r = Response.new({ cfg = pursuitCfg, content = PursuitContent, hub = hub, rng = rng,
hasLine = fn(observer, suspect), light = fn(x, z), bill = fn(level, ctx),
graph = roadGraph, people = Wardens.list })
r.director r.firefight r.roadblocks r.cars r.theft r.roster r.record -- pursuitKit parts
r:setUnit("u1", { kind = "foot" | "security" | "car" | "van" | "truck", x, y, z, fx, fz, speed, roadClass,
home = { x, z }?, out = false }) -- every tick for every live unit (out: painted out)
r:dropUnit("u1")
local view = r:tick(dt, {
suspect = { x, y, z, vx, vz, act, concealment, hidden, appearance, inVehicle, speed, charges, fillFactor, grabFactor,
strikes, fx, fz, roadClass, onFoot },
observers = { [id] = { kind, x, y, z, fx, fz, relay, atRelay, knows, active } }, -- everyone else who watches
input = { breakHeld, skip },
route = function(unit, x, z) return { { x, z }, ... } end, -- the host's router (optional)
noCars = { [roadClass] = true }, carSpeeds = { [roadClass] = m/s }, -- the district's rule (optional)
})
-- view = the director's view + { units = { [id] = intent }, shots = { shot, ... }, blocks = { block, ... },
-- want = { foot, car, van, truck, security }, firing = { [id] = phase } }
r:want() -- how many units of each kind the present heat asks for
r:serialise() r:restore(data) -- theft list, roster, record (an incident itself is never saved)
Hub events beyond pursuitKit's: "unitOrder" { id, role, x, z } when a unit's order changes, "roadblock"
{ type = "ordered" | "standing" | "lifted", block }, "firefight" { type = "aim" | "lower", by, arm, seconds },
"ownerReported" { vehicle }.
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# supply
Paint you can carry: tins by pigment, a capacity, a limit on pigments loaded at once.
```
The same object is a satchel, a vehicle's shelf, a stash in a doorway or a shop's stock; only the numbers differ.
Tins are fractional while in use (a stream draws 0.02 of a tin a frame) and whole when counted for a player.
local Supply = require("~.modules.supply")
local bag = Supply.new({ capacity = 12, slots = 3 }) -- slots: how many different pigments at once (nil = any)
bag:add("ochre", 6) -- returns how many were accepted (capacity and slots are respected)
bag:take("ochre", 0.25) -- returns how much was really taken
bag:count("ochre") bag:total() bag:room() bag:pigments() -- pigments: names with paint, sorted
bag:transfer(van, "ochre", 4) -- returns how many moved (limited by what is here and the room there)
local taken = bag:empty() -- { ochre = 5.5, ... } and the bag is empty (a confiscation)
bag:setLimits({ capacity = 20 })
local data = bag:serialise() Supply.restore(data) -- plain tables for a save
```
The interface is documented in the header of `init.luau`; this file repeats it for the asset browser.
# pursuitKit
Being noticed, being hunted, getting away, getting caught: as data-configured, engine-free logic any game can
drive. Nothing in it names a game, a city, a guard or a crime. The host says where observers and the suspect are
and whether the line between them is clear; the kit answers with states, timers and events, and with intents for
pursuers on foot and in vehicles.
**Status:** every module's logic is covered by case modules that run in the engine's Luau VM in edit mode
(`tests/cases/{core,response,standing}`, 92 cases; see "Tests"). The kit has NOT been run against a scene: the
raycast adapter and everything a host stages (animation, vehicles, sound) are untested here.
## What is in it
| Module (`require("pursuitKit.modules.<name>")`) | What it does |
|-|-|
| `config` | `DEFAULTS`, `merge(base, over)` (`Config.NONE` drops a default), `validate(cfg)`: the whole kit's behaviour as one table |
| `hub` | named events: `on`, `onAny`, `emit` |
| `perception` | view cone in 2D or 3D (`inView3`, `vertical`), range by light, fill rate, panning (`sweep`) |
| `awareness` | one 0..1 meter per observer with suspicious/alert thresholds and events |
| `reports` | pending reports with delays, holds, relays that can be jammed |
| `heat` | offences → points → named levels; pursuit tick; decay after a grace; escape factor |
| `incident` | the state machine: clear, noticed, reported, pursuit, search, escaped, arrest, released; last known position; search area |
| `grab` | the telegraphed reach on foot (`reach`) and the vehicle box-in (`box`) |
| `arrest` | the staged arrest with hooks, break-free and skip; several `sequences` (arrest, detain-and-eject, hand-over); `Arrest.bill(rules, facts)` |
| `dispatch` | who is sent where for a heat level: `plan`, `sweepPoints`, `cordon`, `entry` |
| `pursuer` | one pursuer's intent by profile (`cfg.pursuer[name]`: speeds, leash, home, look-round on arrival); writers for the character bus and the vehicle bus |
| `description` | what the pursuers know the suspect looks like (`strength` 0..1), shedding it |
| `firefight` | pursuers who shoot back: who is armed at a level, the aim telegraph, bursts, led and spread shots. Holds no projectile |
| `roadblocks` | blocks and bridge checkpoints on a road GRAPH the host supplies: ordered, standing, lifted; `plan` forecasts |
| `vehiclePursuit` | pursuit cars that work together: shadow, chase, box, ram, block, dismount where a car cannot go |
| `theft` | taking a vehicle: the offence by its state, the owner's delayed report, the hot list, lawful kinds |
| `roster` | pursuers as named people: beats, shifts, bribes and leverage, arrangements found out, faces remembered |
| `record` | strikes that fade; confiscated things in an impound with a growing fee and a sale date |
| `party` | several suspects in one world: heat is each one's own, shared with accomplices standing close |
| `director` | perception, awareness, reports, heat, incident, grab, arrest and description assembled behind `setObserver` / `setSuspect` / `tick` |
| `engineAdapters` | `lineOfSight` on `Physics.raycast`; `lightAt` / `lightByHour` (the only module that calls the engine) |
Every module's header comment is its reference: the calls, the shapes they return, and its section of the config.
## Using it
```lua
local Config = require("pursuitKit.modules.config")
local Director = require("pursuitKit.modules.director")
local Adapters = require("pursuitKit.modules.engineAdapters")
local Arrest = require("pursuitKit.modules.arrest")
local cfg = Config.merge(Config.DEFAULTS, myGameConfig) -- see the schema in modules/config
assert(Config.validate(cfg))
local dir = Director.new(cfg, {
hasLine = Adapters.lineOfSight({ pass = isGlassOrCrowd }),
light = Adapters.lightByHour(function() return clock.hour end),
bill = function(level, ctx) return Arrest.bill(myBillRules, factsFor(level)) end,
})
dir.hub:on("state", function(e) hud.setPursuit(e.to) end)
dir.hub:on("arrestStage", function(e) cast.play(e.stage); camera.cut(e.stage); hud.arrest(e) end)
-- every frame
dir:setObserver(id, { kind = "guard", x = x, y = y, z = z, fx = fx, fz = fz })
dir:setSuspect({ x = px, y = py, z = pz, act = currentAct, concealment = tags, hidden = inHide,
appearance = { jacket = jacket }, inVehicle = driving, speed = speed, charges = slips })
dir:input({ breakHeld = interactHeld, skip = confirmPressed })
local view = dir:tick(dt) -- everything a HUD draws
dir:offence("fired_arm") -- something the game saw her do
dir:report({ offence = "stolen_vehicle", x = x, z = z, delay = 8, appearance = tags }) -- a report from outside
dir:noise({ x = x, z = z, radius = 30 }) -- observers in earshot grow suspicious
```
Pursuers (the host owns their entities):
```lua
local Dispatch = require("pursuitKit.modules.dispatch")
local Pursuer = require("pursuitKit.modules.pursuer")
local orders = Dispatch.plan(cfg, view.level, view, units) -- units: { { id, kind, x, z, available } }
for _, u in units do
local senses = dir:senses(u.id) -- sees, sx, sz, stunned, grabbing
senses.x, senses.z, senses.order, senses.path = u.x, u.z, orders[u.id], route(u, orders[u.id])
local intent = u.brain:decide(dt, senses) -- u.brain = Pursuer.new(cfg, "foot")
if u.kind == "foot" then
u.controller.inputX, u.controller.inputZ = Pursuer.characterBus(intent, u.x, u.z)
else
u.vehicle.inputThrottle, u.vehicle.inputSteer, u.vehicle.inputBrake, u.vehicle.inputHandbrake =
Pursuer.vehicleBus(intent, u.x, u.z, u.fx, u.fz, u.forwardSpeed, cfg.frame.right)
end
end
```
The response beyond the chase (each is independent; use what the game needs):
```lua
local ff = Firefight.new(cfg.firefight, rng) -- rng() -> [0, 1): the kit ships no generator
for _, e in ff:tick(dt, { level = view.level, suspect = s, shooters = shooters }) do
-- "aim" (stage the telegraph), "shot" { from, at, wash, speed, gravity, ... } (fly it), "lower"
end
local rb = Roadblocks.new(cfg.roadblocks, graph) -- graph = { nodes = { [id] = { x, z } }, edges = { { id, a, b, class, bridge } } }
for _, e in rb:update(dt, { level = view.level, state = view.state, x = lkp.x, z = lkp.z, radius = r }) do end
Roadblocks.plan(cfg.roadblocks, graph, { level = view.level + 1, x = x, z = z, radius = r }) -- forecast for a map
local vp = VehiclePursuit.new(cfg.vehiclePursuit, cfg.frame.right)
local intents = vp:tick(dt, { level = view.level, target = car, units = cars }) -- shadow | chase | box | ram | block | dismount
local theft = Theft.new(cfg.theft)
local r = theft:take(vehicle, { witnessed = seen, x = x, z = z }) -- the offence now, the owner's report later
for _, landed in theft:tick(dt) do dir:report(landed) end
local roster = Roster.new(cfg.roster, people, rng) -- named pursuers: onDuty, cover, arrange, use, sawFace
local record = Record.new(cfg.record) -- strike, confiscate, impounded, fee, release, dayPassed
local party = Party.new(cfg.party) -- join, place, together, charge, reported
```
## Interfaces the host provides
- **Line of sight** `hasLine(observer, suspect) -> boolean`. `engineAdapters.lineOfSight` is one implementation.
- **Light** `light(x, z) -> 0..1` (optional).
- **The bill** `bill(level, ctx) -> table` (optional; `Arrest.bill` builds one from rules).
- **A generator** `rng() -> [0, 1)` for firefight spread and roster rolls. Seed it: the kit is deterministic for a
given sequence of inputs and rolls.
- **A road graph** for road blocks, and a `path = { { x, z }, ... }` per pursuer per order (roads for cars, a nav
path on foot). The kit does not pathfind.
- **Movers**: a character with `inputX`, `inputZ`, `inputJump` and a vehicle with `inputThrottle`, `inputSteer`,
`inputBrake`, `inputHandbrake`, or any AI driver that accepts the intent (`mode`, a point, a speed).
- **Projectiles**: whatever flies a `shot` event from `from` towards `at` and reports what it hit.
- **Staging**: animation, camera and UI for `grabWindup`, `grabMissed`, firefight `aim`, and each `arrestStage`;
the kit gives the moments and durations and waits for nobody.
## Frame
Positions are `(x, y, z)` with y up; where only the ground matters `(x, z)`. `cfg.frame.right` is the sign of x
on the right of someone facing +z: `-1` in the Zero engine's frame (+x east, +z south), `1` in a z-north frame.
It decides flank sides and steering.
## Events (on `dir.hub`)
| Event | Payload | When |
|-|-|-|
| `state` | `from, to, level` | the incident changes state |
| `heat` / `heatLevel` | `value, level, name, delta, offence` / `from, to, name` | heat changes / crosses a level |
| `observer` | `type = suspicious, alert or calm; id; kind` | an observer crosses a threshold |
| `cheer` | `id` | an observer whose kind answers alert with "cheer" becomes certain |
| `reportOpened` / `reportLanded` | `id, delay, via, relay` / `id, offence, x, z` | a report starts its delay / arrives |
| `lkp` | `x, z` | the last known position moves by more than a metre outside a pursuit |
| `searchStarted` | `x, z, radius, duration` | a search begins |
| `escaped` | `level, name, heatBefore` | a search ran out |
| `grabWindup` / `grabMissed` | `by` | a pursuer starts / fails a reach |
| `arrested` | `level` | a grab landed |
| `arrestStage` | `stage, control, duration, ctx` | each stage of the sequence begins |
| `arrestBroke` / `arrestDone` | `{}` / `bill, level, sequence, outcome` | the suspect broke free / the sequence ended |
| `released` | `{}` | the incident is over after an arrest |
`firefight`, `roadblocks`, `vehiclePursuit`, `theft` and `record` return their events from `tick` / `update` /
`dayPassed` instead of emitting: the host decides which hub they go on.
## Rules the config must keep
`acts.wanted` (what a certain observer takes the suspect to be doing), `heat.offences.seen`, the offence named by
`arrest.breakOffence`, one `response` entry per heat level, `heat.levels[1].at == 0`, a `firefight.levels`,
`roadblocks.levels` and `vehiclePursuit.levels` entry per heat level when those sections are used.
`Config.validate` checks the structural ones and names what is wrong.
## Tests
The cases are modules (`tests/cases/*.module`, each returns `function(Test)`), registered by
`tests/pursuitKit.testSuite` for the engine's runner. The engine's runner closes and reloads the open scene, so
while a scene is being worked on run them in-process instead with `caseBench` (see its README): same cases, no
scene touched.
# paintKit
Paint as a game system: what you carry, what the tools do, what a mural is meant to be and how well it was done;
and paint as a weapon: arms that fire pigment as real projectiles, cover as the health of everything paintable,
"painted out" instead of dead, the painter's own colour stripped by solvent, and marks that stay on walls, cars
and people. Engine-free logic configured by data; nothing in it names a game.
**Status (2026-11-22): logic run in the engine through `caseBench` (62 cases pass). `engineAdapters` (decal
splats, the `Physics.raycast` query) is written against the documented API and has NOT been run in a scene.**
## What is in it
| Module (`require("paintKit.modules.<name>")`) | What it does | Engine calls |
|-|-|-|
| `config` | `DEFAULTS`, `merge` (with `NONE` to drop a default), `validate`: the whole kit as one table | none |
| `supply` | tins by pigment with a capacity and pigment slots: a satchel, a shelf, a stash | none |
| `design` | a mural's intended picture from rows of characters and a legend, scaled to cells | none |
| `canvas` | cells with fill and pigment: `stroke`, `quality`, `sign`, `scrub`, `nextGap`, `serialise` / `restore` | none |
| `painter` | tool and pigment in hand; one tick of painting a canvas, with reasons for refusal | none |
| `arms` | paint arms: owned, selected, cadence, paint per shot; builds a shot's projectiles (seeded scatter) or a cone pulse | none |
| `ballistics` | projectiles under gravity in fixed sub-steps, hits through an injected query; `cone`, `splash`, `arc`, `lobVelocity`, `lead` | none |
| `pigments` | tactical properties of pigments: cover / blind / fade factors and extra effects by target kind | none |
| `cover` | cover per part of a thing, threshold effects, painted out and back, wiping, repair, save of fixed things | none |
| `colour` | the painter's own colour: `wash`, washed out, recovery unseen and on friendly ground, `effects` | none |
| `impact` | what a hit does: cover or a mark, surface rule, pigment effects, splash; reports offences | none |
| `splats` | marks on the world and on moving things: merge, budgets, fading, spatial lookup, change feed, save | none |
| `surfaces` | rule lookup for paint on a kind of surface; a field of timed and area effects | none |
| `engineAdapters` | `splatView` (decal projectors, also parented to things), `query` (the ballistics query on `Physics.raycast`) | `entity.spawn`, `@builtin::modules.decals`, `Physics.raycast` |
`tests/cases/core` (canvas, supply, painter, splats, surfaces) and `tests/cases/arms` (arms, ballistics, cover,
colour, pigments, impact, splats on things): 62 cases of pure logic. `tests/paintKit.testSuite` hands the same
cases to the engine's framework.
## Config schema
The header of `modules/config` is the schema. In short:
```lua
{
cell = 0.25,
tools = { spray = { mode = "stream", radius, coverage, tinPer, reach, range, spill, loudness, masked? } },
arms = { pistol = { mode = "pellet" | "lob" | "stream" | "cone", pellets, spread, speed, gravity, range, radius,
cover, splash?, shotsPerTin, interval, halfAngle?, loudness, heard, mount?, scope? } },
ballistics = { step, maxShots },
pigments = { white = { cover?, blind?, fade?, effects = { { effect, on = { kind }, seconds?, radius?, factor? } } } },
cover = { kinds = { guard = { parts = { visor = { capacity, effects = { { at, effect, seconds?, offence? } } } },
defaultPart, out = { part?, at, seconds?, effect?, offence? }, wipe?, persist? } } },
colour = { recover = { delay, rate, friendly }, edges, washedOut = { reviveAt, speed, canPaint, canFire, grabWindow } },
quality = { fillAt, overAt, tiers = { { name, coverage, accuracy?, overspray? }, ... } },
repaint = { keep }, scrub = { gone },
surfaces = { [kind] = { [arm | tool] | any = { effect, seconds?, radius?, offence? } } },
splats = { max, bucket, mergeWithin, maxRadius, maxPerTarget, rules = { [surface] = { life?, scrub? } } },
}
```
## Using it: a mural
```lua
local Config = require("paintKit.modules.config")
local Supply = require("paintKit.modules.supply")
local Design = require("paintKit.modules.design")
local Canvas = require("paintKit.modules.canvas")
local Painter = require("paintKit.modules.painter")
local cfg = Config.merge(Config.DEFAULTS, myPaintConfig)
local bag = Supply.new({ capacity = 12, slots = 3 }); bag:add("ochre", 6)
local hand = Painter.new(cfg, bag, { tools = { "spray" } })
local wall = Canvas.new(cfg, Design.fromRows({ rows = { ".oo.", "oooo" }, legend = { o = "ochre" }, scale = 4 }))
local r = hand:paint(wall, dt, { u = u, v = v, distance = d, stand = feetAboveWallFoot })
if not r.ok then hud.say(r.reason) end -- "empty", "too far", "out of reach", "signed", ...
local tier = wall:sign() -- fixes it; nil if below the lowest tier
```
## Using it: a firefight
```lua
local Arms = require("paintKit.modules.arms")
local Ballistics = require("paintKit.modules.ballistics")
local Cover = require("paintKit.modules.cover")
local Splats = require("paintKit.modules.splats")
local Surfaces = require("paintKit.modules.surfaces")
local Impact = require("paintKit.modules.impact")
local arms = Arms.new(cfg, bag, { arms = { "pistol" }, rng = seededRng }) -- same tins as the murals
local air = Ballistics.new(cfg.ballistics, query) -- query: see below
local cover, splats, field = Cover.new(cfg.cover), Splats.new(cfg.splats), Surfaces.field()
local impact = Impact.new(cfg, { cover = cover, splats = splats, field = field, query = query })
-- trigger pulled
local fired = arms:fire({ origin = muzzle, dir = aimDirection, owner = "player" })
if fired.ok then
for _, shot in fired.shots or {} do air:spawn(shot) end
if fired.cone then for _, report in impact:pulse(fired.cone) do handle(report) end end
witnesses.heard(fired.heard, fired.loudness)
end
-- every tick
arms:tick(dt)
for _, e in air:step(dt) do
if e.type == "impact" then
local report = impact:land(e.shot, e.hit) -- cover, mark, effects, offences, splash
for _, c in report.cover do
if c.type == "out" then guards.paintedOut(c.id, c.seconds) end
if c.type == "effect" and c.effect == "blind" then guards.blind(c.id, c.seconds) end
end
for _, offence in report.offences do crimes.report(offence) end
end
end
for _, e in cover:tick(dt) do guards.back(e.id) end
splats:tick(dt); view:sync(splats:drain())
```
Solvent coming the other way is the same machinery with a different consequence: the host flies the pursuers'
shots through its own `Ballistics`, and a hit on the painter calls `colour:wash(amount)`;
`colour:effects()` then says how slow the painter is and whether the hands still work.
## Interfaces the host provides
- **Physics query** (for `ballistics` and `impact`):
`query.raycast(origin, dir, distance, exclude) -> { x, y, z, nx, ny, nz, distance, kind, target?, part?, lx?, ly?, lz? } | nil`
and, for splash and cone arms, `query.overlap(centre, radius) -> { { target, kind, part?, x, y, z } }`.
`kind` is a surface kind (`cfg.surfaces`) or a cover kind (`cfg.cover.kinds`); `target` is the id of a thing.
`engineAdapters.query{ classify, entityOf, things }` builds it on `Physics.raycast`.
- **A seeded generator** `rng() -> [0, 1)` for scatter (the kit ships none, so every random number is the host's).
- **Where a tool points on a canvas**: `(u, v)` in metres from its lower-left corner, the painter's distance and
the height of its feet above the wall's foot.
- **Drawing**: canvases, shots in flight (`air:each`), splats (`store:drain()`; `engineAdapters.splatView`), cover
meters (`cover:view(id)`), the screen draining with `colour:effects().drain`.
## Events
paintKit returns results instead of emitting events: every call that changes something returns what changed
(`fire` → shots or a cone, `step` → impacts and spent shots, `land` / `pulse` → reports, `hit` → cover events,
`tick` → things back, `wash` → value and washed out, `stroke` → touched and added, `sign` → tier, `Field:tick` →
ended effects, `Splats:drain` → added / changed / removed). The host turns those into its own events.
## Example config for a pump gun and a blinding pigment
```lua
local cfg = Config.merge(Config.DEFAULTS, {
arms = { scatter = { mode = "pellet", pellets = 8, spread = 7, speed = 45, gravity = 9.8, range = 12,
radius = 0.14, cover = 0.14, shotsPerTin = 4, interval = 0.9, loudness = 2.5, heard = 60 } },
pigments = { white = { blind = 1.75 } },
})
```