Update aoe_loot.cpp

This commit is contained in:
TerraByte
2025-04-13 22:48:05 -05:00
committed by GitHub
parent 826fe8bfba
commit e41ca1fd5f

View File

@@ -28,7 +28,7 @@ bool AOELootServer::CanPacketReceive(WorldSession* session, WorldPacket& packet)
if (player)
{
/*
// Check if SHIFT key is pressed - if so, bypass AOE loot -> Work In Progress
// Check if SHIFT key is pressed - if so, bypass AOE loot
if (player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_MODIFIER_ACTIVE))
{
if (sConfigMgr->GetOption<bool>("AOELoot.Debug", true))
@@ -83,9 +83,12 @@ bool AoeLootCommandScript::HandleStartAoeLootCommand(ChatHandler* handler, Optio
for (auto* creature : nearbyCorpses)
{
if (!player || !creature || !player->IsInWorld())
{
continue;
}
if (!creature->hasLootRecipient() || !creature->isTappedBy(player)) {
if (!creature->hasLootRecipient() || !creature->isTappedBy(player))
{
// Not a valid loot target for this player
continue;
}
@@ -102,7 +105,7 @@ bool AoeLootCommandScript::HandleStartAoeLootCommand(ChatHandler* handler, Optio
}
// Additional permission check
if (!player->GetMap()->Instanceable())
if (player->GetMap()->Instanceable())
{
if(!player->isAllowedToLoot(creature))
{
@@ -132,16 +135,13 @@ bool AoeLootCommandScript::HandleStartAoeLootCommand(ChatHandler* handler, Optio
Loot* loot = &creature->loot;
if (!loot)
{
continue;
}
// Process regular items
for (uint8 lootSlot = 0; lootSlot < loot->items.size(); ++lootSlot)
{
if (loot->items[lootSlot].is_looted || loot->items[lootSlot].is_blocked)
continue;
if (!loot->items[lootSlot].AllowedForPlayer(player, creature->GetGUID()))
continue;
// Store the loot item in the player's inventory
InventoryResult msg;
@@ -166,9 +166,6 @@ bool AoeLootCommandScript::HandleStartAoeLootCommand(ChatHandler* handler, Optio
// Try to loot each potential quest slot
for (uint8 i = 0; i < loot->quest_items.size(); ++i)
{
if (loot->quest_items[i].is_looted || loot->quest_items[i].is_blocked)
continue;
uint8 lootSlot = firstQuestSlot + i;
// Store the loot item in the player's inventory
@@ -202,24 +199,25 @@ bool AoeLootCommandScript::HandleStartAoeLootCommand(ChatHandler* handler, Optio
}
}
// Check if the corpse is now fully looted
if (loot->isLooted() && loot->quest_items.empty())
if (loot->isLooted())
{
// Cleanup the loot object from the corpse
creature->AllLootRemovedFromCorpse();
creature->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
}
}
if (sConfigMgr->GetOption<bool>("AOELoot.Debug", true))
{
LOG_DEBUG("module.aoe_loot", "AOE Loot: Summary - Looted {} items, {} gold from {} corpses", totalItemsLooted, totalCopperLooted, totalCorpsesLooted);
handler->PSendSysMessage(fmt::format("AOE Loot: Looted {} items and {} gold from {} corpses", totalItemsLooted, totalCopperLooted, totalCorpsesLooted));
}
}
return true;
}
// Copied from sudlud's "mod-aoe-loot" module.
void AOELootPlayer::OnPlayerLogin(Player* player)
{