mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix inventory clear on init quests (#1266)
This commit is contained in:
@@ -2773,7 +2773,7 @@ void PlayerbotFactory::AddPrevQuests(uint32 questId, std::list<uint32>& questIds
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerbotFactory::InitQuests(std::list<uint32>& questMap)
|
||||
void PlayerbotFactory::InitQuests(std::list<uint32>& questMap, bool withRewardItem)
|
||||
{
|
||||
uint32 count = 0;
|
||||
for (std::list<uint32>::iterator i = questMap.begin(); i != questMap.end(); ++i)
|
||||
@@ -2786,17 +2786,30 @@ void PlayerbotFactory::InitQuests(std::list<uint32>& 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ private:
|
||||
void ClearSkills();
|
||||
void InitTalents(uint32 specNo);
|
||||
void InitTalentsByTemplate(uint32 specNo);
|
||||
void InitQuests(std::list<uint32>& questMap);
|
||||
void InitQuests(std::list<uint32>& questMap, bool withRewardItem = true);
|
||||
void ClearInventory();
|
||||
void ClearAllItems();
|
||||
void ResetQuests();
|
||||
|
||||
Reference in New Issue
Block a user