aorecomp

Anarchy Online classic in the browser

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


docs/combat-client-state-machine.md (23191B)


14.9.1 combat client state machine

This records what the shipped client computes, requests, and displays. It is not the missing Funcom server implementation. A server can reproduce these contracts without pretending that animation timers determine authoritative hit rolls. Related findings are in combat-rules.md, combat-client-stats.md, and combat-client-protocol.md.

Target, method, and coverage

Target: anarchy-vanilla-14.9.1/kkr.dll, SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0. Addresses below are original virtual addresses based at 0x10000000. Matching generated C in client/game/kkr.dll/ is relocated to 0x36000000; subtract 0x26000000 to compare its instruction comments with these addresses. REA uses Ghidra 12.1.2. Pseudocode is decompiler output, not original source. Important x87 rounding, flag transitions, and range branches were also read in assembly. There was no live original-server traffic or original-server execution in this investigation.

Coverage checklist:

Question Status Boundary
Character/holder/weapon/timer object links Answered Relevant fields and vtables below
Timer initialization, soft cap, AggDef, conversion Answered Client clock only
Startup random offset Answered Exact client arithmetic, server timing unknown
Attack/recharge phases, shared scheduler Answered Including flag tests, ordering and discarded overshoot
UI timer events Answered Categories and show/hide/start events; widget drawing outside scope
Attack request, acknowledgement, stop Answered Holder state changes and result queue
Dual wield and unarmed binding Partial Binding/requirements recovered; MA-to-QL server policy unknown
Range and physical extent computation Answered Client UI/special checks, not ordinary server hit validation
Line of sight and movement/casting interruptions Partial Concrete client branches; original server checks unknown
Reload and interrupting shared attack timer Answered Client completion and ammo fields; server inventory policy unknown
Damage/critical presentation versus authoritative damage Answered Client queue consumes server supplied damage/result
Death and recovery visual state Partial Stops fighting and runs death state; reclaim/respawn server rules unknown

The call graph was followed from public attack/stop requests, the holder vtable, shared timer callers, received hit results, the fight visual state's update, and equipment/unarmed binding. This is a bounded combat-state investigation, not a claim that every indirect callback or every unrelated character-state branch has been recovered.

SimpleChar constructor 0x1006cc80 allocates these helpers:

Character offset Meaning Constructor
+0xe4 Stat interface subobject, not a pointer to an independent stat interface Character vtable
+0x128 Local player byte Set during client character selection
+0x154 Skill/stat helper 0x10073500
+0x16c WeaponHolder_t * 0x100783e0, allocation 0x7c
+0x174 Animation/character-state controller 0x1004fd60, allocation 0xcc
+0x178 Activity helper; bytes +4/+5 consulted by fight state 0x1006b380
+0x184 Shared timer controller, allocated lazily 0x10071d60 -> 0x10052450
+0x188 Physical/appearance helper 0x10059770, allocation 0x68
+0x1b4 NPC byte Distinguishes observed NPC/player branches

For a runtime read with an already known engine instance, its +0x88 points to the local SimpleChar; *(character + 0x188) + 0x30 is the physical extent used by the range routine. The current target identity is at *(character + 0x16c) + 0x58/+0x5c. Use the dynel registry to resolve that identity, then the same physical-helper chain for the target. A later WASM check read player extent 2 and Leet extent 3 through these pointers; see the range verification below.

Relevant holder fields, initialized by 0x100783e0:

Holder offset Observed use
+0x04 Owning character
+0x08 Skill-keyed map of server supplied special/unarmed items
+0x0c .. +0x48 Sixteen weapon pointers; slot 0 fists, slots 6/8 equipped hands
+0x4c Received special-weapon template binding records
+0x50 State: 1 idle, 2 fighting; other numeric values are not fully named
+0x54 Initialized/reset to 1
+0x58/+0x5c Fighting target identity
+0x68/+0x6c Cleared on acknowledged attack start
+0x70 Cached UI range indicator byte
+0x71 Attack request outstanding byte
+0x74 Received death reason
+0x78 Reload timer index, initially -1

