87 lines
4.5 KiB
Python
87 lines
4.5 KiB
Python
"""#56 (2026-11-25): /dancespecial (anim 211) on the native male models that lack it, copied from the Octo client.
|
|
|
|
Octo has anim 211 for Tauren/Gnome/Troll/Scourge/BloodElf male (Human already native). Each native HD model gets a new
|
|
external sequence 211 (inputs/add_sequence*.py: template = Dance 69 entry, every per-sequence track array grown, AFID
|
|
row, lookup slot), and Octo's 211 is retargeted into it (inputs/retarget.py, Tauren with the #28 hip/knee/hock map).
|
|
Blood Elf carries both Octo variations (211-00, 211-01). New .anim files use fresh FDIDs above the parent maximum.
|
|
Inputs are built by inputs/build.sh from the parent store reads; this script pins the results.
|
|
"""
|
|
import hashlib
|
|
import json
|
|
import struct
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
H = Path(__file__).resolve().parent
|
|
sys.path.insert(0, str(H))
|
|
import frozen_store as fs
|
|
|
|
C = fs.casc
|
|
I = H / 'inputs/out'
|
|
NAT = H / 'inputs/nat'
|
|
WHY = 'Octo /dancespecial (anim 211) added as a new sequence and retargeted onto the native model (#56; owner: copy what Forever lacks from Octo)'
|
|
PINS = {968705: 'character/tauren/male/taurenmale_hd.m2', 900914: 'character/gnome/male/gnomemale_hd.m2',
|
|
1022938: 'character/troll/male/trollmale_hd.m2', 959310: 'character/scourge/male/scourgemale_hd.m2',
|
|
1100087: 'character/bloodelf/male/bloodelfmale_hd.m2', 2140228: 'character/scourge/male/scourgemale_hd.skel',
|
|
1838675: 'character/bloodelf/male/bloodelfmale_hd.skel'}
|
|
OUTS = {968705: '968705.m2', 900914: '900914.m2', 1022938: '1022938.m2', 959310: '959310.m2', 1100087: '1100087.m2',
|
|
2140228: '2140228.skel', 1838675: '1838675.skel'}
|
|
NEW = [(8840132, 'character/tauren/male/taurenmale_hd0211-00.anim'),
|
|
(8840133, 'character/gnome/male/gnomemale_hd0211-00.anim'),
|
|
(8840134, 'character/troll/male/trollmale_hd0211-00.anim'),
|
|
(8840135, 'character/scourge/male/scourgemale_hd0211-00.anim'),
|
|
(8840136, 'character/bloodelf/male/bloodelfmale_hd0211-00.anim'),
|
|
(8840137, 'character/bloodelf/male/bloodelfmale_hd0211-01.anim')]
|
|
md5 = lambda b: hashlib.md5(b).hexdigest()
|
|
sha = lambda b: hashlib.sha256(b).hexdigest()
|
|
|
|
root = (fs.PARENT / 'decoded/root.bin').read_bytes()
|
|
lay = C.root_groups(root)
|
|
assert lay['root_md5'] == fs.ROOT
|
|
assert all(f > lay['max_file_data_id'] for f, _ in NEW)
|
|
cells = {f: [] for f in PINS}
|
|
for g in lay['groups']:
|
|
f = 0
|
|
for i, (delta,) in enumerate(struct.iter_unpack('<I', memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
|
|
f += delta
|
|
if f in cells:
|
|
cells[f].append((g, g['ckeys_offset'] + i * 16))
|
|
f += 1
|
|
patched = bytearray(root)
|
|
pins = []
|
|
for fid, name in sorted(PINS.items()):
|
|
old = (NAT / f'{fid}.bin').read_bytes()
|
|
new = (I / OUTS[fid]).read_bytes()
|
|
ckey = md5(old)
|
|
hits = [(g, at) for g, at in cells[fid] if root[at:at + 16].hex() == ckey]
|
|
en = [(g, at) for g, at in hits if g['locale'] & 2 and not g.get('flags1')]
|
|
# A file with a single ROOT cell outside the enUS-flagged groups is pinned by that cell (root_selector).
|
|
kind = 'wdc_enus' if len(en) == 1 else 'root_selector'
|
|
if kind == 'root_selector':
|
|
assert len(hits) == 1, (fid, len(hits), len(en))
|
|
en = hits
|
|
g, at = en[0]
|
|
patched[at:at + 16] = bytes.fromhex(md5(new))
|
|
d = H / 'pins' / str(fid)
|
|
d.mkdir(parents=True, exist_ok=True)
|
|
(d / 'before.bin').write_bytes(old)
|
|
(d / 'after.bin').write_bytes(new)
|
|
pin = dict(fdid=fid, table=name, parent_root=fs.ROOT, selected_group={},
|
|
original_decoded=dict(file='before.bin', md5=ckey, sha256=sha(old)), encrypted_original=False,
|
|
after_decoded=dict(file='after.bin', md5=md5(new), sha256=sha(new)), reason=WHY)
|
|
(d / 'pin.json').write_text(json.dumps(pin, indent=1) + '\n')
|
|
pins.append(dict(file=str(d / 'pin.json'), sha256=sha((d / 'pin.json').read_bytes()), type=kind))
|
|
assets = []
|
|
for fid, path in NEW:
|
|
src = I / f'{fid}.anim'
|
|
raw = src.read_bytes()
|
|
assets.append(dict(file_data_id=fid, path=path, sha256=sha(raw), ckey=md5(raw), kind='M2', file=str(src)))
|
|
art = H / 'pins' / 'new-anims.json'
|
|
raw = (json.dumps(dict(type='art', parent_root=fs.ROOT, assets=assets), indent=1) + '\n').encode()
|
|
art.write_bytes(raw)
|
|
pins.append(dict(file=str(art), sha256=sha(raw), type='art'))
|
|
(H / 'components.json').write_text(json.dumps(pins, indent=2) + '\n')
|
|
(H / 'selected-root.json').write_text(json.dumps(dict(parent_build=fs.BUILD, parent_root=fs.ROOT,
|
|
decoded_root_sha256=sha(bytes(patched)), parent_root_sha256=sha(root)), indent=2) + '\n')
|
|
print('pins', len(pins) - 1, 'new anims', len(assets))
|