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,66 @@
|
||||
# AVA2 新地图和地下城(sbtest)
|
||||
|
||||
把 AVA2 的 100–125 级地图、地下城和其中的怪物移植到 203。说明见 metin2-server `docs/FEATURE-LEVEL-120.md` 的 L2–L5。现在只装在 sbtest 的 channel5 上。
|
||||
|
||||
| 地图 | index | 中文名 | `/warp x y`(全局米) |
|
||||
|---|---|---|---|
|
||||
| plechito_desert_map_01 | 57 | 法老沙漠 | 6509 23952 |
|
||||
| metin2_map_elemental_04_rework | 37 | 元素圣地 | 9320 4107 |
|
||||
| metin2_map_eastplain_01 | 129 | 东间平原 | 10629 4767 |
|
||||
| metin2_map_eastplain_02 | 130 | 西间荒原 | 12142 4781 |
|
||||
| metin2_map_eastplain_03 | 131 | 南间深渊 | 12776 4407 |
|
||||
| metin2_map_empirecastle | 132 | 皇城 | 5375 4930 |
|
||||
| metin2_map_dawnmist_dungeon_01 | 210 | 晨雾地下城 | 8167 15050 |
|
||||
| metin2_map_n_flame_dragon | 212 | 赤龙巢穴 | 3200 15290 |
|
||||
| metin2_map_n_snow_dungeon_01 | 352 | 冰雪地下城 | 5291 1814 |
|
||||
| defensawe_hydra | 355 | 九头蛇船防 | 33089 116(入口) |
|
||||
|
||||
- `/goto #<index>` 对新地图不可用,请用 `/warp`。
|
||||
- 九头蛇在 AVA2 中的位置是 972800,153600,和 203 的地图重叠,所以搬到了 3276800,0。AVA2 任务里的坐标要按 Δ = (+2304000, −153600) 换算。地图中心那一格不能走,所以 `/warp` 到地图中心时,服务器会把人放到 3276800,0。
|
||||
|
||||
## 文件
|
||||
|
||||
| 文件 | 作用 |
|
||||
|---|---|
|
||||
| `make_maps.py` | 从 AVA2 生成服务端 stage(`mobs-server.tsv`、group、地图目录、动作数据)和客户端 ava2maps 包。由 `scripts/build_zh_locale.py` 调用。 |
|
||||
| `names_zh.tsv` | 新怪物的中文名 |
|
||||
| `drops_maps.tsv` | 新怪物的掉落设计,按档次(普通 / 精英 / 首领 / 石头 / 金怪),并可按地图或 vnum 范围追加 |
|
||||
| `make_drops_maps.py` | 把 `drops_maps.tsv` 写成 stage 里的 `mob_drop_item.txt`,并核对 item_proto |
|
||||
| `install_maps.py` | 把 stage 装进一个 locale + conf,可以重复运行 |
|
||||
| `sbtest_locale.sh` | 给 channel5 建独立的 locale/data 目录,避免安装时改到线上的 |
|
||||
|
||||
## 掉落
|
||||
|
||||
AVA2 只给其中 8 只怪(6401 6402 6410 6411 8059 8061 9018 20442)配了掉落,203 上已有这些掉落组,保持不变。其他怪的掉落按 `drops_maps.tsv` 生成。
|
||||
|
||||
- 表里的“几率 %”指:角色与怪同级,没有 premium 或夺宝手套时,每杀一只的掉落几率。premium 或夺宝手套会让几率翻倍,等级差按 PERCENT_LVDELTA 表折算(首领按 PERCENT_LVDELTA_BOSS)。
|
||||
- 换算公式:文件中的 pct = 几率 / 0.375。依据是 `ITEM_MANAGER::GetDropPct`:非 premium 时几率 ×1.5,随机范围是 4000000。
|
||||
- 地下城的怪由任务刷出,不在 regen 里,所以地下城的特色掉落用 `mob:<first>-<last>` 指定:6222–6231 赤龙巢穴,6401–6411 冰雪地下城,6802–6812 九头蛇船防。
|
||||
- 如果有未知物品,核心会拒绝加载整个 mob_drop_item.txt,所以 `make_drops_maps.py` 和 `install_maps.py` 都会先核对 vnum。
|
||||
|
||||
## 安装到 sbtest
|
||||
|
||||
在本机:
|
||||
|
||||
```sh
|
||||
python3 scripts/build_zh_locale.py # stage 在 build/zh-locale/ava2-maps,也可以手动运行 make_maps.py
|
||||
S=build/zh-locale/ava2-maps/server
|
||||
python3 tools/server/ava2-maps/make_drops_maps.py $S tools/server/ava2-maps/drops_maps.tsv <sbtest 的 item_proto.txt>
|
||||
scp -r $S root@192.168.21.203:/usr/metin2/server/sbtest/stage/ava2-maps/
|
||||
scp tools/server/ava2-maps/{install_maps.py,sbtest_locale.sh} root@192.168.21.203:/usr/metin2/server/sbtest/tools/
|
||||
```
|
||||
|
||||
在 203 上:
|
||||
|
||||
```sh
|
||||
T=/usr/metin2/server/sbtest
|
||||
sh $T/tools/sbtest_locale.sh
|
||||
python3.9 $T/tools/install_maps.py $T/share/locale/newcibn $T/db $T/stage/ava2-maps/server \
|
||||
$T/backup-conf/ava2-maps-$(date +%Y%m%d%H%M%S) $T/share/data
|
||||
# 再把 channel5 CONFIG 的 MAP_ALLOW 加上 57 37 129 130 131 132 210 212 352 355
|
||||
sh $T/tools/restart.sh
|
||||
```
|
||||
|
||||
- 被修改的文件会先备份到 `backup-conf/ava2-maps-<时间>`。
|
||||
- `../sbtest/rollback.sh` 会恢复 channel5 原来的 locale/data 链接。
|
||||
- 如果目标 locale 里的 group.txt、group_group.txt、mob_drop_item.txt、map/ 或 map/index 是符号链接(也就是和线上共用),`install_maps.py` 会拒绝安装。
|
||||
@@ -0,0 +1,109 @@
|
||||
# Drops of the AVA2 new-map monsters (make_drops_maps.py). AVA2 itself gives almost none of them drops.
|
||||
# tier item vnum count chance % (item name, comment)
|
||||
# chance % = per kill, killer at the mob's level, no premium / thief glove (those double it; level gaps scale it
|
||||
# by the PERCENT_LVDELTA table, bosses by PERCENT_LVDELTA_BOSS).
|
||||
# Tiers: normal (PAWN/S_PAWN/KNIGHT), elite (S_KNIGHT), boss (BOSS/KING monster), stone (metin stones),
|
||||
# gold (the gold mobs 4062-4067). map:<map dir> rows are added to every monster its regen files spawn,
|
||||
# mob:<vnum> or mob:<first>-<last> rows to those monsters (dungeon monsters are spawned by quests, not regen:
|
||||
# 6222-6231 赤龙巢穴, 6401-6411 冰雪地下城, 6802-6812 九头蛇船防).
|
||||
|
||||
normal 71084 1 3 物品属性转换秘籍
|
||||
normal 39072 1 3 绿色碎片
|
||||
normal 39073 1 1 黄色碎片
|
||||
normal 27992 1 1 白珍珠
|
||||
normal 27993 1 0.5 蓝珍珠
|
||||
normal 27994 1 0.2 炎珍珠
|
||||
normal 30625 1 1 帕德玛刚玉
|
||||
normal 30626 1 1 蓝晶石
|
||||
normal 30610 1 1 秘银
|
||||
normal 30270 1 1 龙魂石碎片
|
||||
normal 77918 1 1 青铜宝箱
|
||||
normal 77921 1 1 青铜钥匙
|
||||
normal 71302 1 0.5 护符强化道具
|
||||
normal 72064 1 0.3 小型扩充券
|
||||
|
||||
elite 71084 3 15 物品属性转换秘籍
|
||||
elite 71085 1 2 追加物品属性秘籍
|
||||
elite 39073 1 5 黄色碎片
|
||||
elite 27993 1 2 蓝珍珠
|
||||
elite 27994 1 1 炎珍珠
|
||||
elite 50255 1 3 龙魂原石
|
||||
elite 30270 2 5 龙魂石碎片
|
||||
elite 77919 1 3 白银宝箱
|
||||
elite 77922 1 3 白银钥匙
|
||||
elite 71302 1 2 护符强化道具
|
||||
elite 100300 1 1 绿龙豆
|
||||
elite 21210 1 0.1 暗龙铠甲 (lv115)
|
||||
elite 21230 1 0.1 风龙铠甲 (lv115)
|
||||
elite 21250 1 0.1 魔龙铠甲 (lv115)
|
||||
elite 21270 1 0.1 神龙铠甲 (lv115)
|
||||
|
||||
boss 71084 30 100 物品属性转换秘籍
|
||||
boss 71085 5 50 追加物品属性秘籍
|
||||
boss 77920 1 50 黄金宝箱
|
||||
boss 77923 1 50 黄金钥匙
|
||||
boss 27992 2 50 白珍珠
|
||||
boss 27993 1 30 蓝珍珠
|
||||
boss 27994 1 20 炎珍珠
|
||||
boss 50255 10 100 龙魂原石
|
||||
boss 30270 5 100 龙魂石碎片
|
||||
boss 100300 1 30 绿龙豆
|
||||
boss 100400 1 15 蓝龙豆
|
||||
boss 80008 5 30 黄金锭
|
||||
boss 72066 1 10 大型扩充券
|
||||
boss 71302 5 50 护符强化道具
|
||||
boss 30627 1 30 神之果实
|
||||
boss 30628 1 30 神圣之花
|
||||
boss 30629 1 10 众神灵药
|
||||
boss 70043 1 2 夺宝手套
|
||||
boss 70005 1 2 护佑戒指
|
||||
boss 21210 1 3 暗龙铠甲 (lv115)
|
||||
boss 21230 1 3 风龙铠甲 (lv115)
|
||||
boss 21250 1 3 魔龙铠甲 (lv115)
|
||||
boss 21270 1 3 神龙铠甲 (lv115)
|
||||
boss 320 1 1.5 守护者之剑 (lv120)
|
||||
boss 340 1 1.5 守护者之刃 (lv120)
|
||||
boss 1190 1 1.5 守护者匕首 (lv120)
|
||||
boss 2210 1 1.5 守护者之弓 (lv120)
|
||||
boss 3230 1 1.5 守护者大刀 (lv120)
|
||||
boss 5170 1 1.5 守护者之铃 (lv120)
|
||||
boss 7310 1 1.5 守护者之扇 (lv120)
|
||||
boss 17560 1 5 青玉耳环 (lv100)
|
||||
boss 16560 1 5 青玉项链 (lv100)
|
||||
boss 14560 1 5 青玉手镯 (lv100)
|
||||
boss 15460 1 3 锆石之鞋 (lv110)
|
||||
boss 15470 1 3 孔雀石之鞋 (lv110)
|
||||
boss 18080 1 2 灵魂腹带
|
||||
|
||||
stone 71084 20 100 物品属性转换秘籍
|
||||
stone 80008 3 50 黄金锭
|
||||
stone 27987 1 40 珍珠蚌
|
||||
stone 39073 2 100 黄色碎片
|
||||
stone 30270 3 80 龙魂石碎片
|
||||
stone 71302 3 60 护符强化道具
|
||||
stone 50255 3 60 龙魂原石
|
||||
stone 30626 2 40 蓝晶石
|
||||
stone 77919 1 30 白银宝箱
|
||||
stone 77922 1 30 白银钥匙
|
||||
stone 72065 1 10 中型扩充券
|
||||
stone 72066 1 5 大型扩充券
|
||||
stone 70043 1 1 夺宝手套
|
||||
stone 70005 1 1 护佑戒指
|
||||
|
||||
gold 80003 1 20 银砖(5万两)
|
||||
gold 80004 1 10 银砖(10万两)
|
||||
gold 80005 1 3 金砖(50万两)
|
||||
gold 80006 1 1 金砖(100万两)
|
||||
gold 71084 1 5 物品属性转换秘籍
|
||||
|
||||
mob:6222-6231 30620 1 2 红龙之角
|
||||
mob:6222-6231 30621 1 2 红龙鳞片
|
||||
mob:6231 30620 5 100 红龙之角 (赤龙)
|
||||
mob:6231 30621 5 100 红龙鳞片 (赤龙)
|
||||
mob:6231 30630 1 30 龙之翼 (赤龙)
|
||||
mob:6401-6411 71123 1 2 水龙鳞片
|
||||
mob:6401-6411 71129 1 2 水龙爪
|
||||
mob:6802-6812 71123 1 3 水龙鳞片
|
||||
mob:6802-6812 71129 1 3 水龙爪
|
||||
mob:6812 71123 5 100 水龙鳞片 (九头蛇)
|
||||
mob:6812 71129 5 100 水龙爪 (九头蛇)
|
||||
|
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Install the AVA2 maps stage (make_maps.py output/server) into a server locale + conf.
|
||||
|
||||
- mobs-server.tsv -> conf/mob_proto.txt + mob_names.txt, rows replaced by vnum.
|
||||
- group.txt / group_group.txt: blocks whose Vnum is missing are appended; existing vnums are kept.
|
||||
- map/<dir> copied (an existing real dir is moved to the backup first; a symlink is refused).
|
||||
- map/index: missing "<index> <dir>" lines appended; an index used by another map is refused.
|
||||
- data/monster/<folder> (optional 5th arg = the core's data dir): only folders it lacks are added.
|
||||
- mob_drop_item.txt (make_drops_maps.py output): the group of each monster that has no drop group yet is appended;
|
||||
every item vnum must be in conf/item_proto.txt (the core refuses the whole file on an unknown item).
|
||||
- Then every regen group and mob reference is checked against the installed tables.
|
||||
|
||||
Rerunning is idempotent. Runs on 203 (python3.9). The core reads the locale at boot and the db reads
|
||||
conf at boot: restart db and the core afterwards.
|
||||
Usage: install_maps.py <locale dir> <conf dir> <stage server dir> <fresh backup dir> [<data dir>]
|
||||
"""
|
||||
import re,shutil,sys
|
||||
from pathlib import Path
|
||||
locale,conf,stage,backup=map(Path,sys.argv[1:5])
|
||||
data=Path(sys.argv[5]) if len(sys.argv)>5 else None
|
||||
if backup.exists():raise SystemExit('use a fresh backup directory')
|
||||
backup.mkdir(parents=True)
|
||||
|
||||
def lines(raw):return [l for l in raw.replace(b'\r\n',b'\n').split(b'\n') if l.strip()]
|
||||
def newline(raw):return b'\r\n' if b'\r\n' in raw else b'\n'
|
||||
def write(path,data):
|
||||
tmp=path.with_name(path.name+'.tmp');tmp.write_bytes(data);tmp.replace(path)
|
||||
def save(path):
|
||||
dest=backup/path.relative_to(path.parents[1]) if path.parent.name=='map' else backup/path.name
|
||||
dest.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(path,dest)
|
||||
|
||||
# mob_proto.txt + mob_names.txt
|
||||
rows={int(l.split(b'\t',1)[0]):l for l in lines((stage/'mobs-server.tsv').read_bytes())}
|
||||
for name,row in (('mob_proto.txt',lambda v:rows[v]),('mob_names.txt',lambda v:str(v).encode()+b'\t'+rows[v].split(b'\t')[1])):
|
||||
path=conf/name;raw=path.read_bytes();save(path)
|
||||
kept=[l for l in lines(raw) if not (l.split(b'\t',1)[0].isdigit() and int(l.split(b'\t',1)[0]) in rows)]
|
||||
write(path,newline(raw).join(kept+[row(v) for v in sorted(rows)])+newline(raw))
|
||||
mobs={int(l.split(b'\t',1)[0]) for l in lines((conf/'mob_proto.txt').read_bytes()) if l.split(b'\t',1)[0].isdigit()}
|
||||
|
||||
# group.txt / group_group.txt
|
||||
BLOCK=re.compile(rb'Group[ \t]+\S+\s*\{.*?\}',re.S)
|
||||
def blocks(raw):return {int(re.search(rb'Vnum\s+(\d+)',b).group(1)):b for b in BLOCK.findall(raw)}
|
||||
appended={}
|
||||
for name in ('group.txt','group_group.txt'):
|
||||
path=locale/name
|
||||
if path.is_symlink():raise SystemExit('%s is a symlink (shared with the live locale?)'%path)
|
||||
raw=path.read_bytes();have=blocks(raw);new=blocks((stage/name).read_bytes())
|
||||
missing=[new[v] for v in sorted(new) if v not in have];appended[name]=len(missing)
|
||||
if missing:
|
||||
save(path);nl=newline(raw)
|
||||
write(path,raw.rstrip(b'\r\n')+nl+nl.join(b.replace(b'\r\n',b'\n').replace(b'\n',nl) for b in missing)+nl)
|
||||
groups=blocks((locale/'group.txt').read_bytes());ggroups=blocks((locale/'group_group.txt').read_bytes())
|
||||
|
||||
# map dirs + index
|
||||
mapdir=locale/'map';index_path=mapdir/'index'
|
||||
if index_path.is_symlink() or mapdir.is_symlink():raise SystemExit('%s is shared with the live locale'%mapdir)
|
||||
raw=index_path.read_bytes();index={}
|
||||
for l in lines(raw):
|
||||
t=l.split()
|
||||
if len(t)>=2 and t[0].isdigit():index[int(t[0])]=t[1].decode()
|
||||
add=[]
|
||||
for l in lines((stage/'index.txt').read_bytes()):
|
||||
i,m=int(l.split()[0]),l.split()[1].decode()
|
||||
if index.get(i,m)!=m:raise SystemExit('map index %d is %s on the server, not %s'%(i,index[i],m))
|
||||
if i not in index:add.append(b'%d %s'%(i,m.encode()))
|
||||
dst=mapdir/m
|
||||
if dst.is_symlink():raise SystemExit('%s is a symlink'%dst)
|
||||
if dst.exists():(backup/'map').mkdir(exist_ok=True);shutil.move(str(dst),str(backup/'map'/m))
|
||||
shutil.copytree(str(stage/'map'/m),str(dst))
|
||||
if add:save(index_path);write(index_path,raw.rstrip(b'\r\n')+newline(raw)+newline(raw).join(add)+newline(raw))
|
||||
|
||||
# server motion data
|
||||
motion_added=0
|
||||
if data:
|
||||
if (data/'monster').is_symlink() or data.is_symlink():raise SystemExit('%s is shared with the live data'%data)
|
||||
for f in sorted((stage/'data/monster').iterdir()):
|
||||
dst=data/'monster'/f.name
|
||||
if not (dst.exists() or dst.is_symlink()):shutil.copytree(str(f),str(dst));motion_added+=1
|
||||
|
||||
# mob drops
|
||||
drops_added=0;errors=[]
|
||||
if (stage/'mob_drop_item.txt').exists():
|
||||
path=locale/'mob_drop_item.txt'
|
||||
if path.is_symlink():raise SystemExit('%s is a symlink (shared with the live locale?)'%path)
|
||||
raw=path.read_bytes();nl=newline(raw)
|
||||
DROP=re.compile(rb'Group[ \t]+(\S+)\s*\{(.*?)\}',re.S)
|
||||
names={n.lower() for n,_ in DROP.findall(raw)}
|
||||
have={int(m.group(1)) for n,b in DROP.findall(raw) if re.search(rb'Type\s+drop',b,re.I)
|
||||
for m in [re.search(rb'Mob\s+(\d+)',b)] if m}
|
||||
items={int(l.split(b'\t',1)[0]) for l in lines((conf/'item_proto.txt').read_bytes()) if l.split(b'\t',1)[0].isdigit()}
|
||||
add_drops=[]
|
||||
for m in DROP.finditer((stage/'mob_drop_item.txt').read_bytes()):
|
||||
mob=int(re.search(rb'Mob\s+(\d+)',m.group(2)).group(1))
|
||||
if mob in have:continue
|
||||
if m.group(1).lower() in names:raise SystemExit('drop group name %s already used'%m.group(1).decode())
|
||||
for v in re.findall(rb'\n\s*\d+\s+(\d+)\s+\d+\s+[\d.]+',m.group(0)):
|
||||
if int(v) not in items:errors.append('drop group %s: item %s not in item_proto'%(m.group(1).decode(),v.decode()))
|
||||
if mob not in mobs:errors.append('drop group %s: mob %d missing'%(m.group(1).decode(),mob))
|
||||
add_drops.append(m.group(0).replace(b'\r\n',b'\n').replace(b'\n',nl))
|
||||
if errors:raise SystemExit('\n'.join(sorted(set(errors)))+'\nmob_drop_item.txt not changed')
|
||||
if add_drops:
|
||||
save(path);write(path,raw.rstrip(b'\r\n')+nl+nl.join(add_drops)+nl);drops_added=len(add_drops)
|
||||
|
||||
# checks
|
||||
for v in map(int,(stage/'mob_refs.txt').read_text().split()):
|
||||
if v not in mobs:errors.append('mob %d missing from mob_proto'%v)
|
||||
for l in lines((stage/'index.txt').read_bytes()):
|
||||
m=l.split()[1].decode()
|
||||
for f in ('regen.txt','npc.txt','boss.txt','stone.txt','dungeon.txt'):
|
||||
for r in lines((mapdir/m/f).read_bytes()):
|
||||
t=r.split()
|
||||
if not t or t[0].startswith(b'/'):continue
|
||||
kind=t[0][:1].lower();v=int(t[-1]) if len(t)>=11 and t[-1].isdigit() else None
|
||||
if v is None:continue
|
||||
if kind==b'g' and v not in groups:errors.append('%s/%s: group %d missing'%(m,f,v))
|
||||
if kind==b'r' and v not in ggroups:errors.append('%s/%s: group_group %d missing'%(m,f,v))
|
||||
if kind in (b'm',b's') and v not in mobs:errors.append('%s/%s: mob %d missing'%(m,f,v))
|
||||
for v,b in blocks((stage/'group.txt').read_bytes()).items():
|
||||
for mob in re.findall(rb'\n\s*(?:Leader|\d+)\s+\S+\s+(\d+)',groups[v]):
|
||||
if int(mob) not in mobs:errors.append('group %d: mob %s missing'%(v,mob.decode()))
|
||||
print('AVA2 maps installed: mobs=%d groups+=%d group_groups+=%d index+=%d motion+=%d drops+=%d backup=%s'%(len(rows),appended['group.txt'],appended['group_group.txt'],len(add),motion_added,drops_added,backup))
|
||||
if errors:
|
||||
print('\n'.join(sorted(set(errors))));raise SystemExit('%d reference errors'%len(set(errors)))
|
||||
print('references OK')
|
||||
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Write mob_drop_item groups for the AVA2 new-map monsters from drops_maps.tsv.
|
||||
|
||||
Each monster in the stage's mobs-server.tsv gets its tier's rows (by rank and type, see drops_maps.tsv),
|
||||
plus the map:<dir> rows of every map that spawns it (regen/boss/stone/dungeon.txt, directly or via
|
||||
group.txt / group_group.txt) and the mob:<vnum> / mob:<first>-<last> rows covering it.
|
||||
NPCs, warps and buildings get nothing.
|
||||
The chance column is converted to the file's pct: per kill = pct*10000 * delta% * 1.5 (no premium) / 4000000,
|
||||
so pct = chance% / 0.375 at delta 100. Every item vnum is checked against the given item_proto files.
|
||||
|
||||
Output: <stage server dir>/mob_drop_item.txt (one 'drop' group per monster); install_maps.py appends the
|
||||
groups of monsters the server has no drop group for.
|
||||
Usage: make_drops_maps.py <stage server dir> <drops_maps.tsv> <item_proto.txt>...
|
||||
"""
|
||||
import collections,re,sys
|
||||
from pathlib import Path
|
||||
stage,table=Path(sys.argv[1]),Path(sys.argv[2])
|
||||
GOLD=range(4062,4068)
|
||||
|
||||
known=set()
|
||||
for p in sys.argv[3:]:
|
||||
for l in Path(p).read_bytes().splitlines():
|
||||
h=l.split(b'\t',1)[0].strip()
|
||||
if h.isdigit():known.add(int(h))
|
||||
|
||||
rows=collections.defaultdict(list);bad=[]
|
||||
for n,l in enumerate(table.read_text(encoding='utf-8').splitlines(),1):
|
||||
if not l.strip() or l.startswith('#'):continue
|
||||
t=l.split('\t')
|
||||
tier,vnum,count,chance=t[0],int(t[1]),int(t[2]),float(t[3])
|
||||
if vnum not in known:bad.append('%s:%d: item %d not in item_proto'%(table.name,n,vnum))
|
||||
if not 0<chance<=100 or count<1:bad.append('%s:%d: bad count/chance'%(table.name,n))
|
||||
rows[tier].append((vnum,count,chance))
|
||||
if bad:raise SystemExit('\n'.join(bad))
|
||||
|
||||
mobs={}
|
||||
for l in (stage/'mobs-server.tsv').read_bytes().splitlines():
|
||||
t=l.split(b'\t');mobs[int(t[0])]=(t[2].decode(),t[3].decode())
|
||||
def tier(vnum):
|
||||
rank,kind=mobs[vnum]
|
||||
if vnum in GOLD:return 'gold'
|
||||
if kind=='STONE':return 'stone'
|
||||
if kind!='MONSTER':return None
|
||||
return {'S_KNIGHT':'elite','BOSS':'boss','KING':'boss'}.get(rank,'normal')
|
||||
|
||||
# which maps spawn each monster
|
||||
BLOCK=re.compile(rb'Group[ \t]+\S+\s*\{(.*?)\}',re.S)
|
||||
def members(path):
|
||||
r={}
|
||||
for b in BLOCK.findall(path.read_bytes()):
|
||||
v=int(re.search(rb'Vnum\s+(\d+)',b).group(1))
|
||||
r[v]=[int(m) for m in re.findall(rb'\n\s*(?:Leader|\d+)\s+\S+\s+(\d+)',b)]
|
||||
return r
|
||||
groups=members(stage/'group.txt');ggroups=members(stage/'group_group.txt')
|
||||
maps=collections.defaultdict(set)
|
||||
for d in (stage/'map').iterdir():
|
||||
for f in ('regen.txt','boss.txt','stone.txt','dungeon.txt'):
|
||||
if not (d/f).exists():continue
|
||||
for r in (d/f).read_bytes().splitlines():
|
||||
t=r.split()
|
||||
if len(t)<11 or t[0].startswith(b'/') or not t[-1].isdigit():continue
|
||||
kind,v=t[0][:1].lower(),int(t[-1])
|
||||
spawned=[v] if kind in (b'm',b's') else groups.get(v,[]) if kind==b'g' else \
|
||||
[m for g in ggroups.get(v,[]) for m in groups.get(g,[])] if kind==b'r' else []
|
||||
for m in spawned:maps[m].add(d.name)
|
||||
|
||||
out=[];count=collections.Counter()
|
||||
for v in sorted(mobs):
|
||||
t=tier(v)
|
||||
if not t:continue
|
||||
items=list(rows[t])
|
||||
for m in sorted(maps[v]):items+=rows['map:'+m]
|
||||
for k in rows:
|
||||
if k.startswith('mob:'):
|
||||
lo,_,hi=k[4:].partition('-')
|
||||
if int(lo)<=v<=int(hi or lo):items+=rows[k]
|
||||
if len(items)>255:raise SystemExit('mob %d: %d rows (max 255)'%(v,len(items)))
|
||||
out+=['Group\tAVA2MAP_%d'%v,'{','\tMob\t%d'%v,'\tType\tdrop']
|
||||
out+=['\t%d\t%d\t%d\t%s'%(i,vnum,n,('%.4f'%(c/0.375)).rstrip('0').rstrip('.')) for i,(vnum,n,c) in enumerate(items,1)]
|
||||
out+=['}'];count[t]+=1
|
||||
(stage/'mob_drop_item.txt').write_bytes(('\r\n'.join(out)+'\r\n').encode())
|
||||
unused=[k for k in rows if k.startswith('map:') and k[4:] not in {m for s in maps.values() for m in s}]
|
||||
unused+=[k for k in rows if k.startswith('mob:') and not any(int(k[4:].partition('-')[0])<=v<=int(k[4:].partition('-')[2] or k[4:]) for v in mobs)]
|
||||
print('drop groups: %d (%s) -> %s'%(sum(count.values()),', '.join('%s %d'%kv for kv in sorted(count.items())),stage/'mob_drop_item.txt'))
|
||||
if unused:raise SystemExit('rows for no monster: '+' '.join(unused))
|
||||
@@ -0,0 +1,379 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage AVA2's level 100-125 maps and dungeon maps for the 203 server and the zh client
|
||||
(metin2-server docs/FEATURE-LEVEL-120.md L2/L3).
|
||||
Server (install_maps.py): mobs-server.tsv (AVA2-only monsters, stones, NPCs with zh names), group.txt /
|
||||
group_group.txt blocks, the map directories and their map/index lines.
|
||||
Client: the ava2maps pack = locale/zh/mob_proto with the new rows, every map / model / property file the zh
|
||||
client lacks, locale/zh/atlasinfo.txt with the new maps, property/mt_extra_list.txt (read by
|
||||
CPythonBackground::__CreateProperty) and locale/zh/mt_ava2maps.txt (race names and zone names for the
|
||||
mt_ava2maps script). Usage: see build_zh_locale.build_ava2_maps and --help.
|
||||
"""
|
||||
import argparse,json,re,shutil,subprocess,sys
|
||||
from collections import Counter
|
||||
from pathlib import Path
|
||||
HERE=Path(__file__).resolve().parent
|
||||
REPO=HERE.parents[2]
|
||||
sys.path.insert(0,str(REPO/'tools/epk_scan'))
|
||||
import epk_scan
|
||||
# Map directory -> (AVA2 server map index, zh zone name). None of the indexes is used on 203.
|
||||
MAPS={'plechito_desert_map_01':(57,'法老沙漠'),
|
||||
'metin2_map_elemental_04_rework':(37,'元素圣地'),
|
||||
'metin2_map_eastplain_01':(129,'东间平原'),
|
||||
'metin2_map_eastplain_02':(130,'西间荒原'),
|
||||
'metin2_map_eastplain_03':(131,'南间深渊'),
|
||||
'metin2_map_empirecastle':(132,'皇城'),
|
||||
'metin2_map_dawnmist_dungeon_01':(210,'晨雾地下城'),
|
||||
'metin2_map_n_flame_dragon':(212,'赤龙巢穴'),
|
||||
'metin2_map_n_snow_dungeon_01':(352,'冰雪地下城'),
|
||||
'defensawe_hydra':(355,'九头蛇船防')}
|
||||
# The zh client already ships these maps (files and atlasinfo row).
|
||||
CLIENT_HAS={'metin2_map_n_snow_dungeon_01'}
|
||||
# AVA2 leaves these Town.txt files empty (players would land at the map's corner): the 10107 warp landing.
|
||||
TOWN={'metin2_map_eastplain_01':b'133\t415\r\n'}
|
||||
# defensawe_hydra (972800,153600 2x2) is 203's metin2_map_empirewar03; this corner is free on 203 and in
|
||||
# the zh atlas. The shipdefense quest (L4) must shift its coordinates by the same delta.
|
||||
RELOCATE={'defensawe_hydra':(3276800,0)}
|
||||
# Server map files; stone2.txt is appended to stone.txt.
|
||||
MAP_FILES=('Setting.txt','Town.txt','server_attr','regen.txt','npc.txt','boss.txt','stone.txt','dungeon.txt')
|
||||
REGEN_FILES=('regen.txt','npc.txt','boss.txt','stone.txt','stone2.txt','dungeon.txt')
|
||||
# Yohara (AVA2 levels 119-125): AVA2 gives them the plechito level 101 exp; rescale geometrically to the
|
||||
# level 120 value of the plechito curve, bosses x10.
|
||||
YOHARA=range(6686,6732)
|
||||
def yohara_exp(level,rank):return round(83333*(117005/83333)**((level-101)/19)*(10 if rank=='BOSS' else 1))
|
||||
# Rows of the Yohara NPCs that AVA2 wrote with one column out of place (EMPIRE holds the immune flags) are
|
||||
# rebuilt from this ordinary NPC (vnum, name and folder kept).
|
||||
NPC_TEMPLATE=20016
|
||||
ON_CLICK_TALK='2'
|
||||
# Mob model folders RaceManager searches.
|
||||
MODEL_DIRS=('monster','monster2','npc','npc2')
|
||||
TIMER_BOSSES=('nemere','hydra','meley','razador','jotun','devil')
|
||||
# Files the closure follows (text) and the reference pattern (closure of AVA2 packs).
|
||||
NAMES=re.compile(rb'[\w \-:./\\]+?\.(?:dds|tga|jpg|bmp|png|mde|mse|gr2|spt|msf|wav|mp3|mss|msa|msm|msenv|prb|prt|pre|prd|pra|sub|txt|atr|raw|wtr|obv)(?=["\s\x00]|$)',re.I)
|
||||
TEXT=('.mse','.mde','.msm','.msa','.mss','.msenv','.prb','.prt','.pre','.prd','.pra','.sub','.txt','.msf','.spt')
|
||||
EXTRA_PROPERTY_DIR='property/mt_ava2/'
|
||||
|
||||
def mob_enums(proto_reader):
|
||||
src=proto_reader.read_text(encoding='latin1');src=src[src.index('arRank[]')-32:]
|
||||
arr=lambda name:re.findall(r'"([^"]+)"',re.search(r'string\s+'+name+r'\[\]\s*=\s*\{(.*?)\};',src,re.S).group(1))
|
||||
return {k:arr(v) for k,v in (('rank','arRank'),('type','arType'),('battle','arBattleType'),('size','arSize'),
|
||||
('ai','arAIFlag'),('race','arRaceFlag'),('immune','arImmuneFlag'))}
|
||||
|
||||
def norm(path):return path.strip().strip('"').lower().replace('\\','/')
|
||||
def number(text):
|
||||
try:return float(text)
|
||||
except ValueError:return 0.0
|
||||
|
||||
def names():
|
||||
out={}
|
||||
for line in (HERE/'names_zh.tsv').read_text().splitlines():
|
||||
if line and not line.startswith('#'):v,n=line.split('\t');out[int(v)]=n
|
||||
return out
|
||||
|
||||
class Pack:
|
||||
"""The client's effective pack files (pack/Index order, first registered pack wins), without `skip`."""
|
||||
def __init__(self,client,skip):
|
||||
_,self.keys,order,packs,_=epk_scan.load(client,epk_scan.refroot.reference_root())
|
||||
self.index={}
|
||||
for name,_ in order:
|
||||
p=packs.get(name)
|
||||
if name==skip or not p or p['missing']:continue
|
||||
for e in p['entries']:self.index.setdefault(norm(e['name']),(p,e))
|
||||
def __contains__(self,path):return path in self.index
|
||||
def get(self,path):
|
||||
p,e=self.index[path]
|
||||
with open(p['epk'],'rb') as f:
|
||||
f.seek(e['pos']);stored=f.read(e['size'])
|
||||
if e['type']==0:return stored
|
||||
f.seek(e['pos']);data=f.read(epk_scan.lz_object_len(stored[:16]))
|
||||
return epk_scan.lz_object(data,self.keys['s_adwEterPackSecurityKey'] if e['type']==2 else None)
|
||||
|
||||
def ava_index(pack_maker):
|
||||
"""ArchivedPath (lowercase) -> source file, first pack in AVA2 pack/Index wins.
|
||||
|
||||
CEterFileDict is a multimap and GetItem returns the earliest registration,
|
||||
so a duplicate path resolves to the pack listed first in Index (e.g. Maps
|
||||
before Patch_dungeon_meley), not to the alphabetically first manifest."""
|
||||
xmls={x.name[:-len('_create.xml')].lower():x for x in pack_maker.glob('*_create.xml')}
|
||||
order=[l.strip().lower() for l in (pack_maker.parent/'pack/Index').read_text(encoding='latin1').splitlines() if l.strip()]
|
||||
order=[n for n in order if n in xmls]+sorted(set(xmls)-set(order))
|
||||
index={}
|
||||
for name in order:
|
||||
for archived,source in re.findall(r'ArchivedPath="([^"]+)"><!\[CDATA\[([^\]]+)\]\]>',xmls[name].read_text(encoding='latin1')):
|
||||
index.setdefault(archived.lower().replace('\\','/'),pack_maker.parent/source)
|
||||
return index
|
||||
|
||||
def proto_rows(path):
|
||||
rows={}
|
||||
for line in path.read_bytes().splitlines():
|
||||
cols=[c.strip() for c in line.decode('latin1').split('\t')]
|
||||
if cols[0].isdigit():rows[int(cols[0])]=cols
|
||||
return rows
|
||||
|
||||
def server_row(cols,zh,E,template):
|
||||
"""AVA2 db/mob_proto.txt columns -> 203 server row (str columns, zh name)."""
|
||||
c=list(cols)+['0']*(71-len(cols))
|
||||
if not re.fullmatch(r'-?\d*',c[11]): # shifted NPC row
|
||||
c=list(template);c[0],c[12]=cols[0],cols[12];c[13]=ON_CLICK_TALK
|
||||
c[1]=zh
|
||||
for i,k in ((7,'ai'),(9,'race'),(10,'immune')):
|
||||
c[i]=','.join(t for t in (x.strip() for x in c[i].split(',')) if t in E[k])
|
||||
try:float(c[51])
|
||||
except ValueError:c[51]=c[51].split('.')[0] # AVA2 "2.000.000"
|
||||
if int(c[0]) in YOHARA and c[3]=='MONSTER':c[25]=str(yohara_exp(int(c[5]),c[2]))
|
||||
return c[:71]
|
||||
|
||||
def client_row(c,E):
|
||||
"""Server row -> mob_proto_patch fields (tests/port/mob_proto_patch.cpp order)."""
|
||||
idx=lambda k,v:E[k].index(v) if v in E[k] else 0
|
||||
bits=lambda k,v:sum(1<<E[k].index(t) for t in v.split(',') if t in E[k])
|
||||
n=lambda i:number(c[i])
|
||||
f=[int(c[0]),idx('type',c[3]),idx('rank',c[2]),idx('battle',c[4]),n(5),E['size'].index(c[6])+1 if c[6] in E['size'] else 0,
|
||||
n(23),n(24),n(25),n(20),n(21),n(22),n(26),bits('ai',c[7]),bits('race',c[9]),bits('immune',c[10]),
|
||||
n(14),n(15),n(16),n(17),n(18),n(19),n(27),n(28),n(29),n(30),n(31)]
|
||||
f+=[n(i) for i in range(34,40)]+[n(i) for i in range(40,51)]
|
||||
f+=[n(33),n(32),n(8),n(13),n(11),n(51),n(52),n(53),n(54),n(55)]
|
||||
for k in range(5):f+=[n(57+2*k),n(56+2*k)]
|
||||
f+=[n(i) for i in range(66,71)]
|
||||
assert len(f)==69
|
||||
text=' '.join(('%g'%x if isinstance(x,float) and x!=int(x) else str(int(x))) for x in f)
|
||||
# Warps carry "<place> <x> <y>" for the server; the client shows the place only.
|
||||
name=c[1].split(' ')[0] if c[3]=='WARP' else c[1]
|
||||
return (text+'\t'+c[12]+'\t'+name).encode('gbk')
|
||||
|
||||
def blocks(raw,member):
|
||||
"""group.txt / group_group.txt -> {vnum: (block bytes, [member vnums])}; member(tokens) -> vnum or None."""
|
||||
out={};lines=raw.replace(b'\r\n',b'\n').split(b'\n');i=0
|
||||
while i<len(lines):
|
||||
t=lines[i].split()
|
||||
if t and t[0].lower()==b'group':
|
||||
j=i
|
||||
while j<len(lines) and not lines[j].strip().startswith(b'}'):j+=1
|
||||
body=lines[i:j+1];vnum=None;members=[]
|
||||
for l in body[1:]:
|
||||
t=l.split()
|
||||
if len(t)>=2 and t[0].lower()==b'vnum':vnum=int(t[1])
|
||||
elif t and t[0]!=b'{' and t[0]!=b'}':
|
||||
m=member(t)
|
||||
if m is not None:members.append(m)
|
||||
if vnum is not None:out.setdefault(vnum,(b'\r\n'.join(l.rstrip() for l in body),members))
|
||||
i=j
|
||||
i+=1
|
||||
return out
|
||||
|
||||
def regen_lines(raw):
|
||||
"""Regen file -> [(line, kind, vnum)] (kind m/g/r..., None for blank/unknown lines)."""
|
||||
out=[]
|
||||
for line in raw.replace(b'\r\n',b'\n').split(b'\n'):
|
||||
t=line.split()
|
||||
if len(t)>=10 and t[-1].isdigit() and t[0][:1].isalpha():out.append((line.rstrip(),t[0][:1].decode().lower(),int(t[-1])))
|
||||
elif line.strip():out.append((line.rstrip(),None,None))
|
||||
return out
|
||||
|
||||
def prepare(ava,proto_reader,client,output,mob_tool,gr2_tool,packer):
|
||||
srv=ava/'2. Backup SF+SRC and SQL/home/srv1';pack_maker=ava/'1. Client DEV/pack_maker'
|
||||
loc=srv/'share/locale/germany'
|
||||
if not (loc/'map').is_dir() or not (srv/'db/mob_proto.txt').is_file():
|
||||
raise SystemExit('AVA2 maps need the extracted server tree (AVA2/TEST/2. Backup SF+SRC and SQL/home/srv1)')
|
||||
E=mob_enums(proto_reader);zh=names();AP=proto_rows(srv/'db/mob_proto.txt')
|
||||
assert zh.keys()<=AP.keys(),sorted(zh.keys()-AP.keys())
|
||||
report={'warnings':[]};warn=report['warnings'].append
|
||||
output.mkdir(parents=True,exist_ok=True)
|
||||
stage=output/'server'
|
||||
if stage.exists():shutil.rmtree(stage)
|
||||
(stage/'map').mkdir(parents=True)
|
||||
# ---------------------------------------------------------------- server: mob rows
|
||||
template=AP[NPC_TEMPLATE]
|
||||
srows={v:server_row(AP[v],zh[v],E,template) for v in sorted(zh)}
|
||||
(stage/'mobs-server.tsv').write_bytes(b''.join('\t'.join(r).encode('gbk')+b'\n' for r in srows.values()))
|
||||
report['mobs']=len(srows)
|
||||
# ---------------------------------------------------------------- server: map dirs + groups
|
||||
G=blocks((loc/'group.txt').read_bytes(),lambda t:int(t[-1]) if t[-1].isdigit() and (t[0].isdigit() or t[0].lower()==b'leader') else None)
|
||||
GG=blocks((loc/'group_group.txt').read_bytes(),lambda t:int(t[1]) if t[0].isdigit() and t[1].isdigit() else None)
|
||||
groups=set();ggroups=set();mobs=set()
|
||||
def add_mob(v):
|
||||
if v in mobs:return
|
||||
mobs.add(v);r=srows.get(v) or AP.get(v)
|
||||
if r is None:return
|
||||
if r[3]=='STONE':
|
||||
lo,hi=sorted((int(number(r[27])),int(number(r[28]))))
|
||||
if hi-lo<50:
|
||||
for g in range(lo,hi+1):
|
||||
if g in G:add_group(g)
|
||||
if number(r[33]):add_mob(int(number(r[33])))
|
||||
def add_group(g):
|
||||
if g in groups:return
|
||||
groups.add(g)
|
||||
for m in G[g][1]:add_mob(m)
|
||||
index_lines=[];origin={}
|
||||
for m,(index,_) in MAPS.items():
|
||||
src=loc/'map'/m;dst=stage/'map'/m;dst.mkdir()
|
||||
dropped=Counter()
|
||||
for f in MAP_FILES:
|
||||
raw=(src/f).read_bytes() if (src/f).is_file() else b''
|
||||
if f=='stone.txt' and (src/'stone2.txt').is_file():raw=raw.rstrip(b'\r\n')+b'\r\n'+(src/'stone2.txt').read_bytes()
|
||||
if f=='Town.txt' and m in TOWN:raw=TOWN[m]
|
||||
if f=='Setting.txt' and m in RELOCATE:
|
||||
raw=re.sub(rb'BasePosition\s+\d+\s+\d+',b'BasePosition\t%d\t%d'%RELOCATE[m],raw);assert b'\t%d\t'%RELOCATE[m][0] in raw
|
||||
if f=='Setting.txt':origin[m]=tuple(map(int,re.search(rb'BasePosition\s+(\d+)\s+(\d+)',raw).groups()))
|
||||
if f in REGEN_FILES:
|
||||
kept=[]
|
||||
for line,kind,v in regen_lines(raw):
|
||||
if kind=='g' and v not in G or kind=='r' and v not in GG:dropped[(kind,v)]+=1;continue
|
||||
if kind=='g':add_group(v)
|
||||
elif kind=='r':
|
||||
ggroups.add(v)
|
||||
for g in GG[v][1]:
|
||||
if g in G:add_group(g)
|
||||
elif kind:add_mob(v)
|
||||
kept.append(line)
|
||||
raw=b'\r\n'.join(kept)+(b'\r\n' if kept else b'')
|
||||
if f=='Town.txt' and not raw.strip() and m not in TOWN:warn('%s: empty Town.txt (map corner)'%m)
|
||||
if f in ('Setting.txt','server_attr') and not raw:raise SystemExit('%s/%s missing'%(m,f))
|
||||
(dst/f).write_bytes(raw)
|
||||
for (kind,v),n in sorted(dropped.items()):warn('%s: dropped %d regen lines of missing %s %d'%(m,n,'group' if kind=='g' else 'groupgroup',v))
|
||||
index_lines.append(b'%d %s'%(index,m.encode()))
|
||||
(stage/'index.txt').write_bytes(b'\n'.join(index_lines)+b'\n')
|
||||
(stage/'group.txt').write_bytes(b''.join(G[g][0]+b'\r\n' for g in sorted(groups)))
|
||||
(stage/'group_group.txt').write_bytes(b''.join(GG[g][0]+b'\r\n' for g in sorted(ggroups)))
|
||||
# Every regen / group member must be a 203 mob or one of ours; install_maps.py checks the rest on the server.
|
||||
(stage/'mob_refs.txt').write_text(''.join('%d\n'%v for v in sorted(mobs)))
|
||||
# Server motion data (data/monster/<folder>: motlist.txt + .msa timing); install_maps.py adds only folders 203 lacks.
|
||||
# The core opens the folder exactly as spelled (FreeBSD); mob_proto spellings that differ only in case
|
||||
# resolve to the one real folder here, so each is copied once under its on-disk name.
|
||||
motion=srv/'share/data/monster';real={d.name.lower():d.name for d in motion.iterdir() if d.is_dir()};folders=set()
|
||||
for v in mobs|set(srows):
|
||||
r=srows.get(v) or AP.get(v)
|
||||
if r and r[12].lower() in real:folders.add(real[r[12].lower()])
|
||||
for f in sorted(folders):
|
||||
shutil.copytree(motion/f,stage/'data/monster'/f,ignore=lambda d,names:[n for n in names if n.lower().endswith(('.dds','.gr2','.tga','.jpg'))])
|
||||
report['motion_folders']=len(folders)
|
||||
report.update(groups=len(groups),group_groups=len(ggroups),mob_refs=len(mobs))
|
||||
# ---------------------------------------------------------------- client
|
||||
have=Pack(client,'ava2maps');files=ava_index(pack_maker)
|
||||
assets=output/'assets'
|
||||
if assets.exists():shutil.rmtree(assets)
|
||||
target=assets/'locale/zh';target.mkdir(parents=True)
|
||||
crows=[client_row(srows[v],E) for v in sorted(srows)]
|
||||
(output/'mobs-client.tsv').write_bytes(b'\n'.join(crows)+b'\n')
|
||||
(output/'base_mob_proto').write_bytes(have.get('locale/zh/mob_proto'))
|
||||
subprocess.run([str(mob_tool),str(output/'base_mob_proto'),str(output/'mobs-client.tsv'),str(target/'mob_proto')],check=True)
|
||||
# atlasinfo: the locale file the client reads first (CPythonBackground::Initialize), from the root one.
|
||||
base=have.get('locale/zh/atlasinfo.txt') if 'locale/zh/atlasinfo.txt' in have else have.get('atlasinfo.txt')
|
||||
atlas=[l for l in base.replace(b'\r\n',b'\n').split(b'\n') if l.strip()]
|
||||
atlas_names={l.split()[0] for l in atlas}
|
||||
for m in MAPS:
|
||||
if m in CLIENT_HAS:continue
|
||||
setting=files[m+'/setting.txt'].read_bytes()
|
||||
# The server Setting is authoritative: AVA2's Maps pack shadows Patch_dungeon_meley's
|
||||
# flame_dragon setting.txt with BasePosition 0 0, which would misplace the client terrain.
|
||||
bx,by=origin[m]
|
||||
w,h=map(int,re.search(rb'MapSize\s+(\d+)\s+(\d+)',setting).groups())
|
||||
if m.encode() in atlas_names:raise SystemExit('zh atlasinfo already lists %s'%m)
|
||||
atlas.append(b'%s\t%d\t%d\t%d\t%d'%(m.encode(),bx,by,w,h))
|
||||
(target/'atlasinfo.txt').write_bytes(b'\r\n'.join(atlas)+b'\r\n')
|
||||
# Properties: AVA2-only CRCs placed on the new maps.
|
||||
def crc_of(raw):
|
||||
t=raw.split(b'\n',2)
|
||||
return int(t[1].strip()) if raw[:4]==b'YPRT' and len(t)>1 and t[1].strip().isdigit() else None
|
||||
zh_crc={crc_of(have.get(p)) for p in have.index if p.startswith('property/') and p!='property/reserve'}
|
||||
ava_crc={}
|
||||
for p in files:
|
||||
if p.startswith('property/') and p!='property/reserve':
|
||||
c=crc_of(files[p].read_bytes())
|
||||
if c is not None:ava_crc.setdefault(c,p)
|
||||
placed=set()
|
||||
for m in MAPS:
|
||||
if m in CLIENT_HAS:continue
|
||||
for p in files:
|
||||
if p.startswith(m+'/') and p.endswith(('/areadata.txt','/areaambiencedata.txt')):
|
||||
t=files[p].read_bytes().decode('latin1').split('\n')
|
||||
placed|={int(t[i+2].strip()) for i,l in enumerate(t) if l.startswith('Start Object')}
|
||||
extra=[];missing_props=[]
|
||||
for c in sorted(placed-zh_crc):
|
||||
if c not in ava_crc:missing_props.append(c);continue
|
||||
p=ava_crc[c];dest=p if p not in have else EXTRA_PROPERTY_DIR+p[len('property/'):]
|
||||
extra.append((p,dest))
|
||||
report.update(properties=len(extra),properties_missing=missing_props)
|
||||
# Mob models: AVA2 npclist rows of the races the zh npclist lacks.
|
||||
def npclist(raw):
|
||||
race={};alias={}
|
||||
for l in raw.decode('latin1').splitlines():
|
||||
t=l.split()
|
||||
if len(t)>=2 and t[0].isdigit():
|
||||
if t[0]=='0' and len(t)>=3:alias[t[1].lower()]=norm(t[2])
|
||||
elif t[0]!='0':race[int(t[0])]=norm(t[1])
|
||||
return race,alias
|
||||
AR,AA=npclist(files['npclist.txt'].read_bytes());ZR,_=npclist(have.get('npclist.txt'))
|
||||
races=[];srcs={};model_seeds=[]
|
||||
for v in sorted(zh):
|
||||
if v in ZR:continue
|
||||
name=AR.get(v)
|
||||
if not name:warn('race %d: no AVA2 npclist row'%v);continue
|
||||
src=AA.get(name,name);races.append((v,name))
|
||||
if src!=name:srcs[name]=src
|
||||
found=[p for d in MODEL_DIRS for p in files if p.startswith('d:/ymir work/%s/%s/'%(d,src))]
|
||||
if not found:warn('race %d: no AVA2 model folder %s'%(v,src))
|
||||
model_seeds+=found
|
||||
# Closure over the map, atlas, property and model files.
|
||||
seeds=[p for m in MAPS if m not in CLIENT_HAS for p in files if p.startswith(m+'/')]
|
||||
seeds+=[p for m in MAPS if m not in CLIENT_HAS for p in ('d:/ymir work/ui/atlas/%s/atlas.sub'%m,) if p in files]
|
||||
seeds+=[p for p,_ in extra]+model_seeds
|
||||
# Dungeon timer images (DungeonTimerScript.inc, the AVA2 dungeons of ../ava2-dungeons) and their timer.tga.
|
||||
seeds+=['d:/ymir work/ui/game/dungeontimer/%s_%s.sub'%(b,k) for b in TIMER_BOSSES for k in ('back','timer')]
|
||||
need=set();misses=Counter();gr2=[]
|
||||
def refs(a):
|
||||
out=[]
|
||||
if a.endswith(TEXT) and not a.endswith('/motlist.txt'):
|
||||
for n in NAMES.findall(files[a].read_bytes()):
|
||||
n=norm(n.decode('latin1'))
|
||||
if not n:continue
|
||||
if n.startswith('d:/') or n in files or n in have:out.append(n)
|
||||
elif a.endswith('.sub'):out.append('d:/ymir work/ui/'+n)
|
||||
elif n.endswith('.msenv'):out.append('d:/ymir work/environment/'+n.rsplit('/',1)[-1])
|
||||
else:out.append(a.rsplit('/',1)[0]+'/'+n)
|
||||
if a.endswith('.gr2'):gr2.append(a)
|
||||
return out
|
||||
def visit(q,frm):
|
||||
if q in have or q in need:return
|
||||
if q not in files:
|
||||
same=frm.rsplit('/',1)[0]+'/'+q.rsplit('/',1)[-1]
|
||||
if same!=q and (same in have or same in files):visit(same,frm)
|
||||
else:misses[q]+=1
|
||||
return
|
||||
need.add(q)
|
||||
for r in refs(q):visit(r,q)
|
||||
for s in seeds:visit(s,'seed')
|
||||
done=set()
|
||||
while len(done)<len(gr2):
|
||||
batch=[a for a in gr2 if a not in done];done|=set(batch)
|
||||
back={str(files[a]):a for a in batch}
|
||||
out=subprocess.run([str(gr2_tool)],input='\n'.join(back)+'\n',capture_output=True,text=True,check=True).stdout
|
||||
for l in out.splitlines():
|
||||
t=l.split('\t')
|
||||
if t[0]=='TEX':visit(norm(t[2]),back[t[1]])
|
||||
elif t[0]=='ERR':warn('gr2 %s: %s'%(back[t[1]],t[2]))
|
||||
property_dest=dict(extra)
|
||||
for q in sorted(need):
|
||||
dest=assets/property_dest.get(q,q);dest.parent.mkdir(parents=True,exist_ok=True)
|
||||
raw=files[q].read_bytes()
|
||||
if q.endswith('/setting.txt') and q.split('/')[0] in origin:
|
||||
raw=re.sub(rb'BasePosition\s+\d+\s+\d+',b'BasePosition\t%d\t%d'%origin[q.split('/')[0]],raw)
|
||||
dest.write_bytes(raw)
|
||||
(assets/'property').mkdir(exist_ok=True)
|
||||
(assets/'property/mt_extra_list.txt').write_bytes(b''.join(d.encode()+b'\r\n' for _,d in extra))
|
||||
report.update(files=len(need),bytes=sum(files[q].stat().st_size for q in need),misses=sorted(misses))
|
||||
# mt_ava2maps data (gbk): race names, source folders, zone names, server map indexes.
|
||||
lines=['race\t%d\t%s'%r for r in races]+['src\t%s\t%s'%kv for kv in sorted(srcs.items())]
|
||||
lines+=['zone\t%s\t%s'%(m,z) for m,(_,z) in MAPS.items()]+['map\t%d\t%s'%(i,m) for m,(i,_) in MAPS.items()]
|
||||
(target/'mt_ava2maps.txt').write_bytes('\n'.join(lines).encode('gbk')+b'\n')
|
||||
report['races']=len(races)
|
||||
subprocess.run([str(packer),str(output/'ava2maps'),str(assets),''],check=True)
|
||||
(output/'maps.json').write_text(json.dumps(report,indent=1,ensure_ascii=False)+'\n')
|
||||
return report
|
||||
|
||||
if __name__=='__main__':
|
||||
p=argparse.ArgumentParser(description=__doc__)
|
||||
for a in ('ava','proto_reader','client','output','mob_tool','gr2_tool','packer'):p.add_argument(a,type=Path)
|
||||
a=p.parse_args()
|
||||
r=prepare(a.ava,a.proto_reader,a.client,a.output,a.mob_tool.resolve(),a.gr2_tool.resolve(),a.packer.resolve())
|
||||
print(json.dumps({k:(len(v) if isinstance(v,list) and k not in ('warnings',) else v) for k,v in r.items()},indent=1,ensure_ascii=False))
|
||||
@@ -0,0 +1,135 @@
|
||||
# AVA2 map/dungeon monsters, stones and NPCs that 203 lacks (vnum<TAB>zh name). Warp names keep AVA2's "<place> <x> <y>" (server sscanf).
|
||||
4062 诅咒之书
|
||||
4063 黄金僵尸
|
||||
4064 宝石魔像
|
||||
4065 陷阱宝箱
|
||||
4066 金币守护者
|
||||
4067 黄金狮身人面像
|
||||
4111 沙漠蜻蜓
|
||||
4112 沙丘甲虫
|
||||
4113 毒甲虫
|
||||
4114 石龙
|
||||
4115 蜥蜴斥候
|
||||
4116 蜥蜴斗士
|
||||
4117 蜥蜴战士
|
||||
4118 龙人圣骑士
|
||||
4119 安度尔战士
|
||||
4120 安度尔萨满
|
||||
4121 安度尔刺客
|
||||
4122 那伽斥候
|
||||
4123 那伽骑兵
|
||||
4124 蛇人斗士
|
||||
4125 蛇人术士
|
||||
4126 蛇人战士
|
||||
4127 岩石魔像
|
||||
4128 远古魔像
|
||||
4129 木乃伊
|
||||
4130 狂暴木乃伊
|
||||
4131 法老守卫
|
||||
4132 法老祭司
|
||||
4133 法老
|
||||
4134 奥西里斯仆从
|
||||
4135 阿努比斯仆从
|
||||
6222 熔岩雪人
|
||||
6223 熔岩魔像
|
||||
6224 熔岩虫
|
||||
6225 岩浆魔像
|
||||
6226 炽热水晶
|
||||
6227 熔岩飞龙
|
||||
6228 龙之守卫伊达尔
|
||||
6230 龙之雕像
|
||||
6231 龙后美莉
|
||||
6401 恩泰战士
|
||||
6402 恩泰斗士
|
||||
6406 恩泰毁灭者
|
||||
6410 强壮的恩泰战士
|
||||
6411 强壮的恩泰斗士
|
||||
6686 金兵
|
||||
6687 枪兵
|
||||
6688 矛兵
|
||||
6689 弓兵
|
||||
6690 前线术士
|
||||
6693 金兵
|
||||
6694 枪兵
|
||||
6695 矛兵
|
||||
6696 弓兵
|
||||
6697 前线术士
|
||||
6699 宝王
|
||||
6700 地狱猎犬
|
||||
6701 巨魔士兵
|
||||
6702 巨魔战士
|
||||
6703 巨魔弓手
|
||||
6704 巨魔萨满
|
||||
6710 怨灵
|
||||
6711 地狱猎犬
|
||||
6712 巨魔士兵
|
||||
6713 巨魔战士
|
||||
6714 巨魔弓手
|
||||
6715 巨魔萨满
|
||||
6716 纳塔南
|
||||
6717 阿尔戈斯
|
||||
6718 米尔族步兵
|
||||
6719 米尔族劳工
|
||||
6720 米尔族魔像
|
||||
6721 米尔族战士
|
||||
6722 米尔族术士
|
||||
6723 米尔族老兵
|
||||
6724 米尔族首领
|
||||
6730 米尔族老兵
|
||||
6731 米尔族首领
|
||||
6801 桅杆
|
||||
6802 河童首领
|
||||
6803 河童
|
||||
6804 河童
|
||||
6805 河童
|
||||
6806 人鱼蛇兵
|
||||
6807 人鱼毒蛇
|
||||
6808 小九头蛇
|
||||
6809 人鱼海妖
|
||||
6810 九头蛇
|
||||
6811 九头蛇
|
||||
6812 九头蛇
|
||||
8058 寒冰之石
|
||||
8059 树木之石
|
||||
8061 森林之石
|
||||
8062 警戒之石
|
||||
8063 珍爱之石
|
||||
8067 警戒之石
|
||||
8469 沙漠之石
|
||||
8470 荆棘之石
|
||||
8471 木乃伊之石
|
||||
8625 巨魔前哨
|
||||
8626 米尔族前哨
|
||||
8627 米尔族前哨
|
||||
9015 船舵
|
||||
9016 力场
|
||||
9018 九头蛇宝箱
|
||||
9566 变异蜜蜂
|
||||
9571 变异蛇
|
||||
9577 变异蝎子
|
||||
9578 烈焰龙
|
||||
10107 东间平原 10629 4767
|
||||
10127 东间平原 10551 4881
|
||||
10129 南间深渊 12780 4411
|
||||
10130 西间荒原 12144 5555
|
||||
20397 冰狮
|
||||
20398 寒冰魔方
|
||||
20399 北龙之柱
|
||||
20409 森林守卫
|
||||
20410 森林密探
|
||||
20411 森林斥候
|
||||
20440 龙之门
|
||||
20441 守望者多纳尔
|
||||
20442 龙之宝藏
|
||||
20444 龙蛋
|
||||
20480 商会管理员
|
||||
20800 伤员
|
||||
20802 雄原巡守
|
||||
20803 雄原守卫
|
||||
20810 柴吉拉布
|
||||
20812 安格穆尔提督
|
||||
20823 池大师
|
||||
20831 雄原指挥官
|
||||
20836 戟兵
|
||||
20850 神秘祭坛
|
||||
60003 西奥瓦丹
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 104.
|
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
# Give the sbtest channel5 core its own locale and data dir so install_maps.py never touches the live ones.
|
||||
# sbtest/share/locale/newcibn = symlinks to every live newcibn entry, except real copies of
|
||||
# group.txt, group_group.txt, mob_drop_item.txt and a real map/ dir (symlinks to each live map dir + a copied index).
|
||||
# sbtest/share/data = symlinks to the live data entries, except a real monster/ dir (symlinks per live folder).
|
||||
# Idempotent: existing entries are kept, so a rerun only adds what the live locale gained since.
|
||||
# Run on 203: sh sbtest_locale.sh (restart channel5 afterwards)
|
||||
set -e
|
||||
LIVE=/usr/metin2/server/share/locale
|
||||
SB=/usr/metin2/server/sbtest/share/locale
|
||||
CORE=/usr/metin2/server/channel5/first
|
||||
LIVEMAP=$(cd "$LIVE/newcibn/map" && pwd -P)
|
||||
LIVEDATA=/usr/metin2/server/share/data
|
||||
SBDATA=/usr/metin2/server/sbtest/share/data
|
||||
|
||||
mkdir -p "$SB/newcibn/map"
|
||||
[ -e "$SB/english" ] || ln -s "$LIVE/english" "$SB/english"
|
||||
for e in "$LIVE"/newcibn/*; do
|
||||
n=${e##*/}
|
||||
case $n in map) continue ;; esac
|
||||
[ -e "$SB/newcibn/$n" ] || [ -L "$SB/newcibn/$n" ] && continue
|
||||
case $n in
|
||||
group.txt|group_group.txt) cp -p "$e" "$SB/newcibn/$n" ;;
|
||||
*) ln -s "$e" "$SB/newcibn/$n" ;;
|
||||
esac
|
||||
done
|
||||
# entries made into copies after the farm was first built
|
||||
for n in group.txt group_group.txt mob_drop_item.txt; do
|
||||
[ -L "$SB/newcibn/$n" ] && rm "$SB/newcibn/$n" && cp -p "$LIVE/newcibn/$n" "$SB/newcibn/$n" && echo "$n copied"
|
||||
done
|
||||
for e in "$LIVEMAP"/*; do
|
||||
n=${e##*/}
|
||||
[ -e "$SB/newcibn/map/$n" ] || [ -L "$SB/newcibn/map/$n" ] && continue
|
||||
case $n in
|
||||
index) cp -p "$e" "$SB/newcibn/map/index" ;;
|
||||
*) ln -s "$e" "$SB/newcibn/map/$n" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p "$SBDATA/monster"
|
||||
for e in "$LIVEDATA"/*; do
|
||||
n=${e##*/}
|
||||
[ "$n" = monster ] || [ -e "$SBDATA/$n" ] || [ -L "$SBDATA/$n" ] || ln -s "$e" "$SBDATA/$n"
|
||||
done
|
||||
for e in "$LIVEDATA"/monster/*; do
|
||||
[ -e "$SBDATA/monster/${e##*/}" ] || [ -L "$SBDATA/monster/${e##*/}" ] || ln -s "$e" "$SBDATA/monster/${e##*/}"
|
||||
done
|
||||
|
||||
repoint() # <link> <target>
|
||||
{
|
||||
[ "$(readlink "$1")" = "$2" ] && return 0
|
||||
echo "$1 was $(readlink "$1")"
|
||||
rm "$1" && ln -s "$2" "$1"
|
||||
}
|
||||
repoint "$CORE/locale" "$SB"
|
||||
repoint "$CORE/data" "$SBDATA"
|
||||
echo "channel5 locale -> $(readlink "$CORE/locale"); $(ls "$SB/newcibn" | wc -l) entries, $(ls "$SB/newcibn/map" | wc -l) map entries"
|
||||
echo "channel5 data -> $(readlink "$CORE/data"); $(ls "$SBDATA/monster" | wc -l) monster folders"
|
||||
Reference in New Issue
Block a user