1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

expose safeAttackRatio to AI config

This commit is contained in:
Ivan Savenko
2024-11-28 11:53:51 +00:00
parent 00492a60a7
commit b25702f15e
11 changed files with 23 additions and 21 deletions

View File

@@ -146,21 +146,21 @@ bool HeroPtr::operator==(const HeroPtr & rhs) const
return h == rhs.get(true);
}
bool isSafeToVisit(const CGHeroInstance * h, const CCreatureSet * heroArmy, uint64_t dangerStrength)
bool isSafeToVisit(const CGHeroInstance * h, const CCreatureSet * heroArmy, uint64_t dangerStrength, float safeAttackRatio)
{
const ui64 heroStrength = h->getHeroStrength() * heroArmy->getArmyStrength();
if(dangerStrength)
{
return heroStrength / SAFE_ATTACK_CONSTANT > dangerStrength;
return heroStrength > dangerStrength * safeAttackRatio;
}
return true; //there's no danger
}
bool isSafeToVisit(const CGHeroInstance * h, uint64_t dangerStrength)
bool isSafeToVisit(const CGHeroInstance * h, uint64_t dangerStrength, float safeAttackRatio)
{
return isSafeToVisit(h, h, dangerStrength);
return isSafeToVisit(h, h, dangerStrength, safeAttackRatio);
}
bool isObjectRemovable(const CGObjectInstance * obj)