Files

61 lines
3.3 KiB
Python

"""#121 Tauren male /rude = Octo Undead /rude (anim 73) retargeted onto native Tauren male, HD + SD (2026-11-26).
Owner: "/rude is not the requested undead /rude transplanted to tauren" -- #28 (e64b8248) used Octo TaurenMale's own anim 73.
inputs/retarget.py octo_scourgemale.m2 73 -> native seq 105, explicit leg chain (Undead hip/knee/ankle/toe -> Tauren hip 5/8,
knee 12/17, hock 33/34, toe 198/199; the digitigrade mid segment 21/24 follows the knee):
--map=1:1,5:5,14:12,21:33,38:198,6:8,15:17,23:34,39:199
then inputs/ground.py keeps the feet on the stand ground line. FK: Tauren knee swings 0.08->0.15 H (Undead 0.12->0.21),
pelvis dips 0.08 H like the Undead hip thrust.
Sequence flag 0x01 cleared on anim 73 (0x81 -> 0x80): with it the client played only the upper body (owner: "lower part of the
body still does not move"); dances (69, 211) carry 0x0/0x80 and move the legs."""
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 = 'Octo Undead male /rude (anim 73) retargeted onto native Tauren male, leg chain hip/knee/hock/toe, feet grounded (owner #121)'
FILES = {968705: ('character/tauren/male/taurenmale_hd.m2', 'out/hd.m2'), 968734: ('taurenmale_hd 0073-00.anim', 'out/hd.anim'),
122055: ('character/tauren/male/taurenmale.m2', 'out/sd.m2'), 472114: ('taurenmale 0073-00.anim', 'out/sd.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])