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

112 lines
11 KiB
Python

"""Source-owned permanent item haste definitions; no client-side stat execution.
Melee, ranged and casting haste remain distinct effects. Attribute/school/aura
names and source value-multiplier/defense fields are reviewed explicitly; the
original restoration and finite-buff policies are not broadened.
"""
from copy import deepcopy
import hashlib,math
from pathlib import Path
from octo_client_data import canonical_sha256
from spell_result_profile import enum
from spell_passive_compat import (BUILD,SCHEMA,TABLES,SUPPLEMENTAL_TABLES,CONDITIONS,
CHILD_NEUTRAL,NEW_EFFECT_NEUTRAL,encode,integer,new_registry_values,verified_spell_icon)
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)
from item_batch_stage import available_index
POLICY='new-permanent-self-item-haste-definition-candidate-v1'
NAMESPACE='named-item-haste-semantics-v1'
HEADERS={'source':'fd1c65c0266b77a310c066bc3ccce86fe39f73a6cd10f67192d419009f95ead1',
'target':'9b0e2ad90eea77c961b00f1fc482e9d9e521aa85c58b63863a35d3a338a31799',
'source_aura':'ed7f67babe916cbbf91f7a1f1a9a9af694a2469d2e07eb10e94f0ae883678cb8',
'target_aura':'1784b495ea9704bbe12223c2ad42d9d5fea7d320f0dc6c0055cd090cb7e5498b'}
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),
('attributes0','SpellAttributes','SpellAttr0','SPELL_ATTR_HIDE_IN_COMBAT_LOG','SPELL_ATTR0_DO_NOT_LOG',256),
('attributes1','SpellAttributesEx','SpellAttr1','SPELL_ATTR_EX_DONT_DISPLAY_IN_AURA_BAR','SPELL_ATTR1_NO_AURA_ICON',0x10000000),
('school','SpellSchools','SpellSchools','SPELL_SCHOOL_NATURE','SPELL_SCHOOL_NATURE',3),
('damage_class','SpellDmgClass','SpellDmgClass','SPELL_DAMAGE_CLASS_MAGIC','SPELL_DAMAGE_CLASS_MAGIC',1),
('aura','AuraType','AuraType','SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK','SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK',65),
('aura','AuraType','AuraType','SPELL_AURA_MOD_MELEE_HASTE','SPELL_AURA_MOD_MELEE_HASTE',138),
('aura','AuraType','AuraType','SPELL_AURA_MOD_RANGED_HASTE','SPELL_AURA_MOD_RANGED_HASTE',140))
def namespace(paths):
if not isinstance(paths,dict)or set(paths)!=set(HEADERS):raise ValueError('Four explicit item-haste enum headers required')
for role,path in paths.items():
if hashlib.sha256(Path(path).read_bytes()).hexdigest()!=HEADERS[role]:raise ValueError('Pinned item-haste header changed')
mappings=[]
for kind,old_enum,new_enum,old,new,value in MAPPINGS:
a=enum(Path(paths['source_aura'if kind=='aura'else'source']),old_enum)[0]
b=enum(Path(paths['target_aura'if kind=='aura'else'target']),new_enum)[0]
if a.get(old)!=value or b.get(new)!=value:raise ValueError('Named item-haste semantics differ')
mappings.append(dict(kind=kind,source_name=old,target_name=new,source_value=value,target_value=value))
return dict(policy=NAMESPACE,header_sha256=dict(HEADERS),mappings=mappings)
def validate_namespace(proof):
expected=[dict(kind=k,source_name=a,target_name=b,source_value=v,target_value=v)for k,_,_,a,b,v in MAPPINGS]
if not isinstance(proof,dict)or not isinstance(proof.get('mappings'),list)or any(not isinstance(r,dict)or type(r.get('source_value'))is not int or type(r.get('target_value'))is not int for r in proof['mappings'])or proof.get('policy')!=NAMESPACE or proof.get('header_sha256')!=HEADERS or proof.get('mappings')!=expected:raise ValueError('Pinned named item-haste namespace required')
def source_spell(dbc,raw,offsets,*,family_namespace,semantics):
src=checked_constant_source(dbc,raw,offsets,family_namespace=family_namespace,item_haste_context=semantics)
validate_source(src);return src
def validate_source(src):
integer(src.get('entry'),1,0x7fffffff,'item haste source ID')
validate_namespace(src.get('item_haste_context'))
for key,count in(('attributes',5),('power',6),('equippedItem',3),('visuals',2)):
if not isinstance(src.get(key),list)or len(src[key])!=count or any(type(v)is not int for v in src[key]):raise ValueError('Typed item haste scalar groups required')
for key in('school','castingTimeIndex','durationIndex','rangeIndex','defense_type'):integer(src.get(key),0,0x7fffffff,'item haste '+key)
if type(src.get('speed'))not in(int,float)or not math.isfinite(src['speed']):raise ValueError('Typed item haste speed required')
multipliers=src.get('effect_value_multipliers')
if not isinstance(multipliers,list)or len(multipliers)!=3 or any(type(v)not in(int,float)or not math.isfinite(v)for v in multipliers):raise ValueError('Typed item haste value multipliers required')
if src.get('attributes')!=[448,0x10000000,0,0,0]or(src.get('school'),src.get('castingTimeIndex'),src.get('durationIndex'),src.get('rangeIndex'),src.get('speed'))!=(3,1,21,1,0):raise ValueError('Unreviewed permanent item-haste flags/school/timing')
if src.get('defense_type')!=1 or src.get('effect_value_multipliers')!=[1.0]*3:raise ValueError('Item haste defense/value multiplier semantics differ')
if src.get('power')!=[0]*6 or src.get('equippedItem')!=[-1,0,0]or src.get('visuals')!=[0,0]:raise ValueError('Unreviewed item haste power/equipment/visuals')
if validate_family(src.get('class_family'))!=0:raise ValueError('Generic source item-haste family required')
if not isinstance(src.get('conditions'),dict)or set(src['conditions'])!=set(CONDITIONS):raise ValueError('Complete item-haste conditions required')
for k,v in src['conditions'].items():integer(v,0,101 if k=='procChance'else 0,'item haste condition')
if src['conditions']['procChance']not in(0,101):raise ValueError('Unreviewed item-haste chance')
if not isinstance(src.get('timing'),dict)or set(src['timing'])!={'recoveryTime','categoryRecoveryTime','startRecoveryCategory','startRecoveryTime'}:raise ValueError('Complete item-haste timing fields required')
for v in src['timing'].values():integer(v,0,0,'item haste cooldown')
if not isinstance(src.get('levels'),dict)or set(src['levels'])!={'spellLevel','baseLevel','maxLevel'}:raise ValueError('Complete item-haste level fields required')
for v in src['levels'].values():integer(v,0,65535,'item haste level')
for k in('name','nameSubtext','description','auraDescription'):
if not isinstance(src.get(k),str)or '\0'in src[k]or len(src[k].encode())>4096:raise ValueError('Item haste text bound')
effects=src.get('effects');indices=[];auras=set()
if not src['name']or not isinstance(effects,list)or len(effects)!=3:raise ValueError('Complete item haste effects/name required')
for i,e in enumerate(effects):
review_effect_shape(e)
if e[:2]not in([6,65],[6,138],[6,140])or e[3:11]!=[1,1,0,0,0,1,0,0]or e[11]not in(-1,0)or e[1]in auras:raise ValueError('Unreviewed item haste effect/target')
integer(e[2]+1,1,1000,'item haste percentage');auras.add(e[1]);indices.append(i)
if auras!={65,138,140}:raise ValueError('Complete melee/ranged/casting haste effects required')
return indices
def new_component(sources,native,schemas,maxima,registry,*,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('Bounded item-haste sources required')
if any(t not in native for t in(*REQUIRED_REFERENCE_TABLES,'SpellCastTimes','SpellRange')):raise ValueError('Complete item-haste reference tables required')
if set(new_icon_ids)!={str(s['entry'])for s in sources}:raise ValueError('Explicit item-haste icons required')
tables=NEW_DEFINITION_CHILD_TABLES+('SpellCategories',)
for t in {'Spell','SpellName',*tables}:
if t not in schemas or canonical_sha256(schemas[t])!=(TABLES|SUPPLEMENTAL_TABLES)[t][2]:raise ValueError('Reviewed item-haste schema required')
review_new_timing(source_tables,native,21);registry=deepcopy(registry);available=available_index(icon_assets)
occupied={t:{r['ID']for r in native[t]}for t in tables};new_registry_values(registry,maxima,occupied,tables=tables)
categories=registry.pop('SpellCategories',{});records=[];spells=[]
for src in sorted(sources,key=lambda s:s['entry']):
indices=validate_source(src);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('Item haste candidate 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=src['effects'][i][1],EffectBasePointsF=src['effects'][i][2]+1,EffectAmplitude=src['effect_value_multipliers'][i],EffectMiscValue=[src['effects'][i][7],0])for i in indices}
records.extend(new_definition_records(src,effects,fid,schemas,maxima,registry,occupied,allocation_prefix='new-source-item-haste-definition'))
key=str(ident)
if key not in categories:categories[key]=max([maxima['SpellCategories'],*categories.values()])+1
record=dict(CHILD_NEUTRAL['SpellCategories'],ID=categories[key],SpellID=ident,DefenseType=src['defense_type']);wire=encode(record,schemas['SpellCategories'])
records.append(dict(table_name='SpellCategories',table_hash=hex(SUPPLEMENTAL_TABLES['SpellCategories'][0]),id=record['ID'],record=record,wire_hex=wire.hex(),sha256=hashlib.sha256(wire).hexdigest(),source_spell_id=ident,baseline_record_sha256=None,allocation_policy='new-source-item-haste-definition-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,source_semantics=deepcopy(src['item_haste_context']),defense_type=src['defense_type'],effect_value_multipliers=src['effect_value_multipliers'],icon_asset=dict(file_data_id=fid,**asset),known_spells_modified=False,engine_accepted=False))
registry['SpellCategories']=categories;new_registry_values(registry,maxima,occupied,tables=tables)
return dict(kind='source-item-haste-definition-candidates',build=BUILD,schema=SCHEMA,definition_policy=POLICY,records=records,spells=spells,child_id_registry=registry,installable=False,installed=False,engine_accepted=False,gameplay_verified=False,dependency_complete=False,limits=['Permanent three-effect self item haste only; source hidden/passive/log flags, school, defense type and value multipliers retained.','No learned state, server stat change, client proc execution or actual gameplay is synthesized.'])