mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Merge pull request #234 from yuan227301/opt_quest
[Optimization] Optimize quests initialization code.
This commit is contained in:
@@ -212,28 +212,10 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
*/
|
*/
|
||||||
InitInstanceQuests();
|
|
||||||
// clear quest reward inventory
|
|
||||||
ClearInventory();
|
|
||||||
bot->GiveLevel(level);
|
|
||||||
|
|
||||||
if (sPlayerbotAIConfig->randomBotPreQuests)
|
if (sPlayerbotAIConfig->randomBotPreQuests){
|
||||||
{
|
|
||||||
uint32 currentXP = bot->GetUInt32Value(PLAYER_XP);
|
|
||||||
LOG_INFO("playerbots", "Initializing quests...");
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests");
|
||||||
InitQuests(classQuestIds);
|
InitInstanceQuests();
|
||||||
InitQuests(specialQuestIds);
|
|
||||||
|
|
||||||
// quest rewards boost bot level, so reduce back
|
|
||||||
|
|
||||||
bot->GiveLevel(level);
|
|
||||||
|
|
||||||
|
|
||||||
ClearInventory();
|
|
||||||
bot->SetUInt32Value(PLAYER_XP, currentXP);
|
|
||||||
CancelAuras();
|
|
||||||
bot->SaveToDB(false, false);
|
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
}
|
}
|
||||||
@@ -2454,21 +2436,17 @@ void PlayerbotFactory::InitQuests(std::list<uint32>& questMap)
|
|||||||
void PlayerbotFactory::InitInstanceQuests()
|
void PlayerbotFactory::InitInstanceQuests()
|
||||||
{
|
{
|
||||||
// Yunfan: use configuration instead of hard code
|
// Yunfan: use configuration instead of hard code
|
||||||
|
uint32 currentXP = bot->GetUInt32Value(PLAYER_XP);
|
||||||
|
LOG_INFO("playerbots", "Initializing quests...");
|
||||||
|
InitQuests(classQuestIds);
|
||||||
|
InitQuests(specialQuestIds);
|
||||||
|
|
||||||
// The Caverns of Time
|
// quest rewards boost bot level, so reduce back
|
||||||
if (bot->GetLevel() >= 64) {
|
bot->GiveLevel(level);
|
||||||
uint32 questId = 10277;
|
|
||||||
Quest const *quest = sObjectMgr->GetQuestTemplate(questId);
|
ClearInventory();
|
||||||
bot->SetQuestStatus(questId, QUEST_STATUS_COMPLETE);
|
bot->SetUInt32Value(PLAYER_XP, currentXP);
|
||||||
bot->RewardQuest(quest, 5, bot, false);
|
bot->SaveToDB(false, false);
|
||||||
}
|
|
||||||
// Return to Andormu
|
|
||||||
if (bot->GetLevel() >= 66) {
|
|
||||||
uint32 questId = 10285;
|
|
||||||
Quest const *quest = sObjectMgr->GetQuestTemplate(questId);
|
|
||||||
bot->SetQuestStatus(questId, QUEST_STATUS_COMPLETE);
|
|
||||||
bot->RewardQuest(quest, 5, bot, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerbotFactory::ClearInventory()
|
void PlayerbotFactory::ClearInventory()
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ class PlayerbotFactory
|
|||||||
void InitMounts();
|
void InitMounts();
|
||||||
void InitBags(bool destroyOld = true);
|
void InitBags(bool destroyOld = true);
|
||||||
void ApplyEnchantAndGemsNew(bool destoryOld = true);
|
void ApplyEnchantAndGemsNew(bool destoryOld = true);
|
||||||
|
void InitInstanceQuests();
|
||||||
private:
|
private:
|
||||||
void Prepare();
|
void Prepare();
|
||||||
// void InitSecondEquipmentSet();
|
// void InitSecondEquipmentSet();
|
||||||
@@ -151,7 +152,6 @@ class PlayerbotFactory
|
|||||||
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);
|
||||||
void InitInstanceQuests();
|
|
||||||
void ClearInventory();
|
void ClearInventory();
|
||||||
void ClearAllItems();
|
void ClearAllItems();
|
||||||
void ResetQuests();
|
void ResetQuests();
|
||||||
|
|||||||
@@ -628,6 +628,11 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje
|
|||||||
sRandomPlayerbotMgr->Randomize(bot);
|
sRandomPlayerbotMgr->Randomize(bot);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
else if (cmd == "quests"){
|
||||||
|
PlayerbotFactory factory(bot, bot->getLevel());
|
||||||
|
factory.InitInstanceQuests();
|
||||||
|
return "Initialization quests";
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return "unknown command";
|
return "unknown command";
|
||||||
|
|||||||
Reference in New Issue
Block a user