aorecomp

Anarchy Online classic in the browser

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


commit d6d0fbb0f70e55a92b8ac05d959c5eded784ac77
parent 1fb7b0e84d2d8400be5e9b4947758fef2fc39e9c
Author: anon <anon@example.com>
Date:   Sun, 25 Oct 2026 11:35:40 +0000

Return weapon special actions during established fights

Diffstat:
MTODO.md | 12+++++++++++-
Mdocs/fast-attack.md | 4+++-
Mdocs/fling-shot.md | 10++++++----
Adocs/weapon-special-animation.md | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/fast_attack_test.go | 4++++
Mserver/fling_crash_test.go | 12++++++++----
Mserver/fling_shot_test.go | 4++++
Mserver/weapon_special.go | 5+++++
Aserver/weapon_special_animation_test.go | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 232 insertions(+), 10 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -286,11 +286,17 @@ Normal-hit additions and weapon-range modifiers are described in combat-start behavior. Check: period evidence and native tests distinguish independent special use from normal attacks; invalid uses neither damage a target nor create a lock. Do not import the 15.5.5 ammo/evade changes. + Established matching fights now return the native special action to owner + and visible observers before result/lock. Idle notification trials left + skill147 queued with no fight target on both clients; resolve canonical + startup/cleanup before extending this branch. Include target changes, + attack/recharge phases, casting, stopping and target death in the remaining + presentation checks. See [special notifications](docs/weapon-special-animation.md). - [x] Crash-test Fling's current damage/cooldown/corpse transaction. Check: interrupt a shot before and after database commit, including a killing hit, and recover exactly one outcome with matching cooldown and corpse state. Fling's lock, NPC HP, contributions and corpse/respawn state commit together. - Real subprocess kills at SQLite's commit hook and the first native-result + Real subprocess kills at SQLite's commit hook and the first native-action write cover living/killing hits and repeated requests after recovery. A WASM killing shot followed by SIGKILL and restart retained the native corpse and ownership. See `server/fling_crash_test.go` and [Fling Shot](docs/fling-shot.md). @@ -1426,6 +1432,10 @@ and server restarts. Turn every reproduced bug into a focused regression test. applies absolute remote HP without an animation guard, so it shares the unresolved healing/hit ordering problem. Verify the server, owner and observer through impact and subsequent regeneration; see [inspection](docs/character-info.md). + The special-animation smoke also captured Fast target HP54/51 on two clients + at different times during NPC retaliation. Include special animations and + each client's recovery phase in this audit; do not treat matching result + packets as proof of matching displayed HP. - [ ] Audit ranged ammunition and reload. Cover empty/partial/full magazines, matching/wrong/missing ammunition, insufficient stacks, repeated reloads, reload during each attack phase, failed saves and round conservation across diff --git a/docs/fast-attack.md b/docs/fast-attack.md @@ -76,7 +76,9 @@ rating, AC, overequipping and damage additions. The precise special distribution remains open; the shared [critical selection and arithmetic](critical-hits.md) are provisional. The action preserves existing normal-attack/recharge and nano-cast clocks. It triggers NPC retaliation and contribution/corpse/respawn handling, without starting the owner's -normal attack. Historical start/animation/interruption rules remain open. +normal attack. Established matching fights now receive the native animation +notification before result/lock; [idle startup and presentation limits](weapon-special-animation.md) +remain open. Damage and its skill lock use the existing atomic SQLite outcome transaction before publishing live state or feedback. Repeated requests cannot bypass it; diff --git a/docs/fling-shot.md b/docs/fling-shot.md @@ -87,8 +87,10 @@ critical damage, attack rating, AC, overequipping and damage modifiers. The [critical chance and damage policies](critical-hits.md) are provisional. Fling-specific damage distribution and original critical selection remain open. It does not reset an existing normal attack/recharge or nano cast. It triggers normal NPC retaliation and the existing contribution, corpse and -respawn lifecycle. Starting the player's normal attack automatically and -special firing animation/request forwarding remain unverified. +respawn lifecycle. An established matching fight now returns the native special +action before result/lock, including to the owner. Automatic normal attack +startup and the remaining [presentation rules](weapon-special-animation.md) +remain open. `skill_locks` stores player, skill and an absolute deadline. Repeated requests, swapping and reconnecting cannot create another Fling before that @@ -110,9 +112,9 @@ forced process termination immediately around commit is covered below. `server/fling_crash_test.go` starts real child processes with disposable SQLite databases for both Fling and Fast Attack. For controlled critical hits against surviving and killed targets, the parent sends a forced kill -at either SQLite's commit hook or the first native special-result write. The +at either SQLite's commit hook or the first native special-action write. The commit-hook stop occurs after the transaction's writes and before commit; -the output stop occurs after commit and before any result bytes are published. +the output stop occurs after commit and before any action bytes are published. The test does not add production fault switches or change transaction code. Recovery before commit retains the original HP, ammunition and empty cooldown, diff --git a/docs/weapon-special-animation.md b/docs/weapon-special-animation.md @@ -0,0 +1,97 @@ +# Weapon special notifications + +Accepted Fast Attack147 and Fling Shot150 now return CharSecSpecAttackIIR +`0x51492120` to the owner and visible observers when the player is already +fighting the requested target. The action precedes SpecialAttackInfo and the +owner's skill lock. All messages follow the existing atomic outcome commit. +Duplicate, invalid and failed requests publish no action. + +This is a deliberately bounded part of the special implementation. Idle +startup, target changes and casting presentation still need their historical +rules established. The handler preserves existing server attack, recharge and +cast clocks. + +## Original client contract + +Original14.9.1 `kkr.dll` has SHA256 +`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`. +The retained evidence and complete exports are in +`local/special-animation-research/native/README.md`. + +- Sender1002c090 constructs the IIR through1007d8e0, then calls + SendIIRToObservers. The original `llr.dll` chain1001a610 ->1001a300 + ->1001dc20 ->10024450 serializes and sends it without local activation. + The owner needs the returned notification too. +- Activation1007da30 ->10078a40 queues one skill if the queue is empty and + the skill is unlocked. It ignores the payload target and uses the actor's + existing combat target later. Applying the skill lock first suppresses it. +- Fight visual10086390 ->1007b2d0 selects the special animation through + 1007adc0 ->1007b260 ->100504d0. Fast uses token0x19 and Fling0x1c. + Holder10079700 consumes the queued skill and dispatches item event0. + That dispatch can contain authored effects; it is not a second authoritative + server hit calculation. +- SpecialAttackInfo100b2cb0 separately applies the supplied damage once, + named feedback, ammunition and death. It does not queue the special animation. + +No original server capture establishes the total action/result/lock ordering. +Action before lock is required by activation; action -> result -> lock is the +current publication order. + +## Idle and target limits + +The notification does not install a combat target or start ordinary attacks. +Stop10079250 clears the special queue. Starting10078fc0 from idle does not +unconditionally clear it; native selection changes do not retarget its entry. + +An exploratory two-client WASM run confirmed the idle hazard: a15-point Fast +Attack changed both clients' target health to85, but both attacker copies +retained queue count1/skill147 with holder state1 and target0. Returning the +notification for every accepted idle special would leave work for a later +fight. The server therefore sends it only for an established matching fight. +It does not introduce an unverified automatic attack or client timer reset. + +Period [October2002 two-computer observations](https://forums-archive.anarchy-online.com/showthread.php?56578-Question-regarding-weapon-speeds=) +describe general weapon damage preceding animation. They do not establish +Fast/Fling idle startup or exact casting-phase behavior. The source ledger in +`local/special-animation-research/sources/` records those limits. + +## Verification + +`server/weapon_special_animation_test.go` checks exact owner/observer action +bytes before result/lock, duplicate suppression, unavailable observers and a +different current fight target. Existing Fast/Fling tests cover idle outcomes, +invalid uses and unchanged attack/cast clocks. Transaction-failure cases also +exercise an existing fight, where a successful outcome would send the action. + +`server/fling_crash_test.go` kills real processes before commit or at the first +post-commit action write, for living and killing Fast/Fling outcomes. Reopen +and duplicate retries must recover exactly one damage, lock, contribution, +corpse and progression outcome before even the animation can be published. + +Two GPU WASM clients using the published bundle received one11-point Fling +and one6-point Fast result, with matching notifications before result/lock. +Read-only sampling observed each skill queue once, its consumption and authored +mesh resources30980/10181 on both clients. Repeated L/N sent no second request; +stopping cleared the queues. A combat weapon-swap rejection preserved both +instances; after ending combat, a normal inventory/equipment round trip also +preserved their identities, counts and remaining ammunition. The final run had +no page errors, unsupported adapters or renderer exits. + +Fling's later native target-HP captures both read57. Fast's non-simultaneous +captures read54/51 while the NPC still retaliated. Native recovery prediction +and the existing healing/hit-order audit remain open; this run does not prove +general HP agreement. Ordinary nonlethal damage remains on checkpoints, so its +intermediate SQL snapshots can lag live HP. See [NPC recovery](npc-regeneration.md). + +Validation passed: full Go suite733.402s (gamedata7.570s), final browser/special +checks79.754s, focused race checks107.991s, and vet. One crash child exceeded its +two-minute startup deadline while the initial race suite overlapped builds; +that exact case passed alone187.497s including its parent initialization. +The regular full suite passed all eight forced-termination cases. Native +graphics/surface/device checks and the WASM device suite also passed, including +12 projective-transform cases. Captures and the verifier are in +`local/special-animation-smoke/`; the published uncompressed module SHA256 is +`d27a2f9f0fb7db8d76259767579f77bfa7182cbf01f6ff91efca88c660bbf703`. +Both test contexts were closed; owned characters/items and their NPC references +were removed with foreign-key/integrity checks. Existing players8/24 and +unrelated rows were preserved. The single preview retains its default ports. diff --git a/server/fast_attack_test.go b/server/fast_attack_test.go @@ -179,6 +179,10 @@ func TestFastAttackFailedOutcomePublishesNothingAndRollsBackItsLock(t *testing.T "CREATE TRIGGER fail_special BEFORE INSERT ON npc_damage_contributors BEGIN SELECT RAISE(FAIL, 'test contribution failure'); END", } { world, conn := newFastAttackWorld(t) + if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { + t.Fatal(err) + } + conn.packets = nil if _, err := world.db.Exec(statement); err != nil { t.Fatal(err) } diff --git a/server/fling_crash_test.go b/server/fling_crash_test.go @@ -57,6 +57,10 @@ func runFlingCrashChild(t *testing.T, mode string) { if _, err := world.saveDeath_locked(target, time.Now()); err != nil { t.Fatal(err) } + if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { + t.Fatal(err) + } + output.packets = nil // Notify the parent at the transaction boundary, then await its forced kill. directory, err := os.Getwd() @@ -189,10 +193,10 @@ func TestFlingShotProcessCrashRecovery(t *testing.T) { t.Fatalf("uncommitted shot survived the process kill: %+v", target) } } else { - if len(checkpoint.Packet) < 57 || binary.BigEndian.Uint32(checkpoint.Packet[16:20]) != 0x754f1115 { - t.Fatalf("first post-commit output was not the native special result: %x", checkpoint.Packet) + if len(checkpoint.Packet) != 44 || !bytes.Equal(checkpoint.Packet[16:], targetPacket(append([]byte(nil), request...))[16:]) { + t.Fatalf("first post-commit output was not the native special action: %x", checkpoint.Packet) } - damage := binary.BigEndian.Uint32(checkpoint.Packet[33:37]) + damage := initialHealth - target.health expected := uint32(24) if skill == 147 { expected = 25 @@ -201,7 +205,7 @@ func TestFlingShotProcessCrashRecovery(t *testing.T) { t.Fatal("crash fixture did not resolve the controlled critical", damage) } if damage == 0 || damage > initialHealth || target.health != initialHealth-damage || !player.skillLocks[skill].After(time.Now()) || - binary.BigEndian.Uint32(checkpoint.Packet[49:53]) != skill || + binary.BigEndian.Uint32(checkpoint.Packet[37:41]) != skill || initialHealth != 1 && target.damageContributors[damageContributor{player: 1}] != damage { t.Fatalf("committed shot was lost or partially recovered: HP=%d damage=%d lock=%v", target.health, damage, player.skillLocks) } diff --git a/server/fling_shot_test.go b/server/fling_shot_test.go @@ -192,6 +192,10 @@ func TestFlingShotMalformedLengthReturnsError(t *testing.T) { func TestFlingShotSaveFailureDoesNotPublishOrDamage(t *testing.T) { world, conn := newRangedWorld(t) + if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { + t.Fatal(err) + } + conn.packets = nil if _, err := world.db.Exec("CREATE TRIGGER fail_fling BEFORE INSERT ON skill_locks BEGIN SELECT RAISE(FAIL, 'test lock failure'); END"); err != nil { t.Fatal(err) } diff --git a/server/weapon_special.go b/server/weapon_special.go @@ -68,6 +68,11 @@ func (server *server) handleWeaponSpecial(client *worldClient, body []byte) erro previous := *target *target = candidate updates := make(map[*worldClient][][]byte) + // Native 10078a40 uses the current fight target and checks the skill lock. + // Idle startup remains open; do not leave a special queued for a later fight. + if player.fighting == target.id { + server.queueCombat_locked(updates, player, target, n3Packet(0x51492120, 50000, player.id, body[16:28])) + } // Pre-15.5.5 specials do not deduct ammunition or use defensive hit checks. var result []byte death := uint32(0) diff --git a/server/weapon_special_animation_test.go b/server/weapon_special_animation_test.go @@ -0,0 +1,94 @@ +package main + +import ( + "bytes" + "encoding/binary" + "testing" +) + +func TestWeaponSpecialQueuesActionBeforeResultAndLockOnlyForVisibleClients(t *testing.T) { + for _, name := range []string{"fast", "fling"} { + t.Run(name, func(t *testing.T) { + var world *server + var owner *combatTestConn + var request []byte + if name == "fast" { + world, owner = newFastAttackWorld(t) + request = fastAttackRequest(1, 1000000) + } else { + world, owner = newRangedWorld(t) + request = flingShotRequest(1, 1000000) + } + if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { + t.Fatal(err) + } + owner.packets = nil + observers := make([]*combatTestConn, 5) + for index := range observers { + id := uint32(index + 2) + observers[index] = &combatTestConn{} + world.characters[id] = &character{id: id, playfield: 950, health: 100} + world.clients[id] = &worldClient{id: id, conn: observers[index], ready: true, target: true, npcs: map[uint32]bool{1000000: true}} + } + world.clients[3].loading = true + delete(world.clients[4].npcs, 1000000) + world.characters[5].playfield = 705 + world.clients[6].ready = false + expected := targetPacket(append([]byte(nil), request...)) + + for range 2 { + if err := world.handleWeaponSpecial(world.clients[1], request[20:]); err != nil { + t.Fatal(err) + } + } + + for _, output := range []*combatTestConn{owner, observers[0]} { + if len(output.packets) < 2 || !bytes.Equal(output.packets[0][16:], expected[16:]) || + binary.BigEndian.Uint32(output.packets[1][16:20]) != 0x754f1115 { + t.Fatalf("missing ordered special action and result: %x", output.packets) + } + actions := 0 + for _, packet := range output.packets { + if binary.BigEndian.Uint32(packet[16:20]) == 0x51492120 { + actions++ + } + } + if actions != 1 { + t.Fatal("duplicate request replayed a special action") + } + } + if binary.BigEndian.Uint32(owner.packets[2][29:33]) != 170 { + t.Fatal("skill lock preceded the special action") + } + for _, output := range observers[1:] { + if len(output.packets) != 0 { + t.Fatalf("special reached an unavailable observer: %x", output.packets) + } + } + }) + } +} + +func TestWeaponSpecialDoesNotQueueAnActionForAnotherCombatTarget(t *testing.T) { + world, output := newFastAttackWorld(t) + player := world.characters[1] + world.characters[1000001] = &character{id: 1000001, npc: true, appearance: 229, playfield: 950, health: 100} + world.clients[1].npcs[1000001] = true + if err := world.handleCombat(world.clients[1], attackPacket(1, 1000001)[20:]); err != nil { + t.Fatal(err) + } + attack, recharge := player.nextAttack, player.rechargeUntil + output.packets = nil + + err := world.handleWeaponSpecial(world.clients[1], fastAttackRequest(1, 1000000)[20:]) + + if err != nil || world.characters[1000000].health >= 1000 || player.fighting != 1000001 || + player.nextAttack != attack || player.rechargeUntil != recharge { + t.Fatal("special changed the existing fight", err) + } + for _, packet := range output.packets { + if binary.BigEndian.Uint32(packet[16:20]) == 0x51492120 { + t.Fatal("special queued an action against the wrong native fight target") + } + } +}