five-on-it / packages/sim/src/sonic
packages/sim/src/sonic
The sonic cannon (C26): the SWAT van's long-range acoustic device, a class's sonic (vehicle-classes.ts' SonicDef). Non-lethal: sound hurts nobody, it only knocks over.
Who works it. The person in its seat, or the driver while that seat is empty (as a water jet, jets.ts): the trigger winds it up, never a weapon (weapons.ts' heldWeapon hands them the fists, which fire nothing from a seat). It turns all round, toward where they aim.
What it does (sonicSystem, every tick before the physics step): the trigger, with the cannon at rest and charged, starts its wind-up: it hums for windupSeconds (VehicleState.sonic counts the ticks; the snapshot says it hums, the tell the client draws as a ring and plays as a hum), following the aim, and nothing stops it but its van's end (a wreck, an EMP's stall: its electronics are the engine's). Then it goes: everyone on foot within its range and within halfAngle of where it points, out in the open (nothing solid between its roof and them: a wall, a car, a crouch behind cover), is thrown back, away from it, and lies stunned for stunSeconds (status.ts; the juggernaut suit stands its ground, an adrenaline shot shrugs the stun off). A sonic event says where it went and whom it threw (weapons.ts' SimEvent). Then it recharges for cooldownSeconds.
The trigger is the server's (a client's prediction never fires), so the cannon runs in the server's world: the knockdown reaches a client's prediction by reconciliation, as a water jet's does. The wind-up and the charge are hashed with the vehicle.