aorecomp

Anarchy Online classic in the browser

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


docs/combat-client-spell-stream.md (14173B)


Combat spell streams in 14.9.1

This closes the nested wire-layout gap for the combat effects below inside SpellListIIR_t and ApplySpellsIIR_t. It also distinguishes those effects from the actual skill-lock notification. The selected original kkr.dll is SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0. Addresses use original base 0x10000000; generated C uses 0x36000000.

Both the native reader and writer were inspected. This is a network stream contract: integers below are big endian. The item database's little-endian storage and an extractor's 4x labels must not be copied into a network encoder. Several apparently unused database words are explicitly read and written as fields by this client.

The two envelopes

These layouts exclude the common N3 prefix and TCP padding, described in the protocol inventory.

SpellListIIR_t, class-derived ID 0x4d450114:
    spell_container

ApplySpellsIIR_t, class-derived ID 0x342c1d1d:
    spell_container
    u32 target_identity_type
    u32 target_identity_instance
    u8  add_mode

SpellList applies its container to the envelope actor, with addition mode. ApplySpells resolves the appended target identity and uses byte 1 to add and byte 0 to remove. The reader normalizes any nonzero byte to true; an encoder should send 0 or 1. Its activation inverts that boolean before calling the common application method.

This direction is established by 0x10002370: its third argument sets effect-object flag bit 0 when nonzero (removal), and clears it when zero (addition). Modify's executor then adds or subtracts the amount according to that flag. The application mode is not an extra DWORD inside each effect.

Envelope readers/writers are 0x100c3350 / 0x100c33d0 for SpellList and 0x10156b40 / 0x10156b90 for ApplySpells. Common list reader/writer are 0x100bd000 / 0x100bcf40.

Container and effect header

spell_container:
    i32 encoded_count             # 1009 * (number_of_effects + 1)
    repeat number_of_effects:
        u32 function_kind         # e.g. 53045 Modify
        u32 function_instance     # preserved by constructor; 0 in the example
        effect_body

effect_body:
    i32 version                   # must be 4
    i32 requirement_count
    repeat requirement_count:
        i32 stat
        i32 value
        i32 operator
    i32 tick_count                # internal field 3
    i32 tick_interval             # internal field 4
    i32 target_selector           # internal field 32
    i32 argument_header           # internal field 35
    function-specific arguments

The list reader accepts a positive encoded count divisible by 1009 and a decoded count below 1000: 1009 is an empty container; 2018 is one effect; 3027 is two effects; the largest admitted count is 999 effects. This count is not the number of DWORDs or the payload length.

0x100b44b0 stores the two identity words on the effect object and constructs its field/requirement storage. They identify the function; they are not the caster's character identity. Native resources use instance 0 in the examples below. Preserve a received/source instance rather than inventing an actor ID.

Effect reader/writer 0x100b9530 / 0x100b7d80 both use version 4. Original constant 0x101c8d28 contains bytes 04 00 00 00. Requirements are three DWORDs, in the order above, proved by 0x10008150 / 0x10008120. The reader rejects requirement counts greater than 999. Its signed test allows a negative count to behave like zero; an encoder should use 0..999. The writer emits the actual requirement-list length.

The four common fields are not an encoded list. Their native writer obtains fields 3, 4, 32, 35 and writes them directly. Common shipped values for a single immediate self effect are 1, 0, 2, 9; version 4 and argument header 9 are separate fields. The decoder stores the argument header without the version check applied to the leading version.

For zero requirements, the identity and common effect header occupy 32 bytes before the function-specific arguments. Add 12 bytes per requirement. There is no length prefix around an individual effect: its function kind selects exactly how many argument fields are consumed.

Combat argument layouts

Field numbers below are the native effect's internal numeric keys, not actor stat IDs. For example, internal key 0 contains the actor stat to modify. Names are supported by the native StateParse registration and effect handlers; opaque fields remain numeric.

Kind Native name Arguments in wire order Zero-requirement entry size
53002 Hit i32 stat [0], i32 minimum [2], i32 maximum [37], i32 damage type [71] 48 bytes
53012 Skill i32 stat [0], i32 amount [39], i32 opaque [24] 44 bytes
53014 TimedEffect i32 stat [0], i32 amount [39], i32 flag [11], i32 opaque [46], i32 duration in centiseconds [25] 52 bytes
53028 AddSkill i32 section [55], i32 stat [0], i32 value [39] 44 bytes
53033 SkillTime i32 opaque [55], i32 skill [0], i32 value [39] 44 bytes
53045 Modify i32 stat [0], i32 amount [39] 40 bytes

Reader and writer independently select these branches:

Kind Reader branch Writer branch
53002 0x100b9740 0x100b7f98
53012 0x100b9aab 0x100b8039
53014 0x100bb016 0x100b8582
53028 / 53033 0x100b9999 0x100b7ffe
53045 0x100b9938 0x100b800c

For SkillTime and AddSkill, all three arguments are actual serialized integers. The leading word is not padding. Skill likewise has a third serialized integer. The two words between TimedEffect's amount and duration are serialized too. Their exact layouts therefore come from the native reader/writer rather than the older extractor's uninterpreted-byte labels.

Wire compatibility is separate from execution. Modify and Skill route to the character modifier handler, while AddSkill modifies item state. SkillTime's admitted executor reaches a no-op in this client; it does not create a client skill lock. TimedEffect has a scheduled add/remove path. Hit has a local execution gate, including tick restrictions described in effect/stat findings. Do not use receipt of an effect container as proof that the client will perform authoritative damage ticks. TimedEffect's queued executor advances elapsed time by 200 on the client's two-second update, so raw duration 4000 corresponds to 40 seconds with that update's quantization. This establishes client presentation/execution timing, not the original server's exact expiry policy.

