MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / CheckUnitTargetingCapability

Method CheckUnitTargetingCapability

src/Ext/Script/Mission.Attack.cpp:1445–1474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1443}
1444
1445bool ScriptExt::CheckUnitTargetingCapability(TechnoClass* pTechno, bool targetInAir, bool agentMode)
1446{
1447 if (!targetInAir && agentMode)
1448 return true;
1449
1450 auto checkWeaponCapability = [targetInAir](TechnoClass* pTechno, bool secondary)
1451 {
1452 if (const auto pWeapon = TechnoExt::GetCurrentWeapon(pTechno, secondary))
1453 {
1454 const auto pBulletType = pWeapon->Projectile;
1455 return (targetInAir ? pBulletType->AA : (pBulletType->AG && !BulletTypeExt::ExtMap.Find(pBulletType)->AAOnly));
1456 }
1457 return false;
1458 };
1459
1460 if (checkWeaponCapability(pTechno, false) || checkWeaponCapability(pTechno, true))
1461 return true;
1462
1463 if (!pTechno->GetTechnoType()->OpenTopped || pTechno->Passengers.NumPassengers <= 0)
1464 return false;
1465
1466 // Special case: a Leader with OpenTopped tag
1467 for (auto pPassenger = pTechno->Passengers.GetFirstPassenger(); pPassenger; pPassenger = abstract_cast<FootClass*>(pPassenger->NextObject))
1468 {
1469 if (checkWeaponCapability(pPassenger, false) || checkWeaponCapability(pPassenger, true))
1470 return true;
1471 }
1472
1473 return false;
1474}
1475
1476bool ScriptExt::IsUnitArmed(TechnoClass* pTechno)
1477{

Callers

nothing calls this directly

Calls 2

GetTechnoTypeMethod · 0.80
FindMethod · 0.45

Tested by

no test coverage detected