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

237 lines
15 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Isolated Shield Slam definition prototype with explicit AP/range contracts.
Not registered with the production composer. Source combat scripts remain
server-owned, and native tooltip/API acceptance is an independent pending gate.
"""
from copy import deepcopy
from fractions import Fraction
import math
import spell_active_warrior_compat as active
POLICY = 'source-shield-slam-explicit-ap-definition-draft-v1'
FAMILY_IDS = (23922, 23923, 23924, 23925, 52315)
REVIEWED_NEW_IDS = (52315,)
SOURCE_AP_COEFFICIENT_FLAG = 0x800000
SOURCE_WEAPON_PROC_FLAG = 0x8000
def damage_range(source, index):
"""Source CalculateSpellDamage baseDice/irand interval; not a −1 offset rule."""
n = index + 1
for field in ('effectDicePerLevel', 'effectRealPointsPerLevel', 'effectPointsPerComboPoint'):
if source[field+str(n)] != 0:
raise ValueError('Unreviewed level/combo-dependent damage range')
base = source['effectBasePoints'+str(n)]
die = source['effectDieSides'+str(n)]
dice = source['effectBaseDice'+str(n)]
if any(type(x) is not int for x in (base, die, dice)):
raise ValueError('Noninteger source damage dice')
if die in (0, 1):
lower = upper = base + dice
else:
lower, upper = base + min(dice, die), base + max(dice, die)
if lower < 0 or upper < lower:
raise ValueError('Unreviewed negative damage range')
midpoint = Fraction(lower+upper, 2)
if midpoint == 0 and upper != lower:
raise ValueError('Zero-midpoint varying range')
variance = Fraction(upper-lower, 1) / midpoint if midpoint else Fraction(0)
return {'minimum': lower, 'maximum': upper, 'midpoint': float(midpoint),
'variance': float(variance), 'variance_fraction': str(variance),
'native_rng_parity_claimed': False}
def validate_source(source):
if any(type(value) is bool for value in source.values()):
raise ValueError('Boolean source scalar is not a typed numeric value')
if source['entry'] not in REVIEWED_NEW_IDS or source['name'] != 'Shield Slam':
raise ValueError('Not the captured Shield Slam source family')
if source['spellFamilyName'] != 4 or source['spellFamilyFlags'] != 0x102000000:
raise ValueError('Shield Slam family/mask drift')
import re
for key in ('name','nameSubtext','description','auraDescription'):
if not isinstance(source[key],str) or '\x00' in source[key]:
raise ValueError('Invalid source localized text')
if re.sub(r'\$s[12]', '', source['description']).find('$')!=-1:
raise ValueError('Unreviewed native description token')
attributes = active.map_attributes(source)
if attributes['held_source_bits']:
raise ValueError('Unmapped source attribute semantics')
if source['customFlags'] != SOURCE_AP_COEFFICIENT_FLAG | SOURCE_WEAPON_PROC_FLAG:
raise ValueError('Unreviewed source custom-flag behavior')
if source['script_name'] != 'spell_warrior_shield_slam':
raise ValueError('Missing authoritative Shield Slam source script')
if source['school'] != 0 or source['dmgClass'] != 2 or source['preventionType'] != 2:
raise ValueError('Unreviewed school/defense/prevention semantics')
if (source['equippedItemClass'], source['equippedItemSubClassMask'], source['equippedItemInventoryTypeMask']) != (4, 64, 0):
raise ValueError('Shield equipment requirement drift')
if (source['category'], source['categoryRecoveryTime'], source['recoveryTime'], source['startRecoveryCategory'], source['startRecoveryTime']) != (971, 6000, 0, 133, 1500):
raise ValueError('Unreviewed cooldown/category contract')
if (source['powerType'], source['manaCost']) != (1, 200):
raise ValueError('Unreviewed rage power/cost contract')
if (source['castingTimeIndex'], source['durationIndex'], source['rangeIndex'], source['spellVisual1'], source['spellVisual2'], source['spellIconId']) != (1, 0, 2, 42, 0, 413):
raise ValueError('Unreviewed native timing/range/icon/visual reference')
for key in ('activeIconId','requiresSpellFocus','casterAuraState','targetAuraState','targetCreatureType','maxAffectedTargets','maxTargetLevel','minTargetLevel','requiredAuraVision','interruptFlags','auraInterruptFlags','channelInterruptFlags','stances','stancesNot','speed','modelNextSpell','manCostPerLevel','manaCostPercentage','manaPerSecond','manaPerSecondPerLevel','procFlags','procCharges','stackAmount','mechanic','dispel'):
if source[key] != 0:
raise ValueError('Nonneutral unsupported source field: '+key)
if source['procChance'] != 101:
raise ValueError('Unreviewed inactive proc-chance default')
for prefix,count in (('reagent',8),('reagentCount',8),('totem',2)):
if any(source[prefix+str(i)] for i in range(1,count+1)):
raise ValueError('Unreviewed reagent/totem requirement')
if [source['effect'+str(i)] for i in (1,2,3)] != [38,2,0]:
raise ValueError('Incomplete source Dispel/SchoolDamage effect shape')
for n in (1,2):
for key in ('effectApplyAuraName','effectAmplitude','effectChainTarget','effectItemType','effectMechanic','effectMultipleValue','effectRadiusIndex','effectTriggerSpell'):
if source[key+str(n)] != 0:
raise ValueError('Unsupported source effect field: '+key)
if (source['effectImplicitTargetA'+str(n)],source['effectImplicitTargetB'+str(n)]) != (6,0):
raise ValueError('Enemy-unit target contract drift')
if source['dmgMultiplier'+str(n)] != 1:
raise ValueError('Unreviewed chain multiplier')
if source['effectMiscValue1'] != 1 or source['effectMiscValue2'] != 0:
raise ValueError('Magic dispel / damage miscellaneous operand drift')
if damage_range(source,0)['minimum'] != 1 or damage_range(source,0)['maximum'] != 1:
raise ValueError('Unsupported dispel count range')
# Dispel does not call the damage coefficient consumer. −1 is a source
# default-calculation sentinel, never a literal native coefficient.
if source['effectBonusCoefficient1'] not in (-1,0):
raise ValueError('Unreviewed unused dispel coefficient')
coefficient = source['effectBonusCoefficient2']
if type(coefficient) not in (int,float) or not math.isfinite(coefficient) or coefficient < 0:
raise ValueError('Damage needs an explicit finite AP coefficient, not default sentinel')
if coefficient != 0.2:
raise ValueError('Unreviewed explicit AP coefficient value')
return attributes
def _effect(source,index,template,record_id):
n=index+1
row=deepcopy(template)
if template['EffectIndex']!=index or template['Effect']!=(38 if index==0 else 2) or template['ImplicitTarget']!=[6,0]:
raise ValueError('Native effect kind/index/target counterpart drift')
row.update(ID=record_id,SpellID=source['entry'])
span=damage_range(source,index)
row.update(EffectBasePointsF=span['midpoint'],Variance=span['variance'],
EffectBonusCoefficient=0,BonusCoefficientFromAP=source['effectBonusCoefficient2'] if index==1 else 0)
# The counterpart is used only for named constructor defaults, never damage,
# power scaling or a source-script substitute. All remaining fields match
# this reviewed neutral shape; any additional field is rejected below.
neutral={'Node__Field_12_0_0_63534_001':0,'ScalingClass':0,
'EffectAura':0,'DifficultyID':0,'EffectAmplitude':0,'EffectAttributes':0,
'EffectAuraPeriod':0,'EffectChainAmplitude':1,'EffectChainTargets':0,
'EffectItemType':0,'EffectMechanic':0,'EffectPointsPerResource':0,
'EffectPos_facing':0,'EffectRealPointsPerLevel':0,'EffectTriggerSpell':0,
'PvpMultiplier':1,'Coefficient':0,'ResourceCoefficient':0,
'GroupSizeBasePointsCoefficient':1,'EffectMiscValue':[1 if index==0 else 0,0],
'EffectRadiusIndex':[0,0],'EffectSpellClassMask':[0,0,0,0]}
dynamic={'ID','SpellID','EffectIndex','Effect','ImplicitTarget','EffectBasePointsF','Variance','EffectBonusCoefficient','BonusCoefficientFromAP'}
if set(template) != set(neutral)|dynamic:
raise ValueError('Unreviewed native effect schema/default field')
if any(template[k]!=value for k,value in neutral.items()):
raise ValueError('Nonneutral native effect constructor drift')
return row
def records(source,relationships,controls,allocations):
"""Full native row proposal; production publication/API acceptance still gated."""
attrs=validate_source(source)
if relationships['spell_id']!=source['entry'] or relationships['visual_held']:
raise ValueError('Complete exact book/visual relationships required')
relationship_allocations={table:row['ID'] for table,row in relationships['records'].items() if table!='SpellName'}
expected=active.relationships(source,controls['source_sibling'],controls['relationship'],controls['source_abilities'],relationship_allocations)
if expected['records']!=relationships['records']:
raise ValueError('Source-derived book/class/level/visual relationship drift')
rows=deepcopy(expected['records'])
sid=source['entry']
rows['Spell']={'ID':sid,'NameSubtext_lang':source['nameSubtext'],
'Description_lang':source['description'],'AuraDescription_lang':source['auraDescription']}
misc=deepcopy(controls['misc'])
if misc['SpellID']!=23925 or (misc['CastingTimeIndex'],misc['RangeIndex'],misc['SchoolMask'],misc['SpellIconFileDataID'])!=(1,2,1,134951):
raise ValueError('Native timing/range/school/icon counterpart drift')
neutral={'DifficultyID':0,'DurationIndex':0,'PvPDurationIndex':0,'Speed':0,'LaunchDelay':0,'MinDuration':0,'ActiveIconFileDataID':0,'ContentTuningID':0,'ShowFutureSpellPlayerConditionID':0,'SpellVisualScript':0,'ActiveSpellVisualScript':0}
if set(misc)!=set(neutral)|{'ID','Attributes','CastingTimeIndex','RangeIndex','SchoolMask','SpellIconFileDataID','SpellID'}:
raise ValueError('Unreviewed native miscellaneous field')
if any(misc.get(k)!=v for k,v in neutral.items()):
raise ValueError('Native miscellaneous neutral constructor drift')
misc.update(ID=allocations['SpellMisc'],SpellID=sid,Attributes=attrs['native_attributes'])
rows['SpellMisc']=misc
category=deepcopy(controls['categories'])
expected={'ID':category['ID'],'SpellID':23925,'DifficultyID':0,'Category':971,'DefenseType':2,'DiminishType':0,'DispelType':0,'Mechanic':0,'PreventionType':2,'StartRecoveryCategory':133,'ChargeCategory':0}
if category!=expected:raise ValueError('Native category constructor drift')
category.update(ID=allocations['SpellCategories'],SpellID=sid);rows['SpellCategories']=category
cooldown=deepcopy(controls['cooldowns'])
expected={'ID':cooldown['ID'],'SpellID':23925,'DifficultyID':0,'CategoryRecoveryTime':6000,'RecoveryTime':0,'StartRecoveryTime':1500,'AuraSpellID':0}
if cooldown!=expected:raise ValueError('Native cooldown constructor drift')
cooldown.update(ID=allocations['SpellCooldowns'],SpellID=sid);rows['SpellCooldowns']=cooldown
power=deepcopy(controls['power'])
expected={'ID':power['ID'],'SpellID':23925,'OrderIndex':0,'ManaCost':200,'ManaCostPerLevel':0,'ManaPerSecond':0,'PowerDisplayID':0,'AltPowerBarID':0,'PowerCostPct':0,'PowerCostMaxPct':0,'OptionalCostPct':0,'PowerPctPerSecond':0,'PowerType':1,'RequiredAuraSpellID':0,'OptionalCost':0}
if power!=expected:raise ValueError('Native rage power constructor drift')
power.update(ID=allocations['SpellPower'],SpellID=sid);rows['SpellPower']=power
effect_controls=controls['effects']
if set(effect_controls)=={'0','1'}:effect_controls={int(k):v for k,v in effect_controls.items()}
elif set(effect_controls)!={0,1}:raise ValueError('Complete unique native counterpart effects required')
effects={i:_effect(source,i,effect_controls[i],allocations['SpellEffect:'+str(i)]) for i in (0,1)}
for table,row in rows.items():active.integer(row['ID'],table+' recordID',1)
for row in effects.values():active.integer(row['ID'],'effect recordID',1)
return {'records':rows,'effects':effects,'range_contract':damage_range(source,1),
'source_combat_scripts':{'damage':'Source OnEffectDamageCalculate adds actual shield block value; not reproduced as generic SP/AP coefficient.',
'dispel':'Source script rolls50%, modified by GagOrder ranks; native effect retains one magic dispel and original source text50%.'},
'full_native_row_prototype':True,'production_installable':False,
'remaining_gates':['original-native-api-absence','native-tooltip-range-and-AP-display-acceptance','production-composer-registration-review'],
'native_combat_or_rng_equivalence_claimed':False}
# These two exact70334 native schemas are not yet registered by the production
# passive composer. Keep this isolated extension explicit and independently pinned.
EXTRA_TABLES = {
'SpellPower': (2712461791, 1638736447, '9c9a40a32f6bbdd0523233601277cf0564c02cb1dde6bf3cf18bd13d537911ca'),
'SpellCooldowns': (4193483863, 3700710284, '6f89776b9c983d530ede55aaa3b3d3e4761b28829b59a57aaecc111c72723374'),
}
def extra_fields(path, table):
import re
from spell_passive_compat import BUILD, canonical_sha256
if table not in EXTRA_TABLES:raise ValueError('Unreviewed active spell table')
metadata=EXTRA_TABLES[table];text=path.read_text();kinds={}
for line in text.split('LAYOUT',1)[0].splitlines():
match=re.match(r'(int(?:<[^>]+>)?|float|locstring|string)\s+(\w+)\??',line)
if match:kinds[match[2]]=match[1].split('<')[0]
marker=f'LAYOUT {metadata[1]:08X}\n'
if text.count(marker)!=1:raise ValueError('Missing reviewed native layout')
block=text.split(marker,1)[1].split('\nLAYOUT',1)[0]
if BUILD not in block:raise ValueError('Native build differs')
result=[]
for line in block.splitlines():
if not line or line.startswith(('BUILD','COMMENT')) or line.startswith('$noninline,id$ID'):continue
line=re.sub(r'^\$[^$]+\$','',line)
match=re.fullmatch(r'(\w+)(?:<(u?)(8|16|32|64)>)?(?:\[(\d+)\])?',line)
if not match:raise ValueError('Unreviewed native field syntax')
name,unsigned,bits,count=match.groups();kind=kinds[name]
if kind=='int' and bits is None:raise ValueError('Missing native integer width')
result.append((name,kind,int(bits or 32),bool(unsigned),int(count or 1)))
if canonical_sha256(result)!=metadata[2]:raise ValueError('Reviewed native field sequence changed')
return result
def review_record(source, contract, candidate_row):
"""Exact per-row rederivation interface for a future generic composer hook.
The outer composer still owns raw-file pin verification, complete13-row set,
native API absence, allocation namespaces, schema and wire re-encoding.
"""
rebuilt=records(source,contract['relationships'],contract['controls'],contract['allocations'])
table=candidate_row.get('table_name');row=candidate_row.get('record')
if not isinstance(row,dict):raise ValueError('Missing typed native record')
if table=='SpellEffect':
index=row.get('EffectIndex')
if type(index) is not int or index not in rebuilt['effects']:
raise ValueError('Unreviewed active effect index')
expected=rebuilt['effects'][index]
else:
if table not in rebuilt['records']:raise ValueError('Unreviewed active definition table')
expected=rebuilt['records'][table]
if row!=expected or candidate_row.get('id')!=expected['ID']:
raise ValueError('Source-derived active definition record differs')
return True