367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
127 lines
11 KiB
Python
127 lines
11 KiB
Python
"""Batch candidates for genuine permanent, flat physical armor penetration.
|
|
|
|
Uses the existing source checks, spell serializers, stable child allocator,
|
|
icon validation and package format. No item/spell ID allowlist, installation,
|
|
learned-spell state or client-side gameplay execution.
|
|
"""
|
|
from copy import deepcopy
|
|
import hashlib
|
|
import re
|
|
from pathlib import Path
|
|
from octo_client_data import canonical_sha256
|
|
from spell_result_profile import enum
|
|
from spell_item_haste_compat import HEADERS
|
|
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-item-flat-armor-penetration-candidate-v2'
|
|
NAMESPACE='named-item-flat-target-resistance-v1'
|
|
# Destination-only representation, not a Vanilla attribute bit. Five matching
|
|
# original native definitions and122 item/set contexts carry this marker.
|
|
# Controlled actual70334 A/B: without it25/40/50 become1375/2200/2750;
|
|
# changing ONLY it restores25/40/50. Its wider meaning remains unnamed.
|
|
# See docs/evidence/content-data/native-flat-armor-marker-12636-20261018/.
|
|
NATIVE_MARKER=dict(index=15,mask=0x2000,symbol='SPELL_ATTR15_UNK13')
|
|
MAPPINGS=(
|
|
('attributes','SpellAttributes','SpellAttr0','SPELL_ATTR_HIDDEN_CLIENTSIDE','SPELL_ATTR0_DO_NOT_DISPLAY_SPELLBOOK_AURA_ICON_COMBAT_LOG',128),
|
|
('school','SpellSchools','SpellSchools','SPELL_SCHOOL_NORMAL','SPELL_SCHOOL_NORMAL',0),
|
|
('defense','SpellDmgClass','SpellDmgClass','SPELL_DAMAGE_CLASS_MAGIC','SPELL_DAMAGE_CLASS_MAGIC',1),
|
|
('prevention','SpellPreventionType','SpellPreventionType','SPELL_PREVENTION_TYPE_SILENCE','SPELL_PREVENTION_TYPE_SILENCE',1),
|
|
('aura','AuraType','AuraType','SPELL_AURA_MOD_TARGET_RESISTANCE','SPELL_AURA_MOD_TARGET_RESISTANCE',123))
|
|
|
|
def namespace(paths):
|
|
if not isinstance(paths,dict)or set(paths)!=set(HEADERS):raise ValueError('Four pinned source/target enum headers required')
|
|
for role,path in paths.items():
|
|
if hashlib.sha256(Path(path).read_bytes()).hexdigest()!=HEADERS[role]:raise ValueError('Pinned resistance header changed')
|
|
rows=[]
|
|
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 resistance semantics differ')
|
|
rows.append(dict(kind=kind,source_name=old,target_name=new,source_value=value,target_value=value))
|
|
if enum(Path(paths['target']),'SpellAttr15')[0].get(NATIVE_MARKER['symbol'])!=NATIVE_MARKER['mask']:raise ValueError('Native flat-amount marker enum changed')
|
|
return dict(policy=NAMESPACE,header_sha256=dict(HEADERS),mappings=rows,native_marker=dict(NATIVE_MARKER))
|
|
|
|
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 proof.get('policy')!=NAMESPACE or proof.get('header_sha256')!=HEADERS or proof.get('mappings')!=expected or proof.get('native_marker')!=NATIVE_MARKER:raise ValueError('Pinned named target-resistance proof required')
|
|
if any(type(r.get(k))is not int for r in proof['mappings']for k in('source_value','target_value')):raise ValueError('Typed resistance enum values required')
|
|
|
|
def source_spell(dbc,raw,offsets,*,family_namespace,semantics):
|
|
src=checked_constant_source(dbc,raw,offsets,family_namespace=family_namespace,item_resistance_context=semantics)
|
|
validate_source(src);return src
|
|
|
|
def native_attributes(src):
|
|
"""Retain source flags and select verified flat-value native presentation."""
|
|
validate_namespace(src.get('item_resistance_context'))
|
|
if src.get('attributes')!=[128,0,0,0,0]:raise ValueError('Unreviewed flat-amount source attributes')
|
|
result=src['attributes']+[0]*12;result[NATIVE_MARKER['index']]=NATIVE_MARKER['mask']
|
|
return result
|
|
|
|
def validate_source(src):
|
|
integer(src.get('entry'),1,0x7fffffff,'item resistance source')
|
|
validate_namespace(src.get('item_resistance_context'));validate_family(src.get('class_family'))
|
|
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-resistance scalar groups required')
|
|
for key in('school','castingTimeIndex','durationIndex','rangeIndex','defense_type','prevention_type'):integer(src.get(key),0,0x7fffffff,'item resistance '+key)
|
|
if type(src.get('speed'))not in(int,float)or src['speed']!=0:raise ValueError('Unreviewed item-resistance speed')
|
|
if src['attributes']!=[128,0,0,0,0]or tuple(src[k]for k in('school','castingTimeIndex','durationIndex','rangeIndex','defense_type','prevention_type'))!=(0,1,21,1,1,1):raise ValueError('Unreviewed resistance flags/school/categories/timing')
|
|
if src['power']!=[0]*6 or src['equippedItem']!=[-1,0,0]or src['visuals']!=[0,0]:raise ValueError('Unreviewed resistance resources/equipment/visuals')
|
|
if set(src.get('conditions',{}))!=set(CONDITIONS):raise ValueError('Complete resistance conditions required')
|
|
for key,value in src['conditions'].items():integer(value,0,255 if key=='procChance'else 0,'resistance '+key)
|
|
if src['conditions']['procChance']not in(0,101):raise ValueError('Unreviewed no-trigger resistance chance')
|
|
if src.get('timing')!={k:0 for k in('recoveryTime','categoryRecoveryTime','startRecoveryCategory','startRecoveryTime')}or any(type(v)is not int for v in src['timing'].values()):raise ValueError('Resistance timing must be unconditional')
|
|
if src.get('levels')!={k:0 for k in('spellLevel','baseLevel','maxLevel')}or any(type(v)is not int for v in src['levels'].values()):raise ValueError('Unreviewed resistance level scaling')
|
|
if not isinstance(src.get('effects'),list)or len(src['effects'])!=3:raise ValueError('Three source resistance slots required')
|
|
active=[]
|
|
for i,e in enumerate(src['effects']):
|
|
review_effect_shape(e)
|
|
if not e[0]:
|
|
if e!=[0]*11+[-1]:raise ValueError('Non-neutral empty resistance slot')
|
|
continue
|
|
if e[:2]!=[6,123]or e[3:11]!=[1,1,0,0,1,1,0,0]or e[11]not in(-1,0):raise ValueError('Unreviewed flat physical target-resistance effect')
|
|
integer(e[2]+1,-0xffffff,-1,'negative target armor modifier');active.append(i)
|
|
if len(active)!=1:raise ValueError('One flat physical target-resistance effect required')
|
|
integer(src['spellIconId'],1,0x7fffffff,'source resistance icon')
|
|
for key in('name','nameSubtext','description','auraDescription'):
|
|
text=src.get(key)
|
|
if not isinstance(text,str)or '\0'in text or len(text.encode())>4096:raise ValueError('Resistance text bound')
|
|
if key in('description','auraDescription'):
|
|
for token in re.findall(r'\$[^\s.,%;:!?()]*',text):
|
|
if token!='$s'+str(active[0]+1):raise ValueError('Unreviewed resistance tooltip token')
|
|
if not src['name']:raise ValueError('Named resistance source required')
|
|
return active
|
|
|
|
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 resistance source identities required')
|
|
if any(t not in native for t in(*REQUIRED_REFERENCE_TABLES,'SpellCastTimes','SpellRange')):raise ValueError('Complete resistance reference tables required')
|
|
if set(new_icon_ids)!={str(s['entry'])for s in sources}:raise ValueError('Explicit resistance icon identities required')
|
|
tables=NEW_DEFINITION_CHILD_TABLES+('SpellCategories',)
|
|
for table in {'Spell','SpellName',*tables}:
|
|
if table not in schemas or canonical_sha256(schemas[table])!=(TABLES|SUPPLEMENTAL_TABLES)[table][2]:raise ValueError('Reviewed resistance 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 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('Resistance 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=123,EffectBasePointsF=src['effects'][i][2]+1,EffectMiscValue=[1,0])for i in indices}
|
|
generated=new_definition_records(src,effects,fid,schemas,maxima,registry,occupied,allocation_prefix='new-source-item-resistance-definition')
|
|
for row in generated:
|
|
if row['table_name']=='SpellMisc':
|
|
row['record']['Attributes']=native_attributes(src);wire=encode(row['record'],schemas['SpellMisc']);row.update(wire_hex=wire.hex(),sha256=hashlib.sha256(wire).hexdigest())
|
|
records.extend(generated)
|
|
key=str(ident)
|
|
if key not in categories:categories[key]=max([maxima['SpellCategories'],*categories.values()])+1
|
|
row=dict(CHILD_NEUTRAL['SpellCategories'],ID=categories[key],SpellID=ident,DefenseType=src['defense_type'],PreventionType=src['prevention_type']);wire=encode(row,schemas['SpellCategories'])
|
|
records.append(dict(table_name='SpellCategories',table_hash=hex(SUPPLEMENTAL_TABLES['SpellCategories'][0]),id=row['ID'],record=row,wire_hex=wire.hex(),sha256=hashlib.sha256(wire).hexdigest(),source_spell_id=ident,baseline_record_sha256=None,allocation_policy='new-source-item-resistance-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,defense_type=src['defense_type'],prevention_type=src['prevention_type'],source_semantics=deepcopy(src['item_resistance_context']),icon_asset=dict(file_data_id=fid,**asset),filtered_reference_absence_only=True,installed_definition_absence_verified=False,known_spells_modified=False,engine_accepted=False,gameplay_verified=False))
|
|
registry['SpellCategories']=categories;new_registry_values(registry,maxima,occupied,tables=tables)
|
|
return dict(kind='source-item-resistance-definition-candidates',build=BUILD,schema=SCHEMA,definition_policy=POLICY,records=records,spells=spells,child_id_registry=registry,id_remapping=False,installable=False,installed=False,engine_accepted=False,gameplay_verified=False,dependency_complete=False,limits=['Signed negative physical target-armor modifiers only; not percent penetration, rating or magic resistance.','Full original-client absence, icon registration, cache acceptance and actual tooltip/equipped behavior still require real-client verification.','No item-specific IDs, learned spells, fabricated server state or local damage execution.'])
|