Skip to content

Commit

Permalink
fix. Failed to skin looted creature (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
pangolp authored Mar 21, 2024
1 parent bb2d718 commit 7633396
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
33 changes: 12 additions & 21 deletions src/aoe_loot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
Expand All @@ -53,32 +55,21 @@ 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();

_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())
Expand Down Expand Up @@ -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());
}

/*
Expand Down
4 changes: 2 additions & 2 deletions src/aoe_loot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -39,7 +39,7 @@ class AoeLootPlayer : public PlayerScript

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;
};
Expand Down

0 comments on commit 7633396

Please sign in to comment.