Files

37 lines
2.0 KiB
Python

"""#121 (2026-11-26): play /rude (AnimationData 73) on the whole body.
70334 AnimationData.Flags[0]: 0x10000 alone = the client plays the animation on the upper body only (attacks 17-36, rude 73),
while bit 0x40000000 makes it full-body (dance 69 = 0x40000843, also 61/63/77...). Rude 73 = 0x10843, so the retargeted
Undead hip thrust never reached the Tauren legs (owner, twice: "only the upper part of the body moves").
This gives row 73 the same Flags as dance 69 by pointing its 8-bit pallet index at 69's existing pallet entry; no other byte
changes. usage: animflags.py in.db2 out.db2"""
import struct, sys
def main(src, dst, anim=73, like=69):
B = bytearray(open(src, 'rb').read())
o = 136
H = struct.unpack_from('<4I2I3I2H7I', B, o); o += struct.calcsize('<4I2I3I2H7I')
rc, fc, rs, sts = H[:4]; fsis, cds, pds, sc = H[14], H[15], H[16], H[17]
assert B[:4] == b'WDC5' and sc == 1 and rs == 5
tkh, fo, nrec, strsz, endoff, idsz, relsz, ocount, ccount = struct.unpack_from('<Q8I', B, o); o += 40 + 4 * fc
fsi = [struct.unpack_from('<HHII3I', B, o + 24 * i) for i in range(fsis // 24)]; o += fsis
off, size, addsz, ctype, _, _, card = fsi[3]
assert ctype == 4 and size == 8 and card == 2, fsi[3]
pal_at = o + sum(f[2] for f in fsi[:3] if f[3] in (3, 4))
pal = [struct.unpack_from('<2I', B, pal_at + 8 * k) for k in range(addsz // 8)]
ids = struct.unpack_from(f'<{idsz // 4}I', B, fo + nrec * rs + strsz)
rec = lambda i: int.from_bytes(B[fo + i * rs:fo + i * rs + rs], 'little')
idx = lambda i: (rec(i) >> off) & 0xff
r_anim, r_like = ids.index(anim), ids.index(like)
old, new = pal[idx(r_anim)], pal[idx(r_like)]
print(f'anim {anim} flags {old[0]:#x} -> {new[0]:#x} (pallet {idx(r_anim)} -> {idx(r_like)}, like anim {like})')
assert old[0] & 0x10000 and not old[0] & 0x40000000 and new[0] & 0x40000000
v = (rec(r_anim) & ~(0xff << off)) | (idx(r_like) << off)
B[fo + r_anim * rs:fo + r_anim * rs + rs] = v.to_bytes(rs, 'little')
open(dst, 'wb').write(B)
if __name__ == '__main__':
main(*sys.argv[1:3])