Holder vtable 0x10171500 binds +0x30 to equip 0x10078e80, +0x34 to range predicate 0x10078cb0, +0x38 to slot-range wrapper 0x10078c70, +0x40 to start 0x10078fc0, +0x44 to stop 0x10079250, and +0x64 to queued special action consumption 0x10079700. Raw vtable evidence: ev_7d6762ab9ca524bf50401534ef85eca9805b9846bad1e09ab7cb11cf7c885c93. The target lookup helpers at 0x10079540, 0x100795b0, and 0x100795e0 are present in generated assembly, although Ghidra did not admit them as procedures. This is a disassembler coverage limitation, not an absent client feature.

WeaponBase constructor 0x100aac50 allocates a timer and a ring of 50 damage/result pairs. Its fields include timer pointer +4, weapon slot +8, blocked-retry counter +0xc, result-ring vector +0x10, write/read indices +0x14/+0x18, item stat object +0x1c, actual inventory item +0x20, cached original min/max/crit +0x24/+0x28/+0x2c, and owner identity +0x30/+0x34. 0x100ab4c0 appends one server supplied pair and wraps the write index at 50; 0x100ab580 reports write != read. There is no overflow detection in this helper, so large bursts of result messages can overwrite unread visual results. This is not an authoritative server combat log.

Shared timer and phase transitions

The controller at character +0x184 has owner +0, allocated slot count +4, timer vector +8, active attacking index +0xc (-1 means none). Each timer is 0x20 bytes:

Offset Type and meaning
+0x00 Float remaining centiseconds
+0x04 Attack duration, stored integer bits
+0x08 Recharge duration, stored integer bits
+0x0c/+0x10 Pending replacement attack/recharge durations
+0x14 Flags
+0x18 Category: weapon 1, nano 3, item use 4, reload 5
+0x1c UI timer slot/index

These flag names describe observed tests, not recovered enum identifiers:

Mask Observed effect
0x01 Set at insertion; no additional meaning established
0x02 Attack phase; clear means recharge
0x08 Enabled for repeated timer transitions
0x20 Hold/completed-attack latch; blocks automatic recharge decrement
0x40 Set when recharge completes
0x80 Controller owns/deletes allocated temporary timer
0x100 Suppresses setting 0x20 at attack completion
0x200 Remove the timer after recharge completion
0x400 Suppresses recharge-start UI event

0x10052550 first detaches an existing occurrence of a timer, finds a free vector slot, sets remaining to the integer attack duration, stores both durations/category/index, sets flags 0x03, and selects an active timer if none exists. 0x1007a940 subsequently enables weapon timers with flags |= 0x08. 0x10052630 allocates an owned temporary timer and sets 0x80; weapon timers belong to their WeaponBase instead.

Per character frame 0x1006ea50 passes engine.deltaSeconds * 100 to 0x100527c0. The exact update order is:

if an active attacking slot exists:
    subtract delta from that timer only
    if remaining <= 0:
        if !(flags & 0x100): flags |= 0x20
        remaining = integer recharge duration
        flags &= ~0x02
        active = -1
        send recharge UI event unless category 3 or flags & 0x400
        scan slots in increasing index order:
            choose first enabled attack-phase timer without 0x20
            apply its pending durations if pending attack != 0
            make it active and stop scanning

if an active slot exists: return
for each timer in increasing slot order:
    if enabled AND !attack-phase AND remaining > 0 AND !(flags & 0x20):
        subtract delta
        if remaining <= 0:
            flags |= 0x42
            remaining = integer attack duration
            select it if no active slot exists
            send attack UI event unless category 3
            remove it if flags & 0x200

The loop does not carry negative remaining time into the next phase or replay multiple elapsed cycles. It can advance a newly recharging timer by the same frame delta used to complete its attack. It can also complete multiple recharges in one scan even after selecting the first active attack, because the active-index guard precedes that loop. Those ordering details matter when matching frame observations.

Only one weapon attack phase progresses at a time. Recharge phases pause while another attack remains active. Ready weapons can therefore attack in sequence and then recharge together. Treating dual-wielded weapons as independent repeating hit clocks does not reproduce this client scheduler. This still does not establish whether the original server used precisely the same frame granularity or the same first-hit policy.

