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