Level 120 (L1-L5): AVA2 maps, drops, dungeons, dungeon timer UI
- tools/server/level-120: sbtest install of the 120 exp table and the unsigned exp column. - tools/server/ava2-maps: the 10 AVA2 maps (pack, map data, regen, designed drops) for sbtest; Ava2MapsScript.inc, gr2 texture and mob_proto tests. - tools/server/ava2-dungeons: snow / ship defence / Meley quests ported from AVA2 (make_quests.py + install.sh). - mt_dungeon_timer (DungeonTimerScript.inc): AVA2 dungeon timer in place of the minimap (RefreshDungeonTimer) and the hydra mast HP bar (gethydrahp). - Autohunt skips a target that is hit but takes no damage for 4 s (blocked Meley statues) and keeps it skipped for 60 s; FindCloseTarget now honours the skip list. Meley full run passed on sbtest with the Mac client. Not deployed live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
657e49e52a
commit
a1e7da68a4
@@ -0,0 +1,68 @@
|
||||
# AVA2 地下城任务(sbtest)
|
||||
|
||||
把 AVA2 的三个地下城任务移植到 203:冰雪地下城(奈梅尔瞭望塔)、九头蛇船防、赤龙巢穴。地图和怪物掉落在 `../ava2-maps`(L2/L3/L5),这里是 L4,说明见 metin2-server `docs/FEATURE-LEVEL-120.md`。现在只装在 sbtest 的 channel5 上。
|
||||
|
||||
| 任务 | AVA2 源文件 | 入口 NPC | 等级 | 钥匙 | 冷却 | 出口 |
|
||||
|---|---|---|---|---|---|---|
|
||||
| `snow_dungeon` | snow.lua | 20395,map_n_snowm_01(61) | ≥90 | 25168 | 60 分钟 | 61:4319,1647 |
|
||||
| `ShipDefense` | shipdefense.lua | 9009,Metin2_map_CapeDragonHead(301) | 100–120 | 25169 | 3 小时 | 301:11082,17824 |
|
||||
| `MeleyDungeon` | meleylair.lua | 20441,metin2_map_n_flame_01(62) | ≥110 | 25170 | 3 小时 | 62:5986,6573 |
|
||||
|
||||
GM 测试:`/level 120`,`/item 25168`(或 25169、25170),再 `/warp` 到入口 NPC 旁:冰雪 `4319 1641`,船防 `11078 17827`,赤龙 `7364 6239`。点 NPC,选任务名 → 单人进入 → 是。赤龙巢穴的冷却没有 GM 豁免。
|
||||
|
||||
服务端需要 metin2-server 的 L4 改动:`port_ava2_dungeon.cpp`(新增的 quest 函数)、QUEST_ATTACK_EVENT(`<vnum>.attack`,赤龙每次被打时触发)、赤龙和九头蛇的 HP 辅助函数。另外,龙之雕像(6230)一下打不死,最多剩 1 HP,只有任务的 `npc.dead_by_vnum` 能杀死它。AVA2 原版没有这层保护:第 8 层的阈值是 30000 HP,暴击高的玩家可能一下把雕像打死,副本就卡住了。
|
||||
|
||||
自动狩猎能打赤龙巢穴:雕像石化后,攻击只会显示“格挡”(伤害 0);如果连续 4 秒都打不出伤害,就换下一个目标,并在 60 秒内不再选它。
|
||||
|
||||
## 文件
|
||||
|
||||
| 文件 | 作用 |
|
||||
|---|---|
|
||||
| `make_quests.py` | 从 AVA2 生成 stage:三个任务(UTF-8)、`data/dungeon/{ice_dungeon,hydra,meley}`、赤龙怪物组、入口 NPC、新 quest 函数名。补丁都带计数断言,AVA2 源文件一改就会报错。 |
|
||||
| `install.sh` | 在 203 上从 stage 目录运行,装进 sbtest 的 locale/data,可以重复运行,每次都先备份 |
|
||||
|
||||
`make_quests.py` 对 AVA2 任务的改动:
|
||||
|
||||
- `lc_quest("KEY")` 和任务提示编号换成中文(203 的任务直接写字符串);`NO_CH2` 改成 203 的格式。
|
||||
- `GetMissionInfo(level, seconds)` 换成 `cmdchat("RefreshDungeonTimer ...")`。客户端的 `mt_dungeon_timer`(`src/platform/ScriptLib/DungeonTimerScript.inc`)收到后,在小地图的位置显示 AVA2 的副本计时器:Boss 头像、第几层(船防是第几波)和倒计时。船防地图里还会显示 `gethydrahp` 发来的船桅血条。计时器图片在 `../ava2-maps` 打的 ava2maps 包里。
|
||||
- 去掉 203 没有的战令任务(`do_battlepass_mission`)、地下城追踪(`d.track_update`)和 `DUNGEON_COOLDOWN_EVENT` 分支,普通冷却保留。
|
||||
- 203 没有 `time_str`,改成秒数。
|
||||
- 九头蛇地图从 AVA2 的 972800,153600 搬到了 3276800,0,入口 10049,1652 改成 33089,116。
|
||||
- 修 AVA2 的两个 bug:冰雪任务 `nemere_full_timer` / `nemere_dead_timer` 里的 `index` 没有定义;赤龙 `6230.attack` 的 `set_meley_hp` 同样。
|
||||
- 删掉非 ASCII 的注释行(土耳其语、韩语注释在 GBK 下会出问题)。
|
||||
|
||||
## 安装到 sbtest
|
||||
|
||||
在本机:
|
||||
|
||||
```sh
|
||||
python3 tools/server/ava2-dungeons/make_quests.py /tmp/ava2-dungeons # 第二个参数可以指定 AVA2 srv1 目录
|
||||
cp tools/server/ava2-dungeons/install.sh /tmp/ava2-dungeons/
|
||||
COPYFILE_DISABLE=1 tar czf /tmp/ava2-dungeons.tgz --no-xattrs --no-mac-metadata -C /tmp ava2-dungeons
|
||||
scp /tmp/ava2-dungeons.tgz root@192.168.21.203:/usr/metin2/server/sbtest/stage/
|
||||
```
|
||||
|
||||
在 203 上:
|
||||
|
||||
```sh
|
||||
cd /usr/metin2/server/sbtest/stage && tar xzf ava2-dungeons.tgz && sh ava2-dungeons/install.sh
|
||||
sh /usr/metin2/server/sbtest/tools/restart.sh
|
||||
```
|
||||
|
||||
`install.sh` 依次:
|
||||
|
||||
1. 确认 channel5 的 locale/data 指向 sbtest(`../ava2-maps/sbtest_locale.sh`)。
|
||||
2. 把 `quest/`、`data/dungeon/` 和地图 61、62 的目录从“指向线上的符号链接”换成真正的副本,免得改到线上。
|
||||
3. 备份到 `sbtest/backup-conf/ava2-dungeons-<时间>`。
|
||||
4. 核对怪物组、NPC 和钥匙的 vnum 都在 sbtest 的 proto 里。
|
||||
5. 追加缺少的赤龙怪物组、入口 NPC 和 quest 函数名(qc 不认识的函数会编译失败;还补上了 203 列表里缺的 `table.remove`)。
|
||||
6. 把任务转成 GBK(GBK 尾字节如果是 0x5C,qc 会当成反斜杠,所以遇到就停下),在独立目录里用 qc 编译,然后只替换这三个任务的 object,并加进 `locale_list`。
|
||||
7. 复制地下城的 regen 数据。
|
||||
|
||||
channel5 的 CONFIG 里 MAP_ALLOW 要有入口地图 61、62、301,以及地下城地图 212、352、355。
|
||||
|
||||
- 钥匙和任务物品 25170、30331–30333 的中文名在 `../ava2-items/names_zh.tsv`;sbtest 的 item_proto 里只装了这 4 行,以免覆盖已解锁的 proto。
|
||||
- qc 用 `%g` 输出数字(2129999 → 2.13e+06),这不影响运行。
|
||||
- AVA2 的 regen 还引用了 6226、6227、20444 这三个组,AVA2 自己也没有,保持原样。
|
||||
|
||||
上线前要单独批准,见 `../ava2-maps/README.md`。
|
||||
@@ -0,0 +1,103 @@
|
||||
#!/bin/sh
|
||||
# Installs the AVA2 dungeons (README.md) into the sbtest locale/data that channel5 uses; never the live ones.
|
||||
# Run on 203 from the uploaded stage dir (make_quests.py output + this script): sh install.sh, then restart channel5.
|
||||
# - makes real copies of the farm's quest/, data/dungeon/ and the map 61/62 dirs (sbtest_locale.sh links them to live);
|
||||
# - appends the Meley groups, the entrance NPCs and the new quest function names that are missing;
|
||||
# - compiles the three quests in an isolated stage and replaces only their objects.
|
||||
# Idempotent; every run backs up what it changes.
|
||||
set -eu
|
||||
SB=${SB:-/usr/metin2/server/sbtest}
|
||||
CORE=${CORE:-/usr/metin2/server/channel5/first}
|
||||
LOC=$SB/share/locale/newcibn
|
||||
QUEST=$LOC/quest
|
||||
DATA=$SB/share/data
|
||||
CONF=$SB/db
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
BACKUP=$SB/backup-conf/ava2-dungeons-$(date +%Y%m%d%H%M%S)
|
||||
QUESTS="snow_dungeon ShipDefense MeleyDungeon"
|
||||
export LC_ALL=C
|
||||
|
||||
[ "$(readlink "$CORE/locale")" = "$SB/share/locale" ] || { echo "$CORE/locale is not the sbtest farm; run sbtest_locale.sh" >&2; exit 1; }
|
||||
[ "$(readlink "$CORE/data")" = "$DATA" ] || { echo "$CORE/data is not the sbtest data; run sbtest_locale.sh" >&2; exit 1; }
|
||||
|
||||
real() # <farm entry>: replace a symlink to the live tree with a copy of it
|
||||
{
|
||||
[ -L "$1" ] || return 0
|
||||
t=$(cd "$1" && pwd -P)
|
||||
case $t in "$SB"/*) return 0 ;; esac
|
||||
rm "$1" && cp -pR "$t" "$1" && echo "$1: copied from $t"
|
||||
}
|
||||
real "$QUEST"
|
||||
real "$DATA/dungeon"
|
||||
mkdir -p "$DATA/dungeon"
|
||||
while IFS=" " read -r map row; do real "$LOC/map/$map"; done < "$HERE/npc.tsv"
|
||||
|
||||
mkdir -p "$BACKUP"
|
||||
cp -p "$QUEST/locale_list" "$QUEST/quest_functions" "$LOC/group.txt" "$BACKUP/"
|
||||
while IFS=" " read -r map row; do cp -p "$LOC/map/$map/npc.txt" "$BACKUP/$map.npc.txt"; done < "$HERE/npc.tsv"
|
||||
echo "backup: $BACKUP"
|
||||
|
||||
# Every monster the groups and NPC rows name, and the dungeon keys and quest items, must be in the sbtest protos.
|
||||
python3.9 - "$HERE" "$CONF" <<'EOF'
|
||||
import re,sys
|
||||
here,conf=sys.argv[1:]
|
||||
def vnums(p):return {int(l.split(b'\t',1)[0]) for l in open(p,'rb') if l.split(b'\t',1)[0].strip().isdigit()}
|
||||
mobs,items=vnums(conf+'/mob_proto.txt'),vnums(conf+'/item_proto.txt')
|
||||
need={int(v) for v in re.findall(rb'^\t(?:Leader|\d+)\t\S+\t(\d+)',open(here+'/group.txt','rb').read(),re.M)}
|
||||
need|={int(l.split('\t')[-1]) for l in open(here+'/npc.tsv')}
|
||||
bad=['mob %d'%v for v in sorted(need-mobs)]+['item %d'%v for v in (25168,25169,25170,30331,30332,30333) if v not in items]
|
||||
if bad:sys.exit('not in %s: %s'%(conf,' '.join(bad)))
|
||||
EOF
|
||||
|
||||
# Meley groups: append the vnums group.txt lacks.
|
||||
python3.9 - "$HERE/group.txt" "$LOC/group.txt" <<'EOF'
|
||||
import re,sys
|
||||
src,dst=sys.argv[1:]
|
||||
have={int(v) for v in re.findall(rb'Vnum\s+(\d+)',open(dst,'rb').read())}
|
||||
add=[b for b in re.findall(rb'Group\t\S+\r\n\{.*?\}\r\n',open(src,'rb').read(),re.S) if int(re.search(rb'Vnum\t(\d+)',b).group(1)) not in have]
|
||||
if add:
|
||||
t=open(dst,'rb').read()
|
||||
open(dst,'ab').write((b'' if t.endswith(b'\n') else b'\r\n')+b''.join(add))
|
||||
print('group.txt: %d groups added'%len(add))
|
||||
EOF
|
||||
|
||||
# Entrance NPCs.
|
||||
while IFS=" " read -r map row; do
|
||||
f=$LOC/map/$map/npc.txt
|
||||
vnum=${row##* }
|
||||
if awk -v v="$vnum" '{ sub(/[\t\r ]+$/, "") } $1 == "m" && $NF == v { f = 1 } END { exit !f }' "$f"; then
|
||||
echo "$map: npc $vnum already placed"
|
||||
else
|
||||
[ -z "$(tail -c 1 "$f")" ] || printf '\r\n' >> "$f"
|
||||
printf '%s\r\n' "$row" >> "$f" && echo "$map: npc $vnum added"
|
||||
fi
|
||||
done < "$HERE/npc.tsv"
|
||||
|
||||
# Quest function names (qc rejects calls it does not know).
|
||||
while read -r fn; do grep -qx "$fn" "$QUEST/quest_functions" || { echo "$fn" >> "$QUEST/quest_functions"; echo "quest_functions: $fn"; }; done < "$HERE/quest_functions"
|
||||
|
||||
# Compile in isolation; a GBK trail byte 0x5C would be a backslash to qc.
|
||||
STAGE=$BACKUP/stage
|
||||
mkdir -p "$STAGE"
|
||||
cp "$QUEST/quest_functions" "$STAGE/"
|
||||
for q in $QUESTS; do
|
||||
iconv -f UTF-8 -t GBK "$HERE/quest/$q.quest" > "$STAGE/$q.quest"
|
||||
if grep -q '\\' "$STAGE/$q.quest"; then echo "$q.quest: backslash byte in GBK" >&2; exit 1; fi
|
||||
(cd "$STAGE" && "$QUEST/qc" "$q.quest") > "$BACKUP/qc-$q.log" 2>&1 || { cat "$BACKUP/qc-$q.log" >&2; exit 1; }
|
||||
test -s "$STAGE/object/state/$q"
|
||||
done
|
||||
# Replace only these quests' objects.
|
||||
for q in $QUESTS; do
|
||||
find "$QUEST/object" -type f \( -name "$q.*" -o -path "*/state/$q" \) -exec rm {} +
|
||||
cp "$STAGE/$q.quest" "$QUEST/$q.quest"
|
||||
grep -qx "$q.quest" "$QUEST/locale_list" || echo "$q.quest" >> "$QUEST/locale_list"
|
||||
done
|
||||
(cd "$STAGE/object" && tar cf - .) | (cd "$QUEST/object" && tar xpf -)
|
||||
echo "objects: $(cd "$STAGE/object" && find . -type f | wc -l) files"
|
||||
|
||||
# Regen data (local coordinates).
|
||||
for d in ice_dungeon hydra meley; do
|
||||
rm -rf "$DATA/dungeon/$d"
|
||||
cp -pR "$HERE/data/dungeon/$d" "$DATA/dungeon/$d"
|
||||
done
|
||||
echo "done; restart channel5 (sh $SB/tools/restart.sh)"
|
||||
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage AVA2's three new dungeons for the 203 server: quests, regen data, monster groups and entrance NPCs.
|
||||
|
||||
The quests are AVA2's quest/Mazmorras/{snow,shipdefense,meleylair}.lua with asserted patches (every patch must
|
||||
match, so a changed source fails loudly):
|
||||
- lc_quest("KEY") and the mission notice numbers become zh text (the 203 quests carry their strings inline);
|
||||
- GetMissionInfo(level, seconds) becomes d.command("RefreshDungeonTimer ...") (the client ignores it for now);
|
||||
- the battle pass / dungeon tracker calls and the DUNGEON_COOLDOWN_EVENT branch go (203 has neither; the normal
|
||||
cooldown stays: snow 60 min, ship and Meley 3 h);
|
||||
- time_str, which 203 lacks, becomes seconds;
|
||||
- the hydra map entry moves with the map (AVA2 972800,153600 -> 203 3276800,0: entry 10049,1652 -> 33089,116);
|
||||
- two AVA2 bugs: an undefined `index` in snow's nemere_full_timer / nemere_dead_timer warps and in Meley's
|
||||
6230.attack set_meley_hp.
|
||||
|
||||
Output (UTF-8; install.sh converts the quests to GBK):
|
||||
<stage>/quest/<name>.quest snow_dungeon, ShipDefense, MeleyDungeon
|
||||
<stage>/data/dungeon/{ice_dungeon,hydra,meley}/ AVA2 regen files (local coordinates, unchanged)
|
||||
<stage>/group.txt AVA2 Meley groups 6220/6223-6225 (install.sh appends the ones 203 lacks)
|
||||
<stage>/npc.tsv entrance NPC rows: <map dir> <npc.txt row>
|
||||
<stage>/quest_functions new quest function names (port_ava2_dungeon.cpp)
|
||||
Usage: make_quests.py <stage dir> [<AVA2 srv1 dir>]
|
||||
"""
|
||||
import re,shutil,sys
|
||||
from pathlib import Path
|
||||
HERE=Path(__file__).resolve().parent
|
||||
SRV1=Path(sys.argv[2]) if len(sys.argv)>2 else HERE.parents[3]/'AVA2/TEST/2. Backup SF+SRC and SQL/home/srv1'
|
||||
stage=Path(sys.argv[1])
|
||||
MAZ=SRV1/'share/locale/germany/quest/Mazmorras'
|
||||
|
||||
QUESTS={'snow_dungeon':'snow.lua','ShipDefense':'shipdefense.lua','MeleyDungeon':'meleylair.lua'}
|
||||
LC={'10':'剩余时间:','11':'秒','12':'确定要开始吗?','29':'顺序不正确!','30':'奈梅尔瞭望塔','31':'开始副本',
|
||||
'32':'确定要开始副本吗?','33':'冰块消失了。','50':'船只防御战','50_1':'需要等待:','51':'守住桅杆,别让它们摧毁!',
|
||||
'71':'赤龙巢穴','BACK_DUNGEON':'返回副本','BACK_QUESTION':'要回到之前所在的副本吗?',
|
||||
'CANT_BACK':'只能在5分钟内重新进入,已超时!','COOLDOWN':'以下玩家仍需等待:','DUNGEON_REMOVE':'副本已关闭,请从头开始。',
|
||||
'ENTER_DUNGEON':'要进入副本吗?','GROUP':'要组队进入吗?','INDIVIDUAL':'单人进入','LEVEL_ERROR':'你的等级不足,无法进入此副本!',
|
||||
'LOW_LEVEL':'以下玩家等级不足:','NO_CH':'副本不在本频道开启。','NO_KEY':'你没有进入副本的钥匙!',
|
||||
'NO_MEMBER_KEY':'以下玩家没有钥匙:','NO_PARTY':'你不在队伍中!','NO_PARTY_MEMBER':'附近的队员不足!','PARTY':'组队进入',
|
||||
'YES':'是','CANCEL':'取消'}
|
||||
NOTICE={'1003':'副本完成!即将传送出去。','1019':'消灭所有怪物。','1020':'任务完成!','1021':'摧毁寒冰之石。',
|
||||
'1022':'找出正确的钥匙。','1023':'钥匙不对。','1024':'按正确的顺序解开冰块。','1025':'摧毁北方龙柱。','1026':'击败奈梅尔!',
|
||||
'1027':'击败艾斯特尔继续前进。','1047':'你登上了被九头蛇和它的爪牙占领的船!','1048':'准备迎接海战!','1049':'守卫船只!',
|
||||
'1050':'你成功守住了桅杆!准备迎接下一波。','1051':'……但战斗还没有结束','1052':'……去领取你的宝箱奖励!',
|
||||
'1053':'九头蛇和它的军队有备而来,保护船只!','1054':'它们不知疲倦地进攻,继续守卫船只!','1102':'摧毁龙之雕像!',
|
||||
'1103':'摧毁所有龙蛋!','1104':'击败变异怪物!'}
|
||||
# (quest, old, new, expected count)
|
||||
FIXES=[
|
||||
('snow_dungeon','1647*100,index,60)','1647*100,get_server_timer_arg(),60)',2),
|
||||
('ShipDefense','time_str(r_cooldown)','r_cooldown.."秒"',1),
|
||||
('ShipDefense','d.new_jump(355, 10049*100,1652*100)','d.new_jump(355, 33089*100,116*100)',1),
|
||||
('ShipDefense','d.new_jump_party(355, 10049, 1652)','d.new_jump_party(355, 33089, 116)',1),
|
||||
('ShipDefense','d.jump_all(10049,1652)','d.jump_all(33089,116)',1),
|
||||
('ShipDefense','pc.warp(10049*100,1652*100, dungeonMapIndex)','pc.warp(33089*100,116*100, dungeonMapIndex)',1),
|
||||
('MeleyDungeon','npc.set_meley_hp(index,6230,','npc.set_meley_hp(d.get_map_index(),6230,',8),
|
||||
('MeleyDungeon','say("Bileti olmayan \xfcyeler: ")','say("以下玩家没有钥匙:")',1),
|
||||
]
|
||||
NEW_FUNCTIONS=['d.mission_notice','d.global_warp_all_to_base','d.new_kill_all','d.command','d.dungeon_remove_all',
|
||||
'd.kill_area','d.spawn_mob_new','npc.get_protect_time','npc.set_protect_time','npc.set_statu_affect',
|
||||
'npc.set_statu_clear_aff','npc.show_statu','npc.set_meley_hp','npc.show_end_statu','npc.set_protect_flag2',
|
||||
'npc.dead_by_vnum','npc.set_hp','npc.get_hp',
|
||||
'table.remove'] # a Lua 5.0 builtin the 203 list lacks
|
||||
# Entrance NPCs AVA2 places on the 203 maps (snow: 冰原守卫 on map 61; Meley: 守望者多纳尔 on map 62).
|
||||
# ShipDefense's fisherman 9009 already stands on 301 (838,1187).
|
||||
NPCS=[('map_n_snowm_01','m\t735\t105\t0\t0\t0\t5\t1m\t100\t1\t20395'),
|
||||
('metin2_map_n_flame_01','m\t1476\t95\t0\t0\t0\t5\t1m\t100\t1\t20441')]
|
||||
GROUPS=(6220,6223,6224,6225)
|
||||
|
||||
def sub(text,pattern,repl,where,flags=0,min_count=1):
|
||||
out,n=re.subn(pattern,repl,text,flags=flags)
|
||||
if n<min_count:raise SystemExit('%s: no match for %r'%(where,pattern))
|
||||
return out
|
||||
|
||||
def mission_info(text,where):
|
||||
"""GetMissionInfo(a,b) -> d.command(string.format("RefreshDungeonTimer %d %d",a,b)); args may nest calls."""
|
||||
out=[];i=0;n=0
|
||||
while True:
|
||||
j=text.find('GetMissionInfo(',i)
|
||||
if j<0:break
|
||||
k=j+len('GetMissionInfo(');depth=1;args=k
|
||||
while depth:
|
||||
depth+={'(':1,')':-1}.get(text[k],0);k+=1
|
||||
line_start=text.rfind('\n',0,j)+1
|
||||
commented=text[line_start:j].lstrip().startswith('--')
|
||||
out.append(text[i:j])
|
||||
out.append(text[j:k] if commented else 'd.command(string.format("RefreshDungeonTimer %%d %%d",%s))'%text[args:k-1])
|
||||
n+=not commented;i=k
|
||||
if not n:raise SystemExit(where+': no GetMissionInfo')
|
||||
return ''.join(out)+text[i:]
|
||||
|
||||
def convert(name,src):
|
||||
# AVA2's Turkish comments (latin1-decoded) have no GBK form
|
||||
t=''.join(l for l in src.splitlines(True) if not (l.lstrip().startswith('--') and not l.isascii()))
|
||||
for q,old,new,count in FIXES:
|
||||
if q!=name:continue
|
||||
if t.count(old)!=count:raise SystemExit('%s: %r found %d times, expected %d'%(name,old,t.count(old),count))
|
||||
t=t.replace(old,new)
|
||||
t=re.sub(r'lc_quest\(string\.format\("NO_CH2 %d ?",(\w+)\)\)',r'string.format("请切换到 %d 频道。",\1)',t)
|
||||
def lc(m):
|
||||
k=m.group(1).strip()
|
||||
if k not in LC:raise SystemExit('%s: lc_quest key %r has no zh text'%(name,k))
|
||||
return '"%s"'%LC[k]
|
||||
t=re.sub(r'lc_quest\("([^"]*)"\)',lc,t)
|
||||
def notice(m):
|
||||
k=m.group(2).strip()
|
||||
if k not in NOTICE:raise SystemExit('%s: notice %r has no zh text'%(name,k))
|
||||
return '%s"%s")'%(m.group(1),NOTICE[k])
|
||||
t=re.sub(r'(d\.mission_notice\([^,()]+(?:\(\))?,)"(\d+ ?)"\)',notice,t)
|
||||
t=re.sub(r'(d\.notice\()"(\d+)"\)',notice,t)
|
||||
t=mission_info(t,name)
|
||||
# AVA2 systems 203 does not have: battle pass missions, the dungeon tracker, DUNGEON_COOLDOWN_EVENT.
|
||||
t=re.sub(r'[ \t]*do_battlepass_mission\([^\n]*\n','',t)
|
||||
t=re.sub(r'[ \t]*d\.track_update\([^\n]*\n','',t)
|
||||
t=re.sub(r'[ \t]*if game\.check_event\([^\n]*\n[^\n]*\n[ \t]*else[ \t]*\n([^\n]*\n)[ \t]*end[ \t]*\n',r'\1',t)
|
||||
for bad in ('lc_quest','GetMissionInfo(','do_battlepass_mission','track_update','check_event','time_str'):
|
||||
if bad in t.replace('--GetMissionInfo(','').replace('-- GetMissionInfo(',''):
|
||||
raise SystemExit('%s: %s left'%(name,bad))
|
||||
if not re.search(r'^quest %s begin'%re.escape(name),t,re.M):raise SystemExit(name+': quest name changed')
|
||||
return t
|
||||
|
||||
def main():
|
||||
(stage/'quest').mkdir(parents=True,exist_ok=True)
|
||||
for name,lua in QUESTS.items():
|
||||
src=(MAZ/lua).read_bytes().decode('latin1').replace('\r\n','\n')
|
||||
text=convert(name,src)
|
||||
text='-- AVA2 quest/Mazmorras/%s for 203, generated by tools/server/ava2-dungeons/make_quests.py\n%s'%(lua,text)
|
||||
(stage/'quest'/(name+'.quest')).write_text(text,encoding='utf-8')
|
||||
text.encode('gbk') # every string must have a GBK form
|
||||
data=stage/'data/dungeon'
|
||||
for d in ('ice_dungeon','hydra','meley'):
|
||||
if (data/d).exists():shutil.rmtree(data/d)
|
||||
(data/d).mkdir(parents=True)
|
||||
for f in sorted((SRV1/'share/data/dungeon'/d).glob('*.txt')):shutil.copy2(f,data/d/f.name)
|
||||
blocks={}
|
||||
for b in re.finditer(r'Group[ \t]+(\S+)\s*\{(.*?)\}',(SRV1/'share/locale/germany/group.txt').read_bytes().decode('latin1'),re.S):
|
||||
v=re.search(r'Vnum\s+(\d+)',b.group(2))
|
||||
if v and int(v.group(1)) in GROUPS:blocks[int(v.group(1))]=b.group(2)
|
||||
if sorted(blocks)!=sorted(GROUPS):raise SystemExit('group.txt: missing '+str(set(GROUPS)-set(blocks)))
|
||||
out=[]
|
||||
for v in GROUPS:
|
||||
body=[l.strip() for l in blocks[v].replace('\r','').split('\n') if l.strip()]
|
||||
rows=[re.findall(r'"[^"]*"|\S+',l) for l in body]
|
||||
# member names are only labels; AVA2's quoted English ones contain spaces
|
||||
out+=['Group\tAVA2Meley_%d'%v,'{']+['\t'+'\t'.join(r if r[0]=='Vnum' else [r[0],'mob%s'%r[-1],r[-1]]) for r in rows]+['}']
|
||||
(stage/'group.txt').write_bytes(('\r\n'.join(out)+'\r\n').encode('latin1'))
|
||||
(stage/'npc.tsv').write_text(''.join('%s\t%s\n'%r for r in NPCS))
|
||||
(stage/'quest_functions').write_text('\n'.join(NEW_FUNCTIONS)+'\n')
|
||||
print('staged %d quests, %d data files, %d groups, %d npcs -> %s'%(len(QUESTS),sum(1 for _ in data.rglob('*.txt')),len(GROUPS),len(NPCS),stage))
|
||||
|
||||
if __name__=='__main__':main()
|
||||
Reference in New Issue
Block a user