quest item config

This commit is contained in:
crow
2025-08-06 23:56:11 -05:00
parent 698222fe46
commit ab678cc91a
3 changed files with 112 additions and 7 deletions

View File

@@ -48,11 +48,20 @@ AOELoot.DefaultLootThreshold = 2
# AOELoot.Debug
# Description: Enables debugging mode.
# Values: 0 = Disabled
# 1 = Enabled
# Default: 0 (Disabled)
# 1 - (Enabled)
AOELoot.Debug = 0
# AOELoot.QuestItemsAsRegular
# Description: Treat quest items as regular loot instead of processing them separately
# Values: 0 = Process quest items separately (default behavior)
# 1 = Treat quest items as regular loot
# Default: 0 (Process separately)
AOELoot.QuestItemsAsRegular = 0
# Chat Commands
# .aoeloot off If module is enabled, disables AoE looting for player
# .aoeloot on If module is enabled, reenables AoE looting for player

View File

@@ -715,14 +715,23 @@ bool AoeLootCommandScript::TriggerAoeLootCommand(ChatHandler* handler, Optional<
}
}
// Process quest items separately if they exist
// Handle quest items based on configuration
if (ShouldProcessQuestItemsSeparately())
{
// Process quest items separately (default behavior)
ProcessQuestItemsForPlayer(player, lguid, loot);
}
else
{
// Treat quest items as regular loot (like quest loot party mod)
for (uint8 i = 0; i < loot->quest_items.size(); ++i)
{
uint8 questLootSlot = loot->items.size() + i;
ProcessSingleLootSlot(player, lguid, questLootSlot);
if (debugMode)
{
LOG_DEBUG("module.aoe_loot", "AOE Loot: looted quest item in slot {}", questLootSlot);
LOG_DEBUG("module.aoe_loot", "AOE Loot: looted quest item (as regular) in slot {}", questLootSlot);
}
}
}
@@ -975,6 +984,86 @@ LootMethod AoeLootGroupScript::GetLootMethodFromConfig(uint32 configValue)
}
}
// Quest item processing functions
bool AoeLootCommandScript::ShouldProcessQuestItemsSeparately()
{
return !sConfigMgr->GetOption<bool>("AOELoot.QuestItemsAsRegular", false);
}
bool AoeLootCommandScript::IsQuestItemForPlayer(Player* player, uint32 itemId)
{
if (!player)
return false;
const ItemTemplate* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
if (!itemTemplate)
return false;
// Check if this item starts a quest or is a quest item
if (itemTemplate->StartQuest != 0)
return true;
// Check if player has quests requiring this item
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{
uint32 questId = player->GetQuestSlotQuestId(slot);
if (questId == 0)
continue;
Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
if (!quest)
continue;
// Check quest objectives for this item
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
{
if (quest->RequiredItemId[i] == itemId)
{
// Check if player still needs this item for the quest
uint32 currentCount = player->GetItemCount(itemId, true);
uint32 requiredCount = quest->RequiredItemCount[i];
if (currentCount < requiredCount)
{
return true;
}
}
}
}
return false;
}
bool AoeLootCommandScript::ProcessQuestItemsForPlayer(Player* player, ObjectGuid lguid, Loot* loot)
{
if (!player || !loot)
return false;
bool processedAny = false;
bool debugMode = sConfigMgr->GetOption<bool>("AOELoot.Debug", false);
for (uint8 i = 0; i < loot->quest_items.size(); ++i)
{
LootItem& questItem = loot->quest_items[i];
// Check if this quest item is for the current player
if (IsQuestItemForPlayer(player, questItem.itemid))
{
uint8 questLootSlot = loot->items.size() + i;
ProcessSingleLootSlot(player, lguid, questLootSlot);
processedAny = true;
if (debugMode)
{
LOG_DEBUG("module.aoe_loot", "AOE Loot: looted quest item {} from slot {} for player {}",
questItem.itemid, questLootSlot, player->GetName());
}
}
}
return processedAny;
}
// Add script registrations
void AddSC_AoeLoot()
{

View File

@@ -11,6 +11,8 @@
#include "ChatCommand.h"
#include "ChatCommandArgs.h"
#include "AccountMgr.h"
#include "ObjectMgr.h"
#include "QuestDef.h"
#include <vector>
#include <list>
#include <map>
@@ -49,6 +51,11 @@ public:
static bool ProcessCreatureGold(Player* player, Creature* creature);
static void ReleaseAndCleanupLoot(ObjectGuid lguid, Player* player, Loot* loot);
// Quest item processing functions
static bool IsQuestItemForPlayer(Player* player, uint32 itemId);
static bool ShouldProcessQuestItemsSeparately();
static bool ProcessQuestItemsForPlayer(Player* player, ObjectGuid lguid, Loot* loot);
// Renamed validation functions
static bool ValidateLootingDistance(Player* player, ObjectGuid lguid, float maxDistance = 0.0f);
static bool IsAoeLootEnabledForPlayer(Player* player);