mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 15:00:06 +00:00
revised getRarity set logic
This commit is contained in:
parent
80b11b4364
commit
527ca817d5
@ -133,16 +133,15 @@ static int getRarity(int crateId, int itemSetId) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> relevantWeights;
|
std::vector<int> relevantWeights(rarityWeights.size(), 0);
|
||||||
for (int index : rarityIndices)
|
for (int index : rarityIndices) {
|
||||||
relevantWeights.push_back(rarityWeights[index]);
|
// sanity check
|
||||||
|
if (index >= 0 && index < rarityWeights.size())
|
||||||
|
relevantWeights[index] = rarityWeights[index];
|
||||||
|
}
|
||||||
|
|
||||||
// now return a random rarity number (starting from 1)
|
// now return a random rarity number (starting from 1)
|
||||||
int rarityChoice = Rand::randWeighted(relevantWeights);
|
return Rand::randWeighted(relevantWeights) + 1;
|
||||||
|
|
||||||
auto it = rarityIndices.begin();
|
|
||||||
std::advance(it, rarityChoice);
|
|
||||||
return *it + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getCrateItem(sItemBase* result, int itemSetId, int rarity, int playerGender) {
|
static int getCrateItem(sItemBase* result, int itemSetId, int rarity, int playerGender) {
|
||||||
|
Loading…
Reference in New Issue
Block a user