Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/game/MotionGenerators/PathFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "Map.h"
#include "PathFinder.h"
#include "Log.h"
#include "Player.h"

////////////////// PathFinder //////////////////

Expand Down Expand Up @@ -254,7 +255,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ BuildPolyPath :: farFromPoly distToStartPoly=%.3f distToEndPoly=%.3f for %s\n",
distToStartPoly, distToEndPoly, m_sourceUnit->GetGuidStr().c_str());

bool buildShotrcut = false;
bool buildShortcut = false;
if (m_sourceUnit->GetTypeId() == TYPEID_UNIT)
{
const Creature* owner = m_sourceUnit->ToCreature();
Expand All @@ -265,20 +266,20 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ BuildPolyPath :: underWater case for %s\n", m_sourceUnit->GetGuidStr().c_str());
if (owner->CanSwim())
{
buildShotrcut = true;
buildShortcut = true;
}
}
else
{
DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ BuildPolyPath :: flying case for %s\n", m_sourceUnit->GetGuidStr().c_str());
if (owner->CanFly())
{
buildShotrcut = true;
buildShortcut = true;
}
}
}

if (buildShotrcut)
if (buildShortcut)
{
BuildShortcut();
m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
Expand Down Expand Up @@ -461,6 +462,23 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
{
m_type = PATHFIND_NORMAL;
}
#ifdef ENABLE_PLAYERBOTS
else // case for playerbots navigating polyless gaps in water nav
if (m_sourceUnit->GetMap()->GetTerrain()->IsInWater(startPos.x, startPos.y, startPos.z) &&
dtVdist(startPoint, endPoint) < 25.0f &&
m_sourceUnit->GetTypeId() == TYPEID_PLAYER &&
m_sourceUnit->GetMap()->IsInLineOfSight(startPos.x, startPos.y, startPos.z + 2.0f, endPos.x, endPos.y, endPos.z + 2.0f))

{
Player* player = (Player*)m_sourceUnit;
if (player->GetPlayerbotAI())
{
BuildShortcut();
m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
return;
}
}
#endif
else
{
m_type = PATHFIND_INCOMPLETE;
Expand Down