#!/usr/bin/env python3 """Build the 203 drop tables from AVA2's (docs/FEATURE-AVA2-DROPS.md). mob_drop_item.txt AVA2's, entries whose item 203 lacks are dropped and the rest renumbered (the reader stops at the first missing index and fails on an unknown item) common_drop_new.txt AVA2's NEW_COMMON_DROP groups, filtered the same way special_item_group.txt 203's groups with AVA2's groups replacing those of the same vnum; AVA2-only groups added common_drop_item.txt empty, like AVA2 (common drops come from common_drop_new.txt) etc_drop_item.txt empty, like AVA2 Usage: make_drops.py <203 locale dir> ... The item_proto files are every row the servers will load (the live one plus ava2-items' items-server.tsv). """ import json,re,sys from pathlib import Path # AVA2 reused these vnums for a different box: 50035 is 203's children's day gift box but AVA2's GM-only # 'Pct' box handing out thousands of items, so 203's group stays. KEEP_203={50035} def vnums(paths): result=set() for p in paths: for line in Path(p).read_bytes().splitlines(): head=line.split(b'\t',1)[0].strip() if head.isdigit():result.add(int(head)) elif re.fullmatch(rb'\d+~\d+',head): # dragon soul rows cover a vnum range lo,hi=map(int,head.split(b'~'));result.update(range(lo,hi+1)) return result def groups(data): """[(name bytes, [body line bytes])] of a CTextFileLoader file ('Group ' then a braced body).""" lines=data.replace(b'\r\n',b'\n').split(b'\n');result=[];i=0 while i