five-on-it / packages/ai/src/chaos
packages/ai/src/chaos
The city's big events (GAME_DESIGN §12, "Escape kit & chaos"), run by the server before the step, after the police (chaosSystem). Each is set off by the game's rules (rules.chaos), a mission's do (chaos), or a debug command, and runs on the AI's own clock and order, hashed with the rest (chaosHashFields).
- Make it rain (R32): Cash thrown into the street (
@foi/sim'sescape.ts, arainevent) draws every pedestrian within GRAB.reach: each runs for the nearest bundle nobody else makes for and takes it (grabSystem, the crowd'sgrabgoal, written over the pedestrian's own input). The cars after the thrower give way to the crowd as the traffic gives way to people. - Riot (E1, startRiot): about RIOT
.countpedestrians (those near, then new ones while the crowd's budget allows) gather at a place and mill there, fists up, for RIOT.seconds. The police answer after RIOT.respondSecondswith a shield wall (officers with ballistic shields,@foi/sim'sshields.ts, in a line facing the crowd) and a water cannon spraying it in bursts (jets.ts), as many as the room's cap on police actors allows (police.ts'policeActorscounts them). - Blending in (blendsIn): a wanted player on foot within BLEND
.nearof BLEND.crowdpedestrians or more is picked out by the police only after twice an officer's reaction (BLEND.ticks):police.ts' sight, the one helper every sighting goes through, holds the sighting back until then. - A raised bridge (E2): a wanted driver of at least a leaf's
starscoming at a bascule bridge fast has its leaves raised (@foi/sim'sbascules.ts) to cut them off; a car fast enough jumps the gap. - Blackout (E3) is the simulation's (a substation shot or blasted down,
devices.ts); the AI's part is in the cameras' and the drones' sight (police-cameras.ts,police-drones.ts: the traffic cameras dark, the drones on thermal). - Hacked billboards (E4): from BILLBOARD
.stars, the billboards (a level's pieces named so) within BILLBOARD.reachof a wanted player show their face (the clients swap the picture), and a pedestrian within BILLBOARD.recogniseof a billboard showing it who sees the player reports them (ChaosHooks.report, the witness's call by default; the Smart City's citizen app takes it over). The counter is a disguise (ChaosHooks.disguised, which the Smart City's disguise answers).