A shot hits a player where the shooter saw it #33

Merged
agra merged 5 commits from task/3996-a-shot-hits-a-player-where-the-shooter-s into master 2026-10-31 15:51:00 +02:00
Owner

Tracker: #3996

Lag-compensated shots, step 5 of the multiplayer netcode plan (#3571).

  • With the pointer locked, a left click fires a shot from the eye along the look, at the crosshair the HUD draws at the centre of the view. The click that locks the pointer fires nothing, and neither does a right click.
  • The shot goes with the next tick's command, which carries its view time: the render time of the frame the client drew before making that command.
  • The server keeps each living player's capsule after every tick for the last second. A shot rewinds every other living player to its view time, between the kept ticks either side as the client interpolates them, at most 0.5 s back. It hits the nearest of those capsules, the map and the bodies where they lie now, within 600 m. A player dead now takes no hit where it stood alive.
  • A hit costs 20 health, so 5 kill, and the existing death and respawn follow.
  • Each snapshot names what the receiver's shots hit (a player, a body, the map or nothing), until the client acknowledges a snapshot that carried it, so a lost snapshot loses no answer.
  • Wire format: a command carries an optional f64 view time, and the decoder refuses one that is NaN as malformed. MAX_COMMANDS is 42, the number that fit one datagram when each fires a shot. PROTOCOL_VERSION is 5.
  • The README says how a shot fires, what it costs, and how the server rewinds the players.

Tests:

  • tests/sim_lagged_shots.sx: at 150 ms round trip with jitter and 2% loss, a shooter fires at a target strafing across its view, aimed where its client draws it. The server's answer names the target. The same ray against the target where the server has it as the shot fires misses. Five hits kill, and the respawn follows.
  • tests/sim_rewind.sx: interpolation between kept ticks, the 0.5 s limit, a wall and a body in front of the rewound target taking the hit, and five hits killing.
  • tests/net_messages.sx, tests/net_deltas.sx, tests/sim_client.sx and tests/walk_sdl_events.sx: the wire format and the NaN refusal, answers repeating until acknowledged, the view time, and the clicks.

To check in the app: under --lag 150, shoot a bot walking past. It dies in 5 hits where it was drawn.

Tracker: [#3996](https://sak.swipelab.com/tasks/3996) Lag-compensated shots, step 5 of the multiplayer netcode plan (#3571). - With the pointer locked, a left click fires a shot from the eye along the look, at the crosshair the HUD draws at the centre of the view. The click that locks the pointer fires nothing, and neither does a right click. - The shot goes with the next tick's command, which carries its view time: the render time of the frame the client drew before making that command. - The server keeps each living player's capsule after every tick for the last second. A shot rewinds every other living player to its view time, between the kept ticks either side as the client interpolates them, at most 0.5 s back. It hits the nearest of those capsules, the map and the bodies where they lie now, within 600 m. A player dead now takes no hit where it stood alive. - A hit costs 20 health, so 5 kill, and the existing death and respawn follow. - Each snapshot names what the receiver's shots hit (a player, a body, the map or nothing), until the client acknowledges a snapshot that carried it, so a lost snapshot loses no answer. - Wire format: a command carries an optional f64 view time, and the decoder refuses one that is NaN as malformed. MAX_COMMANDS is 42, the number that fit one datagram when each fires a shot. PROTOCOL_VERSION is 5. - The README says how a shot fires, what it costs, and how the server rewinds the players. Tests: - `tests/sim_lagged_shots.sx`: at 150 ms round trip with jitter and 2% loss, a shooter fires at a target strafing across its view, aimed where its client draws it. The server's answer names the target. The same ray against the target where the server has it as the shot fires misses. Five hits kill, and the respawn follows. - `tests/sim_rewind.sx`: interpolation between kept ticks, the 0.5 s limit, a wall and a body in front of the rewound target taking the hit, and five hits killing. - `tests/net_messages.sx`, `tests/net_deltas.sx`, `tests/sim_client.sx` and `tests/walk_sdl_events.sx`: the wire format and the NaN refusal, answers repeating until acknowledged, the view time, and the clicks. To check in the app: under `--lag 150`, shoot a bot walking past. It dies in 5 hits where it was drawn.
agra merged commit 2f73abb9d4 into master 2026-10-31 15:51:00 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sx/hulken!33
No description provided.