Skip to content

Commit

Permalink
Distribute the gold obtained, in a group or alone
Browse files Browse the repository at this point in the history
  • Loading branch information
pangolp committed Mar 11, 2024
1 parent 4ff522b commit 3187c29
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/AoeLoot_SC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,45 @@ class AoeLoot_Player : public PlayerScript
_creature->ForceValuesUpdateAtIndex(UNIT_DYNAMIC_FLAGS);
}
}

if (player->GetGroup())
{
Group* group = player->GetGroup();

std::vector<Player*> playersNear;
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
continue;

if (player->IsAtLootRewardDistance(member))
playersNear.push_back(member);
}

uint32 goldPerPlayer = uint32((gold) / (playersNear.size()));

for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
{
(*i)->ModifyMoney(goldPerPlayer);
(*i)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, goldPerPlayer);

WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4 + 1);
data << uint32(goldPerPlayer);
data << uint8(playersNear.size() > 1 ? 0 : 1);
(*i)->GetSession()->SendPacket(&data);
}
}
else
{
player->ModifyMoney(gold);
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, gold);

WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4 + 1);
data << uint32(gold);
data << uint8(1);
player->GetSession()->SendPacket(&data);
}
}

void OnAfterCreatureLoot(Player* player) override
Expand Down

0 comments on commit 3187c29

Please sign in to comment.