returns true when done or failure
| 2247 | |
| 2248 | // returns true when done or failure |
| 2249 | bool CBot::HeadToGoal() |
| 2250 | { |
| 2251 | // Does the bot has a goal(waypoint)? |
| 2252 | if (m_pCurrentGoalWaypoint) |
| 2253 | { |
| 2254 | if (ReachedGoalWP()) |
| 2255 | { |
| 2256 | return false; |
| 2257 | } |
| 2258 | else |
| 2259 | { |
| 2260 | if (CurrentWPIsValid()) |
| 2261 | { |
| 2262 | if (m_bCalculatingAStarPath) |
| 2263 | { |
| 2264 | // Bot is calculating a new path, just stand still for now |
| 2265 | ResetMoveSpeed(); |
| 2266 | m_iWaypointTime += 200; |
| 2267 | |
| 2268 | // Done calculating the path? |
| 2269 | if (AStar()) |
| 2270 | { |
| 2271 | if (m_AStarNodeList.Empty()) |
| 2272 | { |
| 2273 | return false; // Couldn't find a path |
| 2274 | } |
| 2275 | //else |
| 2276 | // SetCurrentWaypoint(m_AStarNodeList.Pop()); |
| 2277 | } |
| 2278 | else |
| 2279 | return true; // else just wait a little bit longer |
| 2280 | } |
| 2281 | //ResetMoveSpeed(); |
| 2282 | //return true; |
| 2283 | } |
| 2284 | else |
| 2285 | { |
| 2286 | // Current waypoint isn't reachable, search new one |
| 2287 | waypoint_s *pWP = NULL; |
| 2288 | |
| 2289 | #ifdef WP_FLOOD |
| 2290 | if (m_pCurrentGoalWaypoint->pNode->iFlags & W_FL_FLOOD) |
| 2291 | pWP = GetNearestFloodWP(8.0f); |
| 2292 | else |
| 2293 | #endif |
| 2294 | pWP = GetNearestWaypoint(15.0f); |
| 2295 | |
| 2296 | if (!pWP || (pWP == m_pCurrentWaypoint)) |
| 2297 | return false; |
| 2298 | |
| 2299 | SetCurrentWaypoint(pWP); |
| 2300 | if (AStar()) |
| 2301 | { |
| 2302 | if (m_AStarNodeList.Empty()) return false; |
| 2303 | } |
| 2304 | else |
| 2305 | { |
| 2306 | m_iWaypointTime += 200; |