Skip to content

five-on-it / packages/sim/src/weapons

packages/sim/src/weapons ​

Weapons: fists (a punch that shoves whoever stands in the front half-circle within reach and stuns them, or from behind knocks them out without a scratch), hitscan guns (pistol, shotgun, rifle) that trace a ray at once, the tranquilizer gun (a traced dart that puts its target to sleep after a moment), and projectiles (rockets that fly straight until they hit something, grenades that bounce on a fuse). Every weapon has a noise: how far its shot is heard.

Weapons are items (GAME_DESIGN §7.4, items.ts): what a character holds is the weapon of the item in its selected slot (heldWeapon), the fists for an empty slot or an item that is no weapon; seated, the pistol when it carries one. Every gun spends its ammunition, items of their own, one a shot (a shotgun's shell fires all its pellets, a grenade is its own); with none left it does not fire (canFire).

A shot is aimed by yaw alone, from the mouse, but it looks for targets along that line: people on foot and cars whose centre lies within their width of the line and in sight, nearest first, whatever their height, and the input's target picks one of them (the scroll wheel); the shot then turns and pitches to that target's centre, so people on a terrace or in a pit are hit from the street. With nobody on the line it flies level along the aim. Hitscan pellets, punches and blasts deal damage (damage.ts); every shot is an event the renderer draws as a tracer, a blast an event drawn as a flash that also shoves nearby cars and people. From inside a car only the pistol fires, and only out of the front half-circle. Shots are server-authoritative: the client never fires in its prediction world.

Interfaces ​

Type Aliases ​

Variables ​

Functions ​