commit 91acb4f050db5f1b68cffaa7ca85875005b9062b
parent cc406ab14571dd528dd568d124881d425573bfcc
Author: anon <anon@example.com>
Date: Thu, 5 Nov 2026 22:39:54 +0000
Keep validated corpse poses above outdoor terrain
Diffstat:
15 files changed, 1023 insertions(+), 16 deletions(-)
diff --git a/DEVELOPERS.md b/DEVELOPERS.md
@@ -270,6 +270,9 @@ appearance definitions; `items/` holds all 87,611 item and nano definitions,
including serialized effects, requirements and undecoded bytes. Item catalog
provenance and coverage live in `items.yaml`. Map coordinates, playfields and
terrain extraction evidence have their own YAML files in the same directory.
+`corpse_poses.yaml` holds the native-validated Leet and Aquaan death-pose vertices;
+regenerate it with `python3 tools/data/extract_corpse_poses.py`. See
+[corpse placement](docs/corpse-pose.md) for the provisional terrain correction.
Go embeds these files and decodes them into typed structs at startup. Item files
contain one YAML document per record, keeping temporary parser memory bounded.
diff --git a/TODO.md b/TODO.md
@@ -142,6 +142,10 @@ research separately. More screenshots and test cases do not count as new gamepla
transaction boundaries. Visible corpse picking/placement is part of this
gate; recovering the original generic slope formula is not a prerequisite
if the actual early-route corpses render and can be looted correctly.
+ The recorded buried Aquaan case now uses held-pose vertex clearance, with
+ native warm/reconnect loot and atomic cold-pose coverage; see
+ [corpse placement](docs/corpse-pose.md). This fixes that visible failure,
+ not the remaining ordinary-action coverage matrix.
- [ ] **A7: All-faction early-game loop through levels 1-10.** Name the finite
training/hunting routes, starter/basic shops, supported mission encounters
@@ -218,6 +222,12 @@ rewriting this document does not close them.
asset tree; the tagged executable runs without external assets; representative
resource reads and HTTP responses agree in both modes. Update build/release
instructions and resource tests to cover both providers.
+- [ ] **Repair the NPC fixture's missing interior resources.**
+ `useNPCData`'s empty database makes corpse-expiry tests panic while loading
+ interior resource `1000001/1180`, also reproduced with the pre-change
+ `98127488` test binary. Keep the authored fake population while supplying
+ resources required by current server initialization. Completion: the affected
+ corpse-expiry tests run their assertions successfully.
- [ ] **Measure server test costs and remove obvious inefficiencies.**
The reported full run takes tens of minutes, but `-v` shows progress; quiet
output alone does not establish a hang. Establish a baseline before setting
diff --git a/docs/corpse-pose.md b/docs/corpse-pose.md
@@ -1,6 +1,6 @@
# Corpse pose and terrain
-The Aquaan remains can be almost entirely hidden by a slope even when the native
+The Aquaan remains were almost entirely hidden by a slope even when the native
corpse, original death animation and skeleton are present and correct. In an
ordinary Omni Training kill, 510 of the original mesh's 540 vertices lay below
the reconstructed terrain. The 30 exposed vertices belonged to its two toe
@@ -8,9 +8,49 @@ groups. Native right-clicking one of these patches opened the loot window;
credits and its pistol transferred successfully.
This diagnoses the captured rendering problem. It does not establish the
-original server's corpse placement policy or justify a species height offset.
-The broader [corpse audit](../TODO.md) remains open, including cold replay,
-scene reentry and expiry while a loot window is open.
+original server's corpse placement policy. The broader [corpse audit](../TODO.md)
+remains open.
+
+## Current placement rule
+
+The server uses a provisional geometric correction for the two independently
+validated held poses, Leet and Aquaan. `tools/data/extract_corpse_poses.py`
+reconstructs their final skinned vertices from the original mesh and animation;
+`server/gamedata/corpse_poses.yaml` retains the distinct vertices and input
+payload hashes. These vertices match the previously native-validated poses
+to the stored six decimal places. The other creature bodies retain their
+existing placement until their pose extraction is validated.
+
+At death, `server/corpse_placement.go` samples the existing terrain triangles
+under each transformed held-pose vertex. It raises the anchor only as far as
+needed for those vertices to clear the terrain by 1 cm. Horizontal position,
+facing and original animation remain unchanged. This is a shared geometry rule,
+not a recovered original server formula. It tests vertices, not every interior
+point of a mesh triangle, and does not conform the horizontal body to a slope.
+It leaves indoor corpses and already clear poses unchanged.
+
+The corrected anchor commits atomically with death, loot and rewards. Before
+publishing a corrected corpse, the server removes its original actor, so native
+warm activation cannot copy that actor's lower position back onto the corpse.
+The recorded Aquaan case moves from Y=13.912122 to approximately Y=15.081813.
+The focused transaction regression covers flat ground, cold load, rejected and
+ignored writes, commit failure, and retry without publishing a premature corpse.
+
+`TestBrowserAquaanCorpseSlope` reproduces the recorded pose with one remaining
+HP and uses native mouse selection and attack input. The corrected body is
+recognizable, its torso opens loot before and after reconnect, and its five
+fixture credits transfer once and survive cold load. A separate retained
+opposite-facing pose requires only about 0.207 m of correction; its native
+living actor is within the one-metre copy threshold. The corrected native
+height survives both warm activation and reconnect. This second case checks
+pose replacement, not another loot interaction. These are controlled fixtures,
+not earned-progression evidence.
+
+A controlled native experiment also tested terrain tilt. On replay, the client
+changed the transmitted quaternion `(0.177903,-0.902129,0.167705,0.355513)` to
+`(0,-0.939406,0,0.342806)`, leaving only the toes exposed. This confirms that a
+server quaternion adjustment alone does not fix this case. Evidence is retained
+under `local/alpha-corpse-slope/20261105-142426/`.
## Original resources
@@ -142,7 +182,7 @@ recover the original server's transmitted anchors or exclude other stat-driven
paths. No placement or species-offset change follows from this result.
Complete original records are retained in
-`local/corpse-pose/placement-policy-kkr.json`, `placement-policy-llr.json` and
+`local/old/corpse-pose/placement-policy-kkr.json`, `placement-policy-llr.json` and
`placement-policy-qqr.json`. Key evidence IDs are
`ev_50825da2fb9e31173ee2759da39987c2cd1bbb91335fe18adf5d8ae995009504`
(activation),
@@ -153,18 +193,20 @@ Complete original records are retained in
## Evidence and remaining checks
-Local evidence is under `local/corpse-pose/`: original resource bytes and offsets,
+Original evidence is under `local/old/corpse-pose/`: original resource bytes and offsets,
hashes, decoded tracks and geometry, independent composition, unchanged C
sampler/skeleton harnesses, original KKR provider evidence, native screenshots,
packet captures and read-only heap samples. `data/runtime-layout.json` records
the exact guest pointers and structure offsets. Cached world matrices must be
read with their dirty flag; invoking a matrix getter can update the cache.
-
-Recover or bound the original corpse placement policy before changing shared
-transforms. Extend the facing control to flat ground, warm transitions,
-cold replay and scene reentry. Distinguish a current placement defect from
-behavior inherent in the original clip. Keep the existing animation resources
-and generic skeleton math unless contrary evidence identifies a defect.
+Current controlled captures and regression logs are under
+`local/alpha-corpse-slope/`.
+
+Exact original placement fidelity remains deferred. Extend pose extraction only
+when another reproduced corpse failure requires it, and validate the decoded
+pose against the original sampler before enabling its correction. Keep the
+existing animation resources and generic skeleton math unless contrary
+evidence identifies a defect.
The public [MMSys2012 server trace](https://web.cs.wpi.edu/~claypool/mmsys-dataset/2012/anarchy/)
cannot establish corpse anchors. Its first64KiB contains931 complete records
diff --git a/server/browser_corpse_slope_test.go b/server/browser_corpse_slope_test.go
@@ -0,0 +1,115 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "testing"
+ "time"
+)
+
+func TestBrowserAquaanCorpseSlope(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for the recorded Aquaan corpse slope")
+ }
+ t.Run("recorded", func(t *testing.T) { testBrowserAquaanCorpseSlope(t, false) })
+ // Below the client's one-metre pose-copy threshold, actor removal matters.
+ t.Run("nearby actor", func(t *testing.T) { testBrowserAquaanCorpseSlope(t, true) })
+}
+
+func testBrowserAquaanCorpseSlope(t *testing.T, nearbyActor bool) {
+ t.Helper()
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/alpha-corpse-slope", time.Now().Format("20060102-150405"))
+ world := newTestServer(t)
+ var target *character
+ for _, actor := range world.characters {
+ if actor.npcDefinitionID == "950/district/6/fixed/0" {
+ target = actor
+ }
+ }
+ if target == nil {
+ t.Fatal("missing original training boss placement")
+ }
+ // Reproduce the recorded buried pose without replaying the boss fight.
+ target.position = [3]float32{186, 13.912122, 174.375}
+ target.rotation = [4]float32{0, -.930363, 0, .366640}
+ target.health = 1
+ player := world.newCharacter()
+ player.playfield, player.position = 950, [3]float32{184, 0, 174.375}
+ player.position[1], _ = world.terrain[950].elevation(player.position[0], player.position[2])
+ player.position[1] += .2
+ player.rotation = [4]float32{0, .70710677, 0, .70710677}
+ if nearbyActor {
+ // The retained opposite-facing control needs only about 20 cm of clearance.
+ target.position = [3]float32{190.5, 15.437122, 179.5}
+ target.rotation = [4]float32{0, .33313298, 0, .94287986}
+ player.position = [3]float32{192.5, 0, 179.5}
+ player.position[1], _ = world.terrain[950].elevation(player.position[0], player.position[2])
+ player.position[1] += .2
+ player.rotation = [4]float32{0, -.70710677, 0, .70710677}
+ }
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("corpse-slope")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ world.combatRoll = landedCombatRoll
+ mux := http.NewServeMux()
+ mux.Handle("/", world.httpHandler())
+ mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ var items []ownedItem
+ var credits uint32
+ if target.corpse != nil {
+ items, credits = target.corpse.items, target.corpse.credits
+ }
+ json.NewEncoder(w).Encode(map[string]any{"target": target.id, "position": target.position, "rotation": target.rotation, "nearbyActor": nearbyActor,
+ "health": target.health, "corpse": target.corpse != nil, "items": items, "credits": credits, "inventory": player.inventory})
+ })
+ host := httptest.NewServer(mux)
+ defer host.Close()
+ defer closeTestSessions(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
+ stopped := make(chan struct{})
+ go func() {
+ defer close(stopped)
+ clock := time.NewTicker(time.Second / 60)
+ defer clock.Stop()
+ for {
+ select {
+ case now := <-clock.C:
+ world.advancePlayerMovement(now)
+ world.advanceCombat(now)
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ defer func() { cancel(); <-stopped }()
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_corpse_slope.mjs"), host.URL, output)
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ t.Logf("Browser artifacts: %s", output)
+ if err != nil {
+ t.Fatal(err)
+ }
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ cold := newTestInventoryServer(t)
+ if cold.characters[target.id].position != target.position || cold.characters[target.id].rotation != target.rotation ||
+ cold.characters[1].inventory.Credits != player.inventory.Credits {
+ t.Fatal("corpse placement or collected cash changed after cold load")
+ }
+}
diff --git a/server/combat.go b/server/combat.go
@@ -507,7 +507,7 @@ func (server *server) applyDamage_locked(attacker, target *character, damage uin
return award, nil
}
-func prepareDamage(attacker, target *character, damage uint32, now time.Time) character {
+func (server *server) prepareDamage_locked(attacker, target *character, damage uint32, now time.Time) character {
// Work on detached mutable state until the outcome's transaction succeeds.
candidate := *target
candidate.health -= damage
@@ -563,6 +563,7 @@ func prepareDamage(attacker, target *character, damage uint32, now time.Time) ch
if candidate.combatProfile != nil && candidate.combatProfile.CorpseSeconds != 0 {
candidate.corpse.expiresAt = now.Add(time.Duration(candidate.combatProfile.CorpseSeconds) * time.Second)
}
+ server.placeCorpse_locked(&candidate)
}
return candidate
}
@@ -617,6 +618,11 @@ func (server *server) finishDamageEffects_locked(attacker, target *character, pr
if target.combatProfile != nil && target.combatProfile.CorpseSeconds != 0 {
server.corpseExpiry = append(server.corpseExpiry, target)
}
+ if target.position != previous.position {
+ // Activation otherwise copies the nearby living actor's old pose.
+ // Source: client/game/kkr.dll/lifted-0052.c, sub_360AFCB0.
+ server.queueCombat_locked(updates, target, target, n3Packet(0x36510078, 50000, target.id, nil))
+ }
server.queueCombat_locked(updates, target, target, corpsePacket(target))
}
if respawn := server.npcRespawnAt_locked(target, now); target.npc && !respawn.IsZero() {
diff --git a/server/corpse_placement.go b/server/corpse_placement.go
@@ -0,0 +1,36 @@
+package main
+
+import "ao/server/gamedata"
+
+func (server *server) placeCorpse_locked(character *character) {
+ pose, exists := gamedata.CorpsePoses[character.monsterData]
+ if !exists {
+ return
+ }
+ ground := server.terrain[character.playfield]
+ if ground == nil {
+ return
+ }
+
+ // The native corpse stays upright. Raise its held mesh until its sampled
+ // vertices clear the terrain, retaining the death's horizontal position/yaw.
+ x, y, z, w := character.rotation[0], character.rotation[1], character.rotation[2], character.rotation[3]
+ rotation := [3][3]float32{
+ {1 - 2*y*y - 2*z*z, 2*x*y + 2*z*w, 2*x*z - 2*y*w},
+ {2*x*y - 2*z*w, 1 - 2*x*x - 2*z*z, 2*y*z + 2*x*w},
+ {2*x*z + 2*y*w, 2*y*z - 2*x*w, 1 - 2*x*x - 2*y*y},
+ }
+ var lift float32
+ for _, vertex := range pose.Vertices {
+ point := character.position
+ for axis := range 3 {
+ for component := range 3 {
+ point[axis] += vertex[component] * rotation[component][axis]
+ }
+ }
+ if height, inside := ground.elevation(point[0], point[2]); inside {
+ lift = max(lift, height+.01-point[1])
+ }
+ }
+ character.position[1] += lift
+}
diff --git a/server/corpse_placement_test.go b/server/corpse_placement_test.go
@@ -0,0 +1,92 @@
+package main
+
+import (
+ "encoding/binary"
+ "math"
+ "testing"
+)
+
+func TestCorpseSlopePlacementCommitsWithDeath(t *testing.T) {
+ for _, scenario := range []struct {
+ name string
+ flat bool
+ failure string
+ }{
+ {name: "slope"},
+ {name: "flat", flat: true},
+ {name: "rejected write", failure: "CREATE TRIGGER reject_pose BEFORE UPDATE ON npcs WHEN NEW.has_corpse=1 BEGIN SELECT RAISE(FAIL,'corpse'); END"},
+ {name: "ignored write", failure: "CREATE TRIGGER reject_pose BEFORE UPDATE ON npcs WHEN NEW.has_corpse=1 BEGIN SELECT RAISE(IGNORE); END"},
+ {name: "commit failure", failure: "CREATE TABLE pose_commit_failure (id INTEGER REFERENCES players(id) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER reject_pose AFTER UPDATE ON npcs WHEN NEW.has_corpse=1 BEGIN INSERT INTO pose_commit_failure VALUES(99999); END"},
+ } {
+ t.Run(scenario.name, func(t *testing.T) {
+ // Set up the recorded body, facing and terrain under an ordinary attack.
+ world, output := newKillExperienceWorld(t, "unarmed")
+ ground, err := readTerrain()
+ if err != nil {
+ t.Fatal(err)
+ }
+ world.terrain = ground
+ target := world.characters[1000000]
+ target.monsterData = 30369
+ target.position = [3]float32{186, 13.912122, 174.375}
+ target.rotation = [4]float32{0, -.930363, 0, .366640}
+ if scenario.flat {
+ world.terrain[target.playfield] = &terrain{width: 2, height: 2, boundsWidth: 2, boundsHeight: 2,
+ spacing: 200, scale: 1, heights: []byte{14, 14, 14, 14, 14, 14, 14, 14, 14}}
+ target.position[1] = 14.2
+ }
+ world.characters[1].position = target.position
+ world.characters[1].position[0] -= 2
+ position, rotation := target.position, target.rotation
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ if scenario.failure != "" {
+ if _, err := world.db.Exec(scenario.failure); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ // Kill through the public attack path; failed transactions must not move it.
+ attackForExperience(t, world, "unarmed")
+ if scenario.failure != "" {
+ cold := newTestInventoryServer(t)
+ if target.health != 1 || target.corpse != nil || target.position != position || cold.characters[target.id].position != position {
+ t.Fatal("failed death leaked its corrected corpse position")
+ }
+ for _, packet := range output.packets {
+ if opcode := binary.BigEndian.Uint32(packet[16:20]); opcode == 0x36510078 || opcode == 0x4f474e05 {
+ t.Fatal("failed death published actor removal or corpse creation")
+ }
+ }
+ if _, err := world.db.Exec("DROP TRIGGER reject_pose"); err != nil {
+ t.Fatal(err)
+ }
+ attackForExperience(t, world, "unarmed")
+ }
+
+ // The committed pose is replayable, with no extra lift on already clear ground.
+ expectedY := float32(15.081813)
+ if scenario.flat {
+ expectedY = 14.2
+ }
+ cold := newTestInventoryServer(t)
+ if target.health != 0 || target.corpse == nil || math.Abs(float64(target.position[1]-expectedY)) > .0001 ||
+ target.position[0] != 186 || target.position[2] != 174.375 || target.rotation != rotation ||
+ cold.characters[target.id].position != target.position || cold.characters[target.id].rotation != rotation {
+ t.Fatal("death did not retain the expected terrain clearance and original facing", target.position, target.rotation)
+ }
+ removed := false
+ for _, packet := range output.packets {
+ switch binary.BigEndian.Uint32(packet[16:20]) {
+ case 0x36510078:
+ removed = true
+ case 0x4f474e05:
+ if removed == scenario.flat {
+ t.Fatal("corrected corpse did not replace the old actor before activation")
+ }
+ }
+ }
+ })
+ }
+}
diff --git a/server/gamedata/corpse_poses.yaml b/server/gamedata/corpse_poses.yaml
@@ -0,0 +1,461 @@
+# Generated by tools/data/extract_corpse_poses.py from original 14.9.1 resources.
+# Held-pose vertices at unit scale; this is geometry, not an original server placement rule.
+17655:
+ mesh: 15222
+ animation: 18107
+ # Mesh SHA-256: f27ac6925a9ef2f7359f9205bc51383f07205f65bc554324120fe0660b904beb
+ # Animation SHA-256: 2ef2cadcc9a6ac58dacde5f6059cb7a21cf84572747ed17bbd7713024fbc6adb
+ vertices:
+ - [-0.25671, 0.055868, 0.069762]
+ - [-0.249383, 0.168317, 0.067036]
+ - [-0.23679, 0.046842, 0.23724]
+ - [-0.211096, 0.000181, 0.157484]
+ - [-0.192378, -0.011878, 0.079274]
+ - [-0.189405, 0.157393, 0.254983]
+ - [-0.160627, 0.043438, 0.2724]
+ - [-0.159544, 0.070056, -0.080328]
+ - [-0.154207, -0.01514, -0.036321]
+ - [-0.152707, 0.226267, 0.068237]
+ - [-0.14732, 0.005475, 0.180194]
+ - [-0.142615, 0.237602, 0.176504]
+ - [-0.133001, 0.024248, 0.262134]
+ - [-0.128797, 0.139391, 0.29242]
+ - [-0.117724, 0.001816, 0.183781]
+ - [-0.110003, 0.164092, -0.082823]
+ - [-0.106624, 0.071824, 0.116882]
+ - [-0.10342, 0.001999, 0.172978]
+ - [-0.100709, 0.01642, -0.126656]
+ - [-0.095979, 0.014493, 0.103441]
+ - [-0.09361, -0.011719, -0.074599]
+ - [-0.092382, 0.00407, 0.250149]
+ - [-0.089186, 0.06548, 0.141239]
+ - [-0.083337, 0.199997, 0.222554]
+ - [-0.082997, 0.212335, 0.152595]
+ - [-0.068535, 0.165061, 0.129384]
+ - [-0.06718, 0.058462, 0.118792]
+ - [-0.066703, 0.030633, -0.067072]
+ - [-0.066462, 0.08633, 0.299411]
+ - [-0.062971, 0.200145, 0.077377]
+ - [-0.062518, 0.119094, -0.191117]
+ - [-0.05804, 0.054892, -0.087585]
+ - [-0.057805, 0.05299, 0.125788]
+ - [-0.05759, 0.016083, -0.11709]
+ - [-0.057483, -0.013133, 0.042631]
+ - [-0.04634, 0.080326, -0.096215]
+ - [-0.040976, 0.074991, -0.158671]
+ - [-0.040315, 0.147651, -0.163719]
+ - [-0.037631, 0.055202, 0.280406]
+ - [-0.035566, 0.051575, -0.073798]
+ - [-0.035444, 0.002682, -0.087886]
+ - [-0.033371, 0.03077, -0.078019]
+ - [-0.031261, 0.156595, -0.011782]
+ - [-0.027109, 0.145791, 0.145205]
+ - [-0.024006, 0.047728, -0.095619]
+ - [-0.016678, 0.004648, -0.031805]
+ - [-0.016284, 0.022806, -0.095371]
+ - [-0.015809, 0.021378, 0.194188]
+ - [-0.015093, 0.001354, -0.025751]
+ - [-0.011942, 0.147094, 0.244581]
+ - [-0.005014, 0.036925, 0.080938]
+ - [-0.004269, 0.030161, -0.058634]
+ - [-0.001799, 0.10512, 0.158244]
+ - [-0.001516, 0.056638, 0.062673]
+ - [-0.000909, 0.121825, -0.136145]
+ - [0.001663, 0.026461, -0.01231]
+ - [0.002288, 0.09981, 0.02566]
+ - [0.002376, 0.04909, -0.13181]
+ - [0.006963, 0.093583, 0.049797]
+ - [0.007338, 0.105262, 0.23569]
+ - [0.008241, 0.021211, -0.081878]
+ - [0.009116, 0.076852, 0.016832]
+ - [0.010026, -0.001865, 0.007022]
+ - [0.013155, 0.05548, -0.035884]
+ - [0.014223, 0.038763, -0.243867]
+ - [0.0226, 0.044348, 0.06438]
+ - [0.025445, 0.035801, -0.200969]
+ - [0.025839, 0.016451, 0.018413]
+ - [0.026243, 0.057753, 0.030399]
+ - [0.029602, 0.03822, 0.001449]
+ - [0.030882, 0.036916, 0.053394]
+ - [0.033083, 0.025015, 0.091991]
+ - [0.036115, 0.076364, -0.238941]
+ - [0.039043, 0.11738, -0.017844]
+ - [0.044249, 0.068211, -0.203992]
+ - [0.048308, 0.086806, 0.005844]
+ - [0.049411, 0.049646, 0.021104]
+ - [0.053715, 0.019196, 0.027315]
+ - [0.05476, 0.050476, 0.048614]
+ - [0.080796, 0.046485, 0.059236]
+ - [0.129225, -0.000934, -0.258073]
+ - [0.138549, 0.026173, -0.236738]
+ - [0.141445, -0.003135, -0.232203]
+ - [0.143759, 0.022408, -0.261982]
+ - [0.211311, 0.014815, -0.226222]
+ - [0.214783, 0.000752, -0.243211]
+ - [0.21811, 0.018153, -0.240673]
+ - [0.218232, -0.006045, -0.221957]
+ - [0.28202, 0.01014, -0.208398]
+ - [0.282986, 0.007451, -0.215033]
+ - [0.285136, 0.007806, -0.2108]
+ - [0.285728, 0.010481, -0.211942]
+ - [0.35601, 0.009879, -0.188645]
+30369:
+ mesh: 25717
+ animation: 25721
+ # Mesh SHA-256: 544f03b87e28e01fd0faee0f98688adfd5902123ce1f2f249e366a1b5c3cb4f0
+ # Animation SHA-256: b21f33a71dc7cd91b40382f9aea0dca9b998b03fbd5bd80f9467328334de463e
+ vertices:
+ - [-0.540503, 0.066005, -1.395087]
+ - [-0.538128, 0.058972, -1.354802]
+ - [-0.537269, 0.013137, -1.387295]
+ - [-0.534348, 0.004001, -1.344898]
+ - [-0.531263, -0.013099, -1.253809]
+ - [-0.529934, 0.018568, -1.440583]
+ - [-0.5295, 0.030402, -1.238683]
+ - [-0.521704, 0.090426, -1.54965]
+ - [-0.502401, 0.079474, -1.342651]
+ - [-0.498243, 0.021021, -1.54487]
+ - [-0.495072, -0.019195, -1.166722]
+ - [-0.489676, 0.027558, -1.238716]
+ - [-0.482388, 0.048439, -1.310015]
+ - [-0.473725, 0.048487, -1.310745]
+ - [-0.468332, 0.044348, -1.243413]
+ - [-0.467112, 0.096369, -1.729284]
+ - [-0.466014, 0.095671, -1.335666]
+ - [-0.465808, 0.127768, -1.389187]
+ - [-0.461296, 0.081793, -1.24557]
+ - [-0.448444, 0.074229, -1.825397]
+ - [-0.44638, 0.129458, -1.571317]
+ - [-0.438945, 0.0384, -1.184204]
+ - [-0.431201, 0.05335, -1.238158]
+ - [-0.430691, 0.123623, -1.492233]
+ - [-0.426077, 0.08094, -1.327858]
+ - [-0.416991, 0.016318, -1.876747]
+ - [-0.415865, 0.092723, -1.389887]
+ - [-0.411373, -0.026353, -1.784314]
+ - [-0.409533, 0.066334, -1.544595]
+ - [-0.3997, 0.106678, -1.714601]
+ - [-0.398838, 0.074633, -1.414717]
+ - [-0.395137, 0.058906, -1.604207]
+ - [-0.388576, 0.096941, -1.415038]
+ - [-0.384875, 0.084805, -1.893349]
+ - [-0.378182, 0.067474, -1.398842]
+ - [-0.371654, 0.076844, -1.362642]
+ - [-0.371456, 0.083035, -1.7957]
+ - [-0.371052, 0.047952, -1.361277]
+ - [-0.367193, 0.05359, -1.701847]
+ - [-0.359766, -0.012713, -1.753797]
+ - [-0.355276, 0.076128, -1.454028]
+ - [-0.3542, 0.111124, -1.843743]
+ - [-0.353973, 0.075446, -1.426587]
+ - [-0.350004, 0.067663, -1.776031]
+ - [-0.347286, 0.013993, -1.940805]
+ - [-0.345503, 0.031131, -1.30689]
+ - [-0.340906, -0.019086, -1.817327]
+ - [-0.338599, 0.056813, -1.368476]
+ - [-0.336859, 0.033949, -2.030869]
+ - [-0.329164, 0.085581, -2.017586]
+ - [-0.321018, 0.100378, -1.817248]
+ - [-0.320211, 0.001531, -2.098675]
+ - [-0.315944, 0.119195, -2.067256]
+ - [-0.312634, 0.030065, -1.829537]
+ - [-0.289128, 0.152363, -2.107315]
+ - [-0.287379, 0.119707, -2.003223]
+ - [-0.286658, 0.112353, -2.117476]
+ - [-0.279252, 0.083041, -2.161931]
+ - [-0.275576, 0.025101, -2.16077]
+ - [-0.268266, -0.005412, -1.942047]
+ - [-0.255003, 0.136564, -2.349316]
+ - [-0.241882, 0.207964, -2.322502]
+ - [-0.24028, 0.132692, -2.403333]
+ - [-0.237911, 0.157225, -1.207641]
+ - [-0.235971, 0.21221, -2.292766]
+ - [-0.232775, 0.13684, -1.428432]
+ - [-0.22729, 0.233669, -2.314667]
+ - [-0.227098, 0.176725, -1.091063]
+ - [-0.226764, 0.065932, -2.182479]
+ - [-0.226684, 0.04149, -2.365417]
+ - [-0.226647, 0.223216, -2.029544]
+ - [-0.225547, 0.193654, -2.001441]
+ - [-0.225378, 0.164071, -2.279967]
+ - [-0.222667, 0.070114, -1.158858]
+ - [-0.220345, 0.11156, -2.277334]
+ - [-0.219264, 0.06418, -0.957442]
+ - [-0.21508, 0.125339, -2.172089]
+ - [-0.213024, 0.00022, -2.169925]
+ - [-0.212148, 0.214996, -2.258488]
+ - [-0.21091, 0.186209, -2.109155]
+ - [-0.207855, 0.237042, -2.291174]
+ - [-0.205926, 0.238357, -2.39778]
+ - [-0.204269, 0.182913, -2.42511]
+ - [-0.200403, 0.137771, -1.012571]
+ - [-0.198936, 0.140313, -2.437399]
+ - [-0.197847, 0.197195, -1.292988]
+ - [-0.194432, 0.148631, -1.906262]
+ - [-0.193304, 0.268358, -2.316009]
+ - [-0.19286, 0.273039, -2.350428]
+ - [-0.191997, 0.107303, -2.440901]
+ - [-0.189859, 0.266922, -2.293911]
+ - [-0.187515, 0.06737, -1.308797]
+ - [-0.186733, 0.261017, -2.273844]
+ - [-0.18571, 0.26905, -2.337312]
+ - [-0.184406, 0.171341, -1.877064]
+ - [-0.181979, 0.052379, -2.16791]
+ - [-0.179965, 0.165079, -2.214556]
+ - [-0.177709, 0.058157, -2.437625]
+ - [-0.177161, 0.214968, -2.217691]
+ - [-0.175813, 0.204207, -1.098956]
+ - [-0.175709, 0.257372, -0.509127]
+ - [-0.173928, 0.031193, -2.279117]
+ - [-0.173571, 0.190523, -1.629585]
+ - [-0.172785, 0.291097, -2.297303]
+ - [-0.170312, 0.249357, -2.215709]
+ - [-0.168316, -0.025785, -2.089174]
+ - [-0.165743, 0.275514, -2.328856]
+ - [-0.165336, 0.006883, -0.985489]
+ - [-0.164975, 0.077112, -0.78777]
+ - [-0.164749, 0.354784, -0.528048]
+ - [-0.16365, 0.282669, -2.282401]
+ - [-0.159518, 0.208946, -1.191009]
+ - [-0.158912, 0.268593, -0.556755]
+ - [-0.158781, 0.119534, -2.186754]
+ - [-0.157068, 0.178967, -1.780106]
+ - [-0.1559, 0.21529, -1.741904]
+ - [-0.155796, 0.08602, -1.575919]
+ - [-0.155782, 0.284257, -2.264636]
+ - [-0.155589, 0.264095, -2.217469]
+ - [-0.154881, 0.265802, -2.048326]
+ - [-0.15452, 0.005512, -2.417205]
+ - [-0.153444, 0.169361, -2.163351]
+ - [-0.151044, 0.277, -2.312003]
+ - [-0.149403, 0.227872, -1.68933]
+ - [-0.148116, 0.156623, -2.446295]
+ - [-0.147561, 0.165247, -1.015923]
+ - [-0.145484, 0.239365, -1.275961]
+ - [-0.141202, -0.013516, -1.989388]
+ - [-0.140109, 0.272957, -2.001364]
+ - [-0.140052, 0.110109, -0.799369]
+ - [-0.140042, 0.29409, -2.225393]
+ - [-0.139676, 0.157897, -1.087641]
+ - [-0.138062, 0.12353, -1.656018]
+ - [-0.135846, 0.27423, -2.297565]
+ - [-0.134239, 0.225006, -2.211966]
+ - [-0.133088, 0.187811, -0.57865]
+ - [-0.132793, 0.258523, -1.975449]
+ - [-0.131824, 0.258458, -2.359168]
+ - [-0.13152, -0.011793, -2.377503]
+ - [-0.130022, 0.084435, -1.143298]
+ - [-0.128172, 0.055524, -1.291336]
+ - [-0.127396, 0.139654, -0.495553]
+ - [-0.126961, 0.258047, -2.328882]
+ - [-0.120653, 0.241444, -2.216175]
+ - [-0.119797, 0.055567, -1.906513]
+ - [-0.118994, 0.239874, -2.379784]
+ - [-0.116642, 0.062481, -1.699602]
+ - [-0.11351, 0.275021, -2.237083]
+ - [-0.111427, 0.194694, -2.177377]
+ - [-0.110089, -0.007872, -0.834018]
+ - [-0.108251, 0.071349, -0.630198]
+ - [-0.107776, 0.020161, -2.308764]
+ - [-0.105659, 0.294526, -1.927698]
+ - [-0.105604, 0.232442, -2.225314]
+ - [-0.105263, 0.175446, -2.419116]
+ - [-0.10315, 0.093927, -1.851839]
+ - [-0.102423, 0.246888, -2.355018]
+ - [-0.102159, 0.14085, -1.170111]
+ - [-0.100951, 0.100437, -1.23092]
+ - [-0.098078, 0.268114, -2.24938]
+ - [-0.094682, 0.122634, -0.808621]
+ - [-0.091939, 0.24621, -2.314522]
+ - [-0.091304, 0.076643, -2.428523]
+ - [-0.091128, 0.027194, -2.238966]
+ - [-0.087648, 0.025339, -1.623376]
+ - [-0.085725, 0.333355, -0.534438]
+ - [-0.084671, 0.207887, -2.177801]
+ - [-0.083748, 0.061652, -1.522876]
+ - [-0.081803, 0.239729, -2.262141]
+ - [-0.080256, 0.181458, -1.347747]
+ - [-0.080054, 0.221605, -2.161964]
+ - [-0.079574, 0.201931, -2.347932]
+ - [-0.079537, 0.080496, -0.959408]
+ - [-0.0767, 0.01655, -0.482421]
+ - [-0.076362, -0.013461, -2.113397]
+ - [-0.071555, 0.251779, -2.133554]
+ - [-0.071086, 0.238987, -1.603017]
+ - [-0.070077, 0.298818, -1.806877]
+ - [-0.0689, -0.017657, -0.620437]
+ - [-0.067363, 0.017627, -0.983937]
+ - [-0.06295, 0.009719, -0.855162]
+ - [-0.062067, 0.192829, -2.19015]
+ - [-0.06103, 0.195962, -2.269997]
+ - [-0.059239, 0.153394, -2.352432]
+ - [-0.057926, 0.370503, -0.544048]
+ - [-0.053889, 0.062363, -2.335072]
+ - [-0.052878, 0.285726, -0.577239]
+ - [-0.050974, 0.291781, -2.062594]
+ - [-0.047036, 0.272867, -1.698304]
+ - [-0.047024, -0.004408, -1.999996]
+ - [-0.044443, 0.202786, -0.593701]
+ - [-0.043811, 0.017626, -0.735335]
+ - [-0.043324, 0.295249, -2.033656]
+ - [-0.039378, 0.292678, -2.018039]
+ - [-0.038715, 0.089696, -0.653429]
+ - [-0.036839, 0.058037, -1.801134]
+ - [-0.030795, -0.017651, -0.483164]
+ - [-0.029633, 0.153069, -2.246955]
+ - [-0.029477, 0.312814, -0.538153]
+ - [-0.025643, -0.010553, -0.636548]
+ - [-0.024782, 0.055143, -1.87709]
+ - [-0.020427, 0.164334, -2.197773]
+ - [-0.019112, 0.326328, -1.963197]
+ - [-0.018423, 0.240618, -0.527583]
+ - [-0.017124, 0.022173, -1.710927]
+ - [-0.016036, 0.031003, -0.645634]
+ - [-0.013701, 0.089292, -0.503556]
+ - [-0.01045, 0.052094, -0.575239]
+ - [-0.004342, 0.058443, -1.530638]
+ - [0.000245, -0.011829, -1.651364]
+ - [0.006035, -0.026863, -2.222975]
+ - [0.008188, 0.038347, -1.568389]
+ - [0.008613, 0.334938, -1.888663]
+ - [0.016056, -0.028208, -2.128179]
+ - [0.018171, 0.014019, -0.496064]
+ - [0.021729, 0.105198, -2.263699]
+ - [0.029412, 0.032268, -2.247902]
+ - [0.034961, 0.1312, -1.536897]
+ - [0.040159, 0.093114, -2.240654]
+ - [0.040246, -0.020373, -2.036342]
+ - [0.044459, 0.257551, -2.099639]
+ - [0.05387, 0.196138, -1.549996]
+ - [0.055092, 0.264644, -2.05152]
+ - [0.055635, 0.073504, -1.87447]
+ - [0.059849, 0.32364, -1.733761]
+ - [0.060175, 0.25018, -2.024981]
+ - [0.065039, 0.047057, -1.953515]
+ - [0.06586, 0.261219, -1.601642]
+ - [0.068854, -0.023993, -2.24503]
+ - [0.073431, 0.156643, -2.186218]
+ - [0.076198, 0.277839, -1.962886]
+ - [0.087028, 0.032709, -2.255185]
+ - [0.111027, 0.18543, -1.624027]
+ - [0.111688, 0.140723, -1.379783]
+ - [0.112384, 0.209874, -2.1171]
+ - [0.11282, 0.245095, -1.846793]
+ - [0.11821, 0.04787, -2.235551]
+ - [0.123526, 0.178277, -2.090929]
+ - [0.126271, 0.091964, -1.84121]
+ - [0.126587, 0.005577, -1.736658]
+ - [0.126959, 0.216023, -1.729991]
+ - [0.130827, -0.060281, -2.19287]
+ - [0.138327, 0.133547, -1.99139]
+ - [0.140301, 0.094888, -2.219732]
+ - [0.140863, -0.016259, -1.655938]
+ - [0.141379, -0.076482, -2.051052]
+ - [0.141541, 0.023304, -1.556038]
+ - [0.145493, 0.156387, -1.96146]
+ - [0.146366, 0.064122, -1.699561]
+ - [0.160047, 0.220673, -1.316296]
+ - [0.160276, 0.116993, -1.807578]
+ - [0.165659, 0.056457, -2.208641]
+ - [0.165776, 0.081203, -2.138659]
+ - [0.167087, 0.117462, -1.206368]
+ - [0.167931, 0.129062, -1.759975]
+ - [0.173207, 0.076852, -1.266748]
+ - [0.175949, 0.161182, -1.67684]
+ - [0.182338, -0.019688, -2.149322]
+ - [0.189025, 0.0691, -1.615933]
+ - [0.191173, 0.033369, -2.152217]
+ - [0.193741, 0.200517, -1.233849]
+ - [0.207344, 0.042062, -1.330251]
+ - [0.207455, 0.082366, -1.185881]
+ - [0.212402, -0.04388, -2.076407]
+ - [0.217475, 0.15569, -1.11839]
+ - [0.219762, 0.000868, -1.009586]
+ - [0.221592, 0.199013, -1.339816]
+ - [0.231747, 0.063843, -0.985237]
+ - [0.232961, 0.032355, -1.95994]
+ - [0.237621, 0.205827, -1.130596]
+ - [0.254295, -0.019869, -1.942459]
+ - [0.256157, 0.161777, -1.054642]
+ - [0.256172, 0.073352, -1.354817]
+ - [0.259613, 0.149543, -1.478793]
+ - [0.259979, 0.097347, -1.974473]
+ - [0.271451, -0.012981, -0.892107]
+ - [0.282683, 0.090568, -2.011311]
+ - [0.282868, 0.179109, -1.260217]
+ - [0.286815, 0.044962, -2.056002]
+ - [0.294237, 0.190392, -1.151428]
+ - [0.295998, 0.049713, -1.926914]
+ - [0.302849, 0.101813, -0.850166]
+ - [0.30488, 0.061992, -1.951992]
+ - [0.305275, 0.094204, -1.210321]
+ - [0.307046, 0.275077, -0.636107]
+ - [0.308284, 0.008158, -1.052333]
+ - [0.308872, 0.144235, -1.076364]
+ - [0.309898, -0.006989, -2.034374]
+ - [0.310175, 0.204775, -0.607731]
+ - [0.312574, 0.337755, -0.662511]
+ - [0.317866, 0.241166, -0.673337]
+ - [0.321292, -0.012756, -0.691146]
+ - [0.323212, 0.160876, -0.670415]
+ - [0.323773, -0.047149, -0.774604]
+ - [0.325134, -0.022576, -0.894267]
+ - [0.330325, 0.03964, -0.711248]
+ - [0.334238, -0.044295, -1.92629]
+ - [0.335471, -0.013958, -0.534881]
+ - [0.335697, 0.01555, -0.6398]
+ - [0.339306, -0.056817, -0.677736]
+ - [0.342964, 0.08412, -1.995768]
+ - [0.346439, 0.062804, -0.561812]
+ - [0.349173, 0.097363, -0.861792]
+ - [0.352722, 0.0181, -1.866775]
+ - [0.359909, 0.073094, -1.042531]
+ - [0.361, 0.079492, -1.880924]
+ - [0.361985, 0.31351, -0.659359]
+ - [0.363884, -0.029582, -1.977009]
+ - [0.381229, 0.068991, -0.865241]
+ - [0.385862, -0.053485, -0.676131]
+ - [0.391711, -0.034061, -0.535119]
+ - [0.407653, 0.037916, -0.710591]
+ - [0.409442, 0.091561, -1.929648]
+ - [0.418131, 0.165229, -0.681677]
+ - [0.420253, 0.337116, -0.677113]
+ - [0.423777, 0.246538, -0.685531]
+ - [0.427122, 0.006816, -0.553899]
+ - [0.428075, 0.0226, -1.798691]
+ - [0.436597, 0.021855, -1.649574]
+ - [0.441429, 0.020294, -1.622567]
+ - [0.443423, 0.133192, -0.598691]
+ - [0.444028, -0.002877, -1.564113]
+ - [0.458067, 0.250388, -0.645246]
+ - [0.470166, -0.027154, -1.507303]
+ - [0.470822, 0.028316, -1.749719]
+ - [0.471243, 0.049777, -1.616676]
+ - [0.471515, 0.02491, -1.5636]
+ - [0.472237, 0.018297, -1.600971]
+ - [0.478429, -0.003174, -1.564315]
+ - [0.484176, 0.099367, -1.778527]
+ - [0.486554, 0.030888, -1.620114]
+ - [0.487798, 0.088041, -1.69857]
+ - [0.503467, 0.052257, -1.597955]
+ - [0.529367, 0.042249, -1.540338]
+ - [0.542067, 0.099022, -1.604744]
+ - [0.561742, 0.066981, -1.554936]
+ - [0.565817, 0.007547, -1.771335]
+ - [0.56968, 0.080744, -1.775539]
+ - [0.578147, 0.04189, -1.454882]
+ - [0.586118, 0.022903, -1.535704]
+ - [0.592945, 0.074889, -1.47637]
+ - [0.594468, 0.025086, -1.536747]
+ - [0.598638, 0.06091, -1.570333]
+ - [0.611927, 0.041909, -1.473489]
+ - [0.612641, 0.045475, -1.404674]
+ - [0.618758, 0.011243, -1.6761]
+ - [0.62671, 0.058854, -1.630252]
+ - [0.634871, 0.050618, -1.590965]
+ - [0.637758, 0.032633, -1.475994]
+ - [0.638483, 0.006803, -1.625959]
+ - [0.647105, -0.003647, -1.584655]
+ - [0.67194, 0.045639, -1.492009]
+ - [0.68222, 0.001887, -1.502223]
+ - [0.682576, 0.005496, -1.407811]
diff --git a/server/gamedata/load.go b/server/gamedata/load.go
@@ -41,6 +41,11 @@ var (
Heads []PlayerHead `yaml:"heads"`
Bodies []PlayerBody `yaml:"bodies"`
}
+ CorpsePoses map[uint32]struct {
+ Mesh uint32 `yaml:"mesh"`
+ Animation uint32 `yaml:"animation"`
+ Vertices [][3]float32 `yaml:"vertices"`
+ }
BankTerminals map[uint32]struct {
Playfield uint32 `yaml:"playfield"`
Position [3]float32 `yaml:"position"`
@@ -104,6 +109,13 @@ func init() {
for index := range Monsters {
MonsterTemplates[Monsters[index].MonsterData] = &Monsters[index]
}
+ loadYAML("corpse_poses.yaml", &CorpsePoses)
+ for identity, pose := range CorpsePoses {
+ monster := MonsterTemplates[identity]
+ if monster == nil || len(monster.DeathAnimations) == 0 || monster.Mesh != pose.Mesh || monster.DeathAnimations[0] != pose.Animation || len(pose.Vertices) == 0 {
+ panic(fmt.Errorf("corpse pose does not match monster %d", identity))
+ }
+ }
loadYAML("map_coordinates.yaml", &MapCoordinates)
loadYAML("terrain_evidence.yaml", &TerrainEvidence)
loadYAML("playfields.yaml", &Playfields)
diff --git a/server/loot_test.go b/server/loot_test.go
@@ -13,6 +13,8 @@ import (
func newLootWorld(t *testing.T) (*server, *combatTestConn) {
t.Helper()
world := newTestServer(t)
+ // This protocol fixture uses an artificial height-zero origin without terrain.
+ world.terrain = nil
player := world.newCharacter()
player.position = [3]float32{}
if err := world.saveUser_locked(player); err != nil {
diff --git a/server/nano_casting.go b/server/nano_casting.go
@@ -326,7 +326,7 @@ func (server *server) advanceNanos(now time.Time) {
}
minimum, maximum := uint32(-*hit.Arguments[1].Integer), uint32(-*hit.Arguments[2].Integer)
damage = min(minimum+rand.Uint32N(maximum-minimum+1), target.health)
- victim = prepareDamage(player, target, damage, now)
+ victim = server.prepareDamage_locked(player, target, damage, now)
if damage != 0 {
server.breakNanos_locked(&victim, 385)
}
diff --git a/server/nano_control.go b/server/nano_control.go
@@ -146,7 +146,7 @@ func (server *server) breakNanos_locked(target *character, event uint32) {
}
func (server *server) prepareWeaponDamage_locked(attacker, target *character, damage uint32, now time.Time) character {
- candidate := prepareDamage(attacker, target, damage, now)
+ candidate := server.prepareDamage_locked(attacker, target, damage, now)
if damage != 0 {
server.breakNanos_locked(&candidate, 422)
}
diff --git a/server/nano_periodic.go b/server/nano_periodic.go
@@ -38,7 +38,7 @@ func (server *server) advancePeriodicNanos_locked(now time.Time, updates map[*wo
attacker = server.characters[effect.caster]
effect.ticksLeft--
effect.nextTick = effect.nextTick.Add(time.Duration(hit.TickInterval) * 10 * time.Millisecond)
- candidate = prepareDamage(attacker, &candidate, damage, now)
+ candidate = server.prepareDamage_locked(attacker, &candidate, damage, now)
if damage != 0 {
server.breakNanos_locked(&candidate, 385)
}
diff --git a/tools/client/test_corpse_slope.mjs b/tools/client/test_corpse_slope.mjs
@@ -0,0 +1,68 @@
+import assert from 'node:assert/strict';
+import fs from 'node:fs/promises';
+import {createRequire} from 'node:module';
+import {GameTest} from './game_test.mjs';
+
+const {chromium} = createRequire(import.meta.url)('playwright');
+const [url, output] = process.argv.slice(2);
+const browser = await chromium.launch({executablePath: '/usr/bin/chromium', args: [
+ '--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+let game;
+const evidence = {};
+try {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'corpse-slope', url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ const server = async () => (await page.request.get(url + '/test-state')).json();
+ await page.goto(url);
+ await game.ready();
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ evidence.initial = await server();
+ if (evidence.initial.nearbyActor) await game.click(512, 480);
+ else await game.click(...await game.pick(50000, evidence.initial.target));
+ evidence.livingPosition = game.state.actors.find(actor => actor.type === 50000 && actor.id === evidence.initial.target).position;
+ await game.key('KeyQ');
+ await game.waitFor('controlled killing blow creates a corpse', async () => (await server()).corpse);
+ await game.wait('held corpse is present', state => state.actors.some(actor => actor.type === 51050 && actor.id === evidence.initial.target));
+ evidence.dead = await server();
+ await game.wait('warm corpse retains its committed height', state => state.actors.some(actor =>
+ actor.type === 51050 && actor.id === evidence.initial.target && Math.abs(actor.position[1] - evidence.dead.position[1]) < .0001));
+ await game.save(output + '/warm');
+ if (evidence.initial.nearbyActor) {
+ assert(evidence.dead.position[1] - evidence.livingPosition[1] > 0);
+ assert(evidence.dead.position[1] - evidence.livingPosition[1] < 1, 'The living actor must be within the native pose-copy threshold');
+ } else {
+ // The held body lies left of its projected origin; use its visible torso in this fixed view.
+ await game.click(300, 360, 'right');
+ await game.wait('warm corpse loot opens', state => state.regions.some(region =>
+ region[0] === 0 && region[1] === 0 && region[2] === 178 && region[3] === 128));
+ evidence.warmLoot = await server();
+ assert.equal(evidence.warmLoot.inventory.Credits, evidence.initial.inventory.Credits + evidence.dead.credits);
+ await game.save(output + '/warm-loot');
+ }
+ await page.reload();
+ await game.ready();
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ await game.wait('replayed corpse retains its committed height', state => state.actors.some(actor =>
+ actor.type === 51050 && actor.id === evidence.initial.target && Math.abs(actor.position[1] - evidence.dead.position[1]) < .0001));
+ await game.save(output + '/reconnected');
+ if (!evidence.initial.nearbyActor) {
+ await game.click(300, 360, 'right');
+ await game.wait('corpse loot opens', state => state.regions.some(region =>
+ region[0] === 0 && region[1] === 0 && region[2] === 178 && region[3] === 128));
+ evidence.opened = await server();
+ assert.equal(evidence.opened.inventory.Credits, evidence.warmLoot.inventory.Credits);
+ assert.deepEqual(evidence.opened.position, evidence.dead.position);
+ }
+ assert.deepEqual(game.errors, []);
+ console.log(evidence.initial.nearbyActor ? 'PASS: nearby living actor cannot overwrite the committed corpse height, including replay' :
+ 'PASS: recorded slope corpse opens warm and after reconnect, with cash collected once');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ if (game) await game.save(output + '/final');
+ } finally { await browser.close(); }
+}
diff --git a/tools/data/extract_corpse_poses.py b/tools/data/extract_corpse_poses.py
@@ -0,0 +1,160 @@
+import hashlib
+import json
+import math
+import pathlib
+import struct
+import zlib
+
+import yaml
+
+import ao_database
+
+
+class DeltaStream:
+ def __init__(self, data, bits):
+ self.data = data
+ self.width = (bits + 7) // 8
+ self.mask = (1 << bits) - 1
+ self.value = 0
+ self.cursor = 0
+
+ def read(self):
+ self.value = (self.value + int.from_bytes(self.data[self.cursor:self.cursor + self.width], 'big')) & self.mask
+ self.cursor += self.width
+ assert self.cursor <= len(self.data)
+ return self.value
+
+ def floating(self):
+ return struct.unpack('<f', struct.pack('<I', self.read()))[0]
+
+
+def final_keys(payload):
+ # Source: client/game/bbr.dll/lifted-0070.c,
+ # sub_251176C0, sub_25118180 and sub_251180A0 (compressed CAT animation).
+ bits_q, bits_p = payload[60:62]
+ cursor = 62
+ streams = []
+ for bits in (32, 20, bits_q, bits_q, bits_q, bits_q, 32, bits_p, bits_p, bits_p):
+ compressed, size = struct.unpack_from('<II', payload, cursor)
+ data = zlib.decompress(payload[cursor + 8:cursor + 8 + compressed])
+ assert len(data) == size
+ streams.append(DeltaStream(data, bits))
+ cursor += 8 + compressed
+ assert cursor == len(payload)
+
+ keys = {}
+ for _ in range(struct.unpack_from('<I', payload, 56)[0]):
+ index, unknown, unsupported, count = [streams[0].read() for _ in range(4)]
+ assert count > 0
+ for _ in range(count):
+ stamp = streams[1].read()
+ assert stamp <= struct.unpack_from('<I', payload, 44)[0]
+ rotation = [stream.read() - (1 << (bits_q - 1)) for stream in streams[2:6]]
+ length = math.sqrt(sum(value * value for value in rotation))
+ rotation = [f32(value / length) for value in rotation]
+ bounds = [streams[6].floating() for _ in range(6)]
+ count = streams[0].read()
+ assert count > 0
+ for _ in range(count):
+ stamp = streams[1].read()
+ assert stamp <= struct.unpack_from('<I', payload, 44)[0]
+ position = [f32(bounds[n * 2] + stream.read() / ((1 << bits_p) - 1) *
+ (bounds[n * 2 + 1] - bounds[n * 2])) for n, stream in enumerate(streams[7:10])]
+ assert index not in keys
+ keys[index] = rotation, position
+ assert all(stream.cursor == len(stream.data) for stream in streams)
+ return keys
+
+
+def f32(value):
+ return struct.unpack('<f', struct.pack('<f', value))[0]
+
+
+def transform(point, matrix):
+ return [sum(point[i] * matrix[i * 3 + n] for i in range(3)) + matrix[9 + n] for n in range(3)]
+
+
+def held_vertices(mesh, keys):
+ # The CIR's named root starts the validated hierarchy, followed by mesh sections.
+ assert mesh.count(b'-nobone-') == 1
+ cursor = mesh.index(b'-nobone-') - 8
+ count = struct.unpack_from('<I', mesh, cursor)[0]
+ assert set(keys) == set(range(count))
+ cursor += 4
+ hierarchy = []
+ for _ in range(count):
+ size = struct.unpack_from('<I', mesh, cursor)[0]
+ cursor += 4 + size
+ scale, children = struct.unpack_from('<fI', mesh, cursor)
+ cursor += 8
+ hierarchy.append((scale, struct.unpack_from('<' + 'I' * children, mesh, cursor)))
+ cursor += children * 4
+
+ # Row-vector hierarchy composition with float32 rounding.
+ # Source: client/game/bbr.dll/lifted-0061.c, sub_250F5FF0/sub_250F6070.
+ matrices = {}
+
+ def compose(index, parent, scale):
+ assert index not in matrices
+ x, y, z, w = keys[index][0]
+ rotation = [1-2*y*y-2*z*z, 2*x*y+2*z*w, 2*x*z-2*y*w,
+ 2*x*y-2*z*w, 1-2*x*x-2*z*z, 2*y*z+2*x*w,
+ 2*x*z+2*y*w, 2*y*z-2*x*w, 1-2*x*x-2*y*y]
+ matrix = [f32(sum(rotation[r*3+k] * parent[k*3+c] for k in range(3))) for r in range(3) for c in range(3)]
+ matrix += [f32(value) for value in transform([f32(value * scale) for value in keys[index][1]], parent)]
+ matrices[index] = matrix
+ for child in hierarchy[index][1]:
+ compose(child, matrix, f32(scale * hierarchy[index][0]))
+
+ compose(0, [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], 1)
+ assert len(matrices) == count
+ sections = struct.unpack_from('<I', mesh, cursor)[0]
+ cursor += 4
+ points = set()
+ for _ in range(sections):
+ size = struct.unpack_from('<I', mesh, cursor)[0]
+ cursor += 4 + size
+ parts = struct.unpack_from('<I', mesh, cursor)[0]
+ cursor += 4
+ for _ in range(parts):
+ material, vertices = struct.unpack_from('<II', mesh, cursor)
+ cursor += 8
+ for _ in range(vertices):
+ values = struct.unpack_from('<14f2If', mesh, cursor)
+ cursor += 68
+ first, second, weight = values[14:]
+ assert 0 <= weight <= 1 and first < count and second < count
+ point = transform(values[:3], matrices[first])
+ if weight <= .99:
+ other = transform(values[3:6], matrices[second])
+ point = [point[n] * weight + other[n] * (1 - weight) for n in range(3)]
+ points.add(tuple(round(f32(value), 6) for value in point))
+ indices = struct.unpack_from('<I', mesh, cursor)[0]
+ cursor += 4
+ assert max(struct.unpack_from('<' + 'H' * indices, mesh, cursor)) < vertices
+ cursor += indices * 2
+ assert points
+ return sorted(points)
+
+
+# These two held poses were compared against the original native sampler and skeleton.
+assert pathlib.Path('anarchy-vanilla-14.9.1/version.id').read_text().strip() == '14.9.1'
+database = ao_database.Database('anarchy-vanilla-14.9.1')
+monsters = yaml.safe_load(pathlib.Path('server/gamedata/monsters.yaml').read_text())
+selected = {17655, 30369}
+lines = ['# Generated by tools/data/extract_corpse_poses.py from original 14.9.1 resources.',
+ '# Held-pose vertices at unit scale; this is geometry, not an original server placement rule.']
+for monster in monsters:
+ if monster['monster_data'] not in selected:
+ continue
+ mesh = database.read(1010002, monster['mesh'])
+ animation = database.read(1010003, monster['death_animations'][0])
+ points = held_vertices(mesh, final_keys(animation))
+ lines += [f"{monster['monster_data']}:", f" mesh: {monster['mesh']}",
+ f" animation: {monster['death_animations'][0]}",
+ f" # Mesh SHA-256: {hashlib.sha256(mesh).hexdigest()}",
+ f" # Animation SHA-256: {hashlib.sha256(animation).hexdigest()}", ' vertices:']
+ lines += [' - ' + json.dumps(point) for point in points]
+ print(monster['monster_data'], len(points))
+database.close()
+pathlib.Path('server/gamedata/corpse_poses.yaml').write_text('\n'.join(lines) + '\n')