@@ -1378,7 +1378,7 @@ uint32_t Battle::Unit::CalculateSpellDamage( const Spell & spell, uint32_t spell
1378
1378
assert ( spell.isDamage () );
1379
1379
1380
1380
// TODO: use fheroes2::getSpellDamage function to remove code duplication.
1381
- uint32_t dmg = spell. Damage () * spellPoints;
1381
+ uint32_t dmg = fheroes2::getSpellDamage ( spell, spellPoints, applyingHero ) ;
1382
1382
1383
1383
switch ( GetID () ) {
1384
1384
case Monster::IRON_GOLEM:
@@ -1449,20 +1449,15 @@ uint32_t Battle::Unit::CalculateSpellDamage( const Spell & spell, uint32_t spell
1449
1449
switch ( spell.GetID () ) {
1450
1450
case Spell::COLDRAY:
1451
1451
case Spell::COLDRING: {
1452
- std::vector<int32_t > extraDamagePercent
1453
- = applyingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactBonusType::COLD_SPELL_EXTRA_EFFECTIVENESS_PERCENT );
1454
- for ( const int32_t value : extraDamagePercent ) {
1455
- dmg = dmg * ( 100 + value ) / 100 ;
1456
- }
1457
-
1458
1452
if ( useDefendingHeroArts ) {
1459
1453
const std::vector<int32_t > damageReductionPercent
1460
1454
= defendingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactBonusType::COLD_SPELL_DAMAGE_REDUCTION_PERCENT );
1461
1455
for ( const int32_t value : damageReductionPercent ) {
1462
1456
dmg = dmg * ( 100 - value ) / 100 ;
1463
1457
}
1464
1458
1465
- extraDamagePercent = defendingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactCurseType::COLD_SPELL_EXTRA_DAMAGE_PERCENT );
1459
+ const std::vector<int32_t > extraDamagePercent
1460
+ = defendingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactCurseType::COLD_SPELL_EXTRA_DAMAGE_PERCENT );
1466
1461
for ( const int32_t value : extraDamagePercent ) {
1467
1462
dmg = dmg * ( 100 + value ) / 100 ;
1468
1463
}
@@ -1472,20 +1467,15 @@ uint32_t Battle::Unit::CalculateSpellDamage( const Spell & spell, uint32_t spell
1472
1467
}
1473
1468
case Spell::FIREBALL:
1474
1469
case Spell::FIREBLAST: {
1475
- std::vector<int32_t > extraDamagePercent
1476
- = applyingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactBonusType::FIRE_SPELL_EXTRA_EFFECTIVENESS_PERCENT );
1477
- for ( const int32_t value : extraDamagePercent ) {
1478
- dmg = dmg * ( 100 + value ) / 100 ;
1479
- }
1480
-
1481
1470
if ( useDefendingHeroArts ) {
1482
1471
const std::vector<int32_t > damageReductionPercent
1483
1472
= defendingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactBonusType::FIRE_SPELL_DAMAGE_REDUCTION_PERCENT );
1484
1473
for ( const int32_t value : damageReductionPercent ) {
1485
1474
dmg = dmg * ( 100 - value ) / 100 ;
1486
1475
}
1487
1476
1488
- extraDamagePercent = defendingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactCurseType::FIRE_SPELL_EXTRA_DAMAGE_PERCENT );
1477
+ const std::vector<int32_t > extraDamagePercent
1478
+ = defendingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactCurseType::FIRE_SPELL_EXTRA_DAMAGE_PERCENT );
1489
1479
for ( const int32_t value : extraDamagePercent ) {
1490
1480
dmg = dmg * ( 100 + value ) / 100 ;
1491
1481
}
@@ -1495,12 +1485,6 @@ uint32_t Battle::Unit::CalculateSpellDamage( const Spell & spell, uint32_t spell
1495
1485
}
1496
1486
case Spell::LIGHTNINGBOLT:
1497
1487
case Spell::CHAINLIGHTNING: {
1498
- const std::vector<int32_t > extraDamagePercent
1499
- = applyingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactBonusType::LIGHTNING_SPELL_EXTRA_EFFECTIVENESS_PERCENT );
1500
- for ( const int32_t value : extraDamagePercent ) {
1501
- dmg = dmg * ( 100 + value ) / 100 ;
1502
- }
1503
-
1504
1488
if ( useDefendingHeroArts ) {
1505
1489
const std::vector<int32_t > damageReductionPercent
1506
1490
= defendingHero->GetBagArtifacts ().getTotalArtifactMultipliedPercent ( fheroes2::ArtifactBonusType::LIGHTNING_SPELL_DAMAGE_REDUCTION_PERCENT );
0 commit comments