75 lines
4.5 KiB
Python
75 lines
4.5 KiB
Python
"""Native rows for Octo displays whose files are all in the client (stage 'rows-only'), 2026-11-23.
|
|
Display ID = Octo display ID (absent in client ItemDisplayInfo). Geosets copied verbatim (as all 2,682 earlier
|
|
imports); ItemVisual copied; HelmetGeosetVis copied only for pairs earlier imports kept verbatim, else 0.
|
|
Textures: Octo's own bytes where Turtle patched them (matched by content key), else the native file of the same
|
|
name. A file has one TextureFileData row (keyed by FDID); reuse its MaterialResources, else a new one (2100001+).
|
|
Models: ModelFileData's ModelResources, else a new one (2100001+). Then ItemAppearance + IMA for each item."""
|
|
import json, collections, sys
|
|
W = '/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/item-displays-20261123'
|
|
S = '/tmp/claude-1000/-home-praxis-Projects/c41b4c2f-f4c2-4e21-8c6d-a961250d8864/scratchpad'
|
|
def tsv(n):
|
|
for l in open(f'{S}/itemdb2/{n}.tsv'):
|
|
p = l.rstrip('\n').split('\t'); yield dict(x.split('=', 1) for x in p[1:])
|
|
tfd = {int(r['FileDataID']): int(r['MaterialResourcesID']) for r in tsv('TextureFileData')}
|
|
mfd = {int(r['FileDataID']): int(r['ModelResourcesID']) for r in tsv('ModelFileData')}
|
|
items = {int(r['ID']): r for r in tsv('Item')}
|
|
apps = collections.defaultdict(list)
|
|
for r in tsv('ItemAppearance'):
|
|
if r['TransmogPlayerConditionID'] == '0': apps[int(r['ItemDisplayInfoID'])].append(int(r['ID']))
|
|
R = json.load(open(f'{W}/resolved.json'))
|
|
plan = json.load(open(f'{S}/ima-plan.json'))
|
|
prev_ia = json.load(open(f'{S}/ia-add.json')); prev_ima = json.load(open(f'{S}/ima-add.json'))
|
|
HELM_KEEP = {(245, 245), (247, 247), (248, 306), (249, 305)}
|
|
nmr, nmres, nidimr = 2100001, 2100001, 1600001
|
|
nia = max(r['ID'] for r in prev_ia) + 1; nima = max(r['ID'] for r in prev_ima) + 1
|
|
out = collections.defaultdict(list); done = {}; holds = []
|
|
def mat_res(fids):
|
|
global nmr
|
|
have = {tfd[f] for f in fids if f in tfd}
|
|
if len(have) == 1 and all(f in tfd for f in fids): return have.pop()
|
|
if have: return min(have) if all(f in tfd for f in fids) else None
|
|
m = nmr; nmr += 1
|
|
for f in fids:
|
|
out['TextureFileData'].append(dict(ID=f, FileDataID=f, UsageType=0, MaterialResourcesID=m)); tfd[f] = m
|
|
return m
|
|
def model_res(fid):
|
|
global nmres
|
|
if fid in mfd: return mfd[fid]
|
|
m = nmres; nmres += 1
|
|
out['ModelFileData'].append(dict(ID=fid, GeoBox=[0, 0, 0, 0, 0, 0], FileDataID=fid, Flags=0, LodCount=0, ModelResourcesID=m)); mfd[fid] = m
|
|
return m
|
|
def files(p):
|
|
if p.get('octo_files') and all(p['octo_files'].values()):
|
|
return sorted({v[0] for v in p['octo_files'].values()})
|
|
return sorted(f for f in p['in_root'])
|
|
for x in R:
|
|
if x.get('stage') != 'rows-only': continue
|
|
d = x['display']; mres = [0, 0]; mmr = [0, 0]; mats = []; bad = None
|
|
for p in x['parts']:
|
|
fl = files(p)
|
|
if not fl: bad = f"{p['kind']} {p['name']} has no file"; break
|
|
if p['kind'] == 'model': mres[p['side']] = model_res(fl[0])
|
|
else:
|
|
m = mat_res(fl)
|
|
if m is None: bad = f"{p['kind']} {p['name']} files split across material groups"; break
|
|
if p['kind'] == 'modeltex': mmr[p['side']] = m
|
|
else: mats.append((p['section'], m))
|
|
if bad: holds.append((d, bad)); continue
|
|
hv = tuple(x['helmvis']); hv = list(hv) if hv in HELM_KEEP else [0, 0]
|
|
gg = list(x['geosets']) + [0] * 3
|
|
out['ItemDisplayInfo'].append(dict(ID=d, ItemVisual=x['item_visual'], Flags=0, ModelResourcesID=mres, ModelMaterialResourcesID=mmr,
|
|
ModelType=[0, 0], GeosetGroup=gg, AttachmentGeosetGroup=[0] * 6, HelmetGeosetVis=hv))
|
|
for sec, m in mats:
|
|
out['ItemDisplayInfoMaterialRes'].append(dict(ID=nidimr, ComponentSection=sec, MaterialResourcesID=m, ItemDisplayInfoID=d)); nidimr += 1
|
|
done[d] = True
|
|
for item, d, inv in plan['conv']:
|
|
if d not in done: continue
|
|
if d in apps: a = min(apps[d])
|
|
else:
|
|
a = nia; nia += 1; apps[d].append(a)
|
|
out['ItemAppearance'].append(dict(ID=a, DisplayType=0, ItemDisplayInfoID=d, DefaultIconFileDataID=int(items[item]['IconFileDataID']), UiOrder=0, TransmogPlayerConditionID=0))
|
|
out['ItemModifiedAppearance'].append(dict(ID=nima, ItemID=item, ItemAppearanceModifierID=0, ItemAppearanceID=a, OrderIndex=0, TransmogSourceTypeEnum=0, Flags=0)); nima += 1
|
|
for t, rows in out.items(): json.dump(rows, open(f'{W}/add-{t}.json', 'w'))
|
|
json.dump(holds, open(f'{W}/holds.json', 'w'))
|
|
print({t: len(v) for t, v in out.items()}, 'displays', len(done), 'holds', len(holds), holds[:5])
|