From 138c18dbd3f9902ee3350467e53480287b14f626 Mon Sep 17 00:00:00 2001 From: atrapalis <104009206+atrapalis@users.noreply.github.com> Date: Sat, 27 Jul 2024 11:18:37 +0100 Subject: [PATCH] fix(Core/LootMgr): Improved drop checks for items that start quests (#19463) * fix(Core/LootMgr): Improved drop checks for items that start quests to prevent unnecessary or inappropriate drops * Tweaked 2nd condition to only be valid for unique items --- src/server/game/Loot/LootMgr.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 182a0f416..5284e5554 100644 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -468,9 +468,20 @@ bool LootItem::AllowedForPlayer(Player const* player, ObjectGuid source) const } // check quest requirements - if (!(pProto->FlagsCu & ITEM_FLAGS_CU_IGNORE_QUEST_STATUS) && ((needs_quest || (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE)) && !player->HasQuestForItem(itemid))) + if (!(pProto->FlagsCu & ITEM_FLAGS_CU_IGNORE_QUEST_STATUS)) { - return false; + // Don't drop quest items if the player is missing the relevant quest + if (needs_quest && !player->HasQuestForItem(itemid)) + return false; + + // for items that start quests + if (pProto->StartQuest) + { + // Don't drop the item if the player has already finished the quest OR player already has the item in their inventory, and that item is unique OR the player has not finished a prerequisite quest + uint32 prevQuestId = sObjectMgr->GetQuestTemplate(pProto->StartQuest) ? sObjectMgr->GetQuestTemplate(pProto->StartQuest)->GetPrevQuestId() : 0; + if (player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE || (player->HasItemCount(itemid, pProto->MaxCount) && pProto->MaxCount) || (prevQuestId && !player->GetQuestRewardStatus(prevQuestId))) + return false; + } } if (!sScriptMgr->OnAllowedForPlayerLootCheck(player, source))