45 lines
2.8 KiB
Python
45 lines
2.8 KiB
Python
"""Reproduce ima-plan.json / ia-add.json / ima-add.json (2026-11-23).
|
|
|
|
Inputs (Db2Bake dump TSVs of the parent content's enUS DB2s, plus tw_world):
|
|
Item.tsv, ItemModifiedAppearance.tsv, ItemAppearance.tsv, idi.tsv (ItemDisplayInfo)
|
|
equip.tsv = `select entry,display_id,inventory_type from tw_world.item_template
|
|
where inventory_type in (1,3-10,13-17,19-23,25,26)`
|
|
include/gateway/item_render_profile.hpp (source display/type -> native display)
|
|
Rule: a client Item row in a visible slot with no ItemModifiedAppearance gets one (modifier 0) when its
|
|
display exists in client ItemDisplayInfo: the render profile's native display if it has a row, else the
|
|
source display itself. Reuse the lowest plain ItemAppearance (no player condition) for that display;
|
|
otherwise add one (200001+). New IMA IDs 400001+. Items whose display is absent need Octo display
|
|
conversion and are listed under "conv" only."""
|
|
import collections, json, re, sys
|
|
d = sys.argv[1]; hdr = sys.argv[2]
|
|
def load(f):
|
|
out = {}
|
|
for l in open(f'{d}/{f}'):
|
|
p = l.rstrip('\n').split('\t'); out[int(p[0])] = dict(x.split('=', 1) for x in p[1:])
|
|
return out
|
|
I, M, A = load('Item.tsv'), load('ItemModifiedAppearance.tsv'), load('ItemAppearance.tsv')
|
|
idi = {int(l.split('\t', 1)[0]) for l in open(f'{d}/idi.tsv')}
|
|
tw = {e: (dd, t) for e, dd, t in (map(int, l.split()) for l in open(f'{d}/equip.tsv'))}
|
|
rows = {(int(a), int(b)): int(c) for a, b, c, _ in re.findall(r'\{(\d+),(\d+),(\d+),(\d+)\}', open(hdr).read().split('ItemAppearances[]')[0])}
|
|
VIS = {1,3,4,5,6,7,8,9,10,13,14,15,16,17,19,20,21,22,23,25,26}
|
|
has = {int(r['ItemID']) for r in M.values()}
|
|
fix, conv = [], []
|
|
for i in sorted(k for k, r in I.items() if int(r['InventoryType']) in VIS and k not in has and k in tw):
|
|
disp, t = tw[i]
|
|
if (disp, t) in rows and rows[(disp, t)] in idi: fix.append((i, rows[(disp, t)], t, 'row'))
|
|
elif disp in idi and disp: fix.append((i, disp, t, 'identity'))
|
|
else: conv.append((i, disp, t))
|
|
by = collections.defaultdict(list)
|
|
for k, r in A.items():
|
|
if r['TransmogPlayerConditionID'] == '0': by[int(r['ItemDisplayInfoID'])].append(k)
|
|
nia, nima, ia, ima, made = 200001, 400001, [], [], {}
|
|
for item, disp, inv, kind in fix:
|
|
if disp in by: app = min(by[disp])
|
|
elif disp in made: app = made[disp]
|
|
else:
|
|
app = made[disp] = nia; nia += 1
|
|
ia.append(dict(ID=app, DisplayType=0, ItemDisplayInfoID=disp, DefaultIconFileDataID=int(I[item]['IconFileDataID']), UiOrder=0, TransmogPlayerConditionID=0))
|
|
ima.append(dict(ID=nima, ItemID=item, ItemAppearanceModifierID=0, ItemAppearanceID=app, OrderIndex=0, TransmogSourceTypeEnum=0, Flags=0)); nima += 1
|
|
json.dump(dict(fix=fix, conv=conv), open('ima-plan.json', 'w')); json.dump(ia, open('ia-add.json', 'w')); json.dump(ima, open('ima-add.json', 'w'))
|
|
print(len(fix), 'fixed,', len(ia), 'new appearances,', len(conv), 'need display conversion')
|