Files
metin2-client/tools/server/ava2-dungeons/install.sh
T
shenleiandClaude Opus 5.5 a1e7da68a4 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>
2026-10-17 08:13:32 +09:00

104 lines
4.6 KiB
Bash

#!/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)"