diff options
| author | Wyrserth <43747507+Wyrserth@users.noreply.github.com> | 2019-05-10 17:49:46 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-12-05 14:01:48 +0100 |
| commit | 558772a0bc7e0d8b768a5b1778a9d598a2288f6f (patch) | |
| tree | 8ede268dbae7ae8086ceda90026cb1fe347d4e10 /src | |
| parent | 13becd1e39bf7c29815519a41669f4d4ab81c935 (diff) | |
Core/Quest: improve source item deletion logic for items that give quests (#23250)
* Core/Quest: improve source item deletion logic for items that give quests.
Prevent deletion of items that aren't supposed to be destroyed (like Demon Scarred Cloak).
* Whoops.
(cherry picked from commit 49dc8a8e4461063b4500e6b8af4eefadbd6698a1)
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 30a096493c6..048837d053c 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -15218,8 +15218,11 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver) Item* item = static_cast<Item*>(questGiver); sScriptMgr->OnQuestAccept(this, item, quest); - // destroy not required for quest finish quest starting item + // There are two cases where the source item is not destroyed when the quest is accepted: + // - It is required to finish the quest, and is an unique item + // - It is the same item present in the source item field (item that would be given on quest accept) bool destroyItem = true; + for (QuestObjective const& obj : quest->GetObjectives()) { if (obj.Type == QUEST_OBJECTIVE_ITEM && uint32(obj.ObjectID) == item->GetEntry() && item->GetTemplate()->GetMaxCount() > 0) @@ -15229,6 +15232,9 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver) } } + if (quest->GetSrcItemId() == item->GetEntry()) + destroyItem = false; + if (destroyItem) DestroyItem(item->GetBagSlot(), item->GetSlot(), true); @@ -16316,6 +16322,11 @@ bool Player::GiveQuestSourceItem(Quest const* quest) uint32 srcitem = quest->GetSrcItemId(); if (srcitem > 0) { + // Don't give source item if it is the same item used to start the quest + ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(srcitem); + if (quest->GetQuestId() == itemTemplate->GetStartQuest()) + return true; + uint32 count = quest->GetSrcItemCount(); if (count <= 0) count = 1; @@ -16353,10 +16364,9 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg) if (count <= 0) count = 1; - // exist two cases when destroy source quest item not possible: - // a) non un-equippable item (equipped non-empty bag, for example) - // b) when quest is started from an item and item also is needed in - // the end as RequiredItemId + // There are two cases where the source item is not destroyed: + // - Item cannot be unequipped (example: non-empty bags) + // - The source item is the item that started the quest, so the player is supposed to keep it (otherwise it was already destroyed in AddQuestAndCheckCompletion()) InventoryResult res = CanUnequipItems(srcItemId, count); if (res != EQUIP_ERR_OK) { @@ -16366,13 +16376,7 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg) } ASSERT(item); - bool destroyItem = true; - if (item->GetStartQuest() == questId) - for (QuestObjective const& obj : quest->GetObjectives()) - if (obj.Type == QUEST_OBJECTIVE_ITEM && srcItemId == uint32(obj.ObjectID)) - destroyItem = false; - - if (destroyItem) + if (item->GetStartQuest() != questId) DestroyItemCount(srcItemId, count, true, true); } } |
