W6 Water and swimming #13

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

Depends on: W1, W3

Add a global sea level in the simulation, with swim movement, stamina and drowning damage in deep water. The level must be able to change during a match, since the tide (M2) drives it.

Acceptance

  • Tests cover entering and leaving the water, stamina drain and drowning.
  • Changing the sea level at runtime updates simulation behaviour immediately.
**Depends on:** W1, W3 Add a global sea level in the simulation, with swim movement, stamina and drowning damage in deep water. The level must be able to change during a match, since the tide (M2) drives it. **Acceptance** - Tests cover entering and leaving the water, stamina drain and drowning. - Changing the sea level at runtime updates simulation behaviour immediately.
claude added this to the v0.2 Movement and Island milestone 2026-11-09 05:26:07 +00:00
claude added the priority/hightype/feature labels 2026-11-09 05:26:07 +00:00
claude added this to the Tidewall v1.0 project 2026-11-09 15:00:04 +00:00
eric referenced this issue from a commit 2026-11-11 17:24:55 +00:00
eric closed this issue 2026-11-11 17:24:55 +00:00
Author
Owner

Done in be987b6.

What changed

  • Simulation.sea_level with set_sea_level(). Movement and water read it every tick, so a change takes effect on the next step. drown_dps is on the simulation too, ready for the tide phases (M2). Both are in state_hash().
  • Movement.step(..., sea_level):
    • In water deeper than WADE_DEPTH you wade at WADE_SPEED, with no sprint.
    • In water SWIM_DEPTH (1.35 m) deep you swim, floating with your feet SWIM_FLOAT_DEPTH under and your head out. Sprint swims faster while stamina lasts, crouch dives, and swimmers rest on the sea floor rather than sinking through it.
    • Jump kicks you out of the water if you're at the surface with stamina left. You stand again where the water is under SWIM_EXIT_DEPTH; the gap between the two depths stops flicker.
    • Falling into deep water catches you with no fall damage.
  • Water (src/sim/water.gd) counts breath, stamina and drowning in whole ticks, so they hash and replay exactly:
    • Swimming spends stamina, three times as fast when sprinting, and it comes back out of the water.
    • With no stamina you slip under at SWIM_EXHAUSTED_DEPTH.
    • Underwater, breath runs down over BREATH_SECONDS. After that the phase's drown_dps lands once a second until you surface or die.
  • New tuning lives in the Water block of tuning.gd, and the GDD's tide section describes it.
  • WaterView draws the sea at the simulation's level with a procedural shader: colour from water thickness via the depth buffer, foam at the waterline, and ripples that fade with distance.

Tests (make check: 142 passed, plus self-check and smoke, p95 tick 0.56 ms with 24 bots)

  • test_water.gd:
    • Wading speed, and that ankle-deep water doesn't slow anyone.
    • Walking down a beach into the sea, swimming starts exactly where the water is SWIM_DEPTH deep. Float height and swim speed are checked, then the swimmer walks back out and stands on the sand.
    • Stamina drain when paddling and when sprinting, exhaustion leading to going under, breath running out, drown damage once a second, and death.
    • Diving costs breath and surfacing restores it. Divers don't sink through the floor.
    • A 40 m fall into the sea does no damage, while the same fall onto land does.
    • Jumping out and falling back in, and no jump with no stamina.
    • Raising the sea over a standing player makes them swim on the next tick. Lowering it to wading depth slows them, and dropping it restores walking speed.
    • Determinism and hashing of breath and sea level.
  • test_water_view.gd: the surface follows the simulation's level.
  • Captures I looked at: water_shore (dock, foam line, clear shallows), water_flood (sea at 18 m, the forest half drowned) and props_beach.

Notes: the sea is one global level, as this issue asks. Water flowing along the terrain, and low ground cut off from the sea staying dry, come with breakwaters in v0.3. Climbing from the water onto a pier deck isn't possible yet: jumping from a float reaches about 1.4 m. Ladders or a climb-out are a follow-up for the building and POI work.

Done in be987b6. **What changed** - `Simulation.sea_level` with `set_sea_level()`. Movement and water read it every tick, so a change takes effect on the next step. `drown_dps` is on the simulation too, ready for the tide phases (M2). Both are in `state_hash()`. - `Movement.step(..., sea_level)`: - In water deeper than `WADE_DEPTH` you wade at `WADE_SPEED`, with no sprint. - In water `SWIM_DEPTH` (1.35 m) deep you swim, floating with your feet `SWIM_FLOAT_DEPTH` under and your head out. Sprint swims faster while stamina lasts, crouch dives, and swimmers rest on the sea floor rather than sinking through it. - Jump kicks you out of the water if you're at the surface with stamina left. You stand again where the water is under `SWIM_EXIT_DEPTH`; the gap between the two depths stops flicker. - Falling into deep water catches you with no fall damage. - `Water` (`src/sim/water.gd`) counts breath, stamina and drowning in whole ticks, so they hash and replay exactly: - Swimming spends stamina, three times as fast when sprinting, and it comes back out of the water. - With no stamina you slip under at `SWIM_EXHAUSTED_DEPTH`. - Underwater, breath runs down over `BREATH_SECONDS`. After that the phase's `drown_dps` lands once a second until you surface or die. - New tuning lives in the Water block of `tuning.gd`, and the GDD's tide section describes it. - `WaterView` draws the sea at the simulation's level with a procedural shader: colour from water thickness via the depth buffer, foam at the waterline, and ripples that fade with distance. **Tests** (`make check`: 142 passed, plus self-check and smoke, p95 tick 0.56 ms with 24 bots) - `test_water.gd`: - Wading speed, and that ankle-deep water doesn't slow anyone. - Walking down a beach into the sea, swimming starts exactly where the water is `SWIM_DEPTH` deep. Float height and swim speed are checked, then the swimmer walks back out and stands on the sand. - Stamina drain when paddling and when sprinting, exhaustion leading to going under, breath running out, drown damage once a second, and death. - Diving costs breath and surfacing restores it. Divers don't sink through the floor. - A 40 m fall into the sea does no damage, while the same fall onto land does. - Jumping out and falling back in, and no jump with no stamina. - Raising the sea over a standing player makes them swim on the next tick. Lowering it to wading depth slows them, and dropping it restores walking speed. - Determinism and hashing of breath and sea level. - `test_water_view.gd`: the surface follows the simulation's level. - Captures I looked at: `water_shore` (dock, foam line, clear shallows), `water_flood` (sea at 18 m, the forest half drowned) and `props_beach`. **Notes:** the sea is one global level, as this issue asks. Water flowing along the terrain, and low ground cut off from the sea staying dry, come with breakwaters in v0.3. Climbing from the water onto a pier deck isn't possible yet: jumping from a float reaches about 1.4 m. Ladders or a climb-out are a follow-up for the building and POI work.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: claude/tidewall#13