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

360 lines
21 KiB
Python

"""Reviewed Warrior active-spell relationship and definition-only proposals.
This is deliberately NOT a production definition-composer policy: book/identity
rows alone cannot stand in for complete effects, timing, power and text. Combat
remains source-server authoritative. Consumers must preserve the explicit holds.
"""
from copy import deepcopy
POLICY = 'source-warrior-active-book-relationships-draft-v1'
# Named source/native semantic pairs, not positional flag copying. The two
# Attr3 bits deliberately exchange positions between the two client schemas.
ATTRIBUTE_PAIRS = (
(0, 0x10, 0, 0x10, 'IS_ABILITY'),
(0, 0x10000, 0, 0x10000, 'NOT_SHAPESHIFTED'),
(0, 0x40000, 0, 0x40000, 'DO_NOT_SHEATH'),
(1, 0x200, 1, 0x200, 'INITIATES_COMBAT_ENABLES_AUTO_ATTACK'),
(1, 0x08000000, 1, 0x08000000, 'DISCOUNT_POWER_ON_MISS'),
(3, 0x8, 3, 0x8, 'COMPLETELY_BLOCKED'),
(3, 0x40000, 3, 0x400, 'REQUIRES_MAIN_HAND_WEAPON'),
(3, 0x400, 3, 0x40000, 'ALWAYS_HIT'),
)
ATTR_KEYS = ('attributes', 'attributesEx', 'attributesEx2', 'attributesEx3', 'attributesEx4')
def integer(value, name, low=0, high=0xffffffff):
if type(value) is not int or not low <= value <= high:
raise ValueError('Invalid ' + name)
return value
def map_attributes(source):
remaining = [integer(source[k], k) for k in ATTR_KEYS]
native = [0] * 17
names = []
for si, sb, ni, nb, name in ATTRIBUTE_PAIRS:
if remaining[si] & sb:
remaining[si] &= ~sb
native[ni] |= nb
names.append(name)
return {'native_attributes': native, 'named_semantics': names,
'held_source_bits': [{'attribute_index': i, 'bits': value}
for i, value in enumerate(remaining) if value]}
def source_ability(rows, spell):
"""Read the complete classic15-column SLA shape, rejecting hidden extras."""
seen = {}
predecessor = {}
for raw in rows:
if not isinstance(raw, list) or len(raw) != 15:
raise ValueError('Incomplete source SkillLineAbility row')
for value in raw:
integer(value, 'source SkillLineAbility value')
if raw[2] in seen:
raise ValueError('Duplicate source ability')
if any(raw[n] for n in (5, 6, 12, 13, 14)):
raise ValueError('Unsupported excluded mask/unknown/training-point fields')
if raw[3] or raw[9] or raw[10] or raw[11]:
raise ValueError('Unreviewed race/acquisition/trivial skill semantics')
if raw[4] not in (0, 1) or raw[7] != 1:
raise ValueError('Unreviewed class/minimum skill mapping')
seen[raw[2]] = raw
if raw[8]:
if raw[8] in predecessor:
raise ValueError('Ambiguous source successor')
predecessor[raw[8]] = raw[2]
for start in seen:
visited = set()
current = start
while current in seen and seen[current][8]:
if current in visited:
raise ValueError('Cyclic source rank chain')
visited.add(current)
current = seen[current][8]
if spell not in seen:
raise ValueError('Missing source ability')
return seen[spell], predecessor.get(spell, 0)
def _check_control(control_source, control_native, ability):
if any(control_native[k]['SpellID'] != control_source['entry'] for k in ('class', 'equipped')):
raise ValueError('Counterpart parent identity drift')
if control_source['spellFamilyName'] != 4 or control_native['class']['SpellClassSet'] != 4:
raise ValueError('Warrior family identity not proven')
if control_native['class']['ModalNextSpell'] != control_source['modelNextSpell']:
raise ValueError('Modal spell drift')
mask = integer(control_source['spellFamilyFlags'], 'source own mask', high=0xffffffffffffffff)
if control_native['class']['SpellClassMask'] != [mask & 0xffffffff, mask >> 32, 0, 0]:
raise ValueError('Counterpart source/native class mask drift')
# Source/target skill identity and complete target neutral constructor are
# checked against the existing same-ID counterpart before sibling reuse.
expected = {'ID': control_native['ability']['ID'], 'AbilityVerb_lang': '',
'AbilityAllVerb_lang': '', 'SkillLine': ability[1], 'Spell': ability[2],
'MinSkillLineRank': ability[7], 'ClassMask': ability[4],
'SupercedesSpell': control_native['ability']['SupercedesSpell'],
'AcquireMethod': 0, 'TrivialSkillLineRankHigh': 0,
'TrivialSkillLineRankLow': 0, 'Flags': 0, 'NumSkillUps': 1,
'UniqueBit': 0, 'TradeSkillCategoryID': 0, 'SkillupSkillLineID': 0,
'Field_5_5_4_67090_014': [0, 0], 'RaceMasks': [0, 0]}
if control_native['ability'] != expected:
raise ValueError('Counterpart ability constructor drift')
eq = control_native['equipped']
if {k: eq[k] for k in ('EquippedItemClass', 'EquippedItemInvTypes', 'EquippedItemSubclass')} != {
'EquippedItemClass': control_source['equippedItemClass'],
'EquippedItemInvTypes': control_source['equippedItemInventoryTypeMask'],
'EquippedItemSubclass': control_source['equippedItemSubClassMask']}:
raise ValueError('Counterpart equipment identity drift')
def relationships(source, control_source, control_native, source_abilities, allocations):
"""Generate supported *whole rows* only; missing parent definitions stay held.
allocations are explicit fresh table IDs reviewed by the isolated preparer.
Source counterpart identity supplies skill/equipment/class semantics; names,
levels and predecessor are independently reconstructed from source evidence.
"""
sid = integer(source['entry'], 'spell identity', 1)
cid = integer(control_source['entry'], 'counterpart identity', 1)
ability, previous = source_ability(source_abilities, sid)
ca, _ = source_ability(source_abilities, cid)
_check_control(control_source, control_native, ca)
if source['spellFamilyName'] != 4 or source['modelNextSpell'] != 0:
raise ValueError('Unreviewed source family/modal identity')
if ability[1] != ca[1] or ability[4] != ca[4]:
raise ValueError('Sibling skill/class identity drift')
for key in ('equippedItemClass', 'equippedItemInventoryTypeMask', 'equippedItemSubClassMask'):
if source[key] != control_source[key]:
raise ValueError('Sibling equipment contract drift')
smask = integer(source['spellFamilyFlags'], 'source own mask', high=0xffffffffffffffff)
cmask = control_source['spellFamilyFlags']
if source['name'] == control_source['name'] and smask != cmask:
raise ValueError('Sibling own-mask drift')
if smask not in (0, cmask):
raise ValueError('Unreviewed sibling own-mask identity')
if not isinstance(source['name'], str) or not source['name'] or '\x00' in source['name']:
raise ValueError('Invalid source spell name')
rows = {'SpellName': {'ID': sid, 'Name_lang': source['name']},
'SpellClassOptions': {'ID': allocations['SpellClassOptions'], 'SpellID': sid,
'ModalNextSpell': 0, 'SpellClassSet': 4,
'SpellClassMask': [smask & 0xffffffff, smask >> 32, 0, 0]},
'SpellLevels': {'ID': allocations['SpellLevels'], 'SpellID': sid,
'DifficultyID': 0, 'MaxLevel': integer(source['maxLevel'], 'maximum level'),
'MaxPassiveAuraLevel': 0, 'BaseLevel': integer(source['baseLevel'], 'base level'),
'SpellLevel': integer(source['spellLevel'], 'spell level')},
'SpellEquippedItems': {'ID': allocations['SpellEquippedItems'], 'SpellID': sid,
'EquippedItemClass': source['equippedItemClass'],
'EquippedItemInvTypes': source['equippedItemInventoryTypeMask'],
'EquippedItemSubclass': source['equippedItemSubClassMask']}}
sla = deepcopy(control_native['ability'])
sla.update(ID=allocations['SkillLineAbility'], Spell=sid, SupercedesSpell=previous)
rows['SkillLineAbility'] = sla
visual = control_native.get('visual')
visual_held = True
if source['spellVisual1'] == control_source['spellVisual1'] and not source['spellVisual2'] and visual:
if visual['SpellVisualID'] != source['spellVisual1'] or visual['SpellID'] != cid:
raise ValueError('Counterpart visual identity drift')
expected = {'ID': visual['ID'], 'SpellID': cid, 'DifficultyID': 0,
'SpellVisualID': source['spellVisual1'], 'Probability': 1,
'CasterPlayerConditionID': 0, 'CasterUnitConditionID': 0,
'ViewerPlayerConditionID': 0, 'ViewerUnitConditionID': 0,
'SpellIconFileID': 0, 'ActiveIconFileID': 0, 'Flags2': 0, 'Priority': 1}
if visual != expected:
raise ValueError('Unreviewed visual conditional/flags constructor')
rows['SpellXSpellVisual'] = dict(visual, ID=allocations['SpellXSpellVisual'], SpellID=sid)
visual_held = False
for table, row in rows.items():
integer(row['ID'], table + ' record identity', 1)
return {'spell_id': sid, 'control_spell_id': cid, 'records': rows,
'attribute_proposal': map_attributes(source), 'visual_held': visual_held,
'complete_definition': False, 'production_installable': False,
'held_dependencies': ['complete-effect-coefficients-and-variance',
'native-description-token-contract', 'timing-power-category-closure',
'original-native-api-before-and-book-acceptance']}
CONCUSSION_POLICY = 'source-concussion-mixed-definition-only-v1'
CONCUSSION_KIND = 'source-concussion-definition-candidates'
CONCUSSION_NEW_IDS = (51600, 51601, 51602)
CONCUSSION_DEFAULT_COEFFICIENT = 1353 / 3500
def concussion_source(source):
"""Exact captured rank family; Source combat eligibility remains authoritative."""
from spell_shield_slam_compat import damage_range
sid = source.get('entry')
if sid not in CONCUSSION_NEW_IDS or source.get('name') != 'Concussion Blow':
raise ValueError('Unreviewed Concussion source family')
rank = CONCUSSION_NEW_IDS.index(sid) + 2
if (source.get('nameSubtext'), source.get('baseLevel'), source.get('spellLevel')) != (f'Rank {rank}', (48,54,60)[rank-2], (48,54,60)[rank-2]):
raise ValueError('Source Concussion rank/level drift')
if any(type(v) is bool for v in source.values()):
raise ValueError('Boolean source scalar')
expected = dict(spellFamilyName=4, spellFamilyFlags=67108864,
attributes=327696, attributesEx=134218240, attributesEx2=0,
attributesEx3=1024, attributesEx4=1, customFlags=0, script_name='',
school=0, dmgClass=2, preventionType=2, category=1167,
categoryRecoveryTime=20000, recoveryTime=0,
startRecoveryCategory=133, startRecoveryTime=1500,
powerType=0, manaCost=0, castingTimeIndex=1, durationIndex=27,
rangeIndex=2, spellVisual1=2719, spellVisual2=0, spellIconId=25,
equippedItemClass=2, equippedItemSubClassMask=173555,
equippedItemInventoryTypeMask=0, procChance=101)
for key, value in expected.items():
if source.get(key) != value:
raise ValueError('Concussion source role drift: '+key)
zero = ('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','maxLevel','targets')
if any(source.get(k) != 0 for k in zero):
raise ValueError('Unsupported Concussion parent requirement/default')
for prefix, count in (('reagent',8),('reagentCount',8),('totem',2)):
if any(source.get(prefix+str(i)) != 0 for i in range(1,count+1)):
raise ValueError('Unsupported Concussion reagent/totem')
for key in ('name','nameSubtext','description','auraDescription'):
if not isinstance(source.get(key),str) or '\x00' in source[key]:
raise ValueError('Invalid Concussion localized text')
if source['auraDescription'] != 'Stunned.' or source['description'] != (
"Deals $s2 damage and stuns the opponent for $d. This ability deals a high amount of threat and penetrates 100% of the enemy's armor. Instantly generates $/10;s3 rage."):
raise ValueError('Unreviewed Concussion text/token contract')
for i, (kind,aura,target,mechanic,misc,base) in enumerate(
((6,12,6,12,0,0),(2,0,6,0,0,(150,190,235)[rank-2]),(30,0,1,0,1,100)),1):
wanted = {'effect':kind,'effectApplyAuraName':aura,
'effectImplicitTargetA':target,'effectImplicitTargetB':0,
'effectMechanic':mechanic,'effectMiscValue':misc,
'effectBonusCoefficient':-1,'dmgMultiplier':1}
wanted.update({k:0 for k in ('effectAmplitude','effectChainTarget',
'effectItemType','effectMultipleValue','effectRadiusIndex','effectTriggerSpell')})
if any(source.get(k+str(i)) != v for k,v in wanted.items()):
raise ValueError('Concussion effect role/default drift')
span = damage_range(source,i-1)
if span['minimum'] != base or span['maximum'] != base:
raise ValueError('Concussion deterministic effect operand drift')
# This extension does not change global attribute admission. Source Ex4bit1
# is a server resistance/hit rule, never copied to a native attribute word.
projected = dict(source, attributesEx4=0)
attrs = map_attributes(projected)
if attrs['held_source_bits'] or attrs['native_attributes'][3] != 0x40000:
raise ValueError('Concussion named attribute projection differs')
return attrs
def concussion_records(source, contract):
"""Compose separately proved effect roles; never emulate Source combat."""
from spell_shield_slam_compat import _effect as neutral_damage_effect
attrs = concussion_source(source)
controls, allocation = contract['controls'], contract['allocations']
sid = source['entry']
sibling = controls['source_sibling']
if sibling.get('entry') != 12809 or sibling.get('spellFamilyFlags') != 67108864:
raise ValueError('Original Concussion relationship control required')
expected = relationships(source,sibling,controls['relationship'],controls['source_abilities'],allocation)
if expected['visual_held'] or contract['relationships']['records'] != expected['records']:
raise ValueError('Complete source-derived Concussion book/VFX required')
rows = deepcopy(expected['records'])
rows['Spell'] = dict(ID=sid,NameSubtext_lang=source['nameSubtext'],
Description_lang=source['description'],AuraDescription_lang=source['auraDescription'])
misc = deepcopy(controls['misc'])
if (misc.get('SpellID'),misc.get('CastingTimeIndex'),misc.get('DurationIndex'),misc.get('RangeIndex'),misc.get('SchoolMask'),misc.get('SpellIconFileDataID')) != (12809,1,28,2,1,132325) or misc.get('Attributes') != [327696,134218240,0,1024,0,0,0,0,0,0,0,0,0,128,0,8192,0]:
raise ValueError('Original Concussion timing/icon control differs')
neutral_misc = dict(DifficultyID=0,PvPDurationIndex=0,Speed=0,LaunchDelay=0,
MinDuration=0,ActiveIconFileDataID=0,ContentTuningID=0,
ShowFutureSpellPlayerConditionID=0,SpellVisualScript=0,ActiveSpellVisualScript=0)
if set(misc) != set(neutral_misc)|{'ID','Attributes','CastingTimeIndex','DurationIndex','RangeIndex','SchoolMask','SpellIconFileDataID','SpellID'} or any(misc[k]!=v for k,v in neutral_misc.items()):
raise ValueError('Unreviewed Concussion Misc defaults')
misc.update(ID=allocation['SpellMisc'],SpellID=sid,DurationIndex=27,
Attributes=attrs['native_attributes'])
rows['SpellMisc'] = misc
cat = deepcopy(controls['categories'])
if cat != dict(ID=cat['ID'],SpellID=12809,DifficultyID=0,Category=0,
DefenseType=2,DiminishType=4,DispelType=0,Mechanic=12,
PreventionType=2,StartRecoveryCategory=133,ChargeCategory=0):
raise ValueError('Original native stun category profile differs')
shared = contract['shared_category']
if shared.get('source_category') != 1167 or shared.get('policy') != 'owned-concussion-neutral-category-v1':
raise ValueError('Explicit owned shared category required')
category_id = integer(shared.get('record',{}).get('ID'),'owned categoryID',1,32767)
if category_id == 1167:
raise ValueError('Source/native category identity cannot be assumed')
cat.update(ID=allocation['SpellCategories'],SpellID=sid,Category=category_id,Mechanic=0)
rows['SpellCategories'] = cat
power = deepcopy(controls['power'])
if power.get('SpellID')!=12809 or power.get('PowerType')!=1 or power.get('ManaCost')!=100:
raise ValueError('Original Rage cost control differs')
if any(v for k,v in power.items() if k not in ('ID','SpellID','PowerType','ManaCost')):
raise ValueError('Unreviewed power defaults')
power.update(ID=allocation['SpellPower'],SpellID=sid,PowerType=0,ManaCost=0)
rows['SpellPower'] = power
cooldown = deepcopy(controls['cooldowns'])
if cooldown != dict(ID=cooldown['ID'],SpellID=12809,DifficultyID=0,
CategoryRecoveryTime=0,RecoveryTime=45000,StartRecoveryTime=0,AuraSpellID=0):
raise ValueError('Original cooldown profile differs')
cooldown.update(ID=allocation['SpellCooldowns'],SpellID=sid,
CategoryRecoveryTime=20000,RecoveryTime=0,StartRecoveryTime=1500)
rows['SpellCooldowns'] = cooldown
# Reuse the established full neutral Effect2 constructor/default validator.
# The Source sentinel is resolved, not forwarded or turned into an AP term.
effect_source = dict(source,effectBonusCoefficient2=0)
damage = neutral_damage_effect(effect_source,1,controls['damage_effect'],allocation['SpellEffect:1'])
damage['EffectBonusCoefficient'] = CONCUSSION_DEFAULT_COEFFICIENT
effects = {1:damage}
for index, key, sid_control, effect, aura, target, misc, bp in (
(0,'stun_effect',12809,6,12,[6,0],[0,0],0),
(2,'rage_effect',2687,30,0,[1,0],[1,0],100)):
original = controls[key]
neutral = dict(damage,ID=original['ID'],SpellID=sid_control,EffectIndex=0,
Effect=effect,EffectAura=aura,ImplicitTarget=target,EffectMiscValue=misc,
EffectBasePointsF=bp,EffectBonusCoefficient=0)
if original != neutral:
raise ValueError('Original stun/Rage full neutral effect control differs')
output = deepcopy(original)
output.update(ID=allocation['SpellEffect:'+str(index)],SpellID=sid,EffectIndex=index)
if index==0:
output['EffectMechanic'] = 12
effects[index] = output
for table,row in rows.items():
integer(row['ID'],table+' record identity',1)
if len(rows)!=11 or set(effects)!={0,1,2}:
raise ValueError('Complete fourteen-row Concussion definition required')
return dict(records=rows,effects=effects,full_native_row_prototype=True,
production_installable=False,native_combat_or_rng_equivalence_claimed=False,
resolved_source_damage_coefficient=CONCUSSION_DEFAULT_COEFFICIENT,
source_server_only_attributes=[dict(attribute_index=4,bits=1,role='IGNORE_RESISTANCES')],
source_dynamic_benefit='School/weapon-matching physical flat auras and creature bonus; Source SpellMod remains authoritative. No total-AP substitution.',
original_base_12809_unchanged=True)
def review_concussion_record(source,contract,candidate):
rebuilt=concussion_records(source,contract)
table,row=candidate.get('table_name'),candidate.get('record')
if table=='SpellEffect':
expected=rebuilt['effects'].get(row.get('EffectIndex')) if isinstance(row,dict) else None
else:
expected=rebuilt['records'].get(table)
if expected is None or row!=expected or candidate.get('id')!=expected['ID']:
raise ValueError('Source-derived Concussion definition record differs')
return True
def concussion_category(shared):
"""One owned grouping identity; never aliases the source numeric category."""
if shared.get('policy') != 'owned-concussion-neutral-category-v1' or shared.get('source_category') != 1167:
raise ValueError('Unreviewed Concussion category contract')
native = shared.get('native_control')
expected = dict(ID=38,Name_lang='Aura',Flags=0,UsesPerWeek=0,
MaxCharges=0,ChargeRecoveryTime=0,TypeMask=0)
if native != expected:
raise ValueError('Original neutral category constructor differs')
row = shared.get('record')
rid = integer(row.get('ID') if isinstance(row,dict) else None,'owned categoryID',1,32767)
if shared.get('native_max_id') != 2595 or shared.get('native_db2_sha256') != 'a8e93a3a261b6764c51a2f9699efde547c1849f51a1112beacf212b2f939004f':
raise ValueError('Pinned whole original category namespace required')
if rid == 1167 or rid <= integer(shared.get('native_max_id'),'native category namespace',1):
raise ValueError('Owned category overlaps original/source namespace')
if row != dict(expected,ID=rid,Name_lang='Concussion Blow'):
raise ValueError('Unreviewed category feature/default')
return deepcopy(row)