From 3744bb6b3b285e890b8852f485795aa8fd40f7bb Mon Sep 17 00:00:00 2001 From: Walter Pagani Date: Thu, 22 Feb 2024 02:50:15 -0300 Subject: [PATCH] fix. Delete quest items after completing it (#26) --- src/AoeLoot_SC.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/AoeLoot_SC.cpp b/src/AoeLoot_SC.cpp index f13aba9..6209d21 100644 --- a/src/AoeLoot_SC.cpp +++ b/src/AoeLoot_SC.cpp @@ -193,6 +193,26 @@ class AoeLoot_Player : public PlayerScript { OnCreatureLootAOE(player); } + + /* + * This function is responsible for deleting the player's leftover items. + * But it only deletes those that are from a quest, and that cannot be obtained if the quest were not being carried out. + * Since there are some items that can be obtained even if you are not doing a quest. + */ + + void OnPlayerCompleteQuest(Player* player, Quest const* quest) override + { + for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + { + if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i])) + { + if ((itemTemplate->Bonding == BIND_QUEST_ITEM) && (!quest->IsRepeatable())) + { + player->DestroyItemCount(quest->RequiredItemId[i], 9999, true); + } + } + } + } }; void AddSC_AoeLoot()