Files
2026-11-23 03:28:32 +02:00

54 lines
3.6 KiB
Python

"""Profession recipe parity: Octo 1.12 DBCs (authoritative) vs the installed client's effective tables (native + hotfix)."""
import struct,json,sys,collections
sys.path.insert(0,'.')
import effective as E
def dbc(path):
d=open(path,'rb').read(); n,f,rs,ss=struct.unpack_from('<4I',d,4); st=d[20+n*rs:]
rows=[struct.unpack_from(f'<{f}I',d,20+i*rs) for i in range(n)]
return rows,(lambda o: st[o:st.index(b'\0',o)].decode('latin1') if o<len(st) else '')
osk,S=dbc('octo/skillline.dbc'); lines={r[0]:S(r[3]) for r in osk if r[1] in (9,11)}
osla,_=dbc('octo/skilllineability.dbc'); osp,SS=dbc('octo/spell.dbc'); ospell={r[0]:r for r in osp}
def o_recipe(sid):
r=ospell.get(sid)
if not r: return None
reag=sorted((r[42+i],r[50+i]) for i in range(8) if r[42+i])
create=sorted(r[103+i] for i in range(3) if r[61+i]==24 and r[103+i])
return dict(name=SS(r[120]),reagents=reag,totems=sorted(t for t in r[40:42] if t),focus=r[15],creates=create)
sla=E.table('SkillLineAbility')['rows']; rg=E.table('SpellReagents')['rows']; tot=E.table('SpellTotems')['rows']
scr=E.table('SpellCastingRequirements')['rows']; eff=E.table('SpellEffect')['rows']; nm=E.table('SpellName')['rows']
by=lambda rows,key: collections.defaultdict(list,{})
R=collections.defaultdict(list); T=collections.defaultdict(list); F=collections.defaultdict(list); X=collections.defaultdict(list)
for r in rg.values(): R[r['SpellID']].append(r)
for r in tot.values(): T[r['SpellID']].append(r)
for r in scr.values(): F[r['SpellID']].append(r)
for r in eff.values():
if r.get('Effect')==24 and r.get('DifficultyID',0)==0: X[r.get('SpellID')].append(r['EffectItemType'])
def c_recipe(sid):
reag=sorted((i,c) for r in R[sid] for i,c in zip(r['Reagent'],r['ReagentCount']) if i)
tots=sorted(t for r in T[sid] for t in r['Totem'] if t)
focus=max([r['RequiresSpellFocus'] for r in F[sid]] or [0])
n=nm.get(sid); return dict(name=n['Name_lang'] if n else None,reagents=reag,totems=tots,focus=focus,creates=sorted(x for x in X[sid] if x))
octo=collections.defaultdict(dict)
for r in osla:
if r[1] in lines: octo[r[1]][r[2]]=dict(sla=r[0],min=r[7],acq=r[9],high=r[10],low=r[11])
client=collections.defaultdict(dict)
for r in sla.values():
if r['SkillLine'] in lines: client[r['SkillLine']][r['Spell']]=dict(sla=r['ID'],min=r['MinSkillLineRank'],acq=r['AcquireMethod'],high=r['TrivialSkillLineRankHigh'],low=r['TrivialSkillLineRankLow'],src=r['_src'])
report={};tot_c=collections.Counter()
for line,name in sorted(lines.items()):
o=octo[line]; c=client[line]; rep=dict(name=name,octo=len(o),client=len(c),missing=[],extra=[],rank_diff=[],data_diff=[])
for sid in sorted(set(o)-set(c)): rep['missing'].append(dict(spell=sid,octo=o[sid],recipe=o_recipe(sid)))
for sid in sorted(set(c)-set(o)): rep['extra'].append(dict(spell=sid,client=c[sid],recipe=c_recipe(sid)))
for sid in sorted(set(o)&set(c)):
a=o[sid];b=c[sid]
dk=[k for k in ('min','high','low') if a[k]!=b[k]]
if dk: rep['rank_diff'].append(dict(spell=sid,fields={k:[a[k],b[k]] for k in dk}))
oa=o_recipe(sid); cb=c_recipe(sid)
if oa and cb:
dd={k:[oa[k],cb[k]] for k in ('reagents','totems','focus','creates','name') if oa[k]!=cb[k]}
if dd: rep['data_diff'].append(dict(spell=sid,diff=dd))
for k in ('missing','extra','rank_diff','data_diff'): tot_c[k]+=len(rep[k])
report[line]=rep
print(f"{line:4d} {name[:22]:22s} octo {len(o):4d} client {len(c):4d} missing {len(rep['missing']):4d} extra {len(rep['extra']):4d} rank {len(rep['rank_diff']):4d} data {len(rep['data_diff']):4d}")
json.dump(report,open('recipe-audit.json','w'),indent=1); print(dict(tot_c))