mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
register altered rarities correcty in rarity roll
This commit is contained in:
parent
527ca817d5
commit
78b87d0f61
@ -108,6 +108,7 @@ static int getRarity(int crateId, int itemSetId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int>& rarityWeights = Items::RarityWeights[crate.rarityWeightId];
|
std::vector<int>& rarityWeights = Items::RarityWeights[crate.rarityWeightId];
|
||||||
|
ItemSet& itemSet = Items::ItemSets[itemSetId];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First we have to check if specified item set contains items with all specified rarities,
|
* First we have to check if specified item set contains items with all specified rarities,
|
||||||
@ -117,11 +118,17 @@ static int getRarity(int crateId, int itemSetId) {
|
|||||||
|
|
||||||
// remember that rarities start from 1!
|
// remember that rarities start from 1!
|
||||||
std::set<int> rarityIndices;
|
std::set<int> rarityIndices;
|
||||||
for (int itemReferenceId : Items::ItemSets[itemSetId].itemReferenceIds) {
|
|
||||||
|
for (int itemReferenceId : itemSet.itemReferenceIds) {
|
||||||
if (Items::ItemReferences.find(itemReferenceId) == Items::ItemReferences.end())
|
if (Items::ItemReferences.find(itemReferenceId) == Items::ItemReferences.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rarityIndices.insert(Items::ItemReferences[itemReferenceId].rarity - 1);
|
// alter rarity
|
||||||
|
int itemRarity = (itemSet.alterRarityMap.find(itemReferenceId) == itemSet.alterRarityMap.end())
|
||||||
|
? Items::ItemReferences[itemReferenceId].rarity
|
||||||
|
: itemSet.alterRarityMap[itemReferenceId];
|
||||||
|
|
||||||
|
rarityIndices.insert(itemRarity - 1);
|
||||||
|
|
||||||
// shortcut
|
// shortcut
|
||||||
if (rarityIndices.size() == rarityWeights.size())
|
if (rarityIndices.size() == rarityWeights.size())
|
||||||
@ -133,14 +140,17 @@ static int getRarity(int crateId, int itemSetId) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// retain the weights of rarities that actually exist in the itemset
|
||||||
std::vector<int> relevantWeights(rarityWeights.size(), 0);
|
std::vector<int> relevantWeights(rarityWeights.size(), 0);
|
||||||
for (int index : rarityIndices) {
|
for (int index : rarityIndices) {
|
||||||
// sanity check
|
// check for out of bounds and rarity 0 items
|
||||||
if (index >= 0 && index < rarityWeights.size())
|
if (index >= 0 && index < rarityWeights.size())
|
||||||
relevantWeights[index] = rarityWeights[index];
|
relevantWeights[index] = rarityWeights[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// now return a random rarity number (starting from 1)
|
// now return a random rarity number (starting from 1)
|
||||||
|
// if relevantWeights is empty or all zeros, we default to giving a common (1) item
|
||||||
|
// rarity 0 items will appear in the drop pool regardless of this roll
|
||||||
return Rand::randWeighted(relevantWeights) + 1;
|
return Rand::randWeighted(relevantWeights) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,11 +170,9 @@ static int getCrateItem(sItemBase* result, int itemSetId, int rarity, int player
|
|||||||
ItemReference* item = &Items::ItemReferences[itemReferenceId];
|
ItemReference* item = &Items::ItemReferences[itemReferenceId];
|
||||||
|
|
||||||
// alter rarity
|
// alter rarity
|
||||||
int itemRarity;
|
int itemRarity = (itemSet.alterRarityMap.find(itemReferenceId) == itemSet.alterRarityMap.end())
|
||||||
if (itemSet.alterRarityMap.find(itemReferenceId) == itemSet.alterRarityMap.end())
|
? item->rarity
|
||||||
itemRarity = item->rarity;
|
: itemSet.alterRarityMap[itemReferenceId];
|
||||||
else
|
|
||||||
itemRarity = itemSet.alterRarityMap[itemReferenceId];
|
|
||||||
|
|
||||||
// if rarity doesn't match the selected one, exclude item
|
// if rarity doesn't match the selected one, exclude item
|
||||||
// rarity 0 bypasses this step for an individual item
|
// rarity 0 bypasses this step for an individual item
|
||||||
@ -172,11 +180,9 @@ static int getCrateItem(sItemBase* result, int itemSetId, int rarity, int player
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// alter rarity
|
// alter rarity
|
||||||
int itemGender;
|
int itemGender = (itemSet.alterGenderMap.find(itemReferenceId) == itemSet.alterGenderMap.end())
|
||||||
if (itemSet.alterGenderMap.find(itemReferenceId) == itemSet.alterGenderMap.end())
|
? item->gender
|
||||||
itemGender = item->gender;
|
: itemSet.alterGenderMap[itemReferenceId];
|
||||||
else
|
|
||||||
itemGender = itemSet.alterGenderMap[itemReferenceId];
|
|
||||||
|
|
||||||
// if gender is incorrect, exclude item
|
// if gender is incorrect, exclude item
|
||||||
// gender 0 bypasses this step for an individual item
|
// gender 0 bypasses this step for an individual item
|
||||||
|
Loading…
Reference in New Issue
Block a user