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

89 lines
5.8 KiB
Python

"""Missing permanent flat spell modifiers with identity-derived affect masks.
Only named jump/chain-target semantics are reviewed. Server gameplay remains
authoritative; loading a definition does not grant it or apply a set bonus.
"""
from copy import deepcopy
import hashlib
import re
from octo_client_data import canonical_sha256
from spell_affect_compat import derive
from spell_item_static_compat import validate_source
from spell_passive_compat import (BUILD, SCHEMA, NEW_EFFECT_NEUTRAL,
verified_spell_icon, new_registry_values)
from spell_definition_common import (REQUIRED_REFERENCE_TABLES,
NEW_DEFINITION_CHILD_TABLES, review_new_timing, new_definition_records)
from item_batch_stage import available_index
POLICY='permanent-flat-chain-target-modifier-with-identity-affect-v1'
PINS={
'source_op':'fd1c65c0266b77a310c066bc3ccce86fe39f73a6cd10f67192d419009f95ead1',
'target_op':'9149582d4020bfc5d4a537512ad48b836c4bb47a33efc49841625475b42a6c08',
'source_aura':'ed7f67babe916cbbf91f7a1f1a9a9af694a2469d2e07eb10e94f0ae883678cb8',
'target_aura':'1784b495ea9704bbe12223c2ad42d9d5fea7d320f0dc6c0055cd090cb7e5498b'}
NAMES={'source_op':('SPELLMOD_JUMP_TARGETS',17),'target_op':('ChainTargets',17),
'source_aura':('SPELL_AURA_ADD_FLAT_MODIFIER',107),
'target_aura':('SPELL_AURA_ADD_FLAT_MODIFIER',107)}
def namespace(paths):
if set(paths)!=set(PINS):raise ValueError('Complete modifier namespace required')
for role,path in paths.items():
raw=path.read_bytes();name,value=NAMES[role]
if hashlib.sha256(raw).hexdigest()!=PINS[role] or not re.search(r'\b'+name+r'\s*=\s*'+str(value)+r'\s*,',raw.decode()):
raise ValueError('Reviewed modifier namespace changed: '+role)
return dict(policy=POLICY,header_sha256=dict(PINS),source_op=17,target_op=17,source_aura=107,target_aura=107)
def validate_namespace(proof):
expected=dict(policy=POLICY,header_sha256=dict(PINS),source_op=17,target_op=17,source_aura=107,target_aura=107)
if proof!=expected:raise ValueError('Named modifier namespace proof differs')
def review(component,spell):
proof=component.get('modifier_namespace')
validate_namespace(proof)
src=spell['source_definition'];indices=validate_source(src,flat_modifier=True)
if src.get('flat_modifier_namespace')!=proof:raise ValueError('Source capture modifier namespace differs')
if src['class_family']['target_id']!=4 or src['conditions']['procChance']not in(0,101):raise ValueError('Unreviewed modifier family/chance')
inputs=component['affect_inventory'];mappings=spell['affect_mappings']
if set(mappings)!={str(i)for i in indices}:raise ValueError('Complete effect affect masks required')
for index in indices:
mapping=mappings[str(index)]
actual=derive(inputs['source'],inputs['target'],4,mapping['source_mask'])
if actual!=mapping:raise ValueError('Modifier mapping differs from complete inventories')
return indices
def new_component(sources,native,schemas,maxima,registry,*,source_tables,
target_icon_names,new_icon_ids,icon_assets,read_icon,
modifier_namespace,affect_inventory,affect_masks):
if not isinstance(sources,list)or not 1<=len(sources)<=4096 or len({s['entry']for s in sources})!=len(sources):raise ValueError('Unique bounded modifier sources required')
if any(t not in native for t in(*REQUIRED_REFERENCE_TABLES,'SpellCastTimes','SpellDuration','SpellRange')):raise ValueError('Complete native modifier references required')
if set(new_icon_ids)!={str(s['entry'])for s in sources}:raise ValueError('Explicit modifier icon identity required')
review_new_timing(source_tables,native,21)
result=dict(kind='source-flat-modifier-definition-candidates',build=BUILD,schema=SCHEMA,
definition_policy=POLICY,modifier_namespace=deepcopy(modifier_namespace),
affect_inventory=deepcopy(affect_inventory),records=[],spells=[],
id_remapping=False,dependency_complete=False,installable=False,installed=False,
engine_accepted=False,gameplay_verified=False)
registry=deepcopy(registry);available=available_index(icon_assets)
if registry.get('SkillLineAbility'):raise ValueError('Modifier definition must not allocate learned-spell links')
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)
for src in sorted(sources,key=lambda s:s['entry']):
ident=src['entry'];indices=validate_source(src,flat_modifier=True)
spell=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,
affect_mappings={str(i):derive(affect_inventory['source'],affect_inventory['target'],4,affect_masks[f'{ident}:{i}'])for i in indices},known_spells_modified=False,engine_accepted=False)
review(result,spell)
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('Modifier has existing native reference: '+table)
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=107,EffectBasePointsF=src['effects'][i][2]+1,
EffectMiscValue=[17,0],EffectSpellClassMask=spell['affect_mappings'][str(i)]['target_mask'])for i in indices}
result['records'].extend(new_definition_records(src,effects,fid,schemas,maxima,registry,occupied,allocation_prefix='new-source-flat-modifier-definition'))
spell['icon_asset']=dict(file_data_id=fid,**asset);result['spells'].append(spell)
result['child_id_registry']=registry
return result