Files
WoW-Hybrid-gateway/ops/spell_item_avoidance_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

94 lines
7.1 KiB
Python

"""Permanent all-school item AoE reduction: source194 -> native229.
The source ignores the aura misc mask; native229 filters by it. Only source127
(all schools) is admitted. Native194 is target absorption and is never emitted.
These definitions describe server-owned equipment effects, not client damage.
"""
from copy import deepcopy
from pathlib import Path
import hashlib,re
from octo_client_data import canonical_sha256
from item_batch_stage import available_index
from spell_definition_common import (checked_constant_source,REQUIRED_REFERENCE_TABLES,
NEW_DEFINITION_CHILD_TABLES,review_new_timing,new_definition_records)
from spell_passive_compat import (BUILD,SCHEMA,NEW_EFFECT_NEUTRAL,integer,
new_registry_values,verified_spell_icon)
import spell_item_static_compat as static
POLICY=static.NEW_STATIC_POLICIES['aoe-damage-avoidance']
PINS={
'source_header':'ed7f67babe916cbbf91f7a1f1a9a9af694a2469d2e07eb10e94f0ae883678cb8',
'target_header':'1784b495ea9704bbe12223c2ad42d9d5fea7d320f0dc6c0055cd090cb7e5498b',
'source_unit':'3cb321fe39a74a612484df6d227bcd319d476d3ffd8b03e75b981ca1633468b5',
'target_unit':'70895cc85720f42319ead6ff1eaebd3272f36b1f87db96905dfa7df668d5ebbd'}
def contract():
return dict(policy='named-all-school-item-aoe-reduction-v1',sha256=dict(PINS),
source_aura=194,target_aura=229,target_absorption_aura_rejected=194,
source_misc_ignored=True,target_misc_is_school_mask=True,required_source_mask=127,
signed_percent_amount_preserved=True)
def namespace(paths):
if set(paths)!=set(PINS):raise ValueError('Complete AoE semantic inputs required')
texts={}
for key,path in paths.items():
raw=Path(path).read_bytes()
if hashlib.sha256(raw).hexdigest()!=PINS[key]:raise ValueError('Pinned AoE semantic input changed: '+key)
texts[key]=raw.decode()
for key,name,value in [('source_header','SPELL_AURA_MOD_AOE_DAMAGE_PERCENT_TAKEN',194),('target_header','SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE',229),('target_header','SPELL_AURA_MOD_TARGET_ABSORB_SCHOOL',194)]:
if not re.search(r'\b'+name+r'\s*=\s*'+str(value)+r'\s*,',texts[key]):raise ValueError('Named AoE enum differs')
if 'GetTotalAuraMultiplier(SPELL_AURA_MOD_AOE_DAMAGE_PERCENT_TAKEN)'not in texts['source_unit']or 'GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, schoolMask)'not in texts['target_unit']:raise ValueError('AoE signed-multiplier consumers differ')
return contract()
def validate_source(src,proof):
if proof!=contract()or canonical_sha256(proof)!=canonical_sha256(contract()):raise ValueError('Explicit source/native AoE semantics required')
normalized=deepcopy(src)
if not isinstance(normalized.get('effects'),list)or len(normalized['effects'])!=3:raise ValueError('Complete AoE source effects required')
for effect in normalized['effects']:
if not isinstance(effect,list)or len(effect)!=12:raise ValueError('AoE source effect shape differs')
if not effect[0]:continue
if any(type(effect[i])is not int for i in(0,1,7))or effect[0]!=6 or effect[1]!=194 or effect[7]!=127:raise ValueError('Only all-school source AoE reduction is reviewed')
integer(effect[2],-101,-2,'negative source AoE base points')
# Reuse the strict passive structural validator. This validation copy is
# never encoded: the output below retains negative amounts and emits229.
effect[1]=49;effect[2]=-effect[2]-2;effect[7]=0
return static.validate_source(normalized,percent_stat='dodge')
def source_spell(dbc,raw,offsets,*,family_namespace,semantics):
src=checked_constant_source(dbc,raw,offsets,family_namespace=family_namespace)
validate_source(src,semantics);return src
def description_fields(src,semantics):
"""Literal source reduction amounts; native229 has a distinct tooltip sign."""
validate_source(src,semantics)
return {key:re.sub(r'\$s([123])(?![0-9])',lambda m:str(abs(src['effects'][int(m[1])-1][2]+1)),src[key])
for key in('description','auraDescription')}
def component(sources,native,schemas,maxima,registry,*,semantics,source_tables,
target_icon_names,new_icon_ids,icon_assets,read_icon):
if not isinstance(sources,list)or not 1<=len(sources)<=4096 or len({s['entry']for s in sources})!=len(sources):raise ValueError('Distinct bounded AoE sources required')
if any(t not in native for t in(*REQUIRED_REFERENCE_TABLES,'SpellCastTimes','SpellDuration','SpellRange')):raise ValueError('Complete AoE native references required')
if any(t not in schemas or t not in maxima for t in('Spell','SpellName',*NEW_DEFINITION_CHILD_TABLES)):raise ValueError('Complete AoE schema/allocation context required')
if set(source_tables)!={'SpellIcon','SpellCastTimes','SpellDuration','SpellRange'}or set(new_icon_ids)!={str(s['entry'])for s in sources}or not callable(read_icon):raise ValueError('Explicit AoE dependencies and icons required')
review_new_timing(source_tables,native,21)
available=available_index(icon_assets);registry=deepcopy(registry)
if registry.get('SkillLineAbility'):raise ValueError('No learned-spell links for item avoidance')
occupied={t:{r['ID']for r in native[t]}for t in NEW_DEFINITION_CHILD_TABLES}
new_registry_values(registry,maxima,occupied,tables=NEW_DEFINITION_CHILD_TABLES)
records=[];verified=[]
for src in sorted(sources,key=lambda s:s['entry']):
indices=validate_source(src,semantics);ident=src['entry']
if src['conditions']['procChance']not in(0,101):raise ValueError('Unreviewed AoE proc context')
for table in REQUIRED_REFERENCE_TABLES:
if any((r.get('ID')if table in('Spell','SpellName')else r.get('SpellID'))==ident for r in native[table]):raise ValueError('AoE parent has a positive native reference: '+table)
fid,asset=verified_spell_icon(src,new_icon_ids,source_tables['SpellIcon'],target_icon_names,available,read_icon)
if asset.get('file_data_id',fid)!=fid:raise ValueError('Registered AoE icon FileDataID differs')
effects={i:dict(deepcopy(NEW_EFFECT_NEUTRAL),EffectAura=229,EffectBasePointsF=src['effects'][i][2]+1,EffectMiscValue=[127,0])for i in indices}
presented=dict(deepcopy(src),**description_fields(src,semantics))
additions=new_definition_records(presented,effects,fid,schemas,maxima,registry,occupied,allocation_prefix='new-item-aoe-avoidance-definition')
for row in additions:
if row['table_name']=='Spell':row['constant_description_policy']=POLICY
records.extend(additions)
verified.append(dict(spell_id=ident,source_definition=deepcopy(src),source_record_sha256=canonical_sha256(src),effect_indices=indices,effects=[dict(index=i,source_aura=194,target_aura=229,amount=src['effects'][i][2]+1,misc=127)for i in indices],icon_asset=dict(asset,file_data_id=fid),class_family=deepcopy(src['class_family']),levels=deepcopy(src['levels']),source_school_index=src['school'],target_school_mask=1<<src['school'],filtered_reference_absence_only=True,installed_definition_absence_verified=False,known_spells_modified=False,gameplay_verified=False))
return dict(kind='source-item-static-definition-candidates',build=BUILD,schema=SCHEMA,definition_policy=POLICY,records=records,spells=verified,child_id_registry=registry,semantic_contract=semantics,id_remapping=False,dependency_complete=False,installable=False,installed=False,engine_accepted=False,gameplay_verified=False)