diff --git a/src/aoe_loot.cpp b/src/aoe_loot.cpp index ecd7bef..b4136ff 100644 --- a/src/aoe_loot.cpp +++ b/src/aoe_loot.cpp @@ -17,19 +17,21 @@ #include "aoe_loot.h" -void OnCreatureLootAOE(Player* player) +void OnCreatureLootAOE(Player* player, ObjectGuid lootguid) { bool _enable = sConfigMgr->GetOption("AOELoot.Enable", true); if (!_enable) return; + if (!lootguid.IsCreature()) + return; + float range = sConfigMgr->GetOption("AOELoot.Range", 30.0); std::list 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()); } /* diff --git a/src/aoe_loot.h b/src/aoe_loot.h index a89e141..8ec77e1 100644 --- a/src/aoe_loot.h +++ b/src/aoe_loot.h @@ -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 @@ 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; };