Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Aokromes/e8a6e838b52c586cbd5f6be404f1db04 to your computer and use it in GitHub Desktop.
Save Aokromes/e8a6e838b52c586cbd5f6be404f1db04 to your computer and use it in GitHub Desktop.
if (roll->totalNeed == 0 && roll->totalGreed > 0) // if (roll->totalNeed == 0 && ...), not else if, because numbers can be modified above if player is on a different map
{
if (!roll->playerVote.empty())
{
uint8 maxresul = 0;
ObjectGuid maxguid = ObjectGuid::Empty;
Player* player = nullptr;
RollVote rollvote = NOT_VALID;
Roll::PlayerVote::iterator itr;
for (itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
{
if (itr->second != GREED && itr->second != DISENCHANT)
continue;
player = ObjectAccessor::FindPlayer(itr->first);
if (!player || (allowedMap != nullptr && player->FindMap() != allowedMap))
{
--roll->totalGreed;
continue;
}
uint8 min = 1;
uint8 max = 100;
if (itr->second == GREED)
{
min = 34;
}
else
{
max = 33;
}
uint8 randomN = urand(min, max);
SendLootRoll(ObjectGuid::Empty, itr->first, randomN, itr->second, *roll);
if (maxresul < randomN)
{
maxguid = itr->first;
maxresul = randomN;
rollvote = itr->second;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment