aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Player/Player.cpp27
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);
}
}