Data-driven hitscan and projectile weapons with fire rate, spread, recoil, magazine and reload, and a health-and-shield damage model with headshots.
Acceptance
Weapon stats are resources, and adding a weapon needs no new code.
Tests cover fire-rate limits, damage falloff, headshots, shields and reloads.
Shots hit terrain, players and structures correctly.
**Depends on:** B5, W1
Data-driven hitscan and projectile weapons with fire rate, spread, recoil, magazine and reload, and a health-and-shield damage model with headshots.
**Acceptance**
- Weapon stats are resources, and adding a weapon needs no new code.
- Tests cover fire-rate limits, damage falloff, headshots, shields and reloads.
- Shots hit terrain, players and structures correctly.
claude
added this to the v0.3 Building and Combat milestone 2026-11-09 05:27:01 +00:00
Weapons: server-side fire at the weapon's fire rate from the loaded magazine. Reload on R or on an empty trigger pull, taking the weapon's reload time; a slot change cancels it.
Spread: pellets are scattered evenly inside a cone from the seeded weapons stream. The cone is hip spread (times AIM_SPREAD_FACTOR or the weapon's own aim_spread when aiming), plus bloom, plus a moving or airborne penalty. Bloom is the server's side of recoil: it builds in sustained fire and clears in a pause. Camera kick is presentation and comes with the client.
Hitscan traces in 16 m segments so long shots stop early. Projectile weapons (projectile_speed > 0: the whaler's longgun and the line thrower) fly as ARCHETYPE_PROJECTILE entities under gravity and trace each tick.
Traces stop at terrain, solids (built pieces and props take the damage) or another player's body box. Damage goes to armor, then health. The top HEAD_HEIGHT of the body takes the weapon's headshot multiplier, and falloff is linear between range_full and range_max.
New stats in Tuning.WEAPONS: spread, bloom, headshot, ammo, and the projectile fields. All are read through ItemDef, so a new weapon needs no code.
Tests:test/sim/test_weapons.gd (22 tests): fire-rate limit, magazine and reload, reload time, no reload without ammo, swap cancels reload, body shot, headshot, falloff curve and a real far hit, armor, lethal hit credits the shooter, a terrain ridge blocks, a built wall blocks and takes damage, no self-hits, spread and bloom, scatter stays in the cone, all fowling-piece pellets, a projectile that drops and hits, a projectile that expires, determinism, and swimmers can't fire. make check passes: 233 tests, self-check and smoke (p95 tick 0.60 ms with 24 bots).
Follow-ups: tier multipliers and the line thrower's pull come with B7, and thrown kegs with B8. Lag compensation is N4. Firing currently traces from the eye, not the third-person camera; N4 or the client work should reconcile camera aim with the eye ray.
— tidewall-build
Done in ed46b6e.
**What changed**
- `Weapons`: server-side fire at the weapon's fire rate from the loaded magazine. Reload on R or on an empty trigger pull, taking the weapon's reload time; a slot change cancels it.
- Spread: pellets are scattered evenly inside a cone from the seeded `weapons` stream. The cone is hip spread (times `AIM_SPREAD_FACTOR` or the weapon's own `aim_spread` when aiming), plus bloom, plus a moving or airborne penalty. Bloom is the server's side of recoil: it builds in sustained fire and clears in a pause. Camera kick is presentation and comes with the client.
- Hitscan traces in 16 m segments so long shots stop early. Projectile weapons (`projectile_speed` > 0: the whaler's longgun and the line thrower) fly as `ARCHETYPE_PROJECTILE` entities under gravity and trace each tick.
- Traces stop at terrain, solids (built pieces and props take the damage) or another player's body box. Damage goes to armor, then health. The top `HEAD_HEIGHT` of the body takes the weapon's `headshot` multiplier, and falloff is linear between `range_full` and `range_max`.
- New stats in `Tuning.WEAPONS`: `spread`, `bloom`, `headshot`, `ammo`, and the projectile fields. All are read through `ItemDef`, so a new weapon needs no code.
**Tests:** `test/sim/test_weapons.gd` (22 tests): fire-rate limit, magazine and reload, reload time, no reload without ammo, swap cancels reload, body shot, headshot, falloff curve and a real far hit, armor, lethal hit credits the shooter, a terrain ridge blocks, a built wall blocks and takes damage, no self-hits, spread and bloom, scatter stays in the cone, all fowling-piece pellets, a projectile that drops and hits, a projectile that expires, determinism, and swimmers can't fire. `make check` passes: 233 tests, self-check and smoke (p95 tick 0.60 ms with 24 bots).
**Follow-ups:** tier multipliers and the line thrower's pull come with B7, and thrown kegs with B8. Lag compensation is N4. Firing currently traces from the eye, not the third-person camera; N4 or the client work should reconcile camera aim with the eye ray.
— tidewall-build
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Depends on: B5, W1
Data-driven hitscan and projectile weapons with fire rate, spread, recoil, magazine and reload, and a health-and-shield damage model with headshots.
Acceptance
Done in
ed46b6e.What changed
Weapons: server-side fire at the weapon's fire rate from the loaded magazine. Reload on R or on an empty trigger pull, taking the weapon's reload time; a slot change cancels it.weaponsstream. The cone is hip spread (timesAIM_SPREAD_FACTORor the weapon's ownaim_spreadwhen aiming), plus bloom, plus a moving or airborne penalty. Bloom is the server's side of recoil: it builds in sustained fire and clears in a pause. Camera kick is presentation and comes with the client.projectile_speed> 0: the whaler's longgun and the line thrower) fly asARCHETYPE_PROJECTILEentities under gravity and trace each tick.HEAD_HEIGHTof the body takes the weapon'sheadshotmultiplier, and falloff is linear betweenrange_fullandrange_max.Tuning.WEAPONS:spread,bloom,headshot,ammo, and the projectile fields. All are read throughItemDef, so a new weapon needs no code.Tests:
test/sim/test_weapons.gd(22 tests): fire-rate limit, magazine and reload, reload time, no reload without ammo, swap cancels reload, body shot, headshot, falloff curve and a real far hit, armor, lethal hit credits the shooter, a terrain ridge blocks, a built wall blocks and takes damage, no self-hits, spread and bloom, scatter stays in the cone, all fowling-piece pellets, a projectile that drops and hits, a projectile that expires, determinism, and swimmers can't fire.make checkpasses: 233 tests, self-check and smoke (p95 tick 0.60 ms with 24 bots).Follow-ups: tier multipliers and the line thrower's pull come with B7, and thrown kegs with B8. Lag compensation is N4. Firing currently traces from the eye, not the third-person camera; N4 or the client work should reconcile camera aim with the eye ray.
— tidewall-build