mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
rarity index fix for egg crates
This commit is contained in:
parent
8a871f7045
commit
6f636b77f2
@ -138,7 +138,11 @@ static int getRarity(int crateId, int itemSetId) {
|
||||
relevantWeights.push_back(rarityWeights[index]);
|
||||
|
||||
// now return a random rarity number (starting from 1)
|
||||
return Rand::randWeighted(relevantWeights) + 1;
|
||||
int rarityChoice = Rand::randWeighted(relevantWeights);
|
||||
|
||||
auto it = rarityIndices.begin();
|
||||
std::advance(it, rarityChoice);
|
||||
return *it + 1;
|
||||
}
|
||||
|
||||
static int getCrateItem(sItemBase* result, int itemSetId, int rarity, int playerGender) {
|
||||
@ -562,18 +566,26 @@ static void chestOpenHandler(CNSocket *sock, CNPacketData *data) {
|
||||
int validCrateId = getValidCrateId(chest->iID);
|
||||
bool failing = (validCrateId == -1);
|
||||
|
||||
std::cout << "validCrateId " << validCrateId << std::endl;
|
||||
|
||||
if (!failing)
|
||||
validItemSetId = getValidItemSetId(validCrateId);
|
||||
failing = (validItemSetId == -1);
|
||||
|
||||
std::cout << "validItemSetId " << validItemSetId << std::endl;
|
||||
|
||||
if (!failing)
|
||||
rarity = getRarity(validCrateId, validItemSetId);
|
||||
failing = (rarity == -1);
|
||||
|
||||
std::cout << "rarity " << rarity << std::endl;
|
||||
|
||||
if (!failing)
|
||||
ret = getCrateItem(&item->sItem, validItemSetId, rarity, plr->PCStyle.iGender);
|
||||
failing = (ret == -1);
|
||||
|
||||
std::cout << "ret " << ret << std::endl;
|
||||
|
||||
// if we failed to open a crate, at least give the player a gumball (suggested by Jade)
|
||||
if (failing) {
|
||||
item->sItem.iType = 7;
|
||||
|
Loading…
Reference in New Issue
Block a user