mod-playerbots/src/Ai/Base/Actions/TravelAction.cpp
Keleborn 439293e100
Warnings PR 2 clean unused variables (#2107)
# Pull Request

Removed unused variables and fixed styling issues. 


## How to Test the Changes

- Step-by-step instructions to test the change
- Any required setup (e.g. multiple players, bots, specific
configuration)
- Expected behavior and how to verify it

## Complexity & Impact

- Does this change add new decision branches?
    - [x] No
    - [] Yes (**explain below**)

- Does this change increase per-bot or per-tick processing?
    - [x] No
    - [ ] Yes (**describe and justify impact**)

- Could this logic scale poorly under load?
    - [x] No
    - [ ] Yes (**explain why**)

---

## Defaults & Configuration

- Does this change modify default bot behavior?
    - [x] No
    - [ ] Yes (**explain why**)

If this introduces more advanced or AI-heavy logic:

- [ ] Lightweight mode remains the default
- [ ] More complex behavior is optional and thereby configurable

---

## AI Assistance

- Was AI assistance (e.g. ChatGPT or similar tools) used while working
on this change?
    - [x] No
    - [ ] Yes (**explain below**)


---

## Final Checklist

- [x] Stability is not compromised
- [x] Performance impact is understood, tested, and acceptable
- [x] Added logic complexity is justified and explained
- [x] Documentation updated if needed

---

## Notes for Reviewers

This was filtered from the code provided by SmashingQuasar. Eliminated
variables were confirmed to be not used, but unclear at times if that is
due to mistakes in writing.

---------

Co-authored-by: bashermens <31279994+hermensbas@users.noreply.github.com>
2026-02-27 16:04:33 -08:00

140 lines
4.5 KiB
C++

/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
* and/or modify it under version 3 of the License, or (at your option), any later version.
*/
#include "TravelAction.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Playerbots.h"
bool TravelAction::Execute(Event /*event*/)
{
TravelTarget* target = AI_VALUE(TravelTarget*, "travel target");
if (bot->isMoving())
return false;
target->setStatus(TRAVEL_STATUS_WORK);
Unit* newTarget = nullptr;
std::list<Unit*> targets;
Acore::AnyUnitInObjectRangeCheck u_check(bot, sPlayerbotAIConfig.sightDistance * 2);
Acore::UnitListSearcher<Acore::AnyUnitInObjectRangeCheck> searcher(bot, targets, u_check);
Cell::VisitObjects(bot, searcher, sPlayerbotAIConfig.sightDistance);
for (Unit* unit : targets)
{
newTarget = unit;
if (!newTarget || !newTarget->IsInWorld() || newTarget->IsDuringRemoveFromWorld())
continue;
if (newTarget->GetMapId() != bot->GetMapId())
continue;
if (!newTarget->IsAlive())
continue;
if (newTarget->GetEntry() == target->getDestination()->getEntry())
continue;
if (newTarget->IsInCombat())
continue;
if (bot->IsHostileTo(newTarget))
SET_AI_VALUE(ObjectGuid, "pull target", newTarget->GetGUID());
else
SET_AI_VALUE(GuidPosition, "rpg target", GuidPosition(newTarget));
break;
}
return true;
}
bool TravelAction::isUseful()
{
return false && AI_VALUE(TravelTarget*, "travel target")->isActive() &&
(!AI_VALUE(GuidPosition, "rpg target") || !AI_VALUE(ObjectGuid, "pull target"));
}
bool MoveToDarkPortalAction::Execute(Event /*event*/)
{
if (bot->GetGroup())
{
if (bot->GetGroup()->GetLeaderGUID() != bot->GetGUID() &&
!GET_PLAYERBOT_AI(GET_PLAYERBOT_AI(bot)->GetGroupLeader()))
return false;
}
if (bot->GetLevel() > 57)
{
if ((bot->GetTeamId() == TEAM_ALLIANCE && bot->GetQuestStatus(10119) == QUEST_STATUS_NONE) ||
(bot->GetTeamId() == TEAM_HORDE && bot->GetQuestStatus(9407) == QUEST_STATUS_NONE))
{
if (!bot->IsInCombat())
{
if (bot->GetTeamId() == TEAM_ALLIANCE)
{
Quest const* quest = sObjectMgr->GetQuestTemplate(10119);
CreatureData const* creatureData = sRandomPlayerbotMgr.GetCreatureDataByEntry(16841);
if (quest && creatureData)
{
auto creatureBounds =
bot->GetMap()->GetCreatureBySpawnIdStore().equal_range(creatureData->spawnId);
if (creatureBounds.first != creatureBounds.second)
bot->AddQuest(quest, creatureBounds.first->second);
}
}
else
{
Quest const* quest = sObjectMgr->GetQuestTemplate(9407);
CreatureData const* creatureData = sRandomPlayerbotMgr.GetCreatureDataByEntry(19254);
if (quest && creatureData)
{
auto creatureBounds =
bot->GetMap()->GetCreatureBySpawnIdStore().equal_range(creatureData->spawnId);
if (creatureBounds.first != creatureBounds.second)
bot->AddQuest(quest, creatureBounds.first->second);
}
}
}
return MoveTo(0, -11815.1f, -3190.39f, -30.7338f, false, true);
}
return MoveTo(0, -11906.9f, -3208.53f, -14.8616f, false, true);
}
return false;
}
bool MoveToDarkPortalAction::isUseful() { return bot->GetLevel() > 54; }
bool DarkPortalAzerothAction::Execute(Event /*event*/)
{
if (bot->GetLevel() > 57)
{
WorldPacket packet(CMSG_AREATRIGGER);
packet << 4354;
return GET_PLAYERBOT_AI(bot)->DoSpecificAction("reach area trigger", Event("travel action", packet));
}
return false;
}
bool DarkPortalAzerothAction::isUseful() { return bot->GetLevel() > 57; }
bool MoveFromDarkPortalAction::Execute(Event /*event*/)
{
RESET_AI_VALUE(GuidPosition, "rpg target");
if (bot->GetTeamId() == TEAM_ALLIANCE)
return MoveTo(530, -319.261f, 1027.213, 54.172638f, false, true);
return MoveTo(530, -180.444f, 1027.947, 54.181538f, false, true);
}