---
name: wegmisbruik-extension
description: Build an extension for Wegmisbruik, the browser driving game set in the real Netherlands. An extension is a few JSON files that open up a real building (a room you walk into, things to use, people to talk to), play cutscenes, and chain them into missions that pay in-game money. Use when someone wants to make a Wegmisbruik extension, mission, cutscene or enterable building, or to check or fix one.
---

# Building a Wegmisbruik extension

Wegmisbruik (https://app.code424.nl) is a GTA-style driving game through the whole real
Netherlands, built from OpenStreetMap and Dutch government map data. An extension adds content to
it as **JSON only, no code**: the game has a fixed set of actions and conditions, and the JSON picks
from them. Every file is checked strictly, and anything unknown is refused.

What one extension can do:
- take over a real building: its outside stays the real one, and E at the door fades into a room
  generated from the building's footprint;
- put **things** in that room (E uses them) and **characters** (E talks; they walk a path and say
  lines in order);
- play **scenes**: camera shots and moves, lines, waits and choices;
- run **missions**: steps such as go there, go inside, talk, watch a scene, choose, deliver an item,
  with fail conditions and a reward the game's server pays.

## Workflow

1. **Ask what they want**: which building (an address or a spot on the map), who is in it, what
   happens, and what the player gets for it. Keep the first version small: one building, one
   character, one mission. It can grow once it works.
2. **Find the building**: its OSM id and centroid (see *Finding the building*).
3. **Write the files** into one folder: `manifest.json`, plus one logic file per building and one
   file per scene and per mission. Use the reference below. Every user-facing text is
   `{ "en": "…", "nl": "…" }`. Dutch is optional but welcome; write it informal (je/jij).
4. **Check it yourself** against the limits and the cross-checks below before handing it over.
5. **Test it in the workbench** (see *Testing*), and tell the user the exact steps.
6. **Host it** if they want other players to have it (see *Hosting and payouts*).

## Finding the building

A building is referenced as `{ "id": "way/<n>" | "relation/<n>", "at": { "lat", "lon" } }`. `at`
must be the footprint's **centroid**: the game matches the building with that id whose middle lies
within **5 m** of `at`, else whichever building's outline contains `at`. If neither, the extension
is *orphaned*.

1. Find the id: on openstreetmap.org, right-click the building → *Query features* → the building
   (`way/…`). Or ask Overpass:
   `https://overpass-api.de/api/interpreter?data=[out:json];way(around:15,LAT,LON)[building];out ids geom;`
2. Get its outline: `[out:json];way(ID);out geom;`. Compute the centroid as the polygon's area
   centroid (shoelace formula), not the mean of the vertices.
3. Positions inside the building (`door`, things, characters) are **metres `[east, north]` of
   that centroid**. To turn a vertex into metres:
   `east = (lon - lon0) * 111320 * cos(lat0)`, `north = (lat - lat0) * 110540`.
4. Put the `door` on the wall that faces the street, about 0.3 m inside the outline. Put things and
   characters well inside the outline, at least 1 m from the walls. A room is as big as the whole
   footprint, so a terraced house is narrow and deep.

Outdoor positions (mission targets, outdoor scenes) are `{ "lat", "lon" }` and must lie in the
Netherlands: lat 50.7–53.6, lon 3.3–7.3.

## Reference

Ids are `[a-z0-9-]`, 1–40 characters. Text is 1–500 characters per language. Paths in the manifest
are relative to the manifest, at most 200 characters, `[A-Za-z0-9._/-]` only, and never leave its
folder (no `..`, no URLs).

### manifest.json

```json
{
  "apiVersion": 1,
  "id": "my-extension",
  "version": "1.0.0",
  "origin": "https://example.github.io/my-extension/",
  "name": { "en": "The spare key", "nl": "De reservesleutel" },
  "description": { "en": "One line on what it is." },
  "permissions": ["interior", "scene", "mission", "money", "progress"],
  "buildings": [{ "id": "way/296712025", "at": { "lat": 52.0044491, "lon": 5.090062 } }],
  "logic": ["logic.json"],
  "scenes": ["scene.json"],
  "missions": ["mission.json"]
}
```

- `apiVersion`: only `1`.
- `version`: semver `x.y.z`. Bump it on every change you publish.
- `origin`: who made it, a URL or a name (≤200). Players' permission grants are keyed on it.
- `permissions`: any of `interior` (needed for logic files), `scene` (for scenes), `mission` (for
  missions), `money`, `progress`, `home`, `car` (one for each reward kind used), `teleport`,
  `vehicle`, `waypoint`, `police` (for the actions of those names, `police` for the pursuit ones;
  `teleport` also for a funnel), `traffic` (for `quietStreets` and `rideAlong`). Ask for no more
  than you use.
- `buildings` ≤20 (optional `height`: 1.5–30 m, room height, default 2.6), `logic` ≤20,
  `scenes` ≤50, `missions` ≤50, optional `lines` ≤50 (line tables) and `campaign` (one file).

### Logic: one building's inside

```json
{
  "building": "way/296712025",
  "door": [-0.3, -4.6],
  "things": [
    {
      "id": "cabinet",
      "name": { "en": "Cabinet", "nl": "Kastje" },
      "at": [-4, -2],
      "do": [
        { "do": "giveItem", "item": "spare-key" },
        { "do": "say", "text": { "en": "A spare key, on a red keyring." } }
      ]
    }
  ],
  "characters": [
    {
      "id": "buur",
      "name": { "en": "Ans" },
      "stand": [2, -1],
      "path": [[2, -1], [-2, 0]],
      "lines": [
        {
          "text": { "en": "My sister locked herself out again." },
          "do": [{ "do": "startMission", "mission": "key-run" }, { "do": "startScene", "scene": "porch" }]
        },
        {
          "text": { "en": "The key's in the cabinet." },
          "when": [{ "if": "choiceWas", "choice": "help", "option": "yes" }]
        }
      ]
    }
  ]
}
```

- `things` ≤50: `id`, `name`, `at`, optional `when` (conditions), `do` (actions). A thing whose
  `when` fails can't be used.
- `characters` ≤50: `id`, `name`, `stand`, optional `path` (≤20 spots, walked back and forth),
  `lines` ≤50, optional `reactions` (≤20 of `{ when, do }`, run on every talk whose `when` holds).
  Each talk says the next line whose `when` holds, then stays on the last one.

**Actions** (≤20 per list), tagged by `do`:
`say {text, who?}` · `giveItem {item, count?}` (1–999, default 1) · `takeItem {item, count?}`
(all of it when left out) · `openDoor` · `startScene {scene}` · `setFlag {flag, value}` ·
`startMission {mission}` · `requestEffect` (claims the running mission's reward) · `emit {event}`
(raises an event a `firstOf` step waits on) · `teleport {at}` (the player, in the car, to the road
nearest `at`; needs `teleport`) · `giveVehicle {model, livery?}` (a player car like `peugeot-206`, a traffic
class like `taxi` (in a company's `livery`, `PostNiL` on a `van`), or `fatbike` (the car then out of the world until a respawn), for the session; needs `vehicle`) · `setWaypoint {at, name}` (the
GPS to `at`; needs `waypoint`) · `startPursuit {at?, model?, paint?, beside?}` (one more patrol car, at most 6, chases the player until `endPursuit`
or the mission or episode ends, coming on at the road nearest `at`, else behind them; with `model` a car of that
traffic class in `paint`, no siren, no arrest, and `beside` rides level with the player; needs `police`) ·
`endPursuit` (needs `police`) · `boxIn {event}` (the chase's cars close round the player, one in front, one
beside, the rest behind; `event` once the player has stood among them 3 s; needs `police`) ·
`rideAlong {who, path, speed?, wait?, off?}` (a companion on a fatbike leads the player along
`path`, 2–50 lat/lons, at `speed` 1–12 m/s, waiting once they fall `wait` 10–100 m behind, then
peels off along `off` and is dropped out of sight; needs `traffic`) ·
`setEnvironment {hour?, weather?, traffic?}` (hour 0–24, `dry`/`rain`, `none`/`quiet`/`normal`/`busy`
held until the episode or mission ends, as a scene's environment; needs `scene`) ·
`lightWindows {at, radius}` (radius 10–300: the rooms round at lit at any hour until the episode or
mission ends; needs `scene`) · `playSound {sound, at?}` (a synth cue, `bark`/`bell`/`gunshot`/`siren`/`ding`/`horn`/
`phone-ring`/`phone-buzz`/`reverse-beep`/`ship-horn`/`alarm`/`party-bass`, rung once at `at`, else at
the player; needs `scene`) · `spillCargo {item, count}` (count 1–50: each hard corner while the
player drives lets one `item` fall out of the car's right door onto the road, until all are out or
the episode or mission ends; the items lie on the road until then; needs `vehicle`) ·
`seatPassenger {who, look?}` (`who` in the front passenger seat of the player's car, in a cast look,
until `dropPassenger` puts them out by its door or the episode or mission ends; needs `vehicle`) ·
`dropPassenger` (needs `vehicle`) · `startFireworks {at, every?}` (1–10 lat/lons: a burst high over
one near the player every `every` 1–60 s, 4 by default, until `endFireworks` or the episode or mission
ends; needs `scene`) · `endFireworks` (needs `scene`) · `standJam {path, gap?}` (2–20 lat/lons: standing
cars nose to tail `gap` 1–10 m apart in every lane of the road along `path` until the episode or mission
ends; add a `quietStreets`; needs `traffic`) · `standCrowd {at, radius, count, facing?, cheer?}` (1–40 people
within `radius` 1–30 m of `at`, facing `facing` or the nearest road, a share `cheer` 0–1 (0.3) of them
cheering with their hands up, until the episode or mission ends;
nobody on a building or in water; they step out of a car's way at walking pace, not a fast one's;
needs `traffic`) · `startCall {speaker}` (the
HUD's video call window with that speaker code, `TRI`, on the line, drawn live head and shoulders:
their lines show in it, not as subtitles; until `endCall` or the episode or mission ends) · `endCall`.

**Conditions** (≤20 per list, all must hold), tagged by `if`:
`flagIs {flag, value}` · `hasItem {item}` · `missionStepIs {mission, step: number | "done"}` ·
`choiceWas {choice, option}`.

Flag values are a string, number or boolean. Wherever a line is said (`say`, a character's
`lines`, a scene `line`), `text` is inline `{en, nl?}` or a line ID from a line table. Any shown
text may hold `{{ player }}`: the name the player chose.

### Scene

```json
{
  "id": "porch",
  "where": { "building": "way/296712025" },
  "entries": [
    { "kind": "shot", "eye": [-5, -3.5, 1.7], "target": [2, -1, 1.5], "seconds": 2 },
    { "kind": "line", "who": "buur", "text": { "en": "Could you bring her my spare key?" }, "seconds": 3 },
    { "kind": "move", "eye": [[-5, -3.5, 1.7], [0, -2.5, 1.6]], "target": [[2, -1, 1.5], [2, -1, 1.5]], "seconds": 2 },
    {
      "kind": "choice", "id": "help",
      "prompt": { "en": "Take the key run?" },
      "options": [{ "id": "yes", "text": { "en": "Sure" } }, { "id": "no", "text": { "en": "Not now" } }],
      "default": "yes"
    }
  ]
}
```

- `where`: `{ "building": id }` (points are `[east, north, up]` metres from its centroid, on its
  floor) or `{ "lat", "lon" }` outdoors (from the ground there).
- `entries` 1–200: `shot {eye, target, seconds}`, `move {eye: [from, to], target: [from, to],
  seconds}`, `line {who?, text, seconds, filter?}` (`filter` `radio` or `megaphone`: its recording
  over a radio or through a megaphone), `wait {seconds}`, `choice {id, prompt, options,
  default}` (waits for the player), `timed {…choice, seconds}` (takes `default` when time runs out).
  `seconds` is above 0 and at most 600. Options: 2–6, and `default` must be one of their ids.
- A player can skip a scene they have seen before. Skipping or quitting takes each remaining
  choice's `default`. Each choice's answer is kept as `choiceWas`.
- A camera (`shot`, `move`) holds through the entries after it until the next one. Outdoors,
  `cast` (up to 6 members for your extension) stages people and cars while the scene plays:
  `{ "id": "gert", "kind": "fatbike", "at": {lat, lon} }`, kind `foot`, `fatbike`, `player`
  (the player as they are, needs `teleport`) or `car` (`model`: a traffic class such as `small` or
  `police`, `paint?` `#rrggbb`, `livery?` a company's (`PostNiL` on a `van`: paint, accent, decal), `siren?` an entry hook from which its light bar and siren run),
  `heading?` in degrees, and `track?`: legs
  `{ "from": entry, "path": [lat/lons], "speed": m/s, "by"?: entry }`, each setting off as entry
  `from` begins (counted from 0) and at its end once entry `by` is over. `"follow": "gert"` on a
  shot or move measures its points from that member, so the camera rides along.
- A `camera` lane's `doorbell` cam frames a member, or with `"building": "way/123"` (no
  `subject`) films from that house's own front door; a house not loaded or with no door: nothing.
  With `"near": {lat, lon, range?}` it films from the nearest house that has a doorbell.

### Mission

```json
{
  "id": "key-run",
  "name": { "en": "The spare key" },
  "steps": [
    { "kind": "enter", "goal": { "en": "Go inside" }, "building": "way/296712025" },
    { "kind": "talk", "goal": { "en": "Talk to Ans" }, "character": "buur" },
    { "kind": "scene", "goal": { "en": "Listen to Ans" }, "scene": "porch" },
    { "kind": "choose", "goal": { "en": "Say yes to Ans" }, "choice": "help", "option": "yes" },
    { "kind": "deliver", "goal": { "en": "Bring the key to her sister" }, "item": "spare-key", "at": { "lat": 52.0058, "lon": 5.0915 } }
  ],
  "fail": [
    { "kind": "timer", "seconds": 300 },
    { "kind": "leaveArea", "at": { "lat": 52.0048, "lon": 5.0905 }, "radius": 800 }
  ],
  "reward": [{ "kind": "money", "amount": 250 }, { "kind": "progress", "key": "key-run", "value": true }],
  "minSeconds": 60
}
```

- `steps` 1–50, done strictly in order, each `goal` shown on screen:
  `goto {at, radius?}` (1–5000 m, default 15) · `enter {building}` · `talk {character}` ·
  `scene {scene}` · `deliver {item, at}` (the player has the item and stops within 15 m, slower
  than 2 m/s; the item is taken) · `dig {at, radius?, seconds}` (on foot within radius, default 3,
  of at, the use key held for seconds on end; letting go starts over) · `horn {times?}` (1–20,
  default 1: the car's horn sounded that many times since the step came on) · `choose {choice, option?}` (answering another option fails the
  mission at once) · `firstOf {goal, triggers}` (passes as the first of 1–5 triggers fires:
  `{on: "timer", seconds}`, `{on: "reach", at, radius}`, `{on: "leave", at, radius}`,
  `{on: "blast", at, radius}` (a charge goes off within radius m of at), `{on: "event", event}`) · `checkpoint`
  (no keys, no goal; passes at once, and in a campaign a failed mission goes again from here).
  Any step may add `do` (0–20 actions), run as it passes.
- `funnel` (optional): `{path: [2–100 lat/lon], width: 4–200}` keeps the player within half the
  width of the path: off it, or upturned or in water, they are put back on it. It never fails the
  mission, and needs `teleport`.
- `set` (optional, 0–100): pieces put in the world from the mission's start until it is done or
  fails, each `{kind, at, heading?, up?, burning?}`: `heading` deg its front looks, `up` m over the
  ground, `burning` flames and smoke from its top. Kinds: `fence`, `crowdBarrier`, `roadClosed`,
  `stork`, `birthSign`, `shippingContainer`, `thermos`, `speaker`, `moroccanFlag`, `waterTable`,
  `trolleyCrates`, `wrappedTube`, `bale`, `protestFlag`, `protestBanner`, `tractor`, `bin`,
  `trolley`, `bench`, `planter`, `container`, `lamp`, `flagpole`, and the security cameras
  `domeCamera` and `bulletCamera` (`aim: [heading, pitch]` instead of `heading`, an `id`).
  Nothing stops against them.
- `fail` ≤10: `timer {seconds}` · `leaveArea {at, radius}` · `recognised {at, radius, seconds}`
  (stood within radius m of at for seconds on end) · `wrecked` (the car is wrecked) ·
  `arrested` (stood still beside any `startPursuit` patrol car for 3 s) · `dead` (WASTED) ·
  `inWater` · `hitCrowd` (one of a `standCrowd` crowd knocked down). The first that holds is the
  reason the player reads.
  A failed mission rolls the player's flags and items back to where they were at its start, so it
  can be offered again.
- `reward` ≤10: `money {amount}` · `progress {key, value}` · `home {building}` · `car {model}`.
- `minSeconds` 0–3600: the server pays nothing for a run quicker than this. Set it to what a fast
  honest player needs.

### Line table

```json
{
  "lines": [
    {
      "id": "KEY1_ANS_001",
      "speaker": "ANS",
      "text": { "nl": "Breng je mijn reservesleutel naar mijn zus?", "en": "Could you take my spare key to my sister?" },
      "audio": { "nl": "vo/nl/KEY1_ANS_001.ogg" }
    }
  ]
}
```

- `lines` ≤1000. `id` is a stable line ID: letters and digits, `_`, a speaker code, `_`, a number
  (`CS00_TRI_001`, `CS01b_EDW_001`), each one once across the extension. `speaker` is an upper-case
  code (`TRI`). `text` is per locale (`nl`, `en`, `pt-BR`, ≤20) and needs `nl`: a line reads the
  player's language, else Dutch. Optional: `parenthetical` (`whispering`; `text-message` shows the line as a text on the phone), `spoken` (the language
  the take is in), `forceSubtitles`, `audio` (`.ogg`/`.mp3`) and `visemes` (`.json`) per locale.

### Campaign

```json
{
  "adult": true,
  "episodes": [
    { "kind": "scene", "scene": "cs00", "enter": [{ "do": "setFlag", "flag": "debt", "value": 300 }] },
    { "kind": "mission", "mission": "gp00", "exit": [{ "do": "giveItem", "item": "cash", "count": 2 }] }
  ]
}
```

- `episodes` 1–100 in play order, each a `scene` or a `mission` of this extension, with optional
  `enter` and `exit` action lists (where the player stands, what they drive and carry, flags).
- The campaign saves as each episode begins and at each `checkpoint`; Continue goes on from there.
- `adult: true` asks the player once whether they are 18 or older, with a content warning, before
  the campaign starts. It is the game's own question: never call it a rating.

### Cross-checks the game runs

Every name must exist in the same extension: a logic file's or scene's building is in
`manifest.buildings`; `startScene`, scene steps and `startMission` name a scene or mission that
exists; a `talk` step names a character. Using logic, scenes or missions needs `interior`,
`scene` or `mission` in `permissions`, and each reward kind needs its own permission. A line ID
must be in one line table, once; `teleport`, `giveVehicle`, `setWaypoint`, the pursuit actions and
a funnel need their permission; a campaign's episodes name this extension's own scenes and missions.
A scene's cast ids are its own, once each, with one `player` at most; a leg's `from`/`by` and a
`follow` name an entry and a member the scene has.

### Assets

The total is at most 20 MB per extension and 5 MB per file. Allowed: `.json`, `.glb`, `.png`,
`.webp`, `.ogg` (Opus), `.mp3`. A file's extension, its content type and its first bytes must
agree. A building may name a `model` (`.glb`) instead of the generated room. Its buffers must be
embedded (no external URIs), it may use only `KHR_materials_unlit` and `KHR_texture_transform`,
and it renders in flat colours (`baseColorFactor`). Prefer the generated room.

## Testing

The workbench is at `https://app.code424.nl/dev/workbench?debug`.

1. *Paste a new extension* → *Edit*: paste `manifest.json` first. A box appears for each file it
   names; paste those too. The checks run as you type and list every problem with its path (e.g.
   `steps[3].option`).
2. *Load as client copy*. It runs only for you, and its payouts are tests, never paid.
3. The copy now has its own row. *Download tiles* fetches the map round every place the extension uses, so testing doesn't wait
   on the world loading.
4. *Jump in* opens the game beside the building with the debug view on: the matched outline (green
   posts = found by id, amber = by outline, red = orphaned), rings where E reaches the door, things
   and characters, the mission target, and a panel showing what the current step still waits for,
   the fail timers, the flags and items, and a log of every action and server answer.
   *Restart mission* / *Replay scene* with *from* set starts at that step or entry.
   With a campaign, `/dev?ext=<id>&episode=<n>&debug` starts it at episode n (0 the first) and
   `/dev?ext=<id>&continue&debug` goes on from its save.
5. Get out of the car (E) to go in. Doors only open on foot.

If the building shows as orphaned, `at` isn't the centroid or the id is wrong: recompute it from
the outline.

## Hosting and payouts

- Host the folder on any **https** URL whose server sends the right content types
  (`application/json` for `.json`). GitHub Pages works. Raw GitHub file links send `text/plain`
  and are refused. Redirects are refused, and only public addresses are fetched.
- In the workbench, *Add an external extension* with the manifest's URL. Each player is asked to
  allow it first, with its permissions listed.
- The server pins every run to the exact files it fetched (a sha256), checks each step in order
  and the minimum time, and pays a run once. Nothing the client says is trusted.
- An extension from outside the game pays money only once its origin is on the game's allow list,
  at most 3 paid runs per player per day, and capped at €500 per run. It never grants a home or a
  car, and its progress keys are kept under `ext:<id>:`. To get listed: in the game press **Report**,
  choose *Something else* and put the manifest URL in the note.

## Before you hand it over

- [ ] Every file parses as JSON; ids match `[a-z0-9-]{1,40}`; every text has `en`.
- [ ] `at` is the area centroid; door, things and characters lie inside the outline.
- [ ] Every name a file uses exists; `permissions` covers logic, scenes, missions and each reward.
- [ ] Choices have a `default` among their options; the mission can't get stuck (a `no` answer
      fails it, and a `timer` or `leaveArea` ends a stalled one).
- [ ] `minSeconds` is reachable by an honest player; money is at most 500.
- [ ] The user has the exact workbench steps to test it.
