mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
vcmi: spell resistance rework
Now instead of XXX_IMMUNITY bonuses we have 2 bonuses with spellSchool subtype: SPELL_SCHOOL_IMMUNITY and NEGATIVE_EFFECT_IMMUNITY. All previous bonuses of subtype 0 is covered by SPELL_SCHOOL_IMMUNITY, and all previous bonuses of subtype 1 is covered by NEGATIVE_EFFECT_IMMUNITY. Unit tests are updated accordingly.
This commit is contained in:
@@ -620,14 +620,14 @@ int32_t CGHeroInstance::getSpellSchoolLevel(const spells::Spell * spell, int32_t
|
||||
{
|
||||
int32_t skill = -1; //skill level
|
||||
|
||||
spell->forEachSchool([&, this](const spells::SchoolInfo & cnf, bool & stop)
|
||||
spell->forEachSchool([&, this](const ESpellSchool & cnf, bool & stop)
|
||||
{
|
||||
int32_t thisSchool = valOfBonuses(BonusType::MAGIC_SCHOOL_SKILL, cnf.id); //FIXME: Bonus shouldn't be additive (Witchking Artifacts : Crown of Skies)
|
||||
int32_t thisSchool = valOfBonuses(BonusType::MAGIC_SCHOOL_SKILL, SpellSchool(cnf)); //FIXME: Bonus shouldn't be additive (Witchking Artifacts : Crown of Skies)
|
||||
if(thisSchool > skill)
|
||||
{
|
||||
skill = thisSchool;
|
||||
if(outSelectedSchool)
|
||||
*outSelectedSchool = static_cast<ui8>(cnf.id);
|
||||
*outSelectedSchool = SpellSchool(cnf);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -650,9 +650,9 @@ int64_t CGHeroInstance::getSpellBonus(const spells::Spell * spell, int64_t base,
|
||||
|
||||
int maxSchoolBonus = 0;
|
||||
|
||||
spell->forEachSchool([&maxSchoolBonus, this](const spells::SchoolInfo & cnf, bool & stop)
|
||||
spell->forEachSchool([&maxSchoolBonus, this](const ESpellSchool & cnf, bool & stop)
|
||||
{
|
||||
vstd::amax(maxSchoolBonus, valOfBonuses(BonusType::SPELL_DAMAGE, cnf.id));
|
||||
vstd::amax(maxSchoolBonus, valOfBonuses(BonusType::SPELL_DAMAGE, SpellSchool(cnf)));
|
||||
});
|
||||
|
||||
base = static_cast<int64_t>(base * (100 + maxSchoolBonus) / 100.0);
|
||||
@@ -739,9 +739,9 @@ bool CGHeroInstance::canCastThisSpell(const spells::Spell * spell) const
|
||||
|
||||
bool schoolBonus = false;
|
||||
|
||||
spell->forEachSchool([this, &schoolBonus](const spells::SchoolInfo & cnf, bool & stop)
|
||||
spell->forEachSchool([this, &schoolBonus](const ESpellSchool & cnf, bool & stop)
|
||||
{
|
||||
if(hasBonusOfType(BonusType::SPELLS_OF_SCHOOL, cnf.id))
|
||||
if(hasBonusOfType(BonusType::SPELLS_OF_SCHOOL, SpellSchool(cnf)))
|
||||
{
|
||||
schoolBonus = stop = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user