Files
metin2-client/tools/server/ava2-maps/make_drops_maps.py
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

86 lines
4.1 KiB
Python

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