aorecomp

Anarchy Online classic in the browser

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


docs/ranged-weapons.md (10653B)


Conventional weapons and ammunition

The first verified example is the exact QL 1 Rusty OT M-10 Flechette Pistol, template 123742, with QL 1 Bullets, template 21605. It occupies the right hand. The catalog also permits the left hand; dual wield and left-hand scheduling remain separate TODOs. Unsupported wear requests receive a source-slot reply so the native client can restore the inventory item.

Main-hand weapon admission and ammunition now use shared catalog rules; starter and catalog weapons describes the scope and unlimited-ammunition contract. The exact-QL1 example above is a regression fixture.

Original 100-round ammunition packages now have a provisional basic-weapon and Budget-shop supplier subset. See ammunition supply for the original package contracts, purchase checks and stock-policy limits.

Catalog rules

The embedded 14.9.1 records provide:

Property Pistol value
Damage 3-12 projectile, critical bonus 12
Attack / recharge / equip delay 1.25 / 1.25 / 1.50 seconds
Range 22 meters before native actor-extent adjustments
Ammunition / capacity Bullets (stat 420 = 2), 20 rounds
Attack / defense skill 100% Pistol / 100% Dodge-Ranged
Wield requirements Pistol > 5 and Fling Shot > 5

The pistol uses Ranged Initiative and the existing aggression/timing rules. Its attack rating uses Pistol with 60% Agility and 40% Sense trickle-down; Fling Shot uses Agility. The requirement's raw value 5 is also used for the native overequipping calculation. Critical hits and misses remain open. Fling Shot uses the shared special prototype.

The AOPPA source mirror provides the stat and ammo enumeration names (output-xml.map), record interpretation (parser.cc) and requirement operators (output-xml.cc). The selected game's records, rather than the mirror's later expansion data, supply these values.

Native protocol

The original 14.9.1 kkr.dll (SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0) provides the reload contract:

The native WeaponItem stat array can be inspected without executing guest methods: subtract 0x8c from its registered dynel pointer, follow [base+4] then [container+4], and read signed DWORD index 26. Constructor sub_360ABA20 in client/game/kkr.dll/lifted-0051.c establishes the subobject offset; getter sub_36003000 in lifted-0000.c establishes the array access.

CharacterAction 106 closes the bank proxy (57005, owner). It does not reload. The original global reload hotkey producer remains unverified; only the native ammo-on-weapon request above is implemented.

Server policy and durability

The original server's transfer policy was not recovered. This implementation transfers as many available rounds as fit from the named ammunition stack. Reloading a full weapon, missing/wrong ammunition, a foreign item, an invalid session, or overlapping equipment/nano/reload work cannot transfer rounds.

Loaded ammunition is an items.ammo scalar. Each shot commits its one-round debit before damage or AttackInfo is published. A killing blow saves NPC HP, solo/team corpse rights, cleared contributions and corpse/respawn deadlines in that same transaction. Character, corpse, contribution or COMMIT failure leaves both ammunition caches and the live target unchanged and publishes no hit/death. Persisted NPC outcomes also reserve their identity in the world allocator, so killing a fresh respawn before its checkpoint cannot leave that ID reusable. Nonlethal shots update only the weapon's ammunition row; simulation damage, contributions and movement remain on periodic checkpoints. Shared detached damage preparation also keeps nano and Fling outcomes isolated until their applicable save succeeds.

Reload commits loaded rounds, source-stack reduction/removal and the weapon deadline in one transaction before publishing ACK/Reload. Failed saves leave the live state unchanged. Equipment moves, admin assignment, backpacks, reclaim and restart preserve the instance's loaded count. Other item types cannot have nonzero ammunition; a finite-ammo weapon cannot exceed its own catalog capacity. There are no schema migrations for earlier development databases.

Automatic reload, multiple-stack reload, left-hand weapons, cancellation policy and original-server timing beyond the recovered native timer remain open. The native reply changes the displayed loaded count at reload start; firing remains blocked until completion.

