| 1298 | } |
| 1299 | |
| 1300 | static bool CheckArcadeDestroyMoveHelper(AIGroupContext* context) |
| 1301 | { |
| 1302 | STATE_PREFIX |
| 1303 | |
| 1304 | AIUnit* leader = group->Leader(); |
| 1305 | if (!leader) |
| 1306 | { |
| 1307 | return false; |
| 1308 | } |
| 1309 | |
| 1310 | Vector3Val posL = leader->Position(); |
| 1311 | Vector3Val posD = mission->_destination; |
| 1312 | const float maxDist = 1000; |
| 1313 | const float minDist = 50; |
| 1314 | float dist2 = (posD - posL).SquareSizeXZ(); |
| 1315 | if (dist2 <= Square(maxDist)) |
| 1316 | { |
| 1317 | // check if target is visible |
| 1318 | TargetType* obj = GetDestroyTarget(context); |
| 1319 | if (!obj) |
| 1320 | { |
| 1321 | context->_fsm->SetState(SArcadeDestroyAttack, context); |
| 1322 | return true; |
| 1323 | } |
| 1324 | Target* tgt = group->FindTarget(obj); |
| 1325 | if (tgt && tgt->IsKnownBy(leader)) |
| 1326 | { |
| 1327 | // target found - start attacking |
| 1328 | context->_fsm->SetState(SArcadeDestroyAttack, context); |
| 1329 | return true; |
| 1330 | } |
| 1331 | if (dist2 <= Square(minDist)) |
| 1332 | { |
| 1333 | // target not found - start checking around |
| 1334 | context->_fsm->SetState(SArcadeDestroyBrown, context); |
| 1335 | return true; |
| 1336 | } |
| 1337 | } |
| 1338 | return false; |
| 1339 | } |
| 1340 | |
| 1341 | static void ArcadeDestroyMove(AIGroupContext* context) |
| 1342 | { |
no test coverage detected