Bot should be more consistent at doing quest +several fixes

This commit is contained in:
Atidot3
2024-07-30 14:45:52 +02:00
parent 30a25ba13f
commit 0008d84f71
34 changed files with 986 additions and 609 deletions

View File

@@ -14,8 +14,10 @@ void QueryQuestAction::TellObjective(std::string const name, uint32 available, u
bool QueryQuestAction::Execute(Event event)
{
Player* requester = event.getOwner() ? event.getOwner() : GetMaster();
Player* bot = botAI->GetBot();
WorldPosition botPos(bot);
WorldPosition* ptr_botpos = &botPos;
std::string text = event.getParam();
bool travel = false;
@@ -28,7 +30,22 @@ bool QueryQuestAction::Execute(Event event)
PlayerbotChatHandler ch(bot);
uint32 questId = ch.extractQuestId(text);
if (!questId)
return false;
{
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{
uint32 logQuest = bot->GetQuestSlotQuestId(slot);
Quest const* quest = sObjectMgr->GetQuestTemplate(logQuest);
if (!quest)
continue;
if (text.find(quest->GetTitle()) != std::string::npos)
{
questId = quest->GetQuestId();
break;
}
}
}
for (uint16 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{
@@ -55,10 +72,7 @@ bool QueryQuestAction::Execute(Event event)
uint32 limit = 0;
std::vector<TravelDestination*> allDestinations = sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1);
std::sort(allDestinations.begin(), allDestinations.end(), [botPos](TravelDestination* i, TravelDestination* j)
{
return i->distanceTo(const_cast<WorldPosition*>(&botPos)) < j->distanceTo(const_cast<WorldPosition*>(&botPos));
});
std::sort(allDestinations.begin(), allDestinations.end(), [ptr_botpos](TravelDestination* i, TravelDestination* j) {return i->distanceTo(ptr_botpos) < j->distanceTo(ptr_botpos); });
for (auto dest : allDestinations)
{
@@ -71,24 +85,18 @@ bool QueryQuestAction::Execute(Event event)
uint32 apoints = dest->getPoints().size();
out << round(dest->distanceTo(const_cast<WorldPosition*>(&botPos)));
out << " to " << dest->getTitle();
out << " " << apoints;
out << round(dest->distanceTo(&botPos));
out << " to " << dest->getTitle();
out << " " << apoints;
if (apoints < tpoints)
out << "/" << tpoints;
out << " points.";
if (!dest->isActive(bot))
out << " not active";
if (dest->isFull(bot))
out << " crowded";
if (dest->isFull(bot))
out << " crowded";
botAI->TellMaster(out);
limit++;