37 lines
2.6 KiB
Python
37 lines
2.6 KiB
Python
"""Zebra space-bar neigh (owner 2026-11-23), on content 0b3a6f43.
|
|
Zebra display 1531 (and NPC-horse displays 229/235-239/1170/1910/1911/1951/1952/2325) use ModelID 65,
|
|
creature/horse/horse.m2 (FDID 124427), whose anim 94 (2.0 s, slot 25) had no $FD1 event at all, so standing
|
|
+ space was silent. ridinghorse.m2 (ModelID 216) keys $FD1 on anim 94. inputs/add_fd1.py adds one $FD1 event
|
|
keyed t=0 on slot 25 only; CreatureSoundFidget set 65 index 0 is already the neigh (729, mount-sounds 78ff).
|
|
NPC horses never play anim 94, so they are unchanged."""
|
|
import json, hashlib, struct, sys
|
|
from pathlib import Path
|
|
H = Path(__file__).resolve().parent; sys.path.insert(0, str(H))
|
|
import frozen_store as fs
|
|
md5 = lambda b: hashlib.md5(b).hexdigest(); sha = lambda b: hashlib.sha256(b).hexdigest()
|
|
TABLES = [(124427, 'creature/horse/horse.m2', H/'inputs/124427.before.m2', H/'inputs/124427.after.m2')]
|
|
WHY = 'Zebra (horse.m2) space-bar neigh: $FD1 on anim 94 (owner request)'
|
|
store = fs.Store(); root = store.root; lay = store.layout; assert lay['root_md5'] == fs.ROOT
|
|
patched = bytearray(root); pins = []
|
|
for fid, name, src, out in TABLES:
|
|
cells = []
|
|
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 == fid: cells.append((g, g['ckeys_offset'] + i * 16))
|
|
f += 1
|
|
en = [(g, at) for g, at in cells if g['locale'] & 2 and not g.get('flags1')]; assert len(en) == 1, (fid, len(en))
|
|
g, at = en[0]; ck = root[at:at + 16].hex()
|
|
old = store.read(ck)[2]; assert old == src.read_bytes(), f'parent {name} differs from edited source'
|
|
new = out.read_bytes(); 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=ck, 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='wdc_enus'))
|
|
(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))
|