diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index bbb4ce06..f67738bc 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -39,6 +39,7 @@ #include "Playerbots.h" #include "PointMovementGenerator.h" #include "PositionValue.h" +#include "RandomPlayerbotMgr.h" #include "SayAction.h" #include "ScriptMgr.h" #include "ServerFacade.h" @@ -4107,20 +4108,11 @@ inline bool ZoneHasRealPlayers(Player* bot) { return false; } - - Map::PlayerList const& players = bot->GetMap()->GetPlayers(); - if (players.IsEmpty()) + + for (auto& player : sRandomPlayerbotMgr->GetPlayers()) { - return false; - } - - for (auto const& itr : players) - { - Player* player = itr.GetSource(); - if (!player || !player->IsVisible()) - { + if (player->GetMapId() != bot->GetMapId()) continue; - } if (player->GetZoneId() == bot->GetZoneId()) { diff --git a/src/strategy/actions/NewRpgAction.cpp b/src/strategy/actions/NewRpgAction.cpp index 40ea5c12..95bdb3fb 100644 --- a/src/strategy/actions/NewRpgAction.cpp +++ b/src/strategy/actions/NewRpgAction.cpp @@ -98,7 +98,7 @@ bool NewRpgStatusUpdateAction::Execute(Event event) case NewRpgStatus::GO_INNKEEPER: { WorldPosition& originalPos = info.innKeeperPos; - assert(info.grindPos != WorldPosition()); + assert(info.innKeeperPos != WorldPosition()); // GO_INNKEEPER -> NEAR_NPC if (bot->GetExactDist(originalPos) < 10.0f) { @@ -217,17 +217,17 @@ bool NewRpgGoFarAwayPosAction::MoveFarTo(WorldPosition dest) return MoveTo(dest.getMapId(), dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ()); } - int attempt = 10; float minDelta = M_PI; const float x = bot->GetPositionX(); const float y = bot->GetPositionY(); const float z = bot->GetPositionZ(); float rx, ry, rz; bool found = false; + int attempt = 5; while (--attempt) { float angle = bot->GetAngle(&dest); - float delta = (rand_norm() - 0.5) * M_PI; + float delta = (rand_norm() - 0.5) * M_PI * 0.6; angle += delta; float dis = rand_norm() * pathFinderDis; float dx = x + cos(angle) * dis; @@ -241,14 +241,11 @@ bool NewRpgGoFarAwayPosAction::MoveFarTo(WorldPosition dest) if (canReach) { G3D::Vector3 endPos = path.GetPath().back(); - if (fabs(delta) < minDelta) - { - found = true; - minDelta = fabs(delta); - rx = endPos.x; - ry = endPos.y; - rz = endPos.z; - } + found = true; + rx = endPos.x; + ry = endPos.y; + rz = endPos.z; + break; } } if (found)