Example #1
0
bool CPathFind::CanSeePoint(position_t point)
{
    if (isNavMeshEnabled())
    {
        return m_PTarget->loc.zone->m_navMesh->raycast(m_PTarget->loc.p, point);
    }

    return true;
}
Example #2
0
bool CPathFind::InWater()
{
	if (isNavMeshEnabled())
	{
		return m_PTarget->loc.zone->m_navMesh->inWater(m_PTarget->loc.p);
	}

	return false;
}
Example #3
0
bool CPathFind::ValidPosition(position_t* pos)
{
    if (isNavMeshEnabled())
    {
        return m_PTarget->loc.zone->m_navMesh->validPosition(*pos);
    }
    else
    {
        return true;
    }
}
Example #4
0
bool CPathFind::RoamAround(position_t point, uint8 roamFlags)
{
	Clear();

	m_roamFlags = roamFlags;

	if (isNavMeshEnabled())
	{

		// all mobs will default to this distance
		float maxRadius = 25.0f;

		// sight aggro mobs will move a bit farther
		// this is until this data is put in the database
		if (m_roamFlags & ROAMFLAG_MEDIUM)
		{
			maxRadius = 35.0f;
		}

		// TODO: finish roam flags. distance should have a distance limit

		if (FindRandomPath(&point, maxRadius))
		{
			return true;
		}
		else
		{
			Clear();
			return false;
		}
	}
	else
	{

		// no point worm roaming cause it'll move one inch
		if (m_roamFlags & ROAMFLAG_WORM)
		{
			Clear();
			return false;
		}

		// ew, we gotta use the old way
		m_pathLength = 1;

		m_points[0].x = point.x - 1 + rand() % 2;
		m_points[0].y = point.y;
		m_points[0].z = point.z - 1 + rand() % 2;

	}

	return true;
}
Example #5
0
bool CPathFind::PathTo(position_t point, uint8 pathFlags, bool clear)
{
    // don't follow a new path if the current path has script flag and new path doesn't
    if (IsFollowingPath() && (m_pathFlags & PATHFLAG_SCRIPT) && !(pathFlags & PATHFLAG_SCRIPT))
        return false;

    if (clear)
    {
        Clear();
    }

    m_pathFlags = pathFlags;

    if (isNavMeshEnabled())
    {
        bool result = false;

        if (m_pathFlags & PATHFLAG_WALLHACK)
        {
            result = FindClosestPath(&m_PTarget->loc.p, &point);
        }
        else
        {
            result = FindPath(&m_PTarget->loc.p, &point);
        }

        if (!result)
        {
            Clear();
        }

        return result;
    }
    else
    {
        m_pathLength = 1;

        m_points[0].x = point.x;
        m_points[0].y = point.y;
        m_points[0].z = point.z;
    }

    return true;
}
Example #6
0
bool CPathFind::RoamAround(position_t point, float maxRadius, uint8 maxTurns, uint8 roamFlags)
{
    Clear();

    m_roamFlags = roamFlags;

    if (isNavMeshEnabled())
    {

        if (FindRandomPath(&point, maxRadius, maxTurns, roamFlags))
        {
            return true;
        }
        else
        {
            Clear();
            return false;
        }
    }
    else
    {

        // no point worm roaming cause it'll move one inch
        if (m_roamFlags & ROAMFLAG_WORM)
        {
            Clear();
            return false;
        }

        // ew, we gotta use the old way
        m_pathLength = 1;

        m_points[0].x = point.x - 1 + rand() % 2;
        m_points[0].y = point.y;
        m_points[0].z = point.z - 1 + rand() % 2;

    }

    return true;
}
Example #7
0
void CPathFind::FinishedPath()
{
    m_currentTurn++;

    // turning is only available to navmeshed maps
    if (m_currentTurn < m_turnLength && isNavMeshEnabled())
    {
        // move on to next turn
        position_t* nextTurn = &m_turnPoints[m_currentTurn];

        bool result = FindPath(&m_PTarget->loc.p, nextTurn);

        if (!result)
        {
            Clear();
        }
    }
    else
    {
        Clear();
    }
}