1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Include bonus from artifacts to Ballista damage, unify code

This commit is contained in:
Ivan Savenko
2025-04-14 15:50:10 +03:00
parent 1cb5f36ccb
commit db2e4c5f6d
3 changed files with 26 additions and 16 deletions

View File

@@ -62,15 +62,15 @@ DamageRange DamageCalculator::getBaseDamageSingle() const
if(info.attacker->hasBonus(selectorSiedgeWeapon, cachingStrSiedgeWeapon) && info.attacker->creatureIndex() != CreatureID::ARROW_TOWERS)
{
auto retrieveHeroPrimSkill = [&](PrimarySkill skill) -> int
{
std::shared_ptr<const Bonus> b = info.attacker->getBonus(Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL).And(Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(skill))));
return b ? b->val : 0;
};
static const auto bonusSelector =
Selector::sourceTypeSel(BonusSource::ARTIFACT).Or(
Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL)).And(
Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::ATTACK)));
//minDmg and maxDmg are multiplied by hero attack + 1
minDmg *= retrieveHeroPrimSkill(PrimarySkill::ATTACK) + 1;
maxDmg *= retrieveHeroPrimSkill(PrimarySkill::ATTACK) + 1;
//minDmg and maxDmg of a Ballista are multiplied by hero attack + 1
int heroAttackSkill = info.attacker->valOfBonuses(bonusSelector);
minDmg *= heroAttackSkill + 1;
maxDmg *= heroAttackSkill + 1;
}
return { minDmg, maxDmg };
}