| 2003 | } |
| 2004 | |
| 2005 | bool CBot::HeadToWaypoint() |
| 2006 | { |
| 2007 | if (!m_pCurrentWaypoint) |
| 2008 | return false; // Can't head to waypoint |
| 2009 | |
| 2010 | bool Touching = false; |
| 2011 | float WPDist = GetDistance(m_pCurrentWaypoint->pNode->v_origin); |
| 2012 | |
| 2013 | #ifndef RELEASE_BUILD |
| 2014 | if (m_pCurrentGoalWaypoint && m_vGoal==g_vecZero) |
| 2015 | condebug("Warning: m_vGoal unset"); |
| 2016 | #endif |
| 2017 | |
| 2018 | // did the bot run past the waypoint? (prevent the loop-the-loop problem) |
| 2019 | if ((m_fPrevWaypointDistance > 1.0) && (WPDist > m_fPrevWaypointDistance) && |
| 2020 | (WPDist <= 5.0f)) |
| 2021 | Touching = true; |
| 2022 | // bot needs to be close for jump and trigger waypoints |
| 2023 | else if ((m_pCurrentWaypoint->pNode->iFlags & W_FL_JUMP) || |
| 2024 | (m_pCurrentWaypoint->pNode->iFlags & W_FL_TRIGGER)) |
| 2025 | Touching = (WPDist <= 1.5f); |
| 2026 | else if (m_pCurrentWaypoint->pNode->iFlags & W_FL_TELEPORT) |
| 2027 | Touching = (WPDist <= 4.0f); |
| 2028 | // are we close enough to a target waypoint... |
| 2029 | else if (WPDist <= 3.0f) |
| 2030 | { |
| 2031 | if (!m_pCurrentGoalWaypoint || (m_pCurrentWaypoint != m_pCurrentGoalWaypoint) || |
| 2032 | IsVisible(m_vGoal) || (WPDist <= 1.5f)) |
| 2033 | Touching = true; |
| 2034 | // If the bot has a goal check if he can see his next wp |
| 2035 | if (m_pCurrentGoalWaypoint && (m_pCurrentGoalWaypoint != m_pCurrentWaypoint) && |
| 2036 | !m_AStarNodeList.Empty() && (WPDist >= 1.0f) && |
| 2037 | !IsVisible(m_AStarNodeList.GetFirst()->Entry->pNode->v_origin)) |
| 2038 | Touching = false; |
| 2039 | } |
| 2040 | |
| 2041 | // save current distance as previous |
| 2042 | m_fPrevWaypointDistance = WPDist; |
| 2043 | |
| 2044 | // Reached the waypoint? |
| 2045 | if (Touching) |
| 2046 | { |
| 2047 | // Does this waypoint has a targetyaw? |
| 2048 | if (m_pCurrentWaypoint->pNode->sYaw != -1) |
| 2049 | { |
| 2050 | // UNDONE: Inhuman |
| 2051 | m_pMyEnt->yaw = m_pMyEnt->targetyaw = m_pCurrentWaypoint->pNode->sYaw; |
| 2052 | } |
| 2053 | |
| 2054 | // Reached a jump waypoint? |
| 2055 | if (m_pCurrentWaypoint->pNode->iFlags & W_FL_JUMP) |
| 2056 | m_pMyEnt->jumpnext = true; |
| 2057 | |
| 2058 | m_fPrevWaypointDistance = 0.0f; |
| 2059 | |
| 2060 | // Does the bot has a goal? |
| 2061 | if (m_pCurrentGoalWaypoint) |
| 2062 | { |
nothing calls this directly
no test coverage detected