367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
86 lines
6.9 KiB
Python
86 lines
6.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Observe an owned equip aura while removing/restoring the same real item.
|
|
|
|
Designated disposable character only; no grants, SQL writes, fabricated aura,
|
|
forced alpha or engine calls. Samples require actual visual review. Final item
|
|
and original GM settings are retained even when a diagnostic fails.
|
|
"""
|
|
import argparse,json,time
|
|
from pathlib import Path
|
|
import client_ui as ui
|
|
from client_session import Session
|
|
from local_tortoise import db
|
|
from native_engine_character_test import Controller,ROOT,local_listeners
|
|
from native_test_guard import require_local_turtle_ports,require_authenticated_turtle_realm,require_native_gameplay_policy,require_solo_test_character
|
|
from native_vendor_buy_test import inventory
|
|
from native_world_trace import WorldTrace
|
|
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__)
|
|
for name in ('item','entry','root','spell'):p.add_argument('--'+name,type=int,required=True)
|
|
p.add_argument('--sample-seconds',type=float,default=0,help='Bounded measured capture duration per equipment phase,0..10seconds')
|
|
p.add_argument('--require-equip-go',action='store_true',help='Require a new source equip GO correlated with its native original-writer GO')
|
|
p.add_argument('--observe-description',action='store_true',help='Print the original spell-description API at each phase for screenshot comparison')
|
|
p.add_argument('--output',type=Path,required=True);a=p.parse_args();out=a.output.resolve()
|
|
if not out.is_relative_to(ROOT/'runtime') or out.exists() or out.suffix!='.json' or not 23<=a.root<39 or not 0<=a.sample_seconds<=10 or any(not 0<v<2**31 for v in (a.item,a.entry,a.spell)):p.error('Require bounded fixture and new runtime report')
|
|
require_local_turtle_ports(local_listeners());c=Controller(int((ROOT/'runtime/native-client.pid').read_text()));require_authenticated_turtle_realm(c.rpc('inspect-wire-account'));require_native_gameplay_policy(c.rpc('inspect-native-channel-policy'));require_solo_test_character(4509,db('SELECT guid FROM tw_char.characters WHERE online<>0 ORDER BY guid;'))
|
|
neck=lambda:db('SELECT item FROM tw_char.character_inventory WHERE guid=4509 AND bag=0 AND slot=1;')
|
|
state=lambda:db('SELECT health,power2,money,extra_flags FROM tw_char.characters WHERE guid=4509;')
|
|
source=db(f'SELECT ii.itemEntry,it.inventory_type,it.spellid_1,it.spelltrigger_1 FROM tw_char.item_instance ii JOIN tw_world.item_template it ON it.entry=ii.itemEntry WHERE ii.guid={a.item} AND ii.owner_guid=4509;')
|
|
if source!=f'{a.entry}\t2\t{a.spell}\t1' or neck()!=str(a.item) or db(f'SELECT item FROM tw_char.character_inventory WHERE guid=4509 AND bag=0 AND slot={a.root};'):raise RuntimeError('Owned neck or empty backpack fixture differs; no input')
|
|
def pipe():
|
|
v=c.rpc('inspect-engine-pipe')
|
|
if v['error'] or v['closed']:raise RuntimeError('Native session unavailable; preserve fixture')
|
|
return v
|
|
def aura_present():return any(v['spell']==a.spell and v['queued'] for v in pipe()['auras']['rows'])
|
|
r=dict(pid=c.pid,item=a.item,entry=a.entry,spell=a.spell,external_gateway_running=False,restoration_pending=False,model_effect_verified=False,ui_review_required=True,samples=[])
|
|
def save():out.write_text(json.dumps(r,indent=2)+'\n');out.chmod(0o600)
|
|
old=ui.KEY_DELAY
|
|
with Session(c.pid) as s, WorldTrace(c) as trace:
|
|
def sample(label):
|
|
row=dict(label=label,monotonic=time.monotonic(),aura_slots=pipe()['auras'])
|
|
s.shot(out.with_name(out.stem+'-'+label+'.png'));r['samples'].append(row);save()
|
|
def phase(label):
|
|
if a.observe_description:
|
|
s.macro('/run if C_Spell.GetSpellDescription then print("EquipProbe '+label+'",C_Spell.GetSpellDescription('+str(a.spell)+')) end')
|
|
start=time.monotonic();count=0
|
|
# Capture repeatedly at actual screenshot speed; save measured frame
|
|
# times instead of assuming three rapid frames cover an animation.
|
|
while count<3 or time.monotonic()-start<a.sample_seconds:
|
|
if count>=30:raise RuntimeError('Visual sample bound exhausted')
|
|
sample(label+'-'+str(count));count+=1
|
|
try:
|
|
s.wait_world();ui.KEY_DELAY=.06;ui.key(s.d,'F1');s.macro('/s .save');before=state();baseline=inventory(4509);flags=int(before.split('\t')[3])
|
|
if flags&17!=17:raise RuntimeError('Require original GM-on/invisible baseline')
|
|
r.update(before_state=before,before_inventory=baseline,restoration_pending=True);save()
|
|
s.macro('/s .gm visible on');s.macro('/s .gm off');s.macro('/s .save');c.wait(lambda:int(state().split('\t')[3])==flags&~17,8)
|
|
phase('equipped')
|
|
s.macro('/run PickupInventoryItem(2);C_Container.PickupContainerItem(0,'+str(a.root-22)+')');s.macro('/s .save')
|
|
c.wait(lambda:not neck() and not aura_present(),8);r['source_removed']=True;save()
|
|
phase('removed')
|
|
r['restore_after_index']=pipe()['world']['trace_count']-1;save()
|
|
s.macro('/use 0 '+str(a.root-22));s.macro('/s .save');c.wait(lambda:neck()==str(a.item) and aura_present(),8);r['source_restored']=True;save()
|
|
if a.require_equip_go:
|
|
native=trace.wait(3,0x69002c,after_index=r['restore_after_index'])
|
|
source=trace.source_before(native,0x132,after_index=r['restore_after_index'])
|
|
r['equip_go']=dict(source=source,native=native);save()
|
|
phase('restored')
|
|
except Exception as error:r['failure']=type(error).__name__+': '+str(error)
|
|
finally:
|
|
try:
|
|
if r['restoration_pending']:
|
|
s.wait_world();ui.key(s.d,'F1')
|
|
if neck()!=str(a.item):
|
|
root=db(f'SELECT item FROM tw_char.character_inventory WHERE guid=4509 AND bag=0 AND slot={a.root};')
|
|
if neck() or root!=str(a.item):raise RuntimeError('Unexpected fixture location; no blind restore')
|
|
s.macro('/use 0 '+str(a.root-22));s.macro('/s .save');c.wait(lambda:neck()==str(a.item),8)
|
|
s.macro('/s .gm on');s.macro('/s .gm visible off');s.macro('/s .whispers '+('on' if flags&4 else 'off'));s.macro('/s .save')
|
|
c.wait(lambda:state().split('\t')[1:]==before.split('\t')[1:] and inventory(4509)==baseline,8)
|
|
r.update(restoration_pending=False,after_state=state(),inventory_unchanged=True,retained_equipment=True)
|
|
except Exception as error:r['restoration_error']=type(error).__name__+': '+str(error)
|
|
ui.KEY_DELAY=old;save()
|
|
r['packet_observation']=trace.report();save()
|
|
print(json.dumps({k:r.get(k) for k in ('pid','source_removed','source_restored','restoration_pending','retained_equipment','inventory_unchanged','before_state','after_state','failure','restoration_error')}))
|
|
return 0 if r.get('source_restored') and not r['restoration_pending'] and not r.get('failure') else 2
|
|
if __name__=='__main__':raise SystemExit(main())
|