mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
BattleAI: stacks should not measure damage against turret
This commit is contained in:
parent
0829593356
commit
fe65edd55d
@ -50,7 +50,22 @@ int64_t AttackPossibility::calculateDamageReduce(
|
||||
vstd::amin(damageDealt, defender->getAvailableHealth());
|
||||
|
||||
// FIXME: provide distance info for Jousting bonus
|
||||
auto enemyDamageBeforeAttack = cb.battleEstimateDamage(defender, attacker, 0);
|
||||
auto attackerUnitForMeasurement = attacker;
|
||||
|
||||
if(attackerUnitForMeasurement->isTurret())
|
||||
{
|
||||
auto ourUnits = cb.battleGetUnitsIf([&](const battle::Unit * u) -> bool
|
||||
{
|
||||
return u->unitSide() == attacker->unitSide() && !u->isTurret();
|
||||
});
|
||||
|
||||
if(ourUnits.empty())
|
||||
attackerUnitForMeasurement = defender;
|
||||
else
|
||||
attackerUnitForMeasurement = ourUnits.front();
|
||||
}
|
||||
|
||||
auto enemyDamageBeforeAttack = cb.battleEstimateDamage(defender, attackerUnitForMeasurement, 0);
|
||||
auto enemiesKilled = damageDealt / defender->getMaxHealth() + (damageDealt % defender->getMaxHealth() >= defender->getFirstHPleft() ? 1 : 0);
|
||||
auto enemyDamage = averageDmg(enemyDamageBeforeAttack.damage);
|
||||
auto damagePerEnemy = enemyDamage / (double)defender->getCount();
|
||||
|
@ -386,9 +386,13 @@ int64_t BattleExchangeEvaluator::calculateExchange(
|
||||
|
||||
for(auto unit : exchangeUnits)
|
||||
{
|
||||
if(unit->isTurret())
|
||||
continue;
|
||||
|
||||
bool isOur = cb->battleMatchOwner(ap.attack.attacker, unit, true);
|
||||
auto & attackerQueue = isOur ? ourStacks : enemyStacks;
|
||||
|
||||
|
||||
if(!vstd::contains(attackerQueue, unit))
|
||||
{
|
||||
attackerQueue.push_back(unit);
|
||||
@ -593,6 +597,9 @@ void BattleExchangeEvaluator::updateReachabilityMap(HypotheticBattle & hb)
|
||||
|
||||
for(const battle::Unit * unit : turnQueue)
|
||||
{
|
||||
if(unit->isTurret())
|
||||
continue;
|
||||
|
||||
if(turnBattle.battleCanShoot(unit))
|
||||
{
|
||||
for(BattleHex hex = BattleHex::TOP_LEFT; hex.isValid(); hex = hex + 1)
|
||||
|
Loading…
Reference in New Issue
Block a user