58 lines
3.1 KiB
Python
58 lines
3.1 KiB
Python
"""#120 /dancespecial grounded on 8b2953ab (2026-11-26). Owner: Tauren /dancespecial floats above the ground.
|
|
|
|
The #56 retarget (Octo anim 211 -> native rigs) copied the Octo pelvis translation, but the native legs reach differently,
|
|
so the lowest leg joint swung between -0.34 and +0.28 (Tauren), sank to -1.24 (Undead) / -0.13 (Gnome) / -1.02 (Troll).
|
|
inputs/ground.py (dance211-a2f8-20261125/inputs) shifts the pelvis Z per key so the lowest non-root joint stays on the
|
|
native stand sequence's ground line. This step swaps the six shipped .anim files for the grounded ones (same FDIDs)."""
|
|
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
|
|
|
|
WHY = '/dancespecial (anim 211) kept on the ground: pelvis height corrected per frame against the native stand pose (#120)'
|
|
FILES = {8840132: 'character/tauren/male/taurenmale0211-00.anim', 8840133: 'character/gnome/male/gnomemale0211-00.anim',
|
|
8840134: 'character/troll/male/trollmale0211-00.anim', 8840136: 'character/bloodelf/male/bloodelfmale0211-00.anim',
|
|
8840137: 'character/bloodelf/male/bloodelfmale0211-01.anim', 8840138: 'character/scourge/male/scourgemale_hd0211-00-full.anim'}
|
|
md5 = lambda b: hashlib.md5(b).hexdigest()
|
|
sha = lambda b: hashlib.sha256(b).hexdigest()
|
|
root = (fs.PARENT / 'decoded/root.bin').read_bytes()
|
|
lay = fs.casc.root_groups(root)
|
|
assert lay['root_md5'] == fs.ROOT
|
|
cells = {f: [] for f in FILES}
|
|
for g in lay['groups']:
|
|
f = 0
|
|
for i, (d,) in enumerate(struct.iter_unpack('<I', memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
|
|
f += d
|
|
if f in cells:
|
|
cells[f].append((g, g['ckeys_offset'] + i * 16))
|
|
f += 1
|
|
patched = bytearray(root)
|
|
pins = []
|
|
for fid, name in sorted(FILES.items()):
|
|
old = (H / 'inputs/nat' / f'{fid}.bin').read_bytes()
|
|
new = (H / 'inputs/out' / f'{fid}.anim').read_bytes()
|
|
assert old != new
|
|
hits = [(g, at) for g, at in cells[fid] if root[at:at + 16].hex() == md5(old)]
|
|
assert len(hits) == 1, (fid, len(hits))
|
|
g, at = hits[0]
|
|
kind = 'wdc_enus' if g['locale'] & 2 and not g.get('flags1') else 'root_selector'
|
|
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=md5(old), 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))
|
|
(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), [p['type'] for p in pins])
|