diff options
author | Wyrserth <43747507+Wyrserth@users.noreply.github.com> | 2019-05-10 17:49:46 +0200 |
---|---|---|
committer | Giacomo Pozzoni <giacomopoz@gmail.com> | 2019-05-10 17:49:46 +0200 |
commit | 49dc8a8e4461063b4500e6b8af4eefadbd6698a1 (patch) | |
tree | 1eb1191d26f489e0a5953db587b6b74d113aa5f9 /src | |
parent | 57f8695dbe4fbfd187251e0390f2612a6b197d3d (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.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 64b13e52f8e..e4ad7d43d55 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -14819,8 +14819,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 (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { if (quest->RequiredItemId[i] == item->GetEntry() && item->GetTemplate()->MaxCount > 0) @@ -14830,6 +14833,9 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver) } } + if (quest->GetSrcItemId() == item->GetEntry()) + destroyItem = false; + if (destroyItem) DestroyItem(item->GetBagSlot(), item->GetSlot(), true); @@ -15741,6 +15747,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->StartQuest) + return true; + uint32 count = quest->GetSrcItemCount(); if (count <= 0) count = 1; @@ -15778,10 +15789,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) { @@ -15791,12 +15801,7 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg) } ASSERT(item); - bool destroyItem = true; - for (uint8 n = 0; n < QUEST_ITEM_OBJECTIVES_COUNT; ++n) - if (item->StartQuest == questId && srcItemId == quest->RequiredItemId[n]) - destroyItem = false; - - if (destroyItem) + if (item->StartQuest != questId) DestroyItemCount(srcItemId, count, true, true); } } |