Skip to content

five-on-it / packages/ai/src/police-swat

packages/ai/src/police-swat ​

SWAT (GAME_DESIGN §12, six stars, "SWAT"; C17–C22): a SWAT van ("Tactical Wellness Response") sent after a wanted player whose stars ask for one (police-ladder.ts), within the room's cap on police actors (police.ts: the van, its driver and its team of four), from the roads around them as a cruiser is. A team (SwatTeam) goes through its phases:

  • driving: the van drives up and stops SWAT.stopMin to .stopMax metres from the player, off the line they face or drive along (stopSpot);
  • deploying: its rear doors open (the radio's megaphone line, megaphone, which the client says and plays with the doors' clang) and the four get out over a second and a half, the K9 unit with them (police-k9.ts);
  • advancing: the team moves on where the player was last seen, in formation: the shield leads (@foi/sim's shields.ts: bullets from the front stop on it), stopping SWAT.standOff short; the rifleman keeps its back; the grenadier and the breacher flank it SWAT.flank metres out. The grenadier throws tear gas at a player hiding in cover, and smoke ahead of the team when the player has a rifle-class gun;
  • stacking, flashing, clearing (breach and clear, C19, C22): a player inside a building (insideBuilding: a roof over them, walls round them) brings the team to the nearest door on its outside; once stacked, the breacher rams it open and throws a flashbang through it (it goes off a second and a half later), and the team goes in on the layered navigation. One breach at a time; given up after SWAT.breachTicks;
  • leaving: the stars dropped below six (or the player is gone): the team walks back to the van and is gone, then the van drives off.

The van's driver stays at its wheel and works its sonic cannon (@foi/sim's sonic.ts; the trigger is written in swat-brain.ts). While the negotiator talks (police-negotiator.ts) the team holds where it stands and neither breaches nor shoots. The members are NPCs with a brain of their own (swat-brain.ts): this module gives them their orders (where to stand, where to face, whether to shoot, what to throw) every tick, and their weapons (their guns once the player used lethal force on the police, their non-lethal tools until then: M7). Deterministic: teams in the order they were sent, members in the van's seat order; the book and the orders are hashed (hashAiState).

Interfaces ​

Type Aliases ​

Variables ​

Functions ​