fix. Failed to skin looted creature (#37)

This commit is contained in:
Walter Pagani
2024-03-21 04:28:09 -03:00
committed by GitHub
parent bb2d7180ef
commit 7633396693
2 changed files with 14 additions and 23 deletions

View File

@@ -17,19 +17,21 @@
#include "aoe_loot.h"
void OnCreatureLootAOE(Player* player)
void OnCreatureLootAOE(Player* player, ObjectGuid lootguid)
{
bool _enable = sConfigMgr->GetOption<bool>("AOELoot.Enable", true);
if (!_enable)
return;
if (!lootguid.IsCreature())
return;
float range = sConfigMgr->GetOption<float>("AOELoot.Range", 30.0);
std::list<Creature*> deadCreatures;
uint32 gold = 0;
player->GetDeadCreatureListInGrid(deadCreatures, range);
ObjectGuid lootGuid = player->GetLootGUID();
for (auto& _creature : deadCreatures)
{
@@ -43,7 +45,7 @@ void OnCreatureLootAOE(Player* player)
InventoryResult msg;
LootItem* lootItem = player->StoreLootItem(lootSlot, loot, msg);
if (msg != EQUIP_ERR_OK && lootGuid.IsItem() && loot->loot_type != LOOT_CORPSE)
if (msg != EQUIP_ERR_OK && lootguid.IsItem() && loot->loot_type != LOOT_CORPSE)
{
lootItem->is_looted = true;
loot->NotifyItemRemoved(lootItem->itemIndex);
@@ -53,12 +55,14 @@ void OnCreatureLootAOE(Player* player)
}
else
{
player->SendLootRelease(lootGuid);
player->SendLootRelease(player->GetLootGUID());
}
}
if (loot->isLooted())
{
player->GetSession()->DoLootRelease(lootguid);
// skip pickpocketing loot for speed, skinning timer reduction is no-op in fact
if (!_creature->IsAlive())
_creature->AllLootRemovedFromCorpse();
@@ -66,19 +70,6 @@ void OnCreatureLootAOE(Player* player)
_creature->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
loot->clear();
}
else
{
// if the round robin player release, reset it.
if (player->GetGUID() == loot->roundRobinPlayer)
{
loot->roundRobinPlayer.Clear();
if (Group* group = player->GetGroup())
group->SendLooter(_creature, nullptr);
}
// force dynflag update to update looter and lootable info
_creature->ForceValuesUpdateAtIndex(UNIT_DYNAMIC_FLAGS);
}
}
if (player->GetGroup())
@@ -134,14 +125,14 @@ bool AoeLootPlayer::CanSendErrorAlreadyLooted(Player* /*player*/)
return true;
}
void AoeLootPlayer::OnAfterCreatureLoot(Player* player)
void AoeLootPlayer::OnLootItem(Player* player, Item* /*item*/, uint32 /*count*/, ObjectGuid lootguid)
{
OnCreatureLootAOE(player);
OnCreatureLootAOE(player, lootguid);
}
void AoeLootPlayer::OnBeforeLootMoney(Player* player, Loot*)
void AoeLootPlayer::OnBeforeLootMoney(Player* player, Loot* /*loot*/)
{
OnCreatureLootAOE(player);
OnCreatureLootAOE(player, player->GetLootGUID());
}
/*

View File

@@ -30,7 +30,7 @@ enum AoeLootString
AOE_ITEM_IN_THE_MAIL
};
void OnCreatureLootAOE(Player* player);
void OnCreatureLootAOE(Player* player, ObjectGuid lootguid);
class AoeLootPlayer : public PlayerScript
{
@@ -39,7 +39,7 @@ public:
void OnLogin(Player* player) override;
bool CanSendErrorAlreadyLooted(Player* /*player*/) override;
void OnAfterCreatureLoot(Player* player) override;
void OnLootItem(Player* player, Item* /*item*/, uint32 /*count*/, ObjectGuid lootguid) override;
void OnBeforeLootMoney(Player* player, Loot* /*loot*/) override;
void OnPlayerCompleteQuest(Player* player, Quest const* quest) override;
};