mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Tweak Battle AI damage prioritization score logic
This commit is contained in:
parent
f68b449e5e
commit
2727958a63
@ -67,14 +67,8 @@ AttackPossibility AttackPossibility::evaluate(const BattleAttackInfo & attackInf
|
||||
auto defender = attackInfo.defender;
|
||||
const std::string cachingStringBlocksRetaliation = "type_BLOCKS_RETALIATION";
|
||||
static const auto selectorBlocksRetaliation = Selector::type(Bonus::BLOCKS_RETALIATION);
|
||||
const auto attackerSide = getCbc()->playerToSide(getCbc()->battleGetOwner(attacker));
|
||||
const bool counterAttacksBlocked = attacker->hasBonus(selectorBlocksRetaliation, cachingStringBlocksRetaliation);
|
||||
const bool mindControlled = [&](const battle::Unit *attacker) -> bool
|
||||
{
|
||||
auto actualSide = getCbc()->playerToSide(getCbc()->battleGetOwner(attacker));
|
||||
if (actualSide && actualSide.get() != attacker->unitSide())
|
||||
return true;
|
||||
return false;
|
||||
} (attacker);
|
||||
|
||||
AttackPossibility bestAp(hex, BattleHex::INVALID, attackInfo);
|
||||
|
||||
@ -153,10 +147,14 @@ AttackPossibility AttackPossibility::evaluate(const BattleAttackInfo & attackInf
|
||||
defenderState->afterAttack(attackInfo.shooting, true);
|
||||
}
|
||||
|
||||
bool isEnemy = state->battleMatchOwner(attacker, u) && !mindControlled;
|
||||
bool isEnemy = state->battleMatchOwner(attacker, u);
|
||||
|
||||
// this includes enemy units as well as attacker units under enemy's mind control
|
||||
if(isEnemy)
|
||||
ap.damageDealt += damageDealt;
|
||||
else // friendly fire
|
||||
|
||||
// damaging attacker's units (even those under enemy's mind control) is considered friendly fire
|
||||
if(attackerSide == u->unitSide())
|
||||
ap.collateralDamage += damageDealt;
|
||||
|
||||
if(u->unitId() == defender->unitId() ||
|
||||
|
Loading…
Reference in New Issue
Block a user