mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-12-01 21:12:50 +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;
|
uint32 count = 0;
|
||||||
for (std::list<uint32>::iterator i = questMap.begin(); i != questMap.end(); ++i)
|
for (std::list<uint32>::iterator i = questMap.begin(); i != questMap.end(); ++i)
|
||||||
@@ -2786,17 +2786,30 @@ void PlayerbotFactory::InitQuests(std::list<uint32>& questMap)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
bot->SetQuestStatus(questId, QUEST_STATUS_COMPLETE);
|
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);
|
||||||
|
|
||||||
// LOG_INFO("playerbots", "Bot {} ({} level) rewarded quest {}: {} (MinLevel={}, QuestLevel={})",
|
if (!withRewardItem)
|
||||||
// bot->GetName().c_str(), bot->GetLevel(), questId, quest->GetTitle().c_str(), quest->GetMinLevel(),
|
{
|
||||||
// quest->GetQuestLevel());
|
// destroy the quest reward item
|
||||||
|
if (uint32 itemId = quest->RewardChoiceItemId[reward])
|
||||||
|
{
|
||||||
|
bot->DestroyItemCount(itemId, quest->RewardChoiceItemCount[reward], true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(count++ % 10))
|
if (quest->GetRewItemsCount())
|
||||||
ClearInventory();
|
{
|
||||||
|
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()
|
void PlayerbotFactory::InitInstanceQuests()
|
||||||
@@ -2804,8 +2817,8 @@ void PlayerbotFactory::InitInstanceQuests()
|
|||||||
// Yunfan: use configuration instead of hard code
|
// Yunfan: use configuration instead of hard code
|
||||||
uint32 currentXP = bot->GetUInt32Value(PLAYER_XP);
|
uint32 currentXP = bot->GetUInt32Value(PLAYER_XP);
|
||||||
// LOG_INFO("playerbots", "Initializing quests...");
|
// LOG_INFO("playerbots", "Initializing quests...");
|
||||||
InitQuests(classQuestIds);
|
InitQuests(classQuestIds, false);
|
||||||
InitQuests(specialQuestIds);
|
InitQuests(specialQuestIds, false);
|
||||||
|
|
||||||
// quest rewards boost bot level, so reduce back
|
// quest rewards boost bot level, so reduce back
|
||||||
bot->GiveLevel(level);
|
bot->GiveLevel(level);
|
||||||
@@ -4447,7 +4460,7 @@ void PlayerbotFactory::InitAttunementQuests()
|
|||||||
// Only complete quests that haven't been finished yet
|
// Only complete quests that haven't been finished yet
|
||||||
if (!questsToComplete.empty())
|
if (!questsToComplete.empty())
|
||||||
{
|
{
|
||||||
InitQuests(questsToComplete);
|
InitQuests(questsToComplete, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ private:
|
|||||||
void ClearSkills();
|
void ClearSkills();
|
||||||
void InitTalents(uint32 specNo);
|
void InitTalents(uint32 specNo);
|
||||||
void InitTalentsByTemplate(uint32 specNo);
|
void InitTalentsByTemplate(uint32 specNo);
|
||||||
void InitQuests(std::list<uint32>& questMap);
|
void InitQuests(std::list<uint32>& questMap, bool withRewardItem = true);
|
||||||
void ClearInventory();
|
void ClearInventory();
|
||||||
void ClearAllItems();
|
void ClearAllItems();
|
||||||
void ResetQuests();
|
void ResetQuests();
|
||||||
|
|||||||
Reference in New Issue
Block a user