feat(quests): add AVA2 travel menu and staged sash compatibility deployment

This commit is contained in:
shen
2026-10-16 23:15:04 -07:00
parent fce6a5e06b
commit 8653edf4c5
8 changed files with 438 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
# 2026-10-16 AVA2 上线后补全记录
基线:客户端 569afb13、服务端 e097b92,均为 feature/ava2-unlock;SDK main 62a5f5a。
## 退出崩溃
`PythonBoot::Stop` 先清空飞行物,再销毁角色及其他管理器,恢复原版 `CPythonApplication::Destroy` 的依赖顺序。飞行物清理附件时仍需访问效果管理器,原来的析构顺序造成已销毁单例访问;角色清理也需在 text-tail/item 管理器之前。
`port_app_loop_test` 在退出时保留一个真实飞行物,修复前退出 139,修复后退出 0;重复 Stop 通过。证据:`build/followup-shutdown-before.log`、`build/followup-shutdown-after.log`。该函数其他未移植行为仍为 DIVERGENT,未提升为完整原版一致。技能要求的 `scripts/port_map.py` 在当前分支不存在,未宣称通过该检查。
## 密集怪物自动狩猎
攻击/技能视线判断以前会对挡住的目标完整运行 A*,随后因不是单段路径而拒绝攻击。现在复用同一条直线与体积检查,挡住时直接返回;真正移动寻路仍完整运行 A*。聚怪检测先执行冷却、状态、HP 等廉价条件,再扫描怪物。
导航回归覆盖开放直线、薄墙、大目标和 240 个被遮挡目标。相同攻击可达性结果下,碰撞查询从 502128 次降为 6432 次(约减少 98.7%)。这是固定场景算法测试,不能代表冰雪副本通关耗时;200 多只怪物楼层仍需无 `/purge` 联机复测。
## 宝箱和动作资源
打包器原来见基础 npclist 已有 9018 就跳过整个模型目录。现在种入所有需要的 AVA2 模型文件,再由资源闭包跳过已存在文件;模型编号已知不再等同于资源齐全。
已实际生成 `build/followup-ava2maps/ava2maps.eix/.epk`(4243 文件),核对包含 hydra_chest 模型、msm、motlist、loop/break/attack/drop 动作及模型引用纹理。用隔离资源目录运行原生假服务器场景,9018 宝箱模型和贴图正常显示,90 帧后正常退出(退出码 0),截图 `build/followup-chest-smoke.png`。该场景不是正式服船防验收。
motlist 现在参与资源依赖检查,maps.json 的 missing_motions 明确列出缺失文件。本机原始 AVA2 目录仍缺少:
- defensewave_hydra_boss/drop.msa(以及原始 drop.gr2);
- defensewave_minihydra/special_attack1.msa(以及对应原始动作模型)。
完整扫描还报告 blue_dragon_red/water_dragon_2.gr2、reddragon_room_boss2/normal_attack.msa、zone/eastplain/gaint_build a_01_d.gr2,以及两个 hydra 地形纹理。未通过复制其他动作冒充原始文件。需完整 AVA2 素材或 FoxFS 解包工具。
## NPC / sash / 任务函数
实现、安装、回滚和 sbtest 验收边界见 `tools/server/ava2-followup/README.md`。十个地图目的地可通过现有传送 NPC 菜单进入,三个实例副本送到原入口 NPC;sash 沿用已有任务;只补缺失的 GFquestlib 函数。正式服尚未安装。
## 构建与剩余验收
macOS `mt_native_render` 与 Android Release 原生构建均通过,APK 在 `android/app/build/outputs/apk/debug/app-debug.apk`。退出回归、导航回归和 Lua 5.0 测试通过。生成资源包通过,原始缺失资源如实记录。
未完成的验收:补齐原始动作;真实客户端 NPC 与 sash 点击流程;冰雪密集层全程自动狩猎;正式服启用。不能将过去使用 GM 清怪的楼层计为自动狩猎通过。
+51
View File
@@ -0,0 +1,51 @@
# AVA2 部署后补全
本目录在 `feature/ava2-unlock` 上补充普通玩家的地图入口、sash 任务和缺失的任务函数。
- 9012(现有传送 NPC)和 20090 增加「新地图与副本入口」,十个目的地分两页。地图与等级见 `destinations.json`。七个野外目的地要求 105 级;副本等级沿用原入口限制。
- 赤龙、冰雪、船防分别送至地图 62 的 20441、地图 61 的 20395、地图 301 的 9009 附近。进入实例仍走原任务,保留门票、冷却和组队检查。
- 王铁匠 20016 使用已有 `../sash/sash.quest`,提供披风合成和吸收。
- 按 AVA2 GFquestlib 补入缺失的 `is_destination_village`;已有同名函数时保留。没有启用整个 GFquestlib,避免覆盖本服已有函数。
生成及本地验证:
```sh
python3 tools/server/ava2-followup/generate.py
python3 tools/server/ava2-followup/test_followup.py
```
测试使用相邻 `metin2-server` 的 Lua 5.0,执行所有十个目的地、等级不足、取消、不可传送、分页,以及 village 分组查询;另验证安装、重复安装与回滚。
203 上编译,默认只写新的工作目录,不安装:
```sh
cd /root/deploy-features/20261017-followup
python3.9 ava2-followup/install.py --work "$PWD/sbtest-check"
```
首次安装(每次使用新的 `--work`,编译失败不会安装):
```sh
python3.9 ava2-followup/install.py --work "$PWD/sbtest-install" --apply
```
默认目标 `/usr/metin2/server/sbtest`,可以显式 `--server` 指定目标根目录。目标 quest 目录必须位于该根目录内;对象文件若通过符号链接指向其他目录则拒绝安装。逐文件备份及安装后的 SHA256 在工作目录 `backup/manifest.json`。安装不自动重启服务;只在核实核心所属数据库和运行目录后重启目标核心。
回滚同一次安装,再重启目标核心:
```sh
python3.9 ava2-followup/install.py --work "$PWD/sbtest-install" --rollback
```
如果文件在安装后有其他修改,回滚会拒绝覆盖,须人工核对。
## 本次验收(2026-10-16 本机 / 10-17 203)
- 本地 Lua 5.0 测试通过,安装/回滚测试通过。
- 203 原生 qc 编译两个任务通过,生成 17 个对象文件;源码传输 SHA256 已与本机核对。
- 已安装到 sbtest;备份 `/root/deploy-features/20261017-followup/sbtest-install/backup`。
- 已检查 a1/b1/c1 三个主城均有 9012 和 20090。
- 只重启 channel5:旧 PID 37083,新 PID 37514;DB_PORT=15040,player_sb/common_sb,游戏/P2P 13040/14040 正常监听。启动后未发现新任务/Lua 错误,既有怪物动作数据警告仍存在。
- 尚未进行真实客户端逐个点击 NPC、合成/吸收及 new_quest_lv52 点击验收;本次未安装到正式服。
客户端配套修复与验证见 `docs/AVA2-FOLLOWUP-20261016.md`。
@@ -0,0 +1,63 @@
-- Generated by generate.py; UTF-8, compiled as GBK by install.py.
quest ava2_travel begin
state start begin
function destinations()
return {
{"法老沙漠", 653000, 2393700, 105, false},
{"元素圣地", 932000, 410700, 105, false},
{"东间平原", 1062900, 476700, 105, false},
{"西间荒原", 1214200, 478100, 105, false},
{"南间深渊", 1277600, 440700, 105, false},
{"皇城", 537500, 493000, 105, false},
{"晨雾地下城", 816700, 1505000, 105, false},
{"赤龙巢穴入口", 736200, 623900, 110, true},
{"冰雪地下城入口", 431700, 164100, 90, true},
{"九头蛇船防入口", 1107600, 1782700, 100, true},
}
end
function menu()
local destinations = ava2_travel.destinations()
local page = 1
while true do
local first = (page-1)*5+1
local last = math.min(first+4,table.getn(destinations))
local options = {}
for i=first,last do table.insert(options,destinations[i][1]) end
local count = table.getn(options)
local previous = 0
local following = 0
if page>1 then table.insert(options,"上一页") previous=table.getn(options) end
if last<table.getn(destinations) then table.insert(options,"下一页") following=table.getn(options) end
table.insert(options,"关闭")
say_title("新地图与副本入口")
local choice=select_table(options)
if choice==table.getn(options) then return
elseif previous>0 and choice==previous then page=page-1
elseif following>0 and choice==following then page=page+1
elseif choice>=1 and choice<=count then
local target=destinations[first+choice-1]
say_title(target[1])
if pc.get_level()<target[4] then
say("需要等级:"..target[4])
return
end
if target[5] then
say("传送到入口 NPC 附近。")
say("门票、组队及冷却仍由原副本检查。")
end
if select("传送","取消")==1 then
if not pc.can_warp() then
say("当前不能传送,请稍后再试。")
return
end
pc.warp(target[2],target[3])
end
return
end
end
end
when 9012.chat."新地图与副本入口" or 20090.chat."新地图与副本入口" begin
ava2_travel.menu()
end
end
end
@@ -0,0 +1,15 @@
{
"source": "AVA2 tp_npc1.lua (Plechito level/position), installed map Town positions and ava2-dungeons entry NPCs; coordinates in cm",
"destinations": [
{"id":57,"name":"法老沙漠","x":653000,"y":2393700,"level":105,"mode":"field"},
{"id":37,"name":"元素圣地","x":932000,"y":410700,"level":105,"mode":"field"},
{"id":129,"name":"东间平原","x":1062900,"y":476700,"level":105,"mode":"field"},
{"id":130,"name":"西间荒原","x":1214200,"y":478100,"level":105,"mode":"field"},
{"id":131,"name":"南间深渊","x":1277600,"y":440700,"level":105,"mode":"field"},
{"id":132,"name":"皇城","x":537500,"y":493000,"level":105,"mode":"field"},
{"id":210,"name":"晨雾地下城","x":816700,"y":1505000,"level":105,"mode":"field"},
{"id":212,"name":"赤龙巢穴入口","x":736200,"y":623900,"level":110,"mode":"entrance","npc":20441,"map":62},
{"id":352,"name":"冰雪地下城入口","x":431700,"y":164100,"level":90,"mode":"entrance","npc":20395,"map":61},
{"id":355,"name":"九头蛇船防入口","x":1107600,"y":1782700,"level":100,"mode":"entrance","npc":9009,"map":301}
]
}
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
"""Generate an NPC menu; instanced dungeons always go to their original admission NPC."""
import json
from pathlib import Path
ROOT=Path(__file__).resolve().parent
def generate():
rows=json.loads((ROOT/'destinations.json').read_text())['destinations']
lines=['-- Generated by generate.py; UTF-8, compiled as GBK by install.py.',
'quest ava2_travel begin',' state start begin',
' function destinations()',' return {']
for row in rows:
lines.append(' {%s, %d, %d, %d, %s},'%(
json.dumps(row['name'],ensure_ascii=False),row['x'],row['y'],row['level'],
'true' if row['mode']=='entrance' else 'false'))
lines+=[' }',' end', ''' function menu()
local destinations = ava2_travel.destinations()
local page = 1
while true do
local first = (page-1)*5+1
local last = math.min(first+4,table.getn(destinations))
local options = {}
for i=first,last do table.insert(options,destinations[i][1]) end
local count = table.getn(options)
local previous = 0
local following = 0
if page>1 then table.insert(options,"上一页") previous=table.getn(options) end
if last<table.getn(destinations) then table.insert(options,"下一页") following=table.getn(options) end
table.insert(options,"关闭")
say_title("新地图与副本入口")
local choice=select_table(options)
if choice==table.getn(options) then return
elseif previous>0 and choice==previous then page=page-1
elseif following>0 and choice==following then page=page+1
elseif choice>=1 and choice<=count then
local target=destinations[first+choice-1]
say_title(target[1])
if pc.get_level()<target[4] then
say("需要等级:"..target[4])
return
end
if target[5] then
say("传送到入口 NPC 附近。")
say("门票、组队及冷却仍由原副本检查。")
end
if select("传送","取消")==1 then
if not pc.can_warp() then
say("当前不能传送,请稍后再试。")
return
end
pc.warp(target[2],target[3])
end
return
end
end
end
when 9012.chat."新地图与副本入口" or 20090.chat."新地图与副本入口" begin
ava2_travel.menu()
end
end
end''']
result='\n'.join(lines)+'\n'
if b'\\' in result.encode('gbk'):raise ValueError('GBK backslash byte is unsafe for qc')
return result
if __name__=='__main__':(ROOT/'ava2_travel.quest').write_text(generate())
+85
View File
@@ -0,0 +1,85 @@
#!/usr/bin/env python3
"""Compile in isolation; --apply backs up and installs only travel/sash objects and the missing quest helper."""
import argparse
import hashlib
import json
import shutil
import subprocess
from pathlib import Path
ROOT=Path(__file__).resolve().parent
def gbk(text):
raw=text.encode('gbk')
if b'\\' in raw:raise ValueError('GBK backslash byte is unsafe for qc')
return raw
def prepare(quest,stage):
stage.mkdir(parents=True,exist_ok=False)
functions=(quest/'quest_functions').read_bytes()
if b'pc.open_sash' not in functions.splitlines():functions=functions.rstrip()+b'\npc.open_sash\n'
(stage/'quest_functions').write_bytes(functions)
for name,source in [('ava2_travel',ROOT/'ava2_travel.quest'),('sash',ROOT.parent/'sash/sash.quest')]:
(stage/(name+'.quest')).write_bytes(gbk(source.read_text()))
result=subprocess.run([str((quest/'qc').resolve()),name+'.quest'],cwd=stage,capture_output=True)
(stage/(name+'.qc.log')).write_bytes(result.stdout+result.stderr)
if result.returncode or not (stage/'object/state'/name).is_file():
raise RuntimeError('qc failed for '+name+'; inspect '+str(stage/(name+'.qc.log')))
return stage
def install(quest,stage,backup):
backup.mkdir(parents=True,exist_ok=False)
files={Path('quest_functions'):(stage/'quest_functions').read_bytes()}
listing=(quest/'locale_list').read_bytes()
for name in (b'ava2_travel.quest',b'sash.quest'):
if name not in listing.splitlines():listing=listing.rstrip()+b'\n'+name+b'\n'
files[Path(name.decode())]=(stage/name.decode()).read_bytes()
files[Path('locale_list')]=listing
for path in (stage/'object').rglob('*'):
if path.is_file():files[Path('object')/path.relative_to(stage/'object')]=path.read_bytes()
library=(quest/'questlib.lua').read_bytes()
marker=b'-- PORT AVA2 missing quest helper'
if marker not in library:
files[Path('questlib.lua')]=library.rstrip()+b'\n'+marker+b'\n'+(ROOT/'quest_compat.lua').read_bytes()+b'\n'
manifest=[]
# Refuse a symlink out of the requested quest tree (sbtest must not modify live objects).
for relative,data in files.items():
target=quest/relative
if quest.resolve() not in target.resolve().parents:raise ValueError('target escapes quest tree: '+str(target))
existed=target.exists()
if existed:
old=backup/relative;old.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(target,old)
manifest.append({'path':str(relative),'existed':existed,'installed_sha256':hashlib.sha256(data).hexdigest()})
(backup/'manifest.json').write_text(json.dumps(manifest,indent=2)+'\n')
for relative,data in files.items():
target=quest/relative;target.parent.mkdir(parents=True,exist_ok=True)
temporary=target.with_name(target.name+'.ava2-new');temporary.write_bytes(data);temporary.replace(target)
return manifest
def rollback(quest,backup):
manifest=json.loads((backup/'manifest.json').read_text())
for row in manifest:
path=quest/row['path']
if path.exists() and hashlib.sha256(path.read_bytes()).hexdigest()!=row['installed_sha256']:
raise ValueError('changed since installation; refusing to overwrite '+str(path))
for row in manifest:
path=quest/row['path']
if row['existed']:shutil.copy2(backup/row['path'],path)
elif path.is_file():path.unlink()
if __name__=='__main__':
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--server',type=Path,default=Path('/usr/metin2/server/sbtest'))
parser.add_argument('--locale',default='newcibn')
parser.add_argument('--work',type=Path,required=True)
parser.add_argument('--apply',action='store_true')
parser.add_argument('--rollback',action='store_true')
args=parser.parse_args();quest=args.server/'share/locale'/args.locale/'quest'
if args.apply and args.server.resolve() not in quest.resolve().parents:
raise ValueError('quest tree points outside --server; isolate sbtest first')
if args.rollback:rollback(quest,args.work/'backup');print('Restored; reload quests or restart target cores.')
else:
prepare(quest,args.work/'compiled');print('Compiled:',args.work/'compiled')
if args.apply:
install(quest,args.work/'compiled',args.work/'backup')
print('Installed with backup:',args.work/'backup','; reload/restart target cores to activate.')
@@ -0,0 +1,17 @@
-- AVA2 GFquestlib.lua: the map lookup needed by new_quest_lv52.
-- Install only the missing helper; retain any server-specific implementation.
if is_destination_village == nil then
function is_destination_village(maps)
local map_lookup = {}
if maps == 1 then
map_lookup = {[1]='', [21]='', [41]=''}
elseif maps == 2 then
map_lookup = {[3]='', [23]='', [43]=''}
elseif maps == 3 then
map_lookup = {[1]='', [21]='', [41]='', [3]='', [23]='', [43]=''}
elseif maps == 65 then
map_lookup = {[65]=''}
end
return map_lookup[pc.get_map_index()]
end
end
+102
View File
@@ -0,0 +1,102 @@
#!/usr/bin/env python3
"""Execute the generated menu and compatibility helper with the server's Lua 5.0."""
import importlib.util
import json
import subprocess
import tempfile
import unittest
from pathlib import Path
ROOT=Path(__file__).resolve().parent
def module(name):
spec=importlib.util.spec_from_file_location(name,ROOT/(name+'.py'))
result=importlib.util.module_from_spec(spec);spec.loader.exec_module(result);return result
class FollowupTests(unittest.TestCase):
def test_live_menu_and_quest_helper(self):
text=module('generate').generate()
self.assertEqual(text,(ROOT/'ava2_travel.quest').read_text())
body=text.split(' function destinations()',1)[1].split(' when ',1)[0]
body='ava2_travel={}\nfunction ava2_travel.destinations()'+body
body=body.replace('function menu()','function ava2_travel.menu()')
body+='''
local choices={} local cursor=0 local warps={} local level=120 local allowed=true local map=1
say_title=function() end say=function() end
select_table=function(options)
assert(table.getn(options)<=8)
cursor=cursor+1
assert(choices[cursor] and choices[cursor]<=table.getn(options))
return choices[cursor]
end
select=function(...) return select_table(arg) end
pc={get_level=function() return level end,can_warp=function() return allowed end,
warp=function(x,y) table.insert(warps,{x,y}) end,get_map_index=function() return map end}
local targets=ava2_travel.destinations()
for i=1,table.getn(targets) do
local function run(lvl,canWarp,confirm)
level=lvl allowed=canWarp warps={} cursor=0 choices={}
if i>5 then table.insert(choices,6) end
table.insert(choices,math.mod(i-1,5)+1)
if lvl>=targets[i][4] then table.insert(choices,confirm) end
ava2_travel.menu()
assert(cursor==table.getn(choices))
end
run(120,true,1)
assert(table.getn(warps)==1 and warps[1][1]==targets[i][2] and warps[1][2]==targets[i][3])
run(targets[i][4]-1,true,1) assert(table.getn(warps)==0)
run(120,false,1) assert(table.getn(warps)==0)
run(120,true,2) assert(table.getn(warps)==0)
end
choices={7} cursor=0 ava2_travel.menu() assert(cursor==1)
'''
body+=(ROOT/'quest_compat.lua').read_text()
body+='''
for i=1,400 do
map=i
assert((is_destination_village(1)~=nil)==(i==1 or i==21 or i==41))
assert((is_destination_village(2)~=nil)==(i==3 or i==23 or i==43))
assert((is_destination_village(3)~=nil)==(i==1 or i==21 or i==41 or i==3 or i==23 or i==43))
assert((is_destination_village(65)~=nil)==(i==65))
end
local existing=function() return "preserved" end
is_destination_village=existing
'''
body+=(ROOT/'quest_compat.lua').read_text()
body+='assert(is_destination_village==existing)\nprint("PASS: 10 destinations, levels, cancel, busy, paging; all quest village lookups")\n'
lua=ROOT.parents[3]/'metin2-server/src/server/liblua'
sources=[p for p in sorted((lua/'src').glob('*.c')) if p.name!='ltests.c']
sources += [lua/'src/lib'/name for name in ('lauxlib.c','lbaselib.c','ltablib.c','lstrlib.c','lmathlib.c')]
with tempfile.TemporaryDirectory(prefix='mt-followup-') as folder:
folder=Path(folder);binary=folder/'lua'
subprocess.run(['cc','-w','-I'+str(lua/'include'),'-I'+str(lua/'src'),
str(ROOT.parent/'ring-warp/tests/lua_runner.c'),*[str(p) for p in sources],'-lm','-o',str(binary)],check=True)
script=folder/'test.lua';script.write_bytes(module('install').gbk(body))
subprocess.run([str(binary),str(script)],check=True)
data=json.loads((ROOT/'destinations.json').read_text())['destinations']
self.assertEqual({r['id']:r['map'] for r in data if r['mode']=='entrance'},{212:62,352:61,355:301})
def test_install_backup_idempotence_and_rollback(self):
installer=module('install')
with tempfile.TemporaryDirectory() as folder:
folder=Path(folder);quest=folder/'quest';stage=folder/'compiled';quest.mkdir();stage.mkdir()
original={'quest_functions':b'existing\n','locale_list':b'old.quest\n','questlib.lua':b'-- original\n'}
for name,data in original.items():(quest/name).write_bytes(data)
(stage/'quest_functions').write_bytes(b'existing\npc.open_sash\n')
for name in ('sash','ava2_travel'):(stage/(name+'.quest')).write_bytes(b'compiled source')
(stage/'object/state').mkdir(parents=True);(stage/'object/state/sash').write_bytes(b'state')
installer.install(quest,stage,folder/'backup')
self.assertEqual((quest/'questlib.lua').read_bytes().count(b'-- PORT AVA2 missing quest helper'),1)
installer.install(quest,stage,folder/'backup2')
self.assertEqual((quest/'questlib.lua').read_bytes().count(b'-- PORT AVA2 missing quest helper'),1)
installer.rollback(quest,folder/'backup2')
installer.rollback(quest,folder/'backup')
for name,data in original.items():self.assertEqual((quest/name).read_bytes(),data)
self.assertFalse((quest/'object/state/sash').exists())
installer.install(quest,stage,folder/'backup3')
(quest/'questlib.lua').write_bytes(b'newer change')
with self.assertRaises(ValueError):installer.rollback(quest,folder/'backup3')
self.assertEqual((quest/'questlib.lua').read_bytes(),b'newer change')
if __name__=='__main__':unittest.main()