Files

60 lines
3.2 KiB
Python

"""#121 Tauren male /rude and /dancespecial leaned forward on d5c863cd (2026-11-26).
Owner: "the body should tilt forward a bit for both animations /dancespecial and /rude for tauren ... it looks like he's
standing on his heels ... lean the tauren over in front a bit". inputs/lean.py adds a world-space forward pitch at the lower
spine (bone 3, key 4: 8 deg) and chest (bone 18, key 53: 7 deg) for every rotation key of the sequence; pelvis, legs and the
feet grounding stay as shipped. Root->head lean: rude HD 13.1->18.5, SD 13.3->18.8, dancespecial HD 11.2->16.7 deg.
Hooves (owner screenshot 19:52: standing on the back of the hooves, toes up): inputs/hooves.py holds the hock bones
33/34 at the native stand world orientation (hock->tip pitch -51 deg instead of ~-27), then ground.py re-grounds.
Files: HD rude 968734 (seq 105), SD rude 472114 (seq 105), HD dancespecial 8840132 (seq 347); models unchanged."""
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 = 'Tauren male /rude and /dancespecial lean forward from the spine like the Undead hunch (owner #121)'
FILES = {968734: ('taurenmale_hd 0073-00.anim', 'hoof/968734.anim'), 472114: ('taurenmale 0073-00.anim', 'hoof/472114.anim'),
8840132: ('character/tauren/male/taurenmale_hd0211-00.anim', 'hoof/8840132.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, src) in sorted(FILES.items()):
old = (H / 'inputs/nat' / f'{fid}.bin').read_bytes()
new = (H / 'inputs' / src).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])