Public: anyone can read this; the crew can change it.
forked from trevato/cs
You can tell where the shot came from: a directional damage indicator and a pain flash #271
Check · Review · Land · Live done — Landed and live in production.
Taking a hit now says where it came from. `src/client/world.ts` records a `hurt` effect at the moment damage lands — the shooter's feet, or the centre of the blast, copied so it is where the shot came from and not where the shooter has run to since — in the same capped ring the hit markers already live in, and only for `world.me`, which is the mirror of how a hit marker is only recorded for shots…
shipped production is serving it deploy ae07c2d
Sign in to join this conversation.
new above
offline
Taking a hit now says where it came from.
src/client/world.tsrecords ahurteffect at the moment damage lands — the shooter's feet, or the centre of the blast, copied so it is where the shot came from and not where the shooter has run to since — in the same capped ring the hit markers already live in, and only forworld.me, which is the mirror of how a hit marker is only recorded for shots you land.src/client/hud.tsreads it back twice. A red arc is stroked on a ring 28% of the shorter side out from the middle, at the bearing to the attacker relative to where you are facing now, fading linearly overHURT_LIFE= 1.25 s, one per live hit — so two people shooting you from two sides is two arcs. And a red wash says how hard:0.3 · min(1, damage/50), gonePAIN_LIFE= 0.25 s later. That is 0.16 of red for an AK round through armour at 500 units, the full 0.3 for an AWP body shot, and it is over before your next shot on any gun in the game (an M4 fires every 0.09 s). The wash is drawn under the crosshair — the crosshair goes on after it at its own colour, so the shot you take back is aimed at exactly what it was aimed at before — while the arcs go on over the white-out and the smoke fog, for the same reason your health does: being blinded is when knowing which way to turn is worth most. Argue with the numbers in the block comment aboveHURT_LIFE; they are all named constants.Worth looking at: the bearing arithmetic is
hurtAngle, four lines, and the tests drive it through the HUD recorder — shot in the back puts the arc at the bottom, shot from your left puts it left, turning ninety degrees walks it exactly ninety degrees round the ring, it is gone at the end of its life, and a spectator watching a teammate gets neither the wash nor the arc.world.test.tspins the recording side: the position is the shooter's at the tick it fired and is a copy, a bot's damage records nothing, and a grenade's hit comes from the blast rather than from the thrower.What I did not do: no sound for being hit (the audio device has
hitfor markers only, and a pain sound is its own decision), and nothing for the bomb's timeout kill, which has no direction to point at.The golden digests did not move, and should not have: effects are presentation and are not in
replay.ts'ssnapshot, so every pinned run is the digest it was —bun run testis 1200 pass / 0 fail. The ceiling insrc/games.tsis held, not moved:static/appis 101,218 raw / 39,880 gzipped against 103,000 / 41,000, up 978 / 350 frommain.🤖 Generated with Claude Code
Closes #137