0x100529a0 forces a temporary timer active, resets the previous active weapon's remaining time to its attack duration, clears its hold flag, and sets enabled. 0x10077300 installs pending durations and clears pending fields. A stats/AggDef refresh during combat 0x100714a0 uses 0x1007a940(0) to stage new durations rather than restart every attack. Equipment changes and acknowledged fight start instead use argument 1.

Timing formulas and base skills are in combat-rules.md. 0x1007aa30 truncates both positive centisecond durations through _ftol. For start/reset argument 1, its additional exact arithmetic is:

remaining = attackCs + 50 - trunc(rand() * attackCs * 0.5 / 32767)

Assembly evidence ev_5d76845488e6c317cf130db5dd72edbe2112b0035e32421273f730ecb8fa9b4f; double constant 0x101708c0 equals 1/32767, verified by bytes 80 00 40 00 20 00 00 3f, evidence ev_1243488403d024a9a63cef7633f85c2c02e3c6f7a7970ff3fe58953cc3fc156d. With MSVCRT's 0..32767 rand, attackCs 198 starts at 149..248 cs. This is client animation/attack-bar startup behavior. It is not proof that server damage should be delayed by a matching random value.

Timer update and UI-event evidence: ev_54c8e5911c3ccf91ab6ce87b5b2df8506f06ab9850e3ae78da5b0cb38fc13d7c, assembly ev_2ce2af1831dd11b56b74c0ec2e1f96cda73af25e4f1af2dc62d5e1a8b22caead.

Requests, acknowledgement, results, and stop

N3Msg_DefaultAttack 0x1002b2b0 requests a stop if already fighting, checks the current action/state and 0x10079880 target eligibility, rejects while previous fight/action is pending, then calls 0x1007bee0. That helper sets holder pending byte +0x71 and sends AttackIIR_t with target identity and a byte. The request path does not call the range predicate. Eligibility checks include self, nonexistent target, target status/death, swimming/state restrictions, surrender ownership, and playfield/gas/team conditions; full original PvP policy is not implied by these client checks.

On received start, 0x10078fc0 clears pending, resets existing fight state if necessary, resets weapon timers with randomized startup, sets target, changes state to 2, emits attack text/UI events, and suppresses normal hand recharge UI using timer 0x400. N3Msg_StopAttack 0x1002b180 sends a StopFight request only if currently attacking. The returned StopFight activation invokes holder stop; it is not just a local target clear when the key is pressed.

0x10079250 attempts to drain already received damage/result queues, clears queued special actions and UI attack state, restores idle state 1, clears target, resets the animation controller, and clears hand timer 0x400. Death visual constructor 0x10085d60 also calls holder stop when needed before locking/playing death state. Disconnect/zoning authoritative cleanup is the server's responsibility; client visual cleanup alone does not establish correct multiplayer state.

AttackInfo supplies damage, slot, target, death reason and result. The client queues the supplied damage/result through 0x1007a660 -> 0x100ab4c0. The fight state's 0x10086390 calls 0x1007b2d0, which plays attacks with pending server results and clears completed timer holds. 0x100ab5a0 consumes the queue, prints combat text and subtracts the supplied amount from target health at the visual hit point. Result 5 adds Critical hit!; the missed-attack path supplies zero damage and result 3. There is no local random hit/damage/critical calculation here. Missing-attacker fallback and absolute-health messages have different health-update paths; see the protocol document before emitting redundant damage notifications.

The ring/animation queue can outlive a stop; stop intentionally drains it when an opponent and pending results remain. Consequently, an already announced hit can appear while the stop animation finishes. A server must distinguish cancelling future swings from retracting previously sent hits.

Range, line of sight, and movement

0x10078cb0 is the holder range predicate. For a character target it computes 3D center distance d, actor extent ra, target extent rt, and effective weapon range r. It first accepts d < r + ra; otherwise it accepts d <= r + 2*ra + rt. The doubled actor extent is present in both assembly and pseudocode; do not silently simplify it to a conventional sum of two radii. Item targets instead use d < r.

