mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-23 03:40:05 +00:00
added mob drop id lookup from mob id
This commit is contained in:
parent
78b87d0f61
commit
20b05a72a0
@ -26,6 +26,7 @@ std::map<int32_t, std::vector<int32_t>> Items::CrateDropTypes;
|
||||
std::map<int32_t, MiscDropChance> Items::MiscDropChances;
|
||||
std::map<int32_t, MiscDropType> Items::MiscDropTypes;
|
||||
std::map<int32_t, MobDrop> Items::MobDrops;
|
||||
std::map<int32_t, int32_t> Items::MobToDropMap;
|
||||
std::map<int32_t, ItemSet> Items::ItemSets;
|
||||
|
||||
#ifdef ACADEMY
|
||||
@ -770,12 +771,20 @@ void Items::giveMobDrop(CNSocket *sock, Mob* mob, int rolledBoosts, int rolledPo
|
||||
memset(respbuf, 0, resplen);
|
||||
|
||||
// sanity check
|
||||
if (MobDrops.find(mob->dropType) == MobDrops.end()) {
|
||||
std::cout << "[WARN] Drop Type " << mob->dropType << " was not found" << std::endl;
|
||||
if (Items::MobToDropMap.find(mob->appearanceData.iNPCType) == Items::MobToDropMap.end()) {
|
||||
std::cout << "[WARN] Mob ID " << mob->appearanceData.iNPCType << " has no drops assigned" << std::endl;
|
||||
return;
|
||||
}
|
||||
// find mob drop id
|
||||
int dropType = Items::MobToDropMap[mob->appearanceData.iNPCType];
|
||||
|
||||
// sanity check
|
||||
if (Items::MobDrops.find(dropType) == Items::MobDrops.end()) {
|
||||
std::cout << "[WARN] Drop Type " << dropType << " was not found" << std::endl;
|
||||
return;
|
||||
}
|
||||
// find correct mob drop
|
||||
MobDrop& drop = MobDrops[mob->dropType];
|
||||
MobDrop& drop = Items::MobDrops[dropType];
|
||||
|
||||
// use the keys to fetch data from other maps
|
||||
// sanity check
|
||||
|
@ -94,6 +94,7 @@ namespace Items {
|
||||
extern std::map<int32_t, MiscDropChance> MiscDropChances;
|
||||
extern std::map<int32_t, MiscDropType> MiscDropTypes;
|
||||
extern std::map<int32_t, MobDrop> MobDrops;
|
||||
extern std::map<int32_t, int32_t> MobToDropMap;
|
||||
extern std::map<int32_t, ItemSet> ItemSets;
|
||||
|
||||
void init();
|
||||
|
@ -274,6 +274,14 @@ static void loadDrops() {
|
||||
};
|
||||
}
|
||||
|
||||
// Mobs
|
||||
nlohmann::json mobs = dropData["Mobs"];
|
||||
for (nlohmann::json::iterator _mob = mobs.begin(); _mob != mobs.end(); _mob++) {
|
||||
auto mob = _mob.value();
|
||||
|
||||
Items::MobToDropMap[(int)mob["MobID"]] = (int)mob["MobDropID"];
|
||||
}
|
||||
|
||||
// RarityWeights
|
||||
nlohmann::json rarityWeights = dropData["RarityWeights"];
|
||||
for (nlohmann::json::iterator _rarityWeightsObject = rarityWeights.begin(); _rarityWeightsObject != rarityWeights.end(); _rarityWeightsObject++) {
|
||||
|
Loading…
Reference in New Issue
Block a user