diff --git a/playerbot/TravelMgr.cpp b/playerbot/TravelMgr.cpp index 7c5bd426..1a0572b3 100644 --- a/playerbot/TravelMgr.cpp +++ b/playerbot/TravelMgr.cpp @@ -2704,7 +2704,7 @@ bool TravelMgr::getObjectiveStatus(Player* bot, Quest const* pQuest, uint32 obje } //any quests to take -std::vector TravelMgr::GetAvailableNewQuestTravelDestinations(Player* bot, bool classQuestsOnly, float maxDistance) +std::vector TravelMgr::GetAvailableNewQuestTravelDestinations(Player* bot, bool classQuestsOnly, bool ignoreLowLevelQuests, float maxDistance) { WorldPosition botLocation(bot); @@ -2716,24 +2716,16 @@ std::vector TravelMgr::GetAvailableNewQuestTravelDestination { auto destinationQuest = sObjectMgr.GetQuestTemplate(dest->GetQuestTemplate()->GetQuestId()); - if (classQuestsOnly) + if (!classQuestsOnly) { - // only class quests bot could do - if (destinationQuest->GetRequiredClasses() == 0 - || !bot->SatisfyQuestClass(destinationQuest, false) - || !bot->SatisfyQuestRace(destinationQuest, false) - || !bot->SatisfyQuestLevel(destinationQuest, false)) - continue; - } - else - { - // only quests bot could do - if (!bot->SatisfyQuestClass(destinationQuest, false) - || !bot->SatisfyQuestRace(destinationQuest, false) - || !bot->SatisfyQuestLevel(destinationQuest, false)) + //ignore low level quests + if (ignoreLowLevelQuests && !bot->CanSeeStartQuest(destinationQuest)) continue; } + if (!bot->CanTakeQuest(destinationQuest, false)) + continue; + if (currentBotQuestIds.count(destinationQuest->GetQuestId()) > 0) continue; diff --git a/playerbot/TravelMgr.h b/playerbot/TravelMgr.h index ef4ec4aa..c4b67494 100644 --- a/playerbot/TravelMgr.h +++ b/playerbot/TravelMgr.h @@ -378,7 +378,7 @@ namespace ai QuestStatusData* getQuestStatus(Player* bot, uint32 questId); bool getObjectiveStatus(Player* bot, Quest const* pQuest, uint32 objective); uint32 getDialogStatus(Player* pPlayer, int32 questgiver, Quest const* pQuest); - std::vector GetAvailableNewQuestTravelDestinations(Player* bot, bool classQuestsOnly, float maxDistance); + std::vector GetAvailableNewQuestTravelDestinations(Player* bot, bool classQuestsOnly, bool ignoreLowLevelQuests, float maxDistance); std::vector GetTurnInCurrentQuestsTravelDestinations(Player* bot, bool classQuestsOnly, float maxDistance); std::vector GetCurrentQuestsObjectivesTravelDestinations(Player* bot, bool classQuestsOnly, float maxDistance); diff --git a/playerbot/strategy/actions/ChooseTravelTargetAction.cpp b/playerbot/strategy/actions/ChooseTravelTargetAction.cpp index 1ab2bc8e..96fe354a 100644 --- a/playerbot/strategy/actions/ChooseTravelTargetAction.cpp +++ b/playerbot/strategy/actions/ChooseTravelTargetAction.cpp @@ -122,6 +122,8 @@ void ChooseTravelTargetAction::getNewTarget(Player* requester, TravelTarget* new } } + bool shouldGetMoney = AI_VALUE(bool, "should get money"); + //Do quests (start, do, end) //95% chance or 100% chance on last retry if bot is not max level uint8 doQuestsChance = bot->GetLevel() < botMaxLevel ? 95 : 30; //can finally relax a bit from questing at max level @@ -129,7 +131,7 @@ void ChooseTravelTargetAction::getNewTarget(Player* requester, TravelTarget* new { ai->TellDebug(requester, "Do questing", "debug travel"); PerformanceMonitorOperation* pmo = sPerformanceMonitor.start(PERF_MON_VALUE, "SetQuestTarget", &context->performanceStack); - foundTarget = SetQuestTarget(requester, newTarget); + foundTarget = SetQuestTarget(requester, newTarget, !shouldGetMoney); if (pmo) pmo->finish(); if (foundTarget) @@ -147,7 +149,7 @@ void ChooseTravelTargetAction::getNewTarget(Player* requester, TravelTarget* new } //Grind for money (if not in dungeon) - if (!foundTarget && AI_VALUE(bool, "should get money") && botPos.isOverworld()) + if (!foundTarget && shouldGetMoney && botPos.isOverworld()) { //Empty mail for money if (AI_VALUE(bool, "can get mail")) @@ -874,24 +876,29 @@ bool ChooseTravelTargetAction::SetCurrentTarget(Player* requester, TravelTarget* return target->isActive(); } -bool ChooseTravelTargetAction::SetQuestTarget(Player* requester, TravelTarget* target) +bool ChooseTravelTargetAction::SetQuestTarget(Player* requester, TravelTarget* target, bool ignoreNewLowLevelQuests) { uint32 initialQuestSearchDistance = 400 + bot->GetLevel() * 10; uint8 maxQuestSearchRetries = 5; + std::vector travelDestinations; + //turn in any completed class quests anywhere - if (SetBestTarget(requester, target, sTravelMgr.GetTurnInCurrentQuestsTravelDestinations(bot, true, 0), 0)) + travelDestinations = sTravelMgr.GetTurnInCurrentQuestsTravelDestinations(bot, true, 0); + if (SetBestTarget(requester, target, travelDestinations, 0)) { return true; } //do current class quests anywhere - if (SetBestTarget(requester, target, sTravelMgr.GetCurrentQuestsObjectivesTravelDestinations(bot, true, 0), 0)) + travelDestinations = sTravelMgr.GetCurrentQuestsObjectivesTravelDestinations(bot, true, 0); + if (SetBestTarget(requester, target, travelDestinations, 0)) { return true; } //find any available class quests anywhere (if quest log is not full) - if (ai->GetAllCurrentQuestIds().size() < MAX_QUEST_LOG_SIZE && SetBestTarget(requester, target, sTravelMgr.GetAvailableNewQuestTravelDestinations(bot, true, 0), 0)) + travelDestinations = sTravelMgr.GetAvailableNewQuestTravelDestinations(bot, true, false, 0); + if (ai->GetAllCurrentQuestIds().size() < MAX_QUEST_LOG_SIZE && SetBestTarget(requester, target, travelDestinations, 0)) { return true; } @@ -904,12 +911,14 @@ bool ChooseTravelTargetAction::SetQuestTarget(Player* requester, TravelTarget* t auto distance = retry == maxQuestSearchRetries ? 0 : initialQuestSearchDistance * (retry); //turn in any completed quests - if (SetBestTarget(requester, target, sTravelMgr.GetTurnInCurrentQuestsTravelDestinations(bot, false, distance), 0)) + travelDestinations = sTravelMgr.GetTurnInCurrentQuestsTravelDestinations(bot, false, distance); + if (SetBestTarget(requester, target, travelDestinations, 0)) { return true; } //do current quests - if (SetBestTarget(requester, target, sTravelMgr.GetCurrentQuestsObjectivesTravelDestinations(bot, false, distance), 0)) + travelDestinations = sTravelMgr.GetCurrentQuestsObjectivesTravelDestinations(bot, false, distance); + if (SetBestTarget(requester, target, travelDestinations, 0)) { return true; } @@ -923,8 +932,9 @@ bool ChooseTravelTargetAction::SetQuestTarget(Player* requester, TravelTarget* t { auto distance = retry == maxQuestSearchRetries ? 0 : initialQuestSearchDistance * (retry); - //find any available quests - if (SetBestTarget(requester, target, sTravelMgr.GetAvailableNewQuestTravelDestinations(bot, false, distance), 0)) + //find any available quests (appropriate level only) + travelDestinations = sTravelMgr.GetAvailableNewQuestTravelDestinations(bot, false, ignoreNewLowLevelQuests, distance); + if (SetBestTarget(requester, target, travelDestinations, 0)) { return true; } @@ -933,14 +943,16 @@ bool ChooseTravelTargetAction::SetQuestTarget(Player* requester, TravelTarget* t //if quest log has some quests but is not full else { - //find any available quests nearby - if (SetBestTarget(requester, target, sTravelMgr.GetAvailableNewQuestTravelDestinations(bot, false, 1000.0f), 0)) + //find any available quests nearby (appropriate level only) + travelDestinations = sTravelMgr.GetAvailableNewQuestTravelDestinations(bot, false, ignoreNewLowLevelQuests, 1000.0f); + if (SetBestTarget(requester, target, travelDestinations, 0)) { return true; } //turn in any current quests nearby (with a chance to skip) - if (!urand(0, 2) && SetBestTarget(requester, target, sTravelMgr.GetTurnInCurrentQuestsTravelDestinations(bot, false, 1000.0f), 0)) + travelDestinations = sTravelMgr.GetTurnInCurrentQuestsTravelDestinations(bot, false, 1000.0f); + if (!urand(0, 2) && SetBestTarget(requester, target, travelDestinations, 0)) { return true; } @@ -951,7 +963,8 @@ bool ChooseTravelTargetAction::SetQuestTarget(Player* requester, TravelTarget* t auto distance = retry == maxQuestSearchRetries ? 0 : initialQuestSearchDistance * (retry); //find any available quests - if (SetBestTarget(requester, target, sTravelMgr.GetCurrentQuestsObjectivesTravelDestinations(bot, false, distance), 0)) + travelDestinations = sTravelMgr.GetCurrentQuestsObjectivesTravelDestinations(bot, false, distance); + if (SetBestTarget(requester, target, travelDestinations, 0)) { return true; } diff --git a/playerbot/strategy/actions/ChooseTravelTargetAction.h b/playerbot/strategy/actions/ChooseTravelTargetAction.h index 0614558a..9d62f60b 100644 --- a/playerbot/strategy/actions/ChooseTravelTargetAction.h +++ b/playerbot/strategy/actions/ChooseTravelTargetAction.h @@ -28,7 +28,7 @@ namespace ai bool SetCurrentTarget(Player* requester, TravelTarget* target, TravelTarget* oldTarget); - bool SetQuestTarget(Player* requester, TravelTarget* target); + bool SetQuestTarget(Player* requester, TravelTarget* target, bool ignoreNewLowLevelQuests); bool SetRpgTarget(Player* requester, TravelTarget* target, bool requireLongDistanceSearch); bool SetGrindTarget(Player* requester, TravelTarget* target); bool SetBossTarget(Player* requester, TravelTarget* target);