Split The code is public; the app answers only to the crew.

Getting shot tells you: a directional damage indicator, a hurt vignette and a pain sound #10

shipped merged opened this has it
opened this

Close the other half of hit feedback — right now you can hit a bot and see it, but being hit yourself is silent and invisible.

shoot in src/client/world.ts pushes a hitmark effect only when the shooter is world.me, and applyHit in src/client/combat.ts changes numbers and nothing else. The victim gets no sound, no flinch and no hint of direction: the health number in the corner drops and that is the whole story. On de_forge, where the shot usually comes from a corridor you are not looking at, this is the single biggest reason a round feels unfair. The bomb detonation in update kills people with the same silence.

The simulation is the tested part, so the event belongs there: add a hurt effect to the Effect union carrying at, the victim, the world position the damage came from and the amount, push it from shoot and from the bomb_timeout branch, and let hud.ts and audio.ts read it. The effects list is already trimmed to two seconds in update, so the indicator's lifetime has to fit inside that or the trim window has to move — say which you chose.

Done looks like

  • [ ] world.ts emits a hurt effect for every point of damage a player takes, from bullets and from the bomb, with the source position and the amount.
  • [ ] The victim flinches: a small view punch proportional to the damage, decaying the way punch already does, so a burst to the chest is felt and does not make the player uncontrollable.
  • [ ] hud.ts draws a directional wedge around the crosshair pointing at where the damage came from, in the yaw frame of the player being drawn, fading over about a second and stacking when several hits land.
  • [ ] A red vignette whose strength follows how low health is, drawn once and cheap — no per-frame allocation in drawHud.
  • [ ] audio.ts plays a short pain tone on taking damage, distinct from the hit beep the shooter hears, and it does not stack into noise when a full rifle burst lands.
  • [ ] Nothing is emitted or drawn for damage to a bot; the HUD only ever reads the player it is drawing.
  • [ ] bun test covers the headless half: a bullet that hits the player pushes exactly one hurt with the shooter's position and the damage actually dealt, a bullet that hits a wall pushes none, and the bomb going off hurts everyone inside the radius.
  • [ ] bun run scripts/build.ts run and the rebuilt bundle committed.

Files I expect to change

src/client/world.ts, src/client/world.test.ts, src/client/hud.ts, src/client/audio.ts, src/client/main.ts (playing the new sound alongside playSounds), static/app.<hash>.js, and a line in the README's "What is real" list.

Risks

The bots observe the world through src/client/observe.ts and the arena in src/rl/ steps the same update; adding to the Effect union must not change what a bot sees or the shipped policy's numbers stop matching the card on the page. Keep the effect out of observe. A view punch on the victim is a real change to the fight, so keep it small and make sure bun test in src/rl/arena.test.ts still passes.

Who

A builder comfortable in the simulation and the HUD canvas. Worth doing before the spectator and match-summary work, since both land in the same two files.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs