Port AVA2 drop tables and drop code

make_drops.py builds 203's mob_drop_item / common_drop_new / special_item_group
from AVA2's (unknown items removed and renumbered, AVA2 boxes replace the same
vnum except 50035). The game loads common_drop_new.txt (level-range common
drops), GetDropPct follows AVA2 (premium/glove rates, fixed precedence bug),
a mob's second drop group no longer uses an uninitialised pointer, special
groups allow 1023 entries, and the wiki lists common_drop_new rows as rule 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-16 10:31:07 +09:00
co-authored by Claude Opus 5.5
parent cd395c73b7
commit 38b62cfdbd
10 changed files with 386 additions and 19 deletions
+10 -1
View File
@@ -12,6 +12,7 @@ points=sorted(set(re.findall(r'\bPOINT_[A-Z_]+', (SRC/'port_features.h').read_te
code=r'''
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdarg>
#include <cstdio>
#include <map>
@@ -28,7 +29,7 @@ GROUPS
#include "item_manager_private_types.h"
std::vector<CItemDropInfo> g_vec_pkCommonDropItem[MOB_RANK_MAX_NUM];
struct TItemTable{unsigned dwVnum;unsigned bType=0;};
struct MobTable{unsigned bType=0,bRank=0,dwPolymorphItemVnum=0,dwDropItemVnum=0;};
struct MobTable{unsigned bType=0,bRank=0,dwPolymorphItemVnum=0,dwDropItemVnum=0;unsigned char bLevel=0;};
struct CMob{MobTable m_table;};
class CMobManager {
public:std::map<DWORD,CMob*> mobs;
@@ -44,6 +45,7 @@ class ITEM_MANAGER {
std::map<DWORD,CLevelItemGroup*> m_map_pkLevelItemGroup;
std::map<DWORD,CBuyerThiefGlovesItemGroup*> m_map_pkGloveItemGroup;
std::map<DWORD,DWORD> m_map_dwEtcItemDropProb;
std::vector<CCommonDropNew*> m_vec_pkCommonNewItemGroup;
std::map<DWORD,CSpecialItemGroup*> special;
static ITEM_MANAGER& instance(){static ITEM_MANAGER m;return m;}
TItemTable* GetTable(unsigned id){for(auto& t:tables)if(t.dwVnum==id)return &t;return nullptr;}
@@ -100,6 +102,13 @@ int main(){
assert(items.PortWikiDrops(9001).empty() && items.PortWikiDrops(99999).empty());
drop.AddItem(30220,25,1);assert(items.PortWikiDrops(101).size()==8);
drop.AddItem(70104,1,1);assert(items.PortWikiDrops(101).size()==9); // Non-common groups retain configured polymorph candidates. // Sees active changes, not exported text.
// common_drop_new: player range clipped to the mob level +-20; groups out of reach are left out
mob.m_table.bLevel=10;CCommonDropNew low,high;low.minLevel=1;low.maxLevel=40;low.AddItem(30006,3,1200);high.minLevel=31;high.maxLevel=60;high.AddItem(19,1,1200);
items.m_vec_pkCommonNewItemGroup={&low,&high};rows=items.PortWikiDrops(101);assert(rows.size()==10);
assert(rows[1].item==30006 && rows[1].count==3 && rows[1].rule==WIKI_COMMON && rows[1].minimum==1 && rows[1].maximum==30 && rows[1].weight==1200);
high.minLevel=30;assert(items.PortWikiDrops(101).size()==11 && items.PortWikiDrops(101)[2].minimum==30);
assert(low.CanDropThisMap(41));low.m_vecMapIndex={1};assert(low.CanDropThisMap(1) && !low.CanDropThisMap(41));
items.m_vec_pkCommonNewItemGroup.clear();mob.m_table.bLevel=0;
CSpecialItemGroup chest(50011);chest.AddItem(19,1,80,0);chest.AddItem(1,500,20,0);items.special[50011]=&chest;
CSpecialItemGroup multi(50012,CSpecialItemGroup::PCT);multi.AddItem(19,2,20,0);multi.AddItem(3,101,150,0);items.special[50012]=&multi;
CSpecialItemGroup attr(50013,CSpecialItemGroup::SPECIAL);attr.AddItem(19,1,100,0);items.special[50013]=&attr;