AutoRunnerWeapons
The player car's guns, missiles, oil and smoke.
What it does
Hold Space and the machine guns fire. Press E for one missile, with a short cooldown between them. Hold Q and an oil slick lands behind the car every dropEvery seconds; R does the same with smoke.
Guns never run out. Missiles, oil and smoke do, and come back from the weapons truck through autoRunnerWeapons.grant. A key pressed for an empty weapon sends autoRunnerWeapons.empty, so a HUD can flash it.
Use it in a scene
A scene is just data — a list of entities, each with its components. At startup the SceneLoader turns this JSON into a live world; edit the file and reload to rebuild it.
Build it from scratch with the bjs CLI:
- 1Scaffold a project
World, renderer, and dev server — ready to run.
- 2Install dependencies
- 3Add AutoRunnerWeapons
Copies its source into src/ so the scene resolves.
First time? Run bjs login once.
- 4Paste the scene into src/scenes/arcade-room.ts and run
SceneLoader builds the world from the JSON; reload to rebuild.
Put it on a car with CarDrive and MeshPrimitive. The scene needs pools named bullet, missile, oil and smoke, or set the pool names. It is the missile blueprint's own seekTag that makes it hunt the bomber; this part only fires it.
Gun levels
Each trigger pull fires every muzzle at once, so a level's punch is barrels times rate times damage. With the default gunRate and bulletDamage:
At level 1 the System swaps its one barrel left and right each shot, so it sounds like a twin mount. At level 3 the outer two barrels fan out by about 2 degrees.
Rounds keep the car's speed
Every round starts with the car's own speed added to its launch speed:
This matters most for the slow rounds. A missile fired at the default 45 m/s from a car doing 52 m/s would start out slower than the car that fired it. With the car's speed added, it leaves at 97 m/s and pulls ahead. Oil and smoke do not move: each one lands dropBack metres behind the car, facing the way the car faces.
Settings
| Field | Default | What it does |
|---|---|---|
gunLevel | 1 | Starting gun level |
missiles | 0 | Starting missiles |
oil | 0 | Starting oil slicks |
smoke | 0 | Starting smoke clouds |
maxGunLevel | 3 | Highest gun level a grant can reach |
maxMissiles | 6 | Most missiles the car can hold |
maxOil | 10 | Most slicks the car can hold |
maxSmoke | 10 | Most clouds the car can hold |
gunRate | 9 | Trigger pulls per second at level 1 |
bulletSpeed | 150 | Round speed, m/s, on top of the car's |
bulletDamage | 7 | Damage per round |
muzzleForward | 2.4 | How far ahead of the car's centre the guns sit, metres |
muzzleSide | 0.55 | How far out to each side the barrels sit, metres |
missileSpeed | 45 | Missile launch speed, m/s, on top of the car's. It speeds up from there. |
missileDamage | 120 | Damage per missile |
missileCooldown | 0.6 | Seconds between missiles |
dropEvery | 0.28 | Seconds between slicks or clouds while the key is held |
dropBack | 3.2 | How far behind the car oil and smoke land, metres |
bulletPool | "bullet" | Pool the rounds come from |
missilePool | "missile" | Pool the missiles come from |
oilPool | "oil" | Pool the slicks come from |
smokePool | "smoke" | Pool the clouds come from |
fireKeys | ["Space", "KeyJ"] | Keys that fire the guns (KeyboardEvent.code) |
missileKeys | ["KeyE", "KeyK"] | Keys that fire a missile |
oilKeys | ["KeyQ", "KeyL"] | Keys that drop oil. Oil wins if oil and smoke are both held. |
smokeKeys | ["KeyR", "KeyI"] | Keys that drop smoke |
Events
| Event | Payload | Direction |
|---|---|---|
autoRunnerWeapons.fired | { entityId, weapon, x, z }, plus seek: "air" for a missile | emits |
autoRunnerWeapons.changed | { entityId, gunLevel, missiles, oil, smoke, maxGunLevel, maxMissiles, maxOil, maxSmoke } | emits, when the loadout moves |
autoRunnerWeapons.empty | { entityId, weapon } | emits |
autoRunnerWeapons.grant | { entityId, weapon, amount }, weapon is missiles, oil, smoke or guns | listens |
autoRunnerWeapons.enabled.set | { entityId, enabled } | listens: holds fire while dead, docked or paused |
autoRunnerWeapons.reset | { entityId } | listens: back to the starting loadout |
keyboard.keydown | { code } | listens |
keyboard.keyup | { code } | listens |
A grant is capped at the max, so a full tank takes nothing. For guns, amount is levels.
Needs
- CarDrive supplies heading and speed.
- MeshPrimitive supplies position.
- AutoRunnerProjectile supplies the bullet and missile pools through
launchProjectile. - RoadHazard supplies the oil and smoke pools through
dropHazard. - KeyboardInput turns DOM keys into
keyboard.keydownandkeyboard.keyupon the bus, which is how the trigger keys arrive.
























































