367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
99 lines
8.9 KiB
Python
99 lines
8.9 KiB
Python
#!/usr/bin/env python3
|
|
"""One source-defined invisibility potion through actual native Forever /use.
|
|
|
|
GM commands prepare/remove one temporary item and restore visibility only. No
|
|
raw cast request, invented aura or forced alpha; screenshots require review.
|
|
"""
|
|
import argparse,json
|
|
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
|
|
from native_posture import establish_standing
|
|
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--item',type=int,required=True);p.add_argument('--output',type=Path,required=True);p.add_argument('--observe-aura',action='store_true',help='Read original self-aura API; protected values are labelled, never unwrapped');p.add_argument('--normal-pve',action='store_true',help='Temporarily disable GM mode through source command; restore original role/visibility afterward');a=p.parse_args();out=a.output.resolve()
|
|
if not 0<a.item<65536 or out.suffix!='.json' or not out.is_relative_to(ROOT/'runtime') or out.exists() or not out.parent.is_dir():p.error('Require bounded source item and new runtime evidence')
|
|
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;'))
|
|
source=db(f'SELECT class,required_level,spellid_1,spelltrigger_1,spellcharges_1,spellcooldown_1 FROM tw_world.item_template WHERE entry={a.item};').split('\t')
|
|
level=int(db('SELECT level FROM tw_char.characters WHERE guid=4509;'))
|
|
if len(source)!=6 or source[0]!='0' or not 1<=int(source[1])<=level or source[3:5]!=['0','-1']:raise RuntimeError('Require genuine consumable on-use with one consumption charge')
|
|
spell=int(source[2]);definition=db(f'SELECT effect1,effect2,effect3,effectApplyAuraName1,effectApplyAuraName2,effectApplyAuraName3,effectMiscValue1 FROM tw_world.spell_template WHERE entry={spell};')
|
|
if definition!='6\t0\t0\t18\t0\t0\t0':raise RuntimeError('Require actual single general-invisibility aura; no name-based effect inference')
|
|
def inspect():
|
|
value=c.rpc('inspect-engine-pipe')
|
|
if value['error'] or value['closed']:raise RuntimeError('Native connection lost; preserve fixture')
|
|
return value
|
|
def items():return [row for row in inspect()['inventory']['rows'] if row['entry']==a.item]
|
|
if items() or db(f'SELECT spell FROM tw_char.character_aura WHERE guid=4509 AND spell={spell};'):raise RuntimeError('Existing potion/effect preserved; choose a separate fixture')
|
|
state=lambda:db('SELECT health,power2,money,extra_flags FROM tw_char.characters WHERE guid=4509;')
|
|
position=lambda:db('SELECT position_x,position_y,position_z,orientation FROM tw_char.characters WHERE guid=4509;')
|
|
r=dict(pid=c.pid,item=a.item,spell=spell,source_item=source,source_effect=definition,external_gateway_running=False,normal_pve=a.normal_pve,cleanup_pending=False,potion_effect_verified=False,transparency_verified=False,ui_review_required=True,cooldown_policy='Retain genuine new potion cooldown to expire; never blanket-reset prior cooldowns')
|
|
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:
|
|
try:
|
|
s.wait_world();ui.KEY_DELAY=.06;ui.key(s.d,'F1');ui.click_at(s.d,s.win,60,750);s.macro('/s .save')
|
|
before=state();flags=int(before.split('\t')[3]);baseline=inventory(4509)
|
|
if flags&17!=17:raise RuntimeError('Require original GM-on/invisible fixture; preserve other roles')
|
|
r.update(before_state=before,before_position=position(),before_inventory=baseline,cleanup_pending=True,before_aura_slots=inspect().get('auras'));save()
|
|
if a.observe_aura:s.macro('/run gwpotion=function()local a=C_UnitAuras.GetPlayerAuraBySpellID('+str(spell)+');print("GW potion aura",a and(issecretvalue and issecretvalue(a.spellId)and"restricted"or a.spellId)or"absent")end')
|
|
s.macro('/s .gm visible on');c.wait(lambda:int(state().split('\t')[3])==flags&~16,8)
|
|
if a.normal_pve:
|
|
# HandleGMCommand changes live state only; unlike visible,
|
|
# it does not persist flags. Save before checking SQL state.
|
|
s.macro('/s .gm off');s.macro('/s .save');c.wait(lambda:int(state().split('\t')[3])==flags&~17,8)
|
|
r['normal_test_flags']=int(state().split('\t')[3]);r['normal_aura_slots']=inspect().get('auras');save()
|
|
s.shot(out.with_name(out.stem+'-visible.png'))
|
|
s.macro(f'/s .additem {a.item} 1');c.wait(lambda:len(items())==1 and items()[0]['count']==1,8);s.macro('/s .save')
|
|
slot=db(f'SELECT ci.bag,ci.slot,ii.guid FROM tw_char.character_inventory ci JOIN tw_char.item_instance ii ON ii.guid=ci.item WHERE ci.guid=4509 AND ii.itemEntry={a.item};').split('\t')
|
|
if len(slot)!=3 or slot[0]!='0' or not 23<=int(slot[1])<39:raise RuntimeError('Fixture must be one real backpack item')
|
|
r['fixture_slot']=int(slot[1]);r['fixture_guid']=int(slot[2]);save()
|
|
before_cast=inspect()['cast_result']['count']
|
|
if a.normal_pve:
|
|
r['standing_handshake']=establish_standing(c,s,self_guid=4509);save()
|
|
anchor=trace.bookmark()
|
|
r['use_attempted']=True;s.macro('/use 0 '+str(int(slot[1])-22))
|
|
def used():
|
|
v=inspect();cast=v['cast_result']
|
|
if cast['count']>before_cast and cast['spell']==spell and cast['status']==2:
|
|
r['rejected_cast_result']=cast;save()
|
|
raise RuntimeError('Source cast rejected with reason '+str(cast['reason'])+'; no action replay')
|
|
return v if not items() and cast['count']>before_cast and cast['spell']==spell and cast['status']==0 else None
|
|
used_state=c.wait(used,8);r['cast_result']=used_state['cast_result'];r['item_request']=used_state['item_request'];r['active_aura_slots']=used_state.get('auras');save()
|
|
r['native_request']=trace.wait(2,0x3e0171,3,after_index=anchor)
|
|
s.shot(out.with_name(out.stem+'-active.png'))
|
|
if a.observe_aura:
|
|
s.macro('/run gwpotion()');s.shot(out.with_name(out.stem+'-native-aura.png'))
|
|
s.macro('/s .list auras');s.macro('/s .save')
|
|
r['saved_active_aura']=db(f'SELECT spell,maxduration,remaintime,effIndexMask FROM tw_char.character_aura WHERE guid=4509 AND spell={spell};')
|
|
r['saved_cooldown']=db(f'SELECT spell,item,CAST(time AS SIGNED)-UNIX_TIMESTAMP(),CAST(catTime AS SIGNED)-UNIX_TIMESTAMP() FROM tw_char.character_spell_cooldown WHERE guid=4509 AND spell={spell};')
|
|
s.shot(out.with_name(out.stem+'-source-aura.png'))
|
|
r['potion_effect_verified']=bool(r['saved_active_aura']) and not items() and r['item_request']['result']==0
|
|
except Exception as error:r['failure']=type(error).__name__+': '+str(error)
|
|
finally:
|
|
try:
|
|
if r['cleanup_pending']:
|
|
s.wait_world();ui.key(s.d,'F1')
|
|
remaining=items()
|
|
if remaining:
|
|
if len(remaining)!=1 or remaining[0]['count']!=1:raise RuntimeError('Unexpected fixture quantity; no blind item removal')
|
|
s.macro(f'/s .additem {a.item} -1');c.wait(lambda:not items(),8)
|
|
# Source-defined test effect only, never blanket aura reset.
|
|
s.macro(f'/s .unaura {spell}')
|
|
if a.normal_pve: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()==before and inventory(4509)==baseline,8)
|
|
if a.observe_aura:s.macro('/run gwpotion=nil')
|
|
r.update(cleanup_pending=False,after_state=state(),after_position=position(),inventory_unchanged=True,after_aura_slots=inspect().get('auras'))
|
|
except Exception as error:r['cleanup_error']=type(error).__name__+': '+str(error)
|
|
ui.KEY_DELAY=old;r.update(trace.report());save()
|
|
print(json.dumps({k:r.get(k) for k in ('pid','item','spell','potion_effect_verified','transparency_verified','cleanup_pending','inventory_unchanged','lost_metadata_rows','observer_error','failure','cleanup_error')}))
|
|
return 0 if r['potion_effect_verified'] and not r['cleanup_pending'] and not r.get('failure') else 2
|
|
if __name__=='__main__':raise SystemExit(main())
|