mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
CSpellHandler: use getBonusBearer
Use getBonusBearer method and cachingStr method for optimization
This commit is contained in:
@@ -383,7 +383,7 @@ int64_t CSpell::adjustRawDamage(const spells::Caster * caster, const battle::Uni
|
||||
//affected creature-specific part
|
||||
if(nullptr != affectedCreature)
|
||||
{
|
||||
const auto * bearer = affectedCreature;
|
||||
const auto * bearer = affectedCreature->getBonusBearer();
|
||||
//applying protections - when spell has more then one elements, only one protection should be applied (I think)
|
||||
forEachSchool([&](const spells::SchoolInfo & cnf, bool & stop)
|
||||
{
|
||||
@@ -396,11 +396,12 @@ int64_t CSpell::adjustRawDamage(const spells::Caster * caster, const battle::Uni
|
||||
});
|
||||
|
||||
CSelector selector = Selector::typeSubtype(BonusType::SPELL_DAMAGE_REDUCTION, SpellSchool(ESpellSchool::ANY));
|
||||
auto cachingStr = "type_SPELL_DAMAGE_REDUCTION_s_ANY";
|
||||
|
||||
//general spell dmg reduction, works only on magical effects
|
||||
if(bearer->hasBonus(selector) && isMagical())
|
||||
if(bearer->hasBonus(selector, cachingStr) && isMagical())
|
||||
{
|
||||
ret *= 100 - bearer->valOfBonuses(selector);
|
||||
ret *= 100 - bearer->valOfBonuses(selector, cachingStr);
|
||||
ret /= 100;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user