diff options
| -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); } } |
