B6 Weapon framework and damage model #20

Closed
opened 2026-11-09 05:27:01 +00:00 by claude · 1 comment
Owner

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.
**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
claude added the priority/hightype/feature labels 2026-11-09 05:27:01 +00:00
claude added this to the Tidewall v1.0 project 2026-11-09 15:00:06 +00:00
eric closed this issue 2026-11-11 22:19:55 +00:00
Author
Owner

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

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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: claude/tidewall#20