0x100aae10 supplies r = min(40, trunc(itemRange * (1 + WeaponRangeIncreaser380/100))). Physical extent starts at 1.0 in 0x10059770, then 0x1005a790 replaces it with the float32 conversion of the signed integer product max(1, MonsterScale360(mode3)) * CharRadius421(mode2), multiplied by float32 .01. It also applies MonsterScale*.01 to body scale. A default constructor value is not evidence that every spawned Leet retains radius 1.0. In fact the stat initializer 0x10072760 sets CharRadius421 to 2 and MonsterScale360 to 100, giving extent 2.0 after this refresh when neither stat is replaced. Even those stat defaults must not be substituted for actual NPC values or treated as proof of an original-server melee hit threshold.

The extracted Leet template 17655 supplies CharRadius421=3 in server/gamedata/monsters.yaml. Published actors currently use scale 100; the server therefore derives player extent 2 and Leet extent 3. It uses the predicate above for authoritative melee validation, replacing the fixed four-meter approximation. Fists, Kinetic Axe 209283 and Leet Bite 120910 have item range 2. With no range modifiers, player-to-Leet range is consequently 9 meters and Leet-to-player range is 10 meters. Direction matters because the attacker's extent is counted twice. Movement prediction still supplies player positions before the three-dimensional distance check. Scale-changing effects and weapon range modifiers are not currently supported.

This is an explicit reconstruction choice based on the client contract, not a recovered original-server normal-attack tolerance. The source distinction below still applies.

Extent follow-up evidence is retained in local/reports/actor-range-extents-1491-evidence.json: refreshed extent ev_4871dfa06ad951f22eec434d4895dfba2c4127bec7a148226a75f1460e9e04e3, float constant ev_09c60b565e012a81f81e9d3c94ec67d0c24254ef6f3b10e62c82b7bed44dbf50, defaults ev_262150600e8d5205a324934ce17968bf1440814efc918e5344b3ad29103466e9, and stat-triggered refresh ev_a2f43ae98c55ad9d0b1c3b494017da7794f4d5b185e6be899d0665f31d4fbb11.

Automated public combat-handler checks accept a Leet at (9,0,0) and (6,3,6) relative to the player and reject (9.125,0,0) and (6,3.125,6). Retaliation separately accepts 10 meters and rejects 10.125 meters. Existing movement tests continue to check predicted positions.

An actual published WASM client also targeted the Leet and pressed Q with the player at (918,20.7,578). At (927.125,20.7,578) the request was rejected and Leet HP remained 8971. At (927,20.7,578) combat started and Leet HP fell to 8903 during the six-second observation. Read-only guest-memory probes confirmed extents 2 and 3; they did not change guest state. The fixture used a 10000-HP Leet to keep the encounter available, without changing its radius or weapon. State, packet logs and screenshots are retained under local/first-aid-smoke/range-*; the extent probes are in self-heal-verified-trace.json in that directory. No browser errors or native adapter aborts were reported. Test-owned processes were closed afterward.

The predicate has two established uses: special-attack validation 0x10078990 and selected-target range UI via 0x10078c70 -> 0x1007acf0 -> events 0x1001c910/0x1001c930. It also supports range failure feedback. Ordinary attack request and received-hit application do not run this predicate. Thus the formula establishes client UI/special range, not the original server's normal-attack distance policy.

0x100721d0 returns false for null targets, different playfields, or no playfield; true for self and for non-dungeon playfields; and for dungeons calls n3Playfield_t::LineOfSight between actor/target global positions with +1.6 vertical offsets and actor zone-instance ID. Outdoors this specific helper performs no raycast. That does not prove the original server allowed attacks through outdoor walls.

The server's shared implementation and evidence for the underlying LLR room gate and two directional Surface queries are described in combat visibility.

When timer hold 0x20 is set, 0x100ab740 increments a retry counter modulo 5 and, only when it becomes 1, checks target line of sight. It returns false at other retries. 0x100ab7a0 clears the hold. These are presentation scheduling checks around received results, not substitutes for authoritative server validation.

