Fixed
Fixed it so a player will not lose money when it gets deposited to the guild bank. Added code to make sure all members of a group within loot distance will deposit money into their guild bank and not just the person who is actually looting.
This commit is contained in:
parent
46d006097e
commit
7ce511d639
1 changed files with 45 additions and 5 deletions
|
|
@ -27,6 +27,43 @@ public:
|
||||||
GuildFundsLoot() : LootScript("GuildFundsLoot") {}
|
GuildFundsLoot() : LootScript("GuildFundsLoot") {}
|
||||||
|
|
||||||
void OnLootMoney(Player* player, uint32 gold) override
|
void OnLootMoney(Player* player, uint32 gold) override
|
||||||
|
{
|
||||||
|
if (Group* group = player->GetGroup())
|
||||||
|
{
|
||||||
|
uint32 membersInRange = 0;
|
||||||
|
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
|
||||||
|
{
|
||||||
|
if (Player* member = groupRef->GetSource())
|
||||||
|
{
|
||||||
|
if (member->IsAtLootRewardDistance(player))
|
||||||
|
membersInRange++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 money = (((gold / membersInRange) / 100) * gfLootMultiplier);
|
||||||
|
|
||||||
|
if (money < 1 || gfLootMultiplier < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
|
||||||
|
{
|
||||||
|
if (Player* member = groupRef->GetSource())
|
||||||
|
{
|
||||||
|
if (member->IsAtLootRewardDistance(player))
|
||||||
|
{
|
||||||
|
if (Guild* guild = member->GetGuild())
|
||||||
|
{
|
||||||
|
guild->HandleMemberDepositMoney(member->GetSession(), money);
|
||||||
|
member->ModifyMoney(money);
|
||||||
|
|
||||||
|
if (gfShowInfo)
|
||||||
|
PrintGuildFundsInformation(member, money);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (Guild* guild = player->GetGuild())
|
if (Guild* guild = player->GetGuild())
|
||||||
{
|
{
|
||||||
|
|
@ -36,11 +73,13 @@ public:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
guild->HandleMemberDepositMoney(player->GetSession(), money);
|
guild->HandleMemberDepositMoney(player->GetSession(), money);
|
||||||
|
player->ModifyMoney(money);
|
||||||
|
|
||||||
if (gfShowInfo)
|
if (gfShowInfo)
|
||||||
PrintGuildFundsInformation(player, money);
|
PrintGuildFundsInformation(player, money);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PrintGuildFundsInformation(Player* player, uint32 money)
|
void PrintGuildFundsInformation(Player* player, uint32 money)
|
||||||
|
|
@ -77,6 +116,7 @@ public:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
guild->HandleMemberDepositMoney(player->GetSession(), money);
|
guild->HandleMemberDepositMoney(player->GetSession(), money);
|
||||||
|
player->ModifyMoney(money);
|
||||||
|
|
||||||
if (gfShowInfo)
|
if (gfShowInfo)
|
||||||
PrintGuildFundsInformation(player, money);
|
PrintGuildFundsInformation(player, money);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue