コード例 #1
0
ファイル: Unit.cpp プロジェクト: SPQRBrutus/skynetbot
int UnitClass::getTimeToKill(Unit unit)
{
	int health = unit->totalHitPoints();

	BWAPI::WeaponType weapon = getWeapon(unit);

	int weaponDamage = weapon.damageAmount() + (weapon.damageFactor() * getPlayer()->getUpgradeLevel(weapon.upgradeType()));
	if(weaponDamage == 0)
		return 5000;

	int thisNumberOfShots = health / weaponDamage;

	if(weapon.damageType() == BWAPI::DamageTypes::Concussive)
	{
		if(unit->getType().size() == BWAPI::UnitSizeTypes::Large)
			thisNumberOfShots *= 4;
		else if(unit->getType().size() == BWAPI::UnitSizeTypes::Medium)
			thisNumberOfShots += thisNumberOfShots;
	}
	else if(weapon.damageType() == BWAPI::DamageTypes::Explosive)
	{
		if(unit->getType().size() == BWAPI::UnitSizeTypes::Small)
			thisNumberOfShots += thisNumberOfShots;
		else if(unit->getType().size() == BWAPI::UnitSizeTypes::Medium)
			thisNumberOfShots += thisNumberOfShots / 2;
	}

	if((BWAPI::Broodwar->getGroundHeight(getTilePosition()) - BWAPI::Broodwar->getGroundHeight(unit->getTilePosition())) < 0)
		thisNumberOfShots += thisNumberOfShots;

	return thisNumberOfShots * weapon.damageCooldown();
}
コード例 #2
0
ファイル: UnitUtil.cpp プロジェクト: Cdingram/GGEZ-Bot
double UnitUtil::CalculateLTD(BWAPI::Unit attacker, BWAPI::Unit target)
{
    BWAPI::WeaponType weapon = GetWeapon(attacker, target);

    if (weapon == BWAPI::WeaponTypes::None)
    {
        return 0;
    }

    return static_cast<double>(weapon.damageAmount()) / weapon.damageCooldown();
}
コード例 #3
0
ファイル: SpecProps.cpp プロジェクト: welwa/ualbertabot
void WeaponProps::SetType(BWAPI::WeaponType type)
{
	this->type		= type;
	cooldown[0]		= cooldown[1]		= type.damageCooldown();
	maxRange[0]		= maxRange[1]		= type.maxRange() << pixelShift;
}