mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Include bonus from artifacts to Ballista damage, unify code
This commit is contained in:
@@ -633,9 +633,20 @@ void StackInfoBasicPanel::initializeData(const CStack * stack)
|
||||
icons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("TWCRPORT"), stack->creatureId() + 2, 0, 10, 6));
|
||||
labels.push_back(std::make_shared<CLabel>(10 + 58, 6 + 64, FONT_MEDIUM, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, TextOperations::formatMetric(stack->getCount(), 4)));
|
||||
|
||||
int damageMultiplier = 1;
|
||||
if (stack->hasBonusOfType(BonusType::SIEGE_WEAPON))
|
||||
{
|
||||
static const auto bonusSelector =
|
||||
Selector::sourceTypeSel(BonusSource::ARTIFACT).Or(
|
||||
Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL)).And(
|
||||
Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::ATTACK)));
|
||||
|
||||
damageMultiplier += stack->valOfBonuses(bonusSelector);
|
||||
}
|
||||
|
||||
auto attack = std::to_string(LIBRARY->creatures()->getByIndex(stack->creatureIndex())->getAttack(stack->isShooter())) + "(" + std::to_string(stack->getAttack(stack->isShooter())) + ")";
|
||||
auto defense = std::to_string(LIBRARY->creatures()->getByIndex(stack->creatureIndex())->getDefense(stack->isShooter())) + "(" + std::to_string(stack->getDefense(stack->isShooter())) + ")";
|
||||
auto damage = std::to_string(LIBRARY->creatures()->getByIndex(stack->creatureIndex())->getMinDamage(stack->isShooter())) + "-" + std::to_string(stack->getMaxDamage(stack->isShooter()));
|
||||
auto damage = std::to_string(damageMultiplier * stack->getMinDamage(stack->isShooter())) + "-" + std::to_string(damageMultiplier * stack->getMaxDamage(stack->isShooter()));
|
||||
auto health = stack->getMaxHealth();
|
||||
auto morale = stack->moraleVal();
|
||||
auto luck = stack->luckVal();
|
||||
|
||||
@@ -592,18 +592,17 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s
|
||||
|
||||
name = std::make_shared<CLabel>(215, 13, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, parent->info->getName());
|
||||
|
||||
const BattleInterface* battleInterface = GAME->interface()->battleInt.get();
|
||||
const CStack* battleStack = parent->info->stack;
|
||||
|
||||
int dmgMultiply = 1;
|
||||
if (battleInterface && battleInterface->getBattle() != nullptr && battleStack->hasBonusOfType(BonusType::SIEGE_WEAPON))
|
||||
if (battleStack != nullptr && battleStack->hasBonusOfType(BonusType::SIEGE_WEAPON))
|
||||
{
|
||||
// Determine the relevant hero based on the unit side
|
||||
const auto hero = (battleStack->unitSide() == BattleSide::ATTACKER)
|
||||
? battleInterface->attackingHeroInstance
|
||||
: battleInterface->defendingHeroInstance;
|
||||
static const auto bonusSelector =
|
||||
Selector::sourceTypeSel(BonusSource::ARTIFACT).Or(
|
||||
Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL)).And(
|
||||
Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::ATTACK)));
|
||||
|
||||
dmgMultiply += hero->getPrimSkillLevel(PrimarySkill::ATTACK);
|
||||
dmgMultiply += battleStack->valOfBonuses(bonusSelector);
|
||||
}
|
||||
|
||||
icons = std::make_shared<CPicture>(ImagePath::builtin("stackWindow/icons"), 117, 32);
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user