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

105 lines
7.7 KiB
Python

"""Source-owned constant passive item damage shields, source/native aura15.
Preserve named presentation flags, flat base amounts and spell school. This is
client definition conversion; server hit/absorb/proc eligibility is not simulated.
"""
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['damage-shield']
PINS={
'source_header':'ed7f67babe916cbbf91f7a1f1a9a9af694a2469d2e07eb10e94f0ae883678cb8',
'target_header':'1784b495ea9704bbe12223c2ad42d9d5fea7d320f0dc6c0055cd090cb7e5498b',
'source_attributes':'fd1c65c0266b77a310c066bc3ccce86fe39f73a6cd10f67192d419009f95ead1',
'target_attributes':'9b0e2ad90eea77c961b00f1fc482e9d9e521aa85c58b63863a35d3a338a31799',
'source_consumer':'3cb321fe39a74a612484df6d227bcd319d476d3ffd8b03e75b981ca1633468b5',
'target_consumer':'70895cc85720f42319ead6ff1eaebd3272f36b1f87db96905dfa7df668d5ebbd'}
def contract():
return dict(policy='named-flat-passive-item-damage-shield-v1',sha256=dict(PINS),source_aura=15,target_aura=15,
source_spell_school_is_index=True,target_spell_school_is_mask=True,flat_base_amount_preserved=True,
attribute_mappings=[['SPELL_ATTR_IS_ABILITY','SPELL_ATTR0_IS_ABILITY',16],['SPELL_ATTR_PASSIVE','SPELL_ATTR0_PASSIVE',64],
['SPELL_ATTR_HIDDEN_CLIENTSIDE','SPELL_ATTR0_DO_NOT_DISPLAY_SPELLBOOK_AURA_ICON_COMBAT_LOG',128],
['SPELL_ATTR_HIDE_IN_COMBAT_LOG','SPELL_ATTR0_DO_NOT_LOG',256],
['SPELL_ATTR_EX_DONT_DISPLAY_IN_AURA_BAR','SPELL_ATTR1_NO_AURA_ICON',268435456]],
server_execution_eligibility_equivalence_claimed=False)
def namespace(paths):
if set(paths)!=set(PINS):raise ValueError('Complete damage-shield semantics required')
text={}
for key,path in paths.items():
raw=Path(path).read_bytes()
if hashlib.sha256(raw).hexdigest()!=PINS[key]:raise ValueError('Pinned damage-shield input changed: '+key)
text[key]=raw.decode()
for key in('source_header','target_header'):
if not re.search(r'\bSPELL_AURA_DAMAGE_SHIELD\s*=\s*15\s*,',text[key]):raise ValueError('Named damage-shield aura differs')
for source,target,value in contract()['attribute_mappings']:
for key,name in [('source_attributes',source),('target_attributes',target)]:
match=re.search(r'\b'+name+r'\s*=\s*(0x[0-9a-fA-F]+|[0-9]+)\s*,',text[key])
if not match or int(match[1],0)!=value:raise ValueError('Named damage-shield attribute differs: '+name)
if 'uint32 damage = (*i)->GetModifier()->m_amount;'not in text['source_consumer']or 'uint32 damage = aurEff->GetAmountAsInt();'not in text['target_consumer']:raise ValueError('Flat damage-shield amount consumers differ')
return contract()
def validate_source(src,semantics):
if semantics!=contract():raise ValueError('Explicit damage-shield namespace required')
attrs=src.get('attributes')
if not isinstance(attrs,list)or len(attrs)!=5 or any(type(v)is not int for v in attrs):raise ValueError('Damage-shield attributes shape differs')
if not attrs[0]&64 or attrs[0]&~464 or attrs[1]not in(0,268435456)or any(attrs[2:]):raise ValueError('Unreviewed passive damage-shield flags')
normalized=deepcopy(src)
# Reuse only structural validation. The output retains original named flags,
# aura15 and misc0. None of these validation-only substitutions is serialized.
normalized['attributes']=[192,0,0,0,0]
if not isinstance(normalized.get('effects'),list)or len(normalized['effects'])!=3:raise ValueError('Complete damage-shield effects required')
for e in normalized['effects']:
if not isinstance(e,list)or len(e)!=12:raise ValueError('Damage-shield effect shape differs')
if not e[0]:continue
if any(type(e[i])is not int for i in(0,1,7))or e[0]!=6 or e[1]!=15 or e[7]:raise ValueError('Only constant passive damage-shield aura15/misc0 is reviewed')
e[1]=13;e[7]=1<<integer(src['school'],0,6,'source damage-shield school')
indices=static.validate_source(normalized,school_damage=True)
if src['conditions']['procChance']not in(0,101):raise ValueError('Unreviewed damage-shield proc chance')
return indices
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):
validate_source(src,semantics)
return {k:re.sub(r'\$s([123])(?![0-9])',lambda m:str(src['effects'][int(m[1])-1][2]+1),src[k])for k 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 damage-shield sources required')
if any(t not in native for t in(*REQUIRED_REFERENCE_TABLES,'SpellCastTimes','SpellDuration','SpellRange')):raise ValueError('Complete damage-shield 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 damage-shield 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 damage-shield 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 damage shields')
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']
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('Damage-shield parent has positive native reference: '+t)
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('Damage-shield icon FileDataID differs')
effects={i:dict(deepcopy(NEW_EFFECT_NEUTRAL),EffectAura=15,EffectBasePointsF=src['effects'][i][2]+1,EffectMiscValue=[0,0])for i in indices}
shown=dict(deepcopy(src),**description_fields(src,semantics));additions=new_definition_records(shown,effects,fid,schemas,maxima,registry,occupied,allocation_prefix='new-item-damage-shield-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,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)