mirror of
https://github.com/brighton-chi/mod-aoe-loot.git
synced 2026-01-13 00:58:34 +00:00
quest item config
This commit is contained in:
101
src/aoe_loot.cpp
101
src/aoe_loot.cpp
@@ -715,14 +715,23 @@ bool AoeLootCommandScript::TriggerAoeLootCommand(ChatHandler* handler, Optional<
|
||||
}
|
||||
}
|
||||
|
||||
// Process quest items separately if they exist
|
||||
for (uint8 i = 0; i < loot->quest_items.size(); ++i)
|
||||
// Handle quest items based on configuration
|
||||
if (ShouldProcessQuestItemsSeparately())
|
||||
{
|
||||
uint8 questLootSlot = loot->items.size() + i;
|
||||
ProcessSingleLootSlot(player, lguid, questLootSlot);
|
||||
if (debugMode)
|
||||
// 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)
|
||||
{
|
||||
LOG_DEBUG("module.aoe_loot", "AOE Loot: looted quest item in slot {}", questLootSlot);
|
||||
uint8 questLootSlot = loot->items.size() + i;
|
||||
ProcessSingleLootSlot(player, lguid, questLootSlot);
|
||||
if (debugMode)
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user