Files
WoW-Hybrid-gateway/ops/spell_scripted_aura_compat.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

138 lines
13 KiB
Python

"""Source-backed definitions for server-executed scripted dummy equipment auras.
The first reviewed family is spell_vampirism. This component never implements
healing, rolls procs, grants a spell or changes server data. The script contract,
source capture and named protocol meanings are pinned independently of spell IDs.
"""
from copy import deepcopy
import hashlib,struct
from pathlib import Path
from octo_client_data import canonical_sha256
from spell_result_profile import enum
from spell_item_haste_compat import HEADERS
from spell_family_compat import validate_family
from spell_definition_common import (REQUIRED_REFERENCE_TABLES,NEW_DEFINITION_CHILD_TABLES,
checked_constant_source,review_effect_shape,review_new_timing,new_definition_records,
review_proc_conditions)
from spell_passive_compat import (BUILD,SCHEMA,TABLES,SUPPLEMENTAL_TABLES,CONDITIONS,
CHILD_NEUTRAL,NEW_EFFECT_NEUTRAL,NEW_MISC_NEUTRAL,encode,integer,new_registry_values,verified_spell_icon,one)
from item_batch_stage import available_index
POLICY='new-server-scripted-dummy-aura-definition-candidate-v1'
NAMESPACE='named-server-vampirism-dummy-aura-v1'
SCRIPT='spell_vampirism'
POSITIVE_AURA=dict(source_name='SPELL_CUSTOM_POSITIVE',source_value=4,target_name='SPELL_ATTR4_AURA_IS_BUFF',target_value=0x1000)
SCRIPT_SHA256='c69592c6e3ed52d191ef5b19af99a802762058bc573720ad501b82c4f152538e'
MAPPINGS=(
('attributes0','SpellAttributes','SpellAttr0','SPELL_ATTR_PASSIVE','SPELL_ATTR0_PASSIVE',64),
('attributes0','SpellAttributes','SpellAttr0','SPELL_ATTR_HIDDEN_CLIENTSIDE','SPELL_ATTR0_DO_NOT_DISPLAY_SPELLBOOK_AURA_ICON_COMBAT_LOG',128),
('attributes1','SpellAttributesEx','SpellAttr1','SPELL_ATTR_EX_DONT_DISPLAY_IN_AURA_BAR','SPELL_ATTR1_NO_AURA_ICON',0x10000000),
('attributes3','SpellAttributesEx3','SpellAttr3','SPELL_ATTR_EX3_CAN_PROC_FROM_PROCS','SPELL_ATTR3_CAN_PROC_FROM_PROCS',0x04000000),
('school','SpellSchools','SpellSchools','SPELL_SCHOOL_SHADOW','SPELL_SCHOOL_SHADOW',5),
('defense','SpellDmgClass','SpellDmgClass','SPELL_DAMAGE_CLASS_MAGIC','SPELL_DAMAGE_CLASS_MAGIC',1),
('prevention','SpellPreventionType','SpellPreventionType','SPELL_PREVENTION_TYPE_SILENCE','SPELL_PREVENTION_TYPE_SILENCE',1),
('target','SpellTarget','Targets','TARGET_UNIT_ENEMY','TARGET_UNIT_TARGET_ENEMY',6),
('aura','AuraType','AuraType','SPELL_AURA_DUMMY','SPELL_AURA_DUMMY',4))
def namespace(paths,script):
if not isinstance(paths,dict)or set(paths)!=set(HEADERS):raise ValueError('Four pinned enum headers required')
for role,path in paths.items():
if hashlib.sha256(Path(path).read_bytes()).hexdigest()!=HEADERS[role]:raise ValueError('Scripted aura enum source changed')
mappings=[]
for kind,a,b,x,y,v in MAPPINGS:
source=Path(paths['source_aura'if kind=='aura'else'source']);target=Path(paths['target_aura'if kind=='aura'else'target'])
if enum(source,a)[0].get(x)!=v or enum(target,b)[0].get(y)!=v:raise ValueError('Named scripted aura semantics differ')
mappings.append(dict(kind=kind,source_name=x,target_name=y,source_value=v,target_value=v))
if enum(Path(paths['source']),'SpellAttributesCustom')[0].get(POSITIVE_AURA['source_name'])!=4 or enum(Path(paths['target']),'SpellAttr4')[0].get(POSITIVE_AURA['target_name'])!=0x1000:raise ValueError('Named positive-aura conversion differs')
text=Path(script).read_text();start=text.index('struct '+SCRIPT+' : public AuraScript');end=text.index('\n};',start)+3
if hashlib.sha256(text[start:end].encode()).hexdigest()!=SCRIPT_SHA256:raise ValueError('Server script body changed; review actual gameplay contract')
return dict(policy=NAMESPACE,header_sha256=dict(HEADERS),mappings=mappings,server_script=SCRIPT,server_script_body_sha256=SCRIPT_SHA256,positive_aura=dict(POSITIVE_AURA))
def validate_namespace(proof):
expected=dict(policy=NAMESPACE,header_sha256=dict(HEADERS),mappings=[dict(kind=k,source_name=x,target_name=y,source_value=v,target_value=v)for k,_,_,x,y,v in MAPPINGS],server_script=SCRIPT,server_script_body_sha256=SCRIPT_SHA256,positive_aura=dict(POSITIVE_AURA))
if not isinstance(proof,dict)or proof!=expected:raise ValueError('Pinned server-script and named aura contract required')
if any(type(r.get(k))is not int for r in proof['mappings']for k in('source_value','target_value')):raise ValueError('Typed scripted aura namespace required')
def source_spell(dbc,raw,offsets,*,family_namespace,proc_proof,semantics,proc_event_rows):
src=checked_constant_source(dbc,raw,offsets,family_namespace=family_namespace,proc_namespace_proof=proc_proof,scripted_aura_context=semantics)
if not isinstance(proc_event_rows,list)or proc_event_rows:raise ValueError('Source default proc filtering requires verified absence of overrides')
src['source_proc_event_rows']=deepcopy(proc_event_rows)
validate_source(src,proc_proof);return src
def validate_source(src,proc_proof):
integer(src.get('entry'),1,0x7fffffff,'scripted aura source ID');validate_namespace(src.get('scripted_aura_context'));validate_family(src.get('class_family'))
if src.get('source_proc_event_rows')!=[]:raise ValueError('Source periodic-heal exclusion requires absent proc-event override')
if src.get('server_script')!=SCRIPT:raise ValueError('Unreviewed server-side script')
for k,n in(('attributes',5),('power',6),('equippedItem',3),('visuals',2)):
if not isinstance(src.get(k),list)or len(src[k])!=n or any(type(v)is not int for v in src[k]):raise ValueError('Typed scripted aura scalar groups required')
for k in('school','castingTimeIndex','durationIndex','rangeIndex','defense_type','prevention_type'):integer(src.get(k),0,0x7fffffff,'scripted aura '+k)
if src['attributes']!=[192,0x10000000,0,0x04000000,0]or tuple(src[k]for k in('school','castingTimeIndex','durationIndex','rangeIndex','defense_type','prevention_type'))!=(5,1,21,4,1,1):raise ValueError('Unreviewed scripted aura flags/categories/range')
if type(src.get('speed'))not in(int,float)or src['speed']or src['power']!=[0]*6 or src['equippedItem']!=[-1,0,0]or src['visuals']!=[0,0]:raise ValueError('Scripted aura resource/equipment/visual context differs')
conditions=src.get('conditions')
if not isinstance(conditions,dict)or set(conditions)!=set(CONDITIONS)or any(v for k,v in conditions.items()if k not in('procFlags','procChance','procCharges','customFlags')):raise ValueError('Complete neutral scripted aura conditions required')
if type(conditions['customFlags'])is not int or conditions['customFlags']!=4:raise ValueError('Source server-positive aura flag required')
raw=dict(entry=src['entry'],**conditions);disk=[0]*173;disk[0]=src['entry'];disk[1:4]=[conditions[k]for k in('procFlags','procChance','procCharges')]
context=review_proc_conditions(raw,disk,dict(ProcFlags=1,ProcChance=2,ProcCharges=3),proc_proof,damage_periodic=True)
if conditions['procChance']!=100 or conditions['procCharges']or src.get('proc_context')!=context:raise ValueError('Source proc context differs')
for name,expected in(('timing',dict(recoveryTime=0,categoryRecoveryTime=0,startRecoveryCategory=0,startRecoveryTime=0)),('levels',dict(spellLevel=1,baseLevel=1,maxLevel=0))):
if src.get(name)!=expected or any(type(v)is not int for v in src[name].values()):raise ValueError('Unreviewed scripted aura '+name)
effects=src.get('effects');active=[]
if not isinstance(effects,list)or len(effects)!=3:raise ValueError('Three scripted aura slots required')
for i,e in enumerate(effects):
review_effect_shape(e)
if not e[0]:
if e!=[0]*11+[-1]:raise ValueError('Nonneutral scripted aura empty slot')
continue
if e[:2]!=[6,4]or e[3:11]!=[1,1,0,0,0,6,0,0]or e[11]!=1:raise ValueError('Scripted dummy effect context differs')
integer(e[2]+1,1,100,'server-script healing percentage');active.append(i)
if len(active)!=1:raise ValueError('One server-script dummy aura required')
integer(src.get('spellIconId'),1,0x7fffffff,'source icon')
for k in('name','nameSubtext','description','auraDescription'):
text=src.get(k)
if not isinstance(text,str)or '\0'in text or len(text.encode())>4096 or '$'in text:raise ValueError('Scripted aura text bound or unsupported token')
if not src['name']:raise ValueError('Source aura name required')
return active
def native_attributes(src):
validate_namespace(src.get('scripted_aura_context'))
if src['attributes']!=[192,0x10000000,0,0x04000000,0]or src['conditions']['customFlags']!=4:raise ValueError('Unreviewed positive dummy flags')
# Explicit semantic conversion: source server-only custom4 -> native AuraIsBuff.
# Never copy custom4 into SpellMisc.Attributes[4] as numeric4.
attrs=src['attributes']+[0]*12;attrs[4]|=POSITIVE_AURA['target_value'];return attrs
def new_component(sources,native,schemas,maxima,registry,*,source_tables,target_icon_names,new_icon_ids,icon_assets,read_icon,proc_proof):
if not isinstance(sources,list)or not 1<=len(sources)<=4096 or len({s['entry']for s in sources})!=len(sources):raise ValueError('Bounded unique scripted aura sources required')
if any(t not in native for t in(*REQUIRED_REFERENCE_TABLES,'SpellCastTimes','SpellRange','SpellDuration')):raise ValueError('Complete scripted aura reference tables required')
if set(new_icon_ids)!={str(s['entry'])for s in sources}:raise ValueError('Explicit source aura icon identities required')
tables=NEW_DEFINITION_CHILD_TABLES+('SpellCategories','SpellAuraOptions')
for t in {'Spell','SpellName',*tables}:
if t not in schemas or canonical_sha256(schemas[t])!=(TABLES|SUPPLEMENTAL_TABLES)[t][2]:raise ValueError('Reviewed scripted aura schema required')
review_new_timing(source_tables,native,21)
source_range=source_tables['SpellRange'].by_id.get(4);target_range=one(native['SpellRange'],lambda r:r['ID']==4,'source scripted range')
if not source_range or len(source_range)!=22 or source_range[0]!=4 or source_range[3]!=0:raise ValueError('Source range4 context differs')
low,high=(struct.unpack('<f',struct.pack('<I',v))[0]for v in source_range[1:3])
if(low,high)!=(0,30)or target_range['RangeMin']!=[low,low]or target_range['RangeMax']!=[high,high]or target_range['Flags']:raise ValueError('Source/native scripted range semantics differ')
registry=deepcopy(registry);occupied={t:{r['ID']for r in native[t]}for t in tables};new_registry_values(registry,maxima,occupied,tables=tables)
extra={t:registry.pop(t,{})for t in('SpellCategories','SpellAuraOptions')};records=[];spells=[];available=available_index(icon_assets)
for src in sorted(sources,key=lambda r:r['entry']):
indices=validate_source(src,proc_proof);ident=src['entry']
for t in REQUIRED_REFERENCE_TABLES:
if any((r.get('ID')if t in('Spell','SpellName')else r.get('SpellID'))==ident for r in native[t]):raise ValueError('Scripted aura has positive native reference')
fid,asset=verified_spell_icon(src,new_icon_ids,source_tables['SpellIcon'],target_icon_names,available,read_icon)
effects={i:dict(deepcopy(NEW_EFFECT_NEUTRAL),EffectAura=4,EffectBasePointsF=src['effects'][i][2]+1,EffectBonusCoefficient=src['effects'][i][11],EffectMiscValue=[0,0],ImplicitTarget=[6,0])for i in indices}
generated=new_definition_records(src,effects,fid,schemas,maxima,registry,occupied,allocation_prefix='new-server-scripted-dummy-aura')
for row in generated:
if row['table_name']=='SpellMisc':
row['record'].update(RangeIndex=src['rangeIndex'],Attributes=native_attributes(src));wire=encode(row['record'],schemas['SpellMisc']);row.update(wire_hex=wire.hex(),sha256=hashlib.sha256(wire).hexdigest())
records+=generated
for t in extra:
entries=extra[t];key=str(ident)
if key not in entries:entries[key]=max([maxima[t],*entries.values()])+1
row=dict(CHILD_NEUTRAL[t],ID=entries[key],SpellID=ident)
if t=='SpellCategories':row.update(DefenseType=src['defense_type'],PreventionType=src['prevention_type'])
else:row.update(ProcTypeMask=src['proc_context']['target_proc_type_mask'],ProcChance=src['conditions']['procChance'],ProcCharges=src['conditions']['procCharges'])
wire=encode(row,schemas[t]);records.append(dict(table_name=t,table_hash=hex(SUPPLEMENTAL_TABLES[t][0]),id=row['ID'],record=row,wire_hex=wire.hex(),sha256=hashlib.sha256(wire).hexdigest(),source_spell_id=ident,baseline_record_sha256=None,allocation_policy='new-server-scripted-dummy-aura-child'))
spells.append(dict(spell_id=ident,source_definition=deepcopy(src),source_record_sha256=canonical_sha256(src),class_family=deepcopy(src['class_family']),levels=deepcopy(src['levels']),effect_indices=indices,icon_asset=dict(file_data_id=fid,**asset),known_spells_modified=False,engine_accepted=False,gameplay_verified=False))
registry.update(extra);new_registry_values(registry,maxima,occupied,tables=tables)
return dict(kind='source-scripted-aura-definition-candidates',definition_policy=POLICY,build=BUILD,schema=SCHEMA,records=records,spells=spells,child_id_registry=registry,proc_namespace=deepcopy(proc_proof),id_remapping=False,installable=False,installed=False,engine_accepted=False,gameplay_verified=False,dependency_complete=False,limits=['Only pinned server-script dummy equipment family; no generic script execution, local healing or spell granting.','Original API absence, cache loading, presentation and actual server gameplay require separate verification.','Native unknown higher attributes remain neutral; no unrelated armor marker inferred.'])