aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit f4beee688df784f66fbc1be1a652ec5dc91ff253
parent 751c16dcb474b8eca53480bc043750eec62f6ea1
Author: anon <anon@example.com>
Date:   Mon, 26 Oct 2026 10:42:15 +0000

Simulate native outdoor jump and landing transitions

Handle jump admission, raw ability-derived height, ceiling clearance and
the native vertical impulse in the shared movement controller. Physical
landing clears its jump guard while preserving horizontal controls; a
received helper landing message cannot restart the physical jump.

Verify 1,273 server tests, 342 focused race results, data packages and vet.
Paired GPU WASM clients confirm ordinary/repeated/high jumps and
swimming rejection. Record frame/transport comparison bounds, remaining
special lifecycles and the separately recovered action20 yaw scalar.

Diffstat:
MTODO.md | 17++++++++++++++++-
Mdocs/player-geometry.md | 67++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mdocs/player-movement.md | 5+++--
Mserver/player_collision.go | 50++++++++++++++++++++++++++++++++++++++++++--------
Aserver/player_jump_test.go | 216+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/player_movement.go | 16+++++++++++++---
6 files changed, 354 insertions(+), 17 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -1242,11 +1242,26 @@ disconnect retention and succession policy still need period corroboration. template heights and in-memory movement without per-tick database writes. - [ ] Complete the outdoor collision/lifecycle matrix. Test stairs, wall sliding, corners, narrow passages, release/reversal, followers and blocked interaction - ranges across multiple forms/scales. Finish jump/landing/fall-damage callbacks, + ranges across multiple forms/scales. Finish fall-damage rules and special-mode + jump/landing behavior, late observers during ascent, midair reconnect and + roots/snares during a jump. Ordinary jump/landing is implemented below. Finish internal/nonzero orientation modes, live Chest mass and encumbrance, and vehicle and Grid form entry/exit body rebuilding (including current thin/fat mesh on return). Add indoor room transforms, actor colliders and dynamic platforms. See [player geometry](docs/player-geometry.md). +- [x] Simulate ordinary outdoor jumping and physical landing. Movement13 uses raw + Strength/Agility, the native upward ceiling probe and mass/impulse float stores. + Preserve horizontal controls, reject swimming/sitting and repeated airborne + jumps, and clear the physical jump guard on landing. Movement14 only submits + the helper transition; it must not itself clear falling or permit a new impulse. + Tests cover ceiling clearance, scale, raw versus modified abilities, irrelevant + packet scalars, a fresh jump during an ordinary fall and missing-provider + landing. Native owner/observer verification: [player geometry](docs/player-geometry.md). +- [ ] Apply the native action20 yaw-offset scalar when anchoring a movement pose. + Its compact signed-short/2048 field is passed to VehicleForwardUpdate, which + composes a Y-axis quaternion with the supplied orientation. It is unrelated to + jump height and is currently ignored by the server; verify nonzero values and + normal zero-offset motion against the native client. - [x] Audit compact actor-spawn Run Speed. Send trained stat 156 as an unsigned byte through 255 or a flagged short above it, preserving following materials. Two GPU WASM clients verified training across 255, separate equipment/nano diff --git a/docs/player-geometry.md b/docs/player-geometry.md @@ -192,8 +192,8 @@ position without Halting cached horizontal velocity. Ground projection yields actorY=hitY+0.01-offsetY+radius. Long-displacement segment checks, contact retries, steep slopes, falling and deep water have additional branches. Gravity is -20 with independent vertical-speed clamp +/-50. The outdoor simulation now applies -these rules; jump, landing actions and fall damage still need their full -callbacks and combined lifecycle coverage. +these rules. Ordinary jump and landing actions are connected below; fall damage +and the combined special-mode lifecycle remain open. ## Outdoor collision query provider @@ -268,11 +268,49 @@ owner and server; input delivery and frame cadence remain comparison bounds. This verifies the formula and replicated limits, not exact swimming trajectories. Remaining work includes shoreline/shallow-water and smoothing cadence, stairs, -corners, narrow passages, blocked interactions, jump/landing/fall damage, +corners, narrow passages, blocked interactions, special jump modes and fall damage, internal and nonzero orientation modes, live carried mass/encumbrance and full vehicle/Grid/body-replacement lifecycles. Indoor room transforms, dynamic platforms and actor colliders also remain separate work. +## Ordinary outdoor jumps and landing + +Movement action13 follows the native helper admission and secondary-state rules. +Swimming4 and sitting8 reject it. An accepted jump sets secondary4 and keeps +the longitudinal, lateral and angular controls. As with other accepted actions, +the helper snapshot copies its previous lateral-state field from the old lateral +state. Repeating jump while secondary4 normally rejects; the separate physical +jump-height guard also prevents an early helper14 from permitting another impulse. + +The height request is float32(1+.005*(rawStrength16+rawAgility17)), retaining the +native coefficient and stores. It does not use effective ability modifiers, +trickle, Adventuring or the extra movement packet scalar. An upward segment from +the actor to Y+100 checks the shared scene provider without world clipping. A hit +limits the height to max(.1,hitY-actorY-2*visualScale), capped by the original +request. This clearance uses visual scale rather than the torso sphere radius. + +StartJump enables falling and stores a float32 vertical impulse +mass*sqrt(2*abs(gravity)*height), then adds impulse/mass to independent vertical +velocity. The intermediate impulse store is retained instead of cancelling the +mass algebraically. Existing gravity and contact projection produce the arc. +A first jump during an ordinary fall is allowed by this recovered client path; +it adds to the existing vertical velocity. No grounded-only policy is invented. + +Physical landing clears vertical velocity, recalculates horizontal speed and +locally submits helper14, then clears jump height and records the callback's +supplied height before clearing falling. Horizontal velocity and controls remain +active. A received movement14 only changes helper state/presentation; it is not +a physical landing. Missing surface providers still perform the native landing +callback after alignment, while complete indoor jump trajectories await indoor +geometry support. + +The extra compact movement scalar is an action20 yaw offset, not a jump +parameter. Its nonzero application remains a separate TODO. The retained native +standing jump sends one action13 and no action14. Neither OnStartFalling nor +OnLand constructs a packet or calculates fall damage. The original server's +damage threshold, formula and immunities remain unknown; absence of a dedicated +packet in these paths does not establish absence of a generic action elsewhere. + ## Evidence `local/player-geometry-research/` retains runtime captures, the 28.73-metre wall @@ -308,6 +346,10 @@ failure, selected-archive comparisons and source ledgers: and direct placement through surface alignment. - `template-mass/`: 16 complete bodies; player form selection versus NPC template stat application, raw breed/sex mass and the zero-mass fallback. +- `jump-control/`: 51 complete bodies; jump/landing admission and callbacks, + ceiling/impulse math, helper snapshot copying and action20 scalar semantics. +- `fall-notification/`: 51 complete bodies; movement publication/serialization, + local landing, retained outbound packets and bounded fall-damage searches. These counts overlap; they are not unique additional procedures. Source checks establish maintained-code contracts and evidence integrity. Runtime probes @@ -347,3 +389,22 @@ Both headed Chromium clients use the GPU and report no WASM page errors. Owned visitors122/123 are removed after closing the browsers; unrelated SQLite rows hash unchanged, with foreign-key and integrity checks passing. The single shared HTTPS8443 preview runs the verified integrated build. + +The jump milestone passes all 1,273 top-level server tests (14,194 results), +342 focused race results, the data packages and `go vet`. Nine new regressions +exercise public movement/ready handlers. `local/player-jump-movement/` binds the +exact source, binaries, source verifiers and paired GPU WASM captures. Normal +and repeated Space inputs peak near Y17.414 from floor16.41, then owner, observer +and server all settle at16.41. Raw abilities100/100 produce the expected larger +arc, with native peaks near18.335. Swimming remains mode4 with zero vertical +impulse after Space. Both clients report no WASM page errors. + +The normal jump's largest sampled owner/server vertical difference is0.1352 m; +the high-jump repeat has an observer/server sample difference0.3546 m. Native heap +probes and the HTTP prediction are sequential: that latter sample's map response +arrives29 ms after the observer probe, while owner/observer vertical velocities +differ by0.68 m/s. Network delivery and frame phase therefore remain comparison +bounds; these captures establish the arc, state and final floor rather than +bit-identical trajectories. Owned visitors124/125 and both browser contexts are +removed after testing, with unrelated SQLite rows unchanged and integrity and +foreign-key checks passing. One shared HTTPS8443 preview retains this jump build. diff --git a/docs/player-movement.md b/docs/player-movement.md @@ -5,10 +5,11 @@ integrator and distinct longitudinal, arrival, lateral and angular controllers. Ordinary input and [player following](player-follow.md) share this state. Strafing and turning continue without pose packets; held input has no age cap. The implementation includes outdoor scene collision, body projection, gravity -and basic swimming transitions. The shared geometry reads selected 14.9.1 grids, +and basic swimming transitions, plus ordinary outdoor jumping and landing. +The shared geometry reads selected 14.9.1 grids, cell surfaces and water directly from the bundled data. [Player geometry](player-geometry.md) records the held-wall and body checks and the remaining lifecycle, indoor, -platform, jump and full flight work. +platform, special jump modes and full flight work. ## Ordinary ground motion diff --git a/server/player_collision.go b/server/player_collision.go @@ -75,13 +75,47 @@ func collisionDirectionOrUp(vector [3]float32) [3]float32 { return vector } -func (movement *playerMovement) land(height float32) { +func (player *character) land(height float32) { + movement := &player.movement movement.velocity[1], movement.verticalVelocity = 0, 0 movement.speed = vectorLength(movement.velocity) + if movement.components[9] == 4 { + movement.action(player, 14) + } + movement.jumpHeight = 0 movement.fallHeight = height movement.falling = false } +func (player *character) jump() { + // Sources: client/game/kkr.dll/lifted-0033.c, sub_36071BD0; + // client/game/kkr.dll/lifted-0023.c, sub_36048FC0. + if player.movement.jumpHeight != 0 { + return + } + abilities := player.baseStats().Abilities + height := float32(1 + float64(float32(.005))*float64(uint32(abilities.Strength)+uint32(abilities.Agility))) + if player.geometry != nil && player.geometry.terrain[player.playfield] != nil { + player.collisionBody() + end := player.position + end[1] += 100 + contact := player.geometry.line(player.playfield, player.geometry.terrain[player.playfield], player.position, end, false) + if contact.hit { + clearance := contact.point[1] - player.position[1] + clearance = max(float32(.1), clearance-2*player.body.scale) + height = min(height, clearance) + } + } + + // The native impulse stores mass*sqrt(2*abs(gravity)*height) before dividing by mass. + bodyMass, _ := player.movementMass() + impulse := float32(float64(bodyMass) * math.Sqrt(40*float64(height))) + player.movement.jumpHeight = height + player.movement.fallHeight = player.position[1] + player.movement.verticalVelocity = float32(float64(player.movement.verticalVelocity) + float64(1)/float64(bodyMass)*float64(impulse)) + player.movement.startFalling() +} + func (movement *playerMovement) startFalling() { if !movement.falling { movement.falling = true @@ -134,14 +168,14 @@ func (player *character) alignSurface(previous [3]float32, skipSegment bool) { movement.normal = [3]float32{0, 1, 0} if player.geometry == nil || player.geometry.terrain[player.playfield] == nil { if movement.falling { - movement.land(player.position[1]) + player.land(player.position[1]) } return } layout, exists := player.geometry.playfields[player.playfield] if !exists { if movement.falling { - movement.land(player.position[1]) + player.land(player.position[1]) } return } @@ -187,7 +221,7 @@ func (player *character) alignSurface(previous [3]float32, skipSegment bool) { } retry, corrected, skipSegment = true, true, true if movement.falling && movement.normal[1] > .5 { - movement.land(position[1]) + player.land(position[1]) } } } @@ -258,7 +292,7 @@ func (player *character) alignSurface(previous [3]float32, skipSegment bool) { } if movement.deepWater { if movement.falling { - movement.land(point[1]) + player.land(point[1]) } point[1] += clearance + float32(-.05) if point[1]-bottom[1] <= 5 && point[1] > bottom[1] { @@ -269,7 +303,7 @@ func (player *character) alignSurface(previous [3]float32, skipSegment bool) { bottom[1] = point[1] + float32(.01) corrected = true if movement.falling { - movement.land(point[1] + float32(.01)) + player.land(point[1] + float32(.01)) } } else if bottom[1]-radius*float32(.125) > point[1] { if fallingEnabled { @@ -277,14 +311,14 @@ func (player *character) alignSurface(previous [3]float32, skipSegment bool) { } } else if bottom[1]-point[1] <= float32(.011) { if movement.falling { - movement.land(point[1] + float32(.01)) + player.land(point[1] + float32(.01)) } } else if movement.velocity[1]+movement.verticalVelocity <= 0 && fallingEnabled { bottom = point bottom[1] += float32(.01) corrected = true if movement.falling { - movement.land(point[1]) + player.land(point[1]) } } for axis := range position { diff --git a/server/player_jump_test.go b/server/player_jump_test.go @@ -0,0 +1,216 @@ +package main + +import ( + "encoding/binary" + "math" + "testing" + "time" +) + +func TestPlayerJumpRisesAndLandsWithoutAnotherMovementPacket(t *testing.T) { + world := newPlayerCollisionWorld(t) + player, client := world.characters[1], world.clients[1] + player.stats.Abilities.Strength, player.stats.Abilities.Agility = 6, 6 + + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + impulse, jumping := player.movement.verticalVelocity, player.movement.components[9] + started := player.movement.updatedAt + peak := player.position[1] + for frame := 1; frame <= 60; frame++ { + world.advancePlayerMovement(started.Add(time.Duration(frame) * time.Second / 60)) + peak = max(peak, player.position[1]) + } + + if math.Abs(float64(impulse)-6.511527) > .00001 || jumping != 4 || peak < 17.39 || peak > 17.47 { + t.Fatal("jump must use native ability-derived height and independent gravity", impulse, jumping, peak) + } + if player.movement.falling || player.movement.verticalVelocity != 0 || player.movement.components[9] != 1 || math.Abs(float64(player.position[1])-16.41) > .00001 { + t.Fatal("landing must finish the jump and return to the authored floor", player.position, player.movement) + } +} + +func TestPlayerJumpCannotRestartBeforeLanding(t *testing.T) { + world := newPlayerCollisionWorld(t) + player, client := world.characters[1], world.clients[1] + player.stats.Abilities.Strength, player.stats.Abilities.Agility = 6, 6 + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + world.advancePlayerMovement(player.movement.updatedAt.Add(100 * time.Millisecond)) + impulse := player.movement.verticalVelocity + + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + secondImpulse := player.movement.verticalVelocity + started := player.movement.updatedAt + for frame := 1; frame <= 60; frame++ { + world.advancePlayerMovement(started.Add(time.Duration(frame) * time.Second / 60)) + } + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + + if secondImpulse > impulse || secondImpulse < impulse-.01 { + t.Fatal("a repeated airborne jump must not add another impulse", impulse, secondImpulse) + } + if !player.movement.falling || math.Abs(float64(player.movement.verticalVelocity)-6.511527) > .00001 || player.movement.components[9] != 4 { + t.Fatal("landing must permit the next ordinary jump", player.movement) + } +} + +func TestPlayerJumpPreservesHorizontalControlsThroughLanding(t *testing.T) { + world := newPlayerCollisionWorld(t) + player, client := world.characters[1], world.clients[1] + for _, action := range []uint32{1, 5} { + if err := world.handleMovement(client, playerMovementRequest(player, action)); err != nil { + t.Fatal(err) + } + } + strafe := player.movement.strafe + + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + started := player.movement.updatedAt + for frame := 1; frame <= 60; frame++ { + world.advancePlayerMovement(started.Add(time.Duration(frame) * time.Second / 60)) + } + + if player.movement.forward != 1 || player.movement.strafe != strafe || player.movement.components[1] != 3 || player.movement.components[3] != 3 || player.movement.components[5] != 3 || player.movement.speed < 1.49 { + t.Fatal("jump and landing must retain longitudinal and lateral controls", player.movement) + } + if player.movement.falling || player.movement.components[9] != 1 || player.movement.jumpHeight != 0 { + t.Fatal("physical landing must clear the jump guard", player.movement) + } +} + +func TestPlayerJumpRejectsSwimmingAndSitting(t *testing.T) { + for _, mode := range []string{"swimming", "sitting"} { + t.Run(mode, func(t *testing.T) { + world := newPlayerCollisionWorld(t) + player, client := world.characters[1], world.clients[1] + player.sitting = mode == "sitting" + player.movement.deepWater = mode == "swimming" + if mode == "swimming" { + player.position, player.rotation = [3]float32{100, 6.5, 25}, [4]float32{0, 0, 0, 1} + } + + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + + if player.movement.falling || player.movement.verticalVelocity != 0 || player.movement.jumpHeight != 0 || player.movement.components[9] != 1 { + t.Fatal("mode admitted an ineligible jump", player.movement) + } + }) + } +} + +func TestPlayerJumpUsesRawAbilitiesAndIgnoresTheAction20Scalar(t *testing.T) { + world := newPlayerCollisionWorld(t) + player, client := world.characters[1], world.clients[1] + player.stats.Abilities.Strength, player.stats.Abilities.Agility = 6, 6 + player.activeNanos = []activeNano{{program: 27169}, {program: 26342}} + request := playerMovementRequest(player, 13) + binary.BigEndian.PutUint16(request[len(request)-2:], 7*2048) + + if err := world.handleMovement(client, request); err != nil { + t.Fatal(err) + } + + if player.effectiveAbility(16) != 18 || player.effectiveAbility(17) != 18 || math.Abs(float64(player.movement.verticalVelocity)-6.511527) > .00001 { + t.Fatal("jump height must read raw abilities without using the action20 yaw scalar", player.movement, player.effectiveAbility(16), player.effectiveAbility(17)) + } +} + +func TestPlayerJumpShortensForTheCeilingAndBodyScale(t *testing.T) { + for _, scenario := range []struct { + name string + ceiling float32 + scale uint16 + height float32 + }{ + {"high ceiling", 20.41, 100, 1.06}, + {"low ceiling", 18.66, 100, .25}, + {"minimum clearance", 17.41, 100, .1}, + {"double scale", 20.66, 200, .25}, + } { + t.Run(scenario.name, func(t *testing.T) { + world := newPlayerCollisionWorld(t) + player, client := world.characters[1], world.clients[1] + player.stats.Abilities.Strength, player.stats.Abilities.Agility = 6, 6 + player.height = scenario.scale + world.geometry.surfaces[705<<16|384] = &sceneSurface{primary: &surfaceTree{ + vertices: [][3]float32{{960, scenario.ceiling, 500}, {980, scenario.ceiling, 500}, {960, scenario.ceiling, 530}}, + groups: []surfaceGroup{{bounds: [6]float32{960, scenario.ceiling, 500, 980, scenario.ceiling, 530}, triangles: [][3]uint32{{0, 1, 2}}}}, + nodes: []surfaceNode{{groups: []uint32{0}}}, + }} + + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + + if math.Abs(float64(player.movement.jumpHeight-scenario.height)) > .00001 || !player.movement.falling { + t.Fatal("ceiling clearance must subtract twice the visual body scale before clamping", player.movement) + } + }) + } +} + +func TestPlayerJumpLandingMessageDoesNotLandThePhysicalBody(t *testing.T) { + world := newPlayerCollisionWorld(t) + player, client := world.characters[1], world.clients[1] + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + world.advancePlayerMovement(player.movement.updatedAt.Add(100 * time.Millisecond)) + impulse := player.movement.verticalVelocity + + if err := world.handleMovement(client, playerMovementRequest(player, 14)); err != nil { + t.Fatal(err) + } + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + + if !player.movement.falling || player.movement.jumpHeight == 0 || player.movement.verticalVelocity > impulse || player.movement.verticalVelocity < impulse-.01 { + t.Fatal("an early helper landing message must not clear or restart the physical jump", impulse, player.movement) + } +} + +func TestPlayerJumpCanAddAnImpulseDuringAnOrdinaryFall(t *testing.T) { + world := newPlayerCollisionWorld(t) + player, client := world.characters[1], world.clients[1] + player.position[1], client.loading = 30, true + player.stats.Abilities.Strength, player.stats.Abilities.Agility = 6, 6 + if err := world.handleCharacterReady(client); err != nil { + t.Fatal(err) + } + world.advancePlayerMovement(player.movement.updatedAt.Add(100 * time.Millisecond)) + before := player.movement.verticalVelocity + + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + + if before != -2 || math.Abs(float64(player.movement.verticalVelocity)-4.511527) > .00001 || !player.movement.falling || player.movement.components[9] != 4 { + t.Fatal("a fresh jump adds to independent vertical velocity during an ordinary fall", before, player.movement) + } +} + +func TestPlayerJumpWithoutASurfaceProviderFinishesFallingOnAlignment(t *testing.T) { + world, _ := newEquipmentWorld(t) + player, client := world.characters[1], world.clients[1] + + if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil { + t.Fatal(err) + } + world.advancePlayerMovement(player.movement.updatedAt.Add(100 * time.Millisecond)) + + if player.movement.falling || player.movement.verticalVelocity != 0 || player.movement.jumpHeight != 0 || player.movement.components[9] != 1 { + t.Fatal("missing surface alignment must still perform the native landing callback", player.movement) + } +} diff --git a/server/player_movement.go b/server/player_movement.go @@ -21,6 +21,7 @@ type playerMovement struct { speed float32 normal [3]float32 verticalVelocity float32 + jumpHeight float32 fallHeight float32 falling bool deepWater bool @@ -236,9 +237,7 @@ func (player *character) advanceMovement(now time.Time, target [3]float32) { if !changed { return } - if physical { - player.alignSurface(previous, false) - } + player.alignSurface(previous, false) movement.previousPosition = previous // Mode0 body orientation follows horizontal velocity, reversed when backing up. if !player.flying() && (movement.velocity[0] != 0 || movement.velocity[2] != 0) { @@ -344,6 +343,17 @@ func (movement *playerMovement) action(player *character, action uint32) bool { movement.turn = 0 movement.components[7], movement.components[8] = 1, 0 } + case 13: + accepted = old[0] != 1 && old[0] != 4 && old[0] != 5 && old[0] != 8 && (old[9] != 4 || old[0] == 7) + if accepted { + movement.components[9] = 4 + player.jump() + } + case 14: + accepted = old[0] != 8 && old[9] == 4 + if accepted && old[0] != 7 { + movement.components[9] = 1 + } case 22, 23: player.running = action == 23 movement.prepare(player, movement.updatedAt)