diff --git a/src/factory/PlayerbotFactory.cpp b/src/factory/PlayerbotFactory.cpp index 9152a4d0..64bedb4d 100644 --- a/src/factory/PlayerbotFactory.cpp +++ b/src/factory/PlayerbotFactory.cpp @@ -2773,7 +2773,7 @@ void PlayerbotFactory::AddPrevQuests(uint32 questId, std::list& questIds } } -void PlayerbotFactory::InitQuests(std::list& questMap) +void PlayerbotFactory::InitQuests(std::list& questMap, bool withRewardItem) { uint32 count = 0; for (std::list::iterator i = questMap.begin(); i != questMap.end(); ++i) @@ -2786,17 +2786,30 @@ void PlayerbotFactory::InitQuests(std::list& questMap) continue; bot->SetQuestStatus(questId, QUEST_STATUS_COMPLETE); - bot->RewardQuest(quest, 0, bot, false); + // set reward to 5 to skip majority quest reward + uint32 reward = withRewardItem ? 0 : 5; + bot->RewardQuest(quest, reward, bot, false); + + if (!withRewardItem) + { + // destroy the quest reward item + if (uint32 itemId = quest->RewardChoiceItemId[reward]) + { + bot->DestroyItemCount(itemId, quest->RewardChoiceItemCount[reward], true); + } - // LOG_INFO("playerbots", "Bot {} ({} level) rewarded quest {}: {} (MinLevel={}, QuestLevel={})", - // bot->GetName().c_str(), bot->GetLevel(), questId, quest->GetTitle().c_str(), quest->GetMinLevel(), - // quest->GetQuestLevel()); - - if (!(count++ % 10)) - ClearInventory(); + if (quest->GetRewItemsCount()) + { + for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i) + { + if (uint32 itemId = quest->RewardItemId[i]) + { + bot->DestroyItemCount(itemId, quest->RewardItemIdCount[i], true); + } + } + } + } } - - ClearInventory(); } void PlayerbotFactory::InitInstanceQuests() @@ -2804,8 +2817,8 @@ void PlayerbotFactory::InitInstanceQuests() // Yunfan: use configuration instead of hard code uint32 currentXP = bot->GetUInt32Value(PLAYER_XP); // LOG_INFO("playerbots", "Initializing quests..."); - InitQuests(classQuestIds); - InitQuests(specialQuestIds); + InitQuests(classQuestIds, false); + InitQuests(specialQuestIds, false); // quest rewards boost bot level, so reduce back bot->GiveLevel(level); @@ -4447,7 +4460,7 @@ void PlayerbotFactory::InitAttunementQuests() // Only complete quests that haven't been finished yet if (!questsToComplete.empty()) { - InitQuests(questsToComplete); + InitQuests(questsToComplete, false); } } diff --git a/src/factory/PlayerbotFactory.h b/src/factory/PlayerbotFactory.h index fed26fd9..a76a2a32 100644 --- a/src/factory/PlayerbotFactory.h +++ b/src/factory/PlayerbotFactory.h @@ -156,7 +156,7 @@ private: void ClearSkills(); void InitTalents(uint32 specNo); void InitTalentsByTemplate(uint32 specNo); - void InitQuests(std::list& questMap); + void InitQuests(std::list& questMap, bool withRewardItem = true); void ClearInventory(); void ClearAllItems(); void ResetQuests();