예제 #1
0
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
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
void WeaponProps::SetType(BWAPI::WeaponType type)
{
	this->type		= type;
	cooldown[0]		= cooldown[1]		= type.damageCooldown();
	maxRange[0]		= maxRange[1]		= type.maxRange() << pixelShift;
}