A periodic Hit/DoT entry uses the same common tick fields and four Hit arguments; it does not acquire a different opaque byte layout. Its admission and local execution restrictions remain separate. In particular, a decoded multi-tick Hit is not evidence that the server can delegate damage timing to this client. The server must schedule its authoritative ticks and replicate the resulting health changes through the result contracts in the protocol inventory.

Hit's reader also marks its internal validity field 999 false when both minimum and maximum are zero, and for a negative health hit with damage type zero. A server must provide an appropriate nonzero damage type for such a damage effect. An accepted stream is not proof of a valid server-side effect or permission to alter a particular stat.

An exact Modify plus SkillTime payload

The following creates a syntactically complete SpellList container with two entries: Modify Martial Arts stat 100 by +5, then a SkillTime entry carrying first argument 9, First Aid stat 123, and value 40. These operands are an explicit example, not a new combat balance rule. Instance 0, version 4, empty requirements, and common fields 1,0,2,9 follow the recovered layout and shipped effect records.

import struct

# Encoded count followed by complete function identities, headers and arguments.
words = [
    3027,
    53045, 0, 4, 0, 1, 0, 2, 9, 100, 5,
    53033, 0, 4, 0, 1, 0, 2, 9, 9, 123, 40,
]
payload = struct.pack(">22i", *words)
assert len(payload) == 88

The exact 88 bytes, grouped into DWORDs:

00000bd3
0000cf35 00000000 00000004 00000000 00000001
00000000 00000002 00000009 00000064 00000005
0000cf29 00000000 00000004 00000000 00000001
00000000 00000002 00000009 00000009 0000007b 00000028

Place these bytes after the common N3 prefix for class-derived ID 0x4d450114, with the receiving character as envelope actor. For an ApplySpells addition to character 1, use class-derived ID 0x342c1d1d and append 0000c350 00000001 01 to the container: target identity (50000,1) and byte add mode 1. Its subclass payload is 97 bytes. Removal uses the same container and target, with the final byte 0; it must correspond to an effect that the server previously applied.

The encoded fixture is retained as local/reports/combat-spelllist-modify-skilltime.bin, with words, hex, target digest and validation limits in the adjacent .json. Its SHA-256 is f0289e06873cfca712d5445596ee83cedb17b8ed9ede9399bb4265177190d0c9. Length and integer roundtrip were checked. A subsequent isolated browser probe sent this exact SpellList payload to character 1. The native skill panel showed Martial Arts change from 7 to 12; sending the corresponding ApplySpells removal returned it to 7. Two complete add/remove rounds were captured, with no browser page errors. This validates the tested framing and modifier direction in the published Chromium/WASM client.

Screenshots are local/combat-smoke/multi-effect-probe-body-before.png, multi-effect-probe-body-add.png and multi-effect-probe-body-removed.png; the retained capture and summary are effect-modifier-events.json and effect-modifier-summary.json. The stats summary's attack rating stayed at 7 while the skill panel showed 12; its refresh/binding behavior needs a separate probe. No skill-lock UI behavior is asserted by this test. The temporary server and browser were closed afterward.

Actual skill-lock notification

To start the corresponding client lock, the server uses CharacterAction 170, not the no-op SkillTime executor:

class-derived ID: 0x5e477770, envelope actor = locked character
u32 action = 170
identity A = (0, 0)                # unused by this receiver branch
identity B = (skill, raw_seconds)  # numeric arguments in identity-shaped fields

For First Aid 123 and raw duration 40, the entire 20-byte subclass payload is:

000000aa 00000000 00000000 0000007b 00000028

0x1007d5c0 decodes this envelope, 0x1007d640 resolves its actor, and 0x1006fa30 case 170 passes identity B's two words to 0x10073ae0. The skill controller stores (skill, remaining) pairs. A new lock's duration is trunc(raw_seconds + effective_stat_382 * raw_seconds * .01). The setter ignores an already locked skill; resending the notification does not refresh its remaining time. A one-second GameTime update decrements each remaining value and removes entries at zero or below through 0x10073d00. The setter also calls 0x100572b0 for the UI update.

The server must own the actual deadline, skill eligibility and action result. The client countdown is separate from weapon attack/recharge and nano shared timers. No explicit early-unlock/reset message has been established by this path; do not invent a negative-duration reset or assume that a second start refreshes it. Reconnect/late-session lock resynchronization needs a deliberate server contract based on remaining time and the client's duplicate behavior.

Coverage and retained evidence

The native argument reader and writer each dispatch kinds 53002..53192. The following in-range kinds select the rejection path in both jump tables: 53007, 53020, 53021, 53022, 53046, 53112, 53182, 53184, 53185, 53186, 53187, 53188, 53189, 53190. Out-of-range kinds likewise mark the stream bad. The database catalog contains later IDs; their presence is not permission to send an unsupported function to this client.

This document fully specifies the six combat argument layouts above and both envelopes. Other admitted function bodies can contain strings, identities, requirements or other typed structures and are not covered by this encoder subset. No generic "skip the unknown effect" operation is safe: there is no per-effect byte length. Tick execution, effect duration/stacking and server resource policy remain distinct from the byte contract.

Retained REA records in local/reports/combat-client-pass2-decompiles-*.json:

The original PE reader/writer jump tables are at 0x100bcc40 and 0x100b9234. Their independent selected branches were checked against the generated original-instruction comments in lifted-0055.c and lifted-0054.c. Requirements are in lifted-0002-01.c; common containers in lifted-0056.c; SpellList wrappers in lifted-0057.c; ApplySpells wrappers in lifted-0099.c. The ApplySpells mode inversion, container outer framing, and CharacterAction dispatch also reuse the earlier evidence linked in the protocol inventory.