Fight visual CharFight_t 0x10086300/0x10086390 uses category/state 10. It can transition to state 0 (idle), 11 (dead), 4 (activity byte +4), 5 (activity byte +5, associated with casting), or 7 (turning). It runs received-result animation pumping before those checks. Every 0.67 seconds, when the numeric state/vehicle predicates permit it, it compares facing with target direction; angle greater than 0.26 radians transitions to turning state 7. Unnamed vehicle/state helper predicates remain numeric in the retained pseudocode rather than being guessed as universal moving/ranged/melee rules. No complete server movement-interruption rule was recovered from this visual state.

Range assembly: ev_9862c91fdfb306342e1a4bada390db357a4002667850e7704ed97713cc8510be. Physical extent/fight state: ev_3e82ca2665af85fa3448bff637a94ef4494a0c5d51260223b3f4fbe14daf4dae. LOS/retry: ev_c6476a44ff6f2acef524789bf74ebddd3ea49bab979bdff76f495ac32a5de6b8 and ev_9081c9ee969a3f64c9cfb5aec6a5d90477aa638090d6ed38e5791a3d0d58eeda.

Equipment, unarmed binding, and reload

Slot binding 0x1007a340 rejects deleted item state, stores one of sixteen weapon pointers, records owner identity, and updates attack-weapon flags stat 274 from fists/ranged/melee/energy categories. Equipping 0x10078e80 clears fists when equipping a nonzero slot unless character status bit 0x800 permits combined MA attacks; a combat equip resets all weapon clocks with startup randomization. Unequipping 0x10078f00 detaches the old timer and restores the skill-100 item as fists if no weapons remain, then resets clocks if still fighting.

0x1007a4c0 checks dual-wield eligibility against the other equipped hand. For ordinary single-hand categories it compares the character's MeleeMultiple 101 or LR_MultipleWeapon 134 against the smaller of the two items' requirements. Zero and missing (0x499602d2) requirements fail. 0x10091060 identifies weapon mesh categories 2, 3, and 6 as excluded from this ordinary check. 0x10091090 classifies ammo type <1 as the melee side of that distinction. The complete inventory/equip transaction still requires server validation.

0x1007b9a0 reads server supplied low/high endpoint IDs and skill key, interpolates an item, inserts it into the skill map, and binds skill 100 as fists when no weapons are equipped, fists already occupy slot 0, or combined-MA status permits it. It does not recover MA-skill-to-fist-QL selection: that endpoint/quality policy must be supplied by the server. The item interpolation itself is covered in the rules/stats documents.

Reload eligibility 0x1007bba0 requires a WeaponItem, no existing reload index, matching weapon/ammo stat 420, ammo ItemType76 == 0, and a weapon not already at capacity stat 212. On accepted server reply 0x1007bca0, the client changes ammo stat 26 to the provided value, allocates category 5 timer with attack and recharge both set to the weapon's raw RechargeDelay210, forces it active, and prints Reloading. Thus this reload UI timer is not the adjusted physical-initiative weapon timer. 0x1007bdf0 removes it after its completion/hold flag appears, resets reload index to -1, and prints completion. Ammo/inventory data is supplied by the server; completing a UI timer alone does not authorize ammunition.

Evidence and implementation boundary

New evidence is exported to local/reports/combat-client-state-evidence.json; readable selected decompilations are in local/reports/combat-client-decompiles-*.json. The matching reusable REA snapshot is local/reports/combat-client-state-1491.snapshot.json (148 evidence records, 21 retained batch workflows). The native analysis session was closed after the state, stats and protocol investigations finished. Earlier evidence remains in combat-rules-1491-evidence.json and combat-1491-evidence.json in that directory. Batch records contain the exact requested selector, canonical entry, successful pseudocode, and explicit failed entries. Do not reinterpret failed disassembler coverage as proof that a generated function is missing from the client.

The server should send coherent target/slot/result/health events and maintain authoritative combat state independently of client render rate. The client supplies a much better timing, equipment, range-UI and message contract than the initial fixed-damage prototype. It does not contain the lost server's hit chance, NPC stat curves, aggro/chase policy, line-of-sight authority, PvP balance, first-hit scheduling, loot, XP, or reclaim policy. Those remain explicit reconstruction work and must not be described as verified canonical rules.