1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

AI will now devalue the usefulness of non-flying units when attacking defensive structures in order to prevent suiciding against castles

This commit is contained in:
Xilmi
2024-12-28 12:40:44 +01:00
committed by Ivan Savenko
parent d3987d8456
commit 6c4996ff54
6 changed files with 33 additions and 10 deletions

View File

@@ -353,11 +353,23 @@ bool CCreatureSet::needsLastStack() const
return false;
}
ui64 CCreatureSet::getArmyStrength() const
ui64 CCreatureSet::getArmyStrength(int fortLevel) const
{
ui64 ret = 0;
for(const auto & elem : stacks)
ret += elem.second->getPower();
for (const auto& elem : stacks)
{
ui64 powerToAdd = elem.second->getPower();
if (fortLevel > 0)
{
if (!elem.second->hasBonusOfType(BonusType::FLYING))
{
powerToAdd /= fortLevel;
if (!elem.second->hasBonusOfType(BonusType::SHOOTER))
powerToAdd /= fortLevel;
}
}
ret += powerToAdd;
}
return ret;
}