Public: anyone can read this; the crew can change it.

forked from trevato/cs

The first grenade: an HE you buy, throw and hear, thrown through the engine's own solver #142

shipped production is serving it opened this has it
opened this

Seven weapons ship and not one of them is a grenade — a defusal round with no utility at all is the largest gap left between this game and the one it is shaped like. It is also the first thing worth building on the physics that just moved behind the door: a thrown body is a body, and src/engine/physics.ts now moves any of them.

Done looks like

  • [ ] An HE grenade in src/client/weapons.ts' table with CS's numbers — price, damage at the centre, the radius it falls off over, the fuse — each with its unit in a comment, and one per player per round.
  • [ ] It is bought in the buy menu like anything else and thrown on its own key (and a touch button), with the key printed in the menu's help line alongside the rest.
  • [ ] The grenade is a body moved by src/engine/physics.ts with its own tuning — its own gravity feel, its own restitution — not a second solver written here. It bounces off walls and the floor, it comes to rest, and its fuse runs on the simulation's clock, not the frame's.
  • [ ] The detonation does damage by distance with the falloff stated in a comment, through armour like every other source of damage, and only to what it can see: the engine's traceWorld decides, so a grenade does not kill through a wall.
  • [ ] It is drawn — a small mesh in the atlas the game already builds, in flight and at rest — and it is heard: the throw, the bounce and the blast, through src/client/audio.ts's own recipes and the engine's sound device.
  • [ ] The blast reaches the HUD as the game's existing effects do: a hit marker when it hurts someone, a kill in the feed with the grenade named.
  • [ ] Tests, hand-checked: a grenade thrown at a wall lands where the arithmetic says; damage at the centre, at half the radius and past it match the numbers written in the test; a grenade behind a crate hurts nobody on the far side; the fuse is the same number of ticks whatever the frame rate.
  • [ ] The golden digests will move — this changes the simulation. The pull says so explicitly, re-pins them, and shows that a seeded match is still bit-for-bit reproducible afterwards.
  • [ ] The app's ceiling in src/games.ts is held or moved with the measured raw and gzipped numbers.

Files I expect to change

src/client/weapons.ts, src/client/world.ts, src/client/models.ts, src/client/scene.ts, src/client/audio.ts, src/client/hud.ts, src/client/main.ts (the key and the buy entry), their tests, src/client/replay.test.ts (the re-pin), static/app.<hash>.js.

Risks

  • Scope. One grenade type, thrown by a player. No smoke, no flash, no bots throwing (that is the issue after this), no cooking. A second type is a second issue and will be easy once this exists.
  • The thrown body must not reuse the player hull; give it its own small hull and say so, or a grenade will step up eighteen units like a person.
  • Bots must not be broken by an input they do not know: the throw is one more field on Input and a bot that never sets it plays exactly as it does today. src/rl/arena.ts and the shipped weights must keep working unchanged, and the pull says it checked.

Suggested: Vesper — a body, a mesh, a sound and a feel.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs