aorecomp

Anarchy Online classic in the browser

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


commit 5c77dadf28e5584cce6040a526c4c2e8a9d5c8df
parent d0b1a280cbe22aecf71c03621450eac7e26409cf
Author: anon <anon@example.com>
Date:   Thu, 22 Oct 2026 05:29:09 +0000

Use creature animation keys for NPC deaths

Diffstat:
Adocs/corpse-loot.md | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/protocol.md | 13+++++++++++--
Mserver/combat.go | 2+-
Mserver/combat_test.go | 4++--
4 files changed, 80 insertions(+), 5 deletions(-)

diff --git a/docs/corpse-loot.md b/docs/corpse-loot.md @@ -0,0 +1,66 @@ +# Corpse and loot protocol research + +This is partial 14.9.1 protocol recovery, not implemented server loot support. +An isolated WASM fixture displays a named corpse's loot window with QL 1 +Monster Parts. Its replacement corpse geometry remains invisible, so opening +the corpse through normal world interaction still needs verification. + +## Corpse creation + +`CorpseFullUpdateIIR_t` (`0x4f474e05`) uses outer identity type 51050 and +version 7. The native reader is `kkr.dll` `sub_360AF9C0`; activation is +`sub_360AFCB0`. The original character identity appears inside the body. +The corpse is a separate object, and activation hides the original actor. +Prerequisite `sub_360AFBC0` waits for the original actor's death state. The +creature must receive the correct death animation key 6000, as described in +[the combat protocol](protocol.md), before this transition can finish. + +The decoded body has this order; integers are network-order uint32 unless +specified otherwise: + +1. Corpse version 7. +2. SimpleItem version 11, parent identity, and, for parent type zero, position + XYZ and quaternion XYZW as float32 values. +3. Playfield, auxiliary identity, then two individual page/placement bytes. +4. Stat-pair list with encoded length `(count + 1) * 1009`, followed by pairs. +5. Extra-data byte length and raw bytes. A NUL-terminated name here supplies + `Remains of Loot Target` in the verified fixture. +6. Lockable version 2, lock field, encoded identity list; Chest version 3. +7. Encoded spell/effect list, original actor identity, encoded ClothData list. +8. Additional-texture-list presence integer and optional texture list. +9. Team, loot mode, looter identity, XP reward count and optional reward entries. + +The SimpleItem reader and activation are `sub_360B2440` and `sub_360B2830`. +The raw name is applied by `sub_36090D90` and returned by `sub_36090DF0`. +An empty name falls back to template lookup and can produce `NameMissing`. +ClothData is clothing data, not a replacement for the corpse's base mesh. +The appearance stats and native world interaction remain unresolved; merely +sending the living creature's mesh stat does not establish a visible corpse. + +## Contents and pickup + +`InventoryUpdateIIR_t` (`0x4e536976`) starts directly with the encoded item +list, using `(count + 1) * 1009`. There is no slot-count prefix in this client. +Each 32-byte entry is slot, uint16 flags, uint16 count, item identity, low/high +templates, quality and auxiliary value. The verified individual-item entry uses +flags 2, count 1 and auxiliary zero. The body ends with corpse identity, zero +and one; the final one opens the native loot window. The outer identity is +the receiving player. Reader `sub_360B0C20`, activation `sub_360B0CD0` and +writer `sub_360B0C80` establish this layout. + +The fixture item is template 42640, QL 1, native type 51005: Monster Parts. +Its icon and native details window were verified. This does not establish a +historical drop rate or a production loot table. + +Left-clicking the displayed item emits `ContainerAddItem` (`0x47537a24`): +source identity `(107, 0)`, target player identity `(50000, playerID)`, and +destination 111, the next-free-slot sentinel. The request contains no corpse +identity. A server implementation must retain the session's opened corpse, +validate ownership and availability, and atomically persist the transfer before +acknowledging it. Pickup acknowledgement, persistence, concurrent requests and +loot rights have not yet been implemented or verified. + +Maintained native source is under `client/game/kkr.dll/`. The functions above +use the rebased image addresses; subtract `0x26000000` for original image +addresses. Local REA evidence bundles and WASM captures are retained under the +ignored `local/loot-smoke/` directory. diff --git a/docs/protocol.md b/docs/protocol.md @@ -606,9 +606,18 @@ Reader `0x1007d5c0` reads the action and two identities; activation Action 99 reaches `0x10070327`, sets visual flag `0x10`, writes the final body word to stat 387 (`DieAnim`), and refreshes the visual state. The death state constructor `0x10085d60` reads that stat at `0x10085ecc` and requests -the animation. The animation registry `0x100dda40` maps key 500 to +the animation. The human animation registry `0x100dda40` maps key 500 to `die-knees` and key 503 to `die-shot` (`0x100de20c` and `0x100de2a2`). -The local implementation sends 500 for players and 503 for NPCs after +Creatures use a separate MonsterData lookup through `0x10050850` and +`0x1008a770`. The Leet's MonsterData record 17655 maps key 6000 to resource +18107, `cutecreature_die-pain_01_01.ani`. Key 6000 is present in 287 of the +290 shipped MonsterData records; the exceptions are a test monster and two +meshless control-tower records. A native WASM trace of `0x10085ed6` confirmed +that key 501 returns no animation while key 6000 returns an animation handle +and visibly plays the Leet's death. A missing animation also prevents a pending +CorpseFullUpdate from activating normally. + +The local implementation sends 500 for players and 6000 for NPCs after StopFight has flushed the killing hit. It also supplies the corpse action after a dead character's spawn for an observer joining later. Health zero and AttackInfo's death reason establish health/text but do not select this diff --git a/server/combat.go b/server/combat.go @@ -293,7 +293,7 @@ func deathPacket(character *character) []byte { // kkr.dll 0x10070327: action 99 sets the corpse visual flag and death animation. animation := uint32(500) if character.npc { - animation = 503 + animation = 6000 } var body []byte for _, value := range []uint32{99, 0, 0, 0, animation} { diff --git a/server/combat_test.go b/server/combat_test.go @@ -161,7 +161,7 @@ func TestCombatKillingHitClampsHealthAndCancelsEveryAttacker(t *testing.T) { if hex.EncodeToString(conn.packets[1][29:57]) != "00000003ffffffff000000000000c350000f42400000000400000004" { t.Fatalf("killing hit: %x", conn.packets[1]) } - if hex.EncodeToString(conn.packets[len(conn.packets)-1][29:49]) != "00000063000000000000000000000000000001f7" { + if hex.EncodeToString(conn.packets[len(conn.packets)-1][29:49]) != "0000006300000000000000000000000000001770" { t.Fatal("NPC death animation was not announced after the final hit") } } @@ -268,7 +268,7 @@ func TestCombatLateObserverSeesDeadNPC(t *testing.T) { world.advanceNPCs(time.Now()) - if len(conn.packets) != 2 || binary.BigEndian.Uint32(conn.packets[0][16:20]) != 0x271b3a6b || hex.EncodeToString(conn.packets[1][29:49]) != "00000063000000000000000000000000000001f7" { + if len(conn.packets) != 2 || binary.BigEndian.Uint32(conn.packets[0][16:20]) != 0x271b3a6b || hex.EncodeToString(conn.packets[1][29:49]) != "0000006300000000000000000000000000001770" { t.Fatalf("late observer did not receive the NPC corpse: %x", conn.packets) } }