mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Merge pull request #4241 from vcmi/fix_damage_estimation
Limit predicted damage / loses to actual stack health
This commit is contained in:
commit
7ec702bac3
@ -77,6 +77,15 @@ public:
|
||||
// FIXME: provide distance info for Jousting bonus
|
||||
DamageEstimation retal;
|
||||
DamageEstimation dmg = cb->getBattle(battleID)->battleEstimateDamage(ourStack, s, 0, &retal);
|
||||
// Clip damage dealt to total stack health
|
||||
auto totalHealth = s->getTotalHealth();
|
||||
vstd::amin(dmg.damage.min, totalHealth);
|
||||
vstd::amin(dmg.damage.max, totalHealth);
|
||||
|
||||
auto ourHealth = s->getTotalHealth();
|
||||
vstd::amin(retal.damage.min, ourHealth);
|
||||
vstd::amin(retal.damage.max, ourHealth);
|
||||
|
||||
adi = static_cast<int>((dmg.damage.min + dmg.damage.max) / 2);
|
||||
adr = static_cast<int>((retal.damage.min + retal.damage.max) / 2);
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ int64_t DamageCalculator::getCasualties(int64_t damageDealt) const
|
||||
int64_t damageLeft = damageDealt - info.defender->getFirstHPleft();
|
||||
int64_t killsLeft = damageLeft / info.defender->getMaxHealth();
|
||||
|
||||
return 1 + killsLeft;
|
||||
return std::min<int32_t>(1 + killsLeft, info.defender->getCount());
|
||||
}
|
||||
|
||||
int DamageCalculator::battleBonusValue(const IBonusBearer * bearer, const CSelector & selector) const
|
||||
|
Loading…
Reference in New Issue
Block a user