本文整理汇总了C++中bwapi::UnitType::isDetector方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitType::isDetector方法的具体用法?C++ UnitType::isDetector怎么用?C++ UnitType::isDetector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bwapi::UnitType
的用法示例。
在下文中一共展示了UnitType::isDetector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAttackPriority
/// Returns target attack priority.
/// Returned value must be greater than 0
int BattlecruiserManagerExt::getAttackPriority(BWAPI::Unit * selectedUnit, BWAPI::Unit * target)
{
BWAPI::UnitType selectedUnitType = selectedUnit->getType();
BWAPI::UnitType targetType = target->getType();
bool canAttackUs = targetType.airWeapon() != BWAPI::WeaponTypes::None;
int selectedUnitWeaponRange = selectedUnitType.groundWeapon().maxRange(); // 160, Concussive
int targetWeaponRange = targetType.groundWeapon().maxRange();
// Detectors are top priority but Photon Cannons are too strong
if (targetType == BWAPI::UnitTypes::Protoss_Carrier)
{
useYamatoGun(selectedUnit, target);
return 99;
}
else if (targetType.isDetector()
&& targetType != BWAPI::UnitTypes::Protoss_Photon_Cannon)
{
useYamatoGun(selectedUnit, target);
return 100;
}
// Larvas are low priority targets
else if (targetType == BWAPI::UnitTypes::Zerg_Larva
|| targetType == BWAPI::UnitTypes::Protoss_Interceptor)
{
return 1;
}
else if (targetType == BWAPI::UnitTypes::Protoss_Pylon)
{
return 3;
}
else if ((targetType.isBuilding()) && !(targetType.canAttack()))
{
return 2;
}
// Workers are priority over ground units and buildings
else if (targetType.isWorker())
{
return 4;
}
else if (isTurret(target))
{
// Attack tower if in its weapon range
// Otherwise attack something else
if (target->isInWeaponRange(selectedUnit))
{
return 5;
}
else
{
return 1;
}
}
// Anti air units are top priority
else if (canAttackUs)
{
return selectedUnitWeaponRange + 10;
}
else
{
return 1;
}
}