| 204 | } |
| 205 | |
| 206 | bool CBot::CheckHunt(void) |
| 207 | { |
| 208 | if (!BotManager.BotsShoot()) return false; |
| 209 | |
| 210 | if (m_pHuntTarget) // Bot already has an enemy to hunt |
| 211 | { |
| 212 | // Check if the enemy is still in game |
| 213 | bool found = IsInGame(m_pHuntTarget); |
| 214 | |
| 215 | // Check if the enemy is still ingame, still alive, not joined my team and is visible |
| 216 | if (found && !isteam(m_pMyEnt->team, m_pHuntTarget->team)) |
| 217 | { |
| 218 | if ((m_pHuntTarget->state == CS_ALIVE) && IsReachable(m_vHuntLocation)) |
| 219 | return true; |
| 220 | } |
| 221 | else |
| 222 | m_pHuntTarget = NULL; |
| 223 | } |
| 224 | |
| 225 | if (m_iHuntDelay > lastmillis) return (m_pHuntTarget!=NULL); |
| 226 | |
| 227 | if (m_vHuntLocation!=g_vecZero) |
| 228 | m_vPrevHuntLocation = m_vHuntLocation; |
| 229 | |
| 230 | m_pHuntTarget = NULL; |
| 231 | m_vHuntLocation = g_vecZero; |
| 232 | |
| 233 | // Add enemy hunt search delay |
| 234 | m_iHuntDelay = lastmillis + 1500; |
| 235 | |
| 236 | playerent *pNewEnemy = NULL, *d = NULL; |
| 237 | float flDist, flNearestDist = 99999.9f, flNearestOldPosDistToEnemy = 99999.9f; |
| 238 | float flNearestOldPosDistToBot = 99999.9f; |
| 239 | short EnemyVal, BestEnemyVal = -100; |
| 240 | vec BestOldPos; |
| 241 | |
| 242 | // First loop through all bots |
| 243 | loopv(bots) |
| 244 | { |
| 245 | d = bots[i]; // Handy shortcut |
| 246 | |
| 247 | if (d == m_pMyEnt || !d || isteam(d->team, m_pMyEnt->team) || (d->state != CS_ALIVE)) |
| 248 | continue; |
| 249 | |
| 250 | flDist = GetDistance(d->o); |
| 251 | |
| 252 | if (flDist > 250.0f) continue; |
| 253 | |
| 254 | EnemyVal = 1; |
| 255 | |
| 256 | if (flDist < flNearestDist) |
| 257 | { |
| 258 | EnemyVal+=2; |
| 259 | flNearestDist = flDist; |
| 260 | } |
| 261 | |
| 262 | if (d == m_pPrevEnemy) |
| 263 | EnemyVal+=2; |
nothing calls this directly
no test coverage detected