AVA2 unlock P4: sash (mt_sash windows/slot/tooltips, sash module, CHR_EQUIPPART_SASH, item_scale)
Client side of metin2-server FEATURE-AVA2-UNLOCK P4: HEADER_CG_SASH 211 / HEADER_GC_SASH 215, a fifth awPart WORD in the character packets (old servers break), the sash part attached by scale per job/sex, the combine and absorb windows in script mt_sash, and quest tools/server/sash on 20016. The ava2items pack keeps the four grade-4 sashes plus their effects, acce window images and item_scale.txt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0d2a9ebe36
commit
4d7306792e
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage the AVA2 drop items that the 203 server lacks as ordinary 40250 items (server rows + client patch pack).
|
||||
Only types/subtypes/flags the 40250 server understands survive; items of AVA2-only systems (pets, pendants,
|
||||
new rings, mounts, sashes, costume enchants, talisman bonus items, new skill books) become plain ITEM_NONE
|
||||
new rings, mounts, costume enchants, talisman bonus items, new skill books) become plain ITEM_NONE
|
||||
items until those systems are ported. Usage: see build_zh_locale.build_ava2_items and --help.
|
||||
"""
|
||||
import argparse,json,re,shutil,subprocess
|
||||
@@ -17,8 +17,15 @@ ARMOR_SHAPES={32:'%s_7_1'}
|
||||
RACE_PATHS={'warrior':('pc','pc2'),'assassin':('pc2','pc'),'sura':('pc','pc2'),'shaman':('pc2','pc')} # (male, female)
|
||||
# Kept with their 40250 meaning; everything else becomes ITEM_NONE (see module doc).
|
||||
KEEP_TYPES={'ITEM_MATERIAL','ITEM_QUEST','ITEM_GIFTBOX','ITEM_NONE','ITEM_TREASURE_BOX','ITEM_TREASURE_KEY'}
|
||||
KEEP_SUBTYPES={('ITEM_WEAPON',s) for s in ('WEAPON_SWORD','WEAPON_DAGGER','WEAPON_BOW','WEAPON_TWO_HANDED','WEAPON_BELL','WEAPON_FAN')}|{('ITEM_ARMOR','ARMOR_FOOTS'),('ITEM_ARMOR','ARMOR_BODY'),('ITEM_METIN','METIN_NORMAL')}
|
||||
DESC={'ITEM_METIN':'可镶嵌到武器的空孔中。','ITEM_MATERIAL':'制作与升级材料。','ITEM_QUEST':'任务物品。','ITEM_GIFTBOX':'打开后可获得物品。','ITEM_TREASURE_BOX':'需要对应的钥匙才能打开。','ITEM_TREASURE_KEY':'可以打开对应的宝箱。','ITEM_WEAPON':'','ITEM_ARMOR':''}
|
||||
KEEP_SUBTYPES={('ITEM_WEAPON',s) for s in ('WEAPON_SWORD','WEAPON_DAGGER','WEAPON_BOW','WEAPON_TWO_HANDED','WEAPON_BELL','WEAPON_FAN')}|{('ITEM_ARMOR','ARMOR_FOOTS'),('ITEM_ARMOR','ARMOR_BODY'),('ITEM_METIN','METIN_NORMAL')}|{('ITEM_COSTUME','COSTUME_SASH')}
|
||||
DESC={'ITEM_METIN':'可镶嵌到武器的空孔中。','ITEM_MATERIAL':'制作与升级材料。','ITEM_QUEST':'任务物品。','ITEM_GIFTBOX':'打开后可获得物品。','ITEM_TREASURE_BOX':'需要对应的钥匙才能打开。','ITEM_TREASURE_KEY':'可以打开对应的宝箱。','ITEM_WEAPON':'','ITEM_ARMOR':'','ITEM_COSTUME':'披风。可在披风工匠处合成升级,或吸收武器、铠甲的部分属性。'}
|
||||
# Sash system (metin2-server docs/FEATURE-AVA2-UNLOCK.md P4): effects registered by the client's mt_sash script
|
||||
# (files they reference are staged too), the window images, and item_scale.txt (model scale per job/sex; a row
|
||||
# covers vnum..vnum+4).
|
||||
SASH_EFFECTS=('d:/ymir work/effect/etc/buff/buff_item6.mse','d:/ymir work/effect/etc/buff/buff_item7.mse',
|
||||
'd:/ymir work/pc/common/effect/armor/acc_01.mse')
|
||||
SASH_LOCALE={'locale/en/ui/acce/acce_combine.tga':'locale/zh/ui/acce/acce_combine.tga',
|
||||
'locale/en/ui/acce/acce_absorb.tga':'locale/zh/ui/acce/acce_absorb.tga'}
|
||||
LOCKED='该物品所属的系统尚未开放,暂时无法使用。'
|
||||
|
||||
def enums(proto_reader):
|
||||
@@ -90,6 +97,21 @@ def shape_models():
|
||||
out+=['d:/ymir work/%s/%s/%s%s'%(d,race,stem%race,e) for e in ('.gr2','.dds','_lod_01.gr2','_lod_02.gr2','_lod_03.gr2')]
|
||||
return out
|
||||
|
||||
def effect_files(files):
|
||||
"""SASH_EFFECTS and every file (mde/textures/models) they name, recursively; names are absolute
|
||||
(d:/ymir work/...) or relative to the referring file."""
|
||||
out=[];todo=list(SASH_EFFECTS)
|
||||
while todo:
|
||||
q=todo.pop()
|
||||
if q in out:continue
|
||||
if q not in files:raise SystemExit('missing AVA2 effect file %s'%q)
|
||||
out.append(q)
|
||||
if q.endswith(('.mse','.mde')):
|
||||
for name in re.findall(rb'[\w \-:./\\]+?\.(?:dds|tga|jpg|mde|gr2|spt|msf)',files[q].read_bytes(),re.I):
|
||||
name=name.decode('latin1').strip().strip('"').lower().replace('\\','/')
|
||||
todo.append(name if name.startswith('d:/') else q.rsplit('/',1)[0]+'/'+name.split('/')[-1])
|
||||
return out
|
||||
|
||||
def pack_index(pack_maker):
|
||||
"""ArchivedPath (lowercase) -> source file, from the AVA2 pack manifests."""
|
||||
index={}
|
||||
@@ -134,7 +156,7 @@ def prepare(ava,proto_reader,locale,output,tool,packer,wrap=lambda text:text):
|
||||
if q not in files:raise SystemExit('missing AVA2 asset %s for %d'%(q,v))
|
||||
target=assets/q;target.parent.mkdir(parents=True,exist_ok=True)
|
||||
if not target.exists():shutil.copy2(files[q],target);copied+=1
|
||||
for q in shape_models():
|
||||
for q in shape_models()+effect_files(files):
|
||||
if q not in files:raise SystemExit('missing AVA2 asset %s'%q)
|
||||
target=assets/q;target.parent.mkdir(parents=True,exist_ok=True)
|
||||
if not target.exists():shutil.copy2(files[q],target);copied+=1
|
||||
@@ -142,6 +164,11 @@ def prepare(ava,proto_reader,locale,output,tool,packer,wrap=lambda text:text):
|
||||
(output/'items-client.tsv').write_bytes(b'\n'.join(client)+b'\n')
|
||||
target=assets/'locale/zh';target.mkdir(parents=True,exist_ok=True)
|
||||
subprocess.run([str(tool),str(locale/'item_proto'),str(output/'items-client.tsv'),str(target/'item_proto')],check=True)
|
||||
for source,dest in SASH_LOCALE.items():
|
||||
(assets/dest).parent.mkdir(parents=True,exist_ok=True);shutil.copy2(files[source],assets/dest);copied+=1
|
||||
scale=[l for l in (pack_maker/'locale/locale/en/item_scale.txt').read_bytes().splitlines()
|
||||
if l[:5].isdigit() and wanted & set(range(int(l[:5]),int(l[:5])+5))]
|
||||
(target/'item_scale.txt').write_bytes(b'\n'.join(scale)+b'\n')
|
||||
for filename in ('item_list.txt','itemdesc.txt'):
|
||||
result=[l for l in (locale/filename).read_bytes().splitlines() if not (l.split(b'\t',1)[0].isdigit() and int(l.split(b'\t',1)[0]) in wanted)]
|
||||
for v in sorted(wanted):
|
||||
|
||||
@@ -46,6 +46,25 @@ class ConvertTests(unittest.TestCase):
|
||||
self.assertEqual(s[5],'ANTI_ASSASSIN | ANTI_SURA | ANTI_MUDANG');self.assertEqual(s[27],'32') # value3 = armor shape
|
||||
models=m.shape_models();self.assertEqual(len(models),40)
|
||||
self.assertIn('d:/ymir work/pc2/warrior/warrior_7_1_lod_03.gr2',models)
|
||||
def test_sash_kept(self):
|
||||
s,c,kept=m.convert(row(85004,'ITEM_COSTUME','COSTUME_SASH',wear='WEAR_COSTUME_BODY',
|
||||
values=('4','0','0','0','0','0')),self.E,{85004})
|
||||
self.assertTrue(kept);self.assertEqual(s[2:4],['ITEM_COSTUME','COSTUME_SASH']);self.assertEqual(s[24],'4') # value0 = grade
|
||||
self.assertEqual(c[2],3) # COSTUME_SASH, after BODY/HAIR/MOUNT
|
||||
def test_sash_effect_closure(self):
|
||||
import tempfile
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
d=Path(d);files={}
|
||||
def put(name,data=b'x'):
|
||||
f=d/str(len(files));f.write_bytes(data);files[name]=f
|
||||
put(m.SASH_EFFECTS[0],b'MeshFileName "buff_item1.mde"\nTextureFileName "d:/ymir work/effect/a.dds"')
|
||||
for q in m.SASH_EFFECTS[1:]:put(q)
|
||||
put('d:/ymir work/effect/etc/buff/buff_item1.mde',b'"light010.dds"');put('d:/ymir work/effect/a.dds')
|
||||
put('d:/ymir work/effect/etc/buff/light010.dds')
|
||||
got=set(m.effect_files(files))
|
||||
self.assertEqual(got,set(files))
|
||||
del files['d:/ymir work/effect/etc/buff/light010.dds']
|
||||
with self.assertRaises(SystemExit):m.effect_files(files)
|
||||
|
||||
def test_names_cover_ranges(self):
|
||||
n=m.names();self.assertEqual(len(n),514);self.assertEqual(n[54100],'武器外观强化石')
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# 披风 (sash) quest
|
||||
|
||||
AVA2 `Globales/sash.lua` ported to 王铁匠 (20016; 203 has no NPC 60003):
|
||||
披风说明 / 披风合成 (`pc.open_sash(true)`) / 属性吸收 (`pc.open_sash(false)`).
|
||||
|
||||
Needs the sash game binary (server `port_sash.cpp`, CG 211 / GC 215) and a client with `mt_sash`.
|
||||
|
||||
sh install.sh # on the server, from this directory; then restart the game cores
|
||||
|
||||
Adds `pc.open_sash` to quest_functions, compiles only sash.quest in an isolated staging dir, copies its
|
||||
objects (state/sash + 20016/chat/sash.start.{0,1,2}.*) into the live tree, and adds it to locale_list.
|
||||
Backups go to /root/backup-sash/<time>.
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# Installs quest sash (README.md): run on the server from this directory, then restart the game cores.
|
||||
# Adds pc.open_sash to quest_functions (needs the sash game binary; an older core would fail the call, not the boot),
|
||||
# compiles only sash.quest in an isolated staging directory and copies its objects into the live quest tree.
|
||||
set -eu
|
||||
SERVER=${SERVER:-/usr/metin2/server}
|
||||
LOCALE=${LOCALE:-newcibn}
|
||||
QUEST="$SERVER/share/locale/$LOCALE/quest"
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
BACKUP=/root/backup-sash/$(date +%Y%m%d-%H%M%S)
|
||||
export LC_ALL=C
|
||||
|
||||
mkdir -p "$BACKUP/stage"
|
||||
cp -p "$QUEST/quest_functions" "$QUEST/locale_list" "$BACKUP/"
|
||||
[ -f "$QUEST/sash.quest" ] && cp -p "$QUEST/sash.quest" "$BACKUP/"
|
||||
echo "backup: $BACKUP"
|
||||
|
||||
# A GBK trail byte 0x5C would be a backslash to qc.
|
||||
iconv -f UTF-8 -t GBK "$HERE/sash.quest" > "$BACKUP/sash.gbk"
|
||||
if grep -q '\\' "$BACKUP/sash.gbk"; then echo "sash.quest: backslash byte in GBK" >&2; exit 1; fi
|
||||
cp "$QUEST/quest_functions" "$BACKUP/stage/"
|
||||
grep -qx 'pc.open_sash' "$BACKUP/stage/quest_functions" || echo 'pc.open_sash' >> "$BACKUP/stage/quest_functions"
|
||||
cp "$BACKUP/sash.gbk" "$BACKUP/stage/sash.quest"
|
||||
(cd "$BACKUP/stage" && "$QUEST/qc" sash.quest) > "$BACKUP/qc.log" 2>&1 || { cat "$BACKUP/qc.log" >&2; exit 1; }
|
||||
test -s "$BACKUP/stage/object/state/sash"
|
||||
[ "$(cd "$BACKUP/stage/object/20016/chat" && ls | grep -c '^sash\.')" -eq 9 ] || { echo "unexpected qc output" >&2; exit 1; }
|
||||
|
||||
cat "$BACKUP/stage/quest_functions" > "$QUEST/quest_functions"
|
||||
cat "$BACKUP/sash.gbk" > "$QUEST/sash.quest"
|
||||
grep -qx 'sash.quest' "$QUEST/locale_list" || echo 'sash.quest' >> "$QUEST/locale_list"
|
||||
(cd "$BACKUP/stage/object" && find . -type f) | while read -r f; do
|
||||
mkdir -p "$QUEST/object/$(dirname "$f")"
|
||||
cp "$BACKUP/stage/object/$f" "$QUEST/object/$f"
|
||||
done
|
||||
echo "done; restart the game cores"
|
||||
@@ -0,0 +1,50 @@
|
||||
-- 披风 (AVA2 Globales/sash.lua): 合成 / 属性吸收 窗口由 pc.open_sash(true/false) 打开。
|
||||
-- AVA2 用 NPC 60003, 203 没有这个 NPC, 挂在 王铁匠 20016。
|
||||
quest sash begin
|
||||
state start begin
|
||||
when 20016.chat."披风说明" begin
|
||||
say_title(mob_name(20016))
|
||||
say("")
|
||||
say("披风可以吸收武器或防具的属性.")
|
||||
say("")
|
||||
say("[披风合成]")
|
||||
say("放入两件同等级的披风合成, 成功后")
|
||||
say("得到吸收率更高的披风, 失败则材料消失.")
|
||||
say("")
|
||||
say("[属性吸收]")
|
||||
say("放入披风和一件武器或防具, 披风按吸收率")
|
||||
say("获得其属性, 被吸收的装备会消失.")
|
||||
say("")
|
||||
end
|
||||
|
||||
when 20016.chat."披风合成" begin
|
||||
say_title(mob_name(20016))
|
||||
say("")
|
||||
say("要打开披风合成窗口吗?")
|
||||
say("")
|
||||
local confirm = select("确定", "取消")
|
||||
if confirm == 2 then
|
||||
return
|
||||
end
|
||||
|
||||
setskin(NOWINDOW)
|
||||
pc.open_sash(true)
|
||||
end
|
||||
|
||||
when 20016.chat."属性吸收" begin
|
||||
say_title(mob_name(20016))
|
||||
say("")
|
||||
say("被吸收的装备会消失, 披风原有的吸收")
|
||||
say("属性会被替换.")
|
||||
say("要打开属性吸收窗口吗?")
|
||||
say("")
|
||||
local confirm = select("确定", "取消")
|
||||
if confirm == 2 then
|
||||
return
|
||||
end
|
||||
|
||||
setskin(NOWINDOW)
|
||||
pc.open_sash(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user