| 1443 | } |
| 1444 | |
| 1445 | bool 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 | |
| 1476 | bool ScriptExt::IsUnitArmed(TechnoClass* pTechno) |
| 1477 | { |
nothing calls this directly
no test coverage detected