Verification

server/ranged_test.go covers deadline boundaries, Ranged Initiative, shared AttackInfo counts, empty magazines, restart, full/partial reload, stack removal, repeated explicit requests, both weapon identity forms, interrupted attack and recharge, invalid requests, failed shot/reload transactions, wield requirements and ammunition preservation through equipment changes. The equipment regression also verifies corrective replies for unsupported wear slots and unchanged durable inventory. These focused checks do not replace the broader gameplay audits in feature backlog.

server/ranged_outcome_test.go additionally exercises failures at the character, corpse, contribution and deferred-COMMIT stages; successful solo/team deaths; one-round consumption under concurrent competing shooters; exact native hit counts; and cache/deadline restoration after database reopen. A write-count regression proves a nonlethal shot performs one ammunition update and no character/NPC updates, while a later checkpoint retains damage and the debit. The fresh-respawn regression kills a new actor before its ordinary checkpoint and verifies that both its outcome and its identity reservation survive reopen.

The atomic-outcome regression initially reproduced a committed round followed by a failed corpse save. After the fix, the complete server suite, focused weapon/nano/loot race checks and final ranged cases passed. Static analyzers passed with stdversion disabled for the existing Go 1.24 declaration versus Go 1.25 test-API mismatch.

Two GPU/OpenGL WASM clients exercised an injected corpse-write failure on the ordinary HTTPS preview. Both native weapon objects retained 18 loaded rounds, the Leet retained 100 HP, and no AttackInfo or corpse was published. After removing the trigger, a native retry delivered one 100-damage hit with 17 rounds to both clients and immediately saved team 15's corpse rights and deadlines. A production-server restart and fresh native clients restored 17 rounds in both weapon objects. This used no server build overlay or client changes. Native high-skill character values and creature placement were test fixtures; they do not establish ordinary damage or spawn rules.

The failure trigger, team, profiles, ammunition and creature state were restored; the fixture respawn was removed and all original 192 item records/placements were conserved. Owned browsers were closed, leaving one normal HTTPS preview on 8443. Packet assertions, native probes, test logs and remaining scope are retained in local/ranged-outcome-research/verification.json.

The two-client WASM check uses the one normal HTTPS development server. Native controls equipped the pistol, hit a real profiled Leet from outside melee range, and reduced the magazine from 3 to 2. Reconnecting after a server restart kept 2 loaded rounds and the five-round source stack. Picking up the visible Bullets stack and right-clicking the worn pistol sent command 5 with target (101,6); the source stack vanished, native stat 26 and SQLite both became 7, and chat reported Reloading followed by Reloading completed. The manual controls checks exposed the wear-slot request form; an identity-only unit test had missed it. No adapter or page errors occurred in those runs.

After that reload, seven native projectile hits dealt 7, 10, 9, 7, 5, 8 and 10 damage to the real Leet. Both clients' native target HP became 44 from 100; both weapon objects and SQLite reached zero loaded rounds, with no remaining ammunition stack. A displayed shot was counted only with its damage result and durable round debit. An empty-magazine retry left the native and durable loaded counts at zero and produced no further projectile damage. Both clients continued to agree on target HP as the NPC regenerated. A second normal-server restart and WASM reconnect restored the empty weapon with native stat 26 still zero and no replacement ammunition stack.

The earlier disappearing-equipment report is still an open regression audit. The missing reply for unsupported slots is reproduced by a server test, but has not established the cause of that historical player report. Metaplast helmets are now supported at both catalog endpoints. The unsupported wear regression uses Basic Flowers Tech Armor Helmet 85535 and native head destination 18. Explicit pickup/place needs a stronger correction than the auto-equip check: the original client skips a same-slot acknowledgement and can hide the dragged icon. The inventory correction and complete Metaplast checks document its reproduction and repair.