60 lines
3.4 KiB
Python
60 lines
3.4 KiB
Python
"""#82 (2026-11-26): the character-creation race details for Turtle's Goblin (race 9) and High Elf (race 10) showed solid
|
|
green icons. GW_SourceRaceDetails in blizzard_charactercreate.lua (FDID 8209459) named icon FDIDs 8560811-8560816, which
|
|
were never icons: an October world-cutout batch reserved them for a bush model/skin, and nothing shipped them.
|
|
|
|
Rule (every entry of the table, not only these six): when an entry's icon FDID is not in the client ROOT, take the trait
|
|
title (first line of its description), find the race's starting spell with that name (tw_world.playercreateinfo_spell,
|
|
names from Octo's Spell.dbc), and use that spell's own client icon (SpellMisc.SpellIconFileDataID). Unresolvable -> fail.
|
|
High Elf also gets its fourth Octo racial, Quel'dorei Meditation (46021), which the earlier creator patch meant to add
|
|
(ops/single_name_creation_ui.py rebase_high_elf_meditation_trait) but the installed file lacks.
|
|
|
|
Usage: race_trait_icons.py <before.lua> <after.lua> <race_spells.tsv> <Spell.octo.tsv> <SpellMisc.dump> <root_fdids.txt>"""
|
|
import re, sys
|
|
|
|
ADD = {10: [(46021, "Quel'dorei Meditation\\nMay meditate, restoring vital resources.")]}
|
|
|
|
|
|
def kv(path):
|
|
for line in open(path, encoding='utf-8', errors='replace'):
|
|
f = line.rstrip('\n').split('\t')
|
|
yield dict(x.split('=', 1) for x in f[1:] if '=' in x)
|
|
|
|
|
|
def main(before, after, race_spells, octo_spell, spellmisc, root_list):
|
|
have = set(int(x) for x in open(root_list).read().split())
|
|
names = {int(d['ID']): d.get('Name_lang', '') for d in kv(octo_spell) if 'ID' in d}
|
|
icon = {}
|
|
for d in kv(spellmisc):
|
|
if 'SpellID' in d: icon.setdefault(int(d['SpellID']), int(d['SpellIconFileDataID']))
|
|
race = {}
|
|
for line in open(race_spells):
|
|
r, s = line.split(); race.setdefault(int(r), []).append(int(s))
|
|
raw = open(before, 'rb').read(); text = raw.decode('utf-8')
|
|
start = text.index('local GW_SourceRaceDetails = {'); end = text.index('\n};', start) + 3
|
|
table = text[start:end]; nl = '\r\n' if '\r\n' in table else '\n'
|
|
out_lines = []; cur = None; changes = []
|
|
for line in table.split(nl):
|
|
m = re.match(r'\s*\[(\d+)\] = \{\s*$', line)
|
|
if m: cur = int(m.group(1))
|
|
e = re.match(r'(\s*)\{icon=(\d+), description="([^"\\]*)\\n', line)
|
|
if e and cur is not None and int(e.group(2)) not in have:
|
|
title = e.group(3)
|
|
hits = [s for s in race.get(cur, []) if names.get(s) == title and icon.get(s, 0) in have]
|
|
if not hits: raise SystemExit(f'race {cur} trait {title!r}: no starting spell with a client icon')
|
|
new = icon[hits[0]]; line = line.replace(f'icon={e.group(2)}', f'icon={new}', 1)
|
|
changes.append((cur, title, int(e.group(2)), hits[0], new))
|
|
if line.strip() == '},' and cur in ADD:
|
|
ind = re.match(r'\s*', out_lines[-1]).group(0)
|
|
for sid, desc in ADD.pop(cur):
|
|
assert icon.get(sid, 0) in have, sid
|
|
out_lines.append(f'{ind}{{icon={icon[sid]}, description="{desc}"}},'); changes.append((cur, desc.split('\\n')[0], None, sid, icon[sid]))
|
|
cur = None
|
|
out_lines.append(line)
|
|
assert not ADD, ADD
|
|
new_text = text[:start] + nl.join(out_lines) + text[end:]
|
|
open(after, 'wb').write(new_text.encode('utf-8'))
|
|
for c in changes: print('race %s %-26s %s -> spell %s icon %s' % c, file=sys.stderr)
|
|
|
|
|
|
if __name__ == '__main__': main(*sys.argv[1:7])
|