MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / CheckArcadeDestroyMoveHelper

Function CheckArcadeDestroyMoveHelper

engine/Poseidon/AI/AIArcade.cpp:1300–1339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1298}
1299
1300static 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
1341static void ArcadeDestroyMove(AIGroupContext* context)
1342{

Callers 2

ArcadeDestroyMoveFunction · 0.85
AIArcade.cppFile · 0.85

Calls 8

GetDestroyTargetFunction · 0.85
IsKnownByMethod · 0.80
SquareFunction · 0.50
LeaderMethod · 0.45
PositionMethod · 0.45
SquareSizeXZMethod · 0.45
SetStateMethod · 0.45
FindTargetMethod · 0.45

Tested by

no test coverage detected