当前位置: 首页>>代码示例>>C++>>正文


C++ UnitType::canAttack方法代码示例

本文整理汇总了C++中bwapi::UnitType::canAttack方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitType::canAttack方法的具体用法?C++ UnitType::canAttack怎么用?C++ UnitType::canAttack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bwapi::UnitType的用法示例。


在下文中一共展示了UnitType::canAttack方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getAttackPriority

/// Returns target attack priority.
/// Returned value must be greater than 0
int VultureManagerExt::getAttackPriority(BWAPI::Unit * selectedUnit, BWAPI::Unit * target)
{
	BWAPI::UnitType selectedUnitType = selectedUnit->getType();
	BWAPI::UnitType targetType = target->getType();

	bool canAttackUs = targetType.groundWeapon() != BWAPI::WeaponTypes::None;
	int selectedUnitWeaponRange = selectedUnitType.groundWeapon().maxRange();		// 160, Concussive
	int targetWeaponRange = targetType.groundWeapon().maxRange();


	// Larvas are low priority targets
	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;
	}
	else if (targetType == BWAPI::UnitTypes::Protoss_Photon_Cannon)
	{
		return 4;
	}
	// Templars are extremely dangerous to bio units and should be eliminated asap.
	else if (targetType == BWAPI::UnitTypes::Protoss_High_Templar
		|| targetType == BWAPI::UnitTypes::Terran_Medic)
	{
		return selectedUnitWeaponRange + 10;
	}
	// Faster than Marine (without Stimpack)
	else if ((targetType.topSpeed() >= selectedUnitType.topSpeed())
		|| ((targetType == BWAPI::UnitTypes::Protoss_Zealot)
		&& (BWAPI::Broodwar->enemy()->getUpgradeLevel(BWAPI::UpgradeTypes::Leg_Enhancements) > 0)))
	{
		return selectedUnitWeaponRange;		// return 160
	}
	// Slower than Vulture
	else
	{
		int priority = selectedUnitWeaponRange - targetWeaponRange;
		if (priority <= 0)
		{
			priority = 1;
		}

		return priority;
	}

}
开发者ID:filipbober,项目名称:scaiCode,代码行数:56,代码来源:VultureManagerExt.cpp

示例2: isCombatUnit

bool InformationManager::isCombatUnit(BWAPI::UnitType type) const
{
	if (type == BWAPI::UnitTypes::Zerg_Lurker/* || type == BWAPI::UnitTypes::Protoss_Dark_Templar*/)
	{
		return false;
	}

	// check for various types of combat units
	if (type.canAttack() || 
		type == BWAPI::UnitTypes::Terran_Medic || 
		type == BWAPI::UnitTypes::Protoss_Observer ||
        type == BWAPI::UnitTypes::Terran_Bunker)
	{
		return true;
	}
		
	return false;
}
开发者ID:0x4849,项目名称:c350,代码行数:18,代码来源:InformationManager.cpp

示例3: setShortName

// UnitType constructor
ActionTypeData::ActionTypeData(BWAPI::UnitType t, const ActionID id) 
	: type                      (UnitType)
	, unit                      (t)
    , raceID                    (GetRaceID(t.getRace()))
	, actionID                  (id)
	, mineralPriceVal           (t.mineralPrice() * Constants::RESOURCE_SCALE)
	, gasPriceVal               (t.gasPrice() * Constants::RESOURCE_SCALE)
	, supplyRequiredVal         (t.supplyRequired())
	, supplyProvidedVal         (t.supplyProvided())
	, buildTimeVal              (t.buildTime())
	, numberProduced            (1)
	, name                      (t.getName())
	, metaName                  (t.getName())
	, building                  (t.isBuilding())
	, worker                    (t.isWorker())
	, refinery                  (t.isRefinery())
	, resourceDepot             (t.isResourceDepot())
	, supplyProvider            (t.supplyProvided() > 0 && !t.isResourceDepot())
	, canProduceBool            (t.isBuilding() && t.canProduce())
	, canAttackBool             (t.canAttack())
	, whatBuildsUnitType        (t.whatBuilds().first)
    , addon                     (t.isAddon())
    , morphed                   (false)
    , reqAddon                  (false)
    , reqAddonID                (0)
{
	if (t == BWAPI::UnitTypes::Zerg_Zergling || t == BWAPI::UnitTypes::Zerg_Scourge)
	{
		numberProduced = 2;
	}

    if (t == BWAPI::UnitTypes::Zerg_Lair ||
        t == BWAPI::UnitTypes::Zerg_Hive ||
        t == BWAPI::UnitTypes::Zerg_Greater_Spire ||
        t == BWAPI::UnitTypes::Zerg_Lurker ||
        t == BWAPI::UnitTypes::Zerg_Guardian ||
        t == BWAPI::UnitTypes::Zerg_Sunken_Colony ||
        t == BWAPI::UnitTypes::Zerg_Spore_Colony)
    {
        morphed = true;
    }

    setShortName();
}
开发者ID:Cdingram,项目名称:GGEZ-Bot,代码行数:45,代码来源:ActionTypeData.cpp

示例4: 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;
	}
}
开发者ID:filipbober,项目名称:scaiCode,代码行数:66,代码来源:BattlecruiserManagerExt.cpp


注:本文中的bwapi::UnitType::canAttack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。