five-on-it / packages/ai/src/swat-brain
packages/ai/src/swat-brain
The brain of the police's specialists of six stars (police-swat.ts' SwatMember): a SWAT team's four, its van's driver, a K9 handler, a negotiator. The police system gives them their orders every tick (where to stand, which way to face, whether to shoot, what to throw); this carries them out, writing an ordinary input as every NPC does.
- In the van, a member waits for its turn and gets out at it (
exitAt), once the van is at a crawl. - On foot it walks to its spot (the path over the layered navigation,
steer-foot.ts, round what its rays find, with the stuck recovery), faces the player when it sees them and its order's way when not, shoots at them in sight within its reach when told to (its profile's gun,profiles.ts'SWAT_PROFILES), and throws what it is told to: the pin pulled until it is out, then let go where it aims, as far as told. The shield turns slowly (SHIELD_TURN): its slab is heavy, so a quick player gets round it. - The driver drives as a chaser does (
chaser.ts, to the van's stop, slowing for it), holds the van there on the handbrake once its doors are open, drives it off when the team is gone, and works the van's sonic cannon (@foi/sim'ssonic.ts): once its team is out, the van still, the player on foot within the cannon's reach, in the open, not hidden, and no officer in its cone, it pulls the trigger and follows the player with it while it winds up.
Down, it does nothing; dead, it is removed once its fall is over. Deterministic: it draws from the AI's own stream only for the aim's jitter (chaser.ts' trigger).