Browse Source

Possible fix for https://bugs.vcmi.eu/view.php?id=2759

AlexVinS 8 years ago
parent
commit
3de0fa37f8
1 changed files with 5 additions and 3 deletions
  1. 5 3
      lib/spells/CSpellHandler.cpp

+ 5 - 3
lib/spells/CSpellHandler.cpp

@@ -418,16 +418,18 @@ int CSpell::adjustRawDamage(const ISpellCaster * caster, const CStack * affected
 		{
 			if(affectedCreature->hasBonusOfType(Bonus::SPELL_DAMAGE_REDUCTION, (ui8)cnf.id))
 			{
-				ret *= affectedCreature->valOfBonuses(Bonus::SPELL_DAMAGE_REDUCTION, (ui8)cnf.id);
+				ret *= 100 - affectedCreature->valOfBonuses(Bonus::SPELL_DAMAGE_REDUCTION, (ui8)cnf.id);
 				ret /= 100;
 				stop = true;//only bonus from one school is used
 			}
 		});
 
+		CSelector selector = Selector::type(Bonus::SPELL_DAMAGE_REDUCTION).And(Selector::subtype(-1));
+
 		//general spell dmg reduction
-		if(affectedCreature->hasBonusOfType(Bonus::SPELL_DAMAGE_REDUCTION, -1))
+		if(affectedCreature->hasBonus(selector))
 		{
-			ret *= affectedCreature->valOfBonuses(Bonus::SPELL_DAMAGE_REDUCTION, -1);
+			ret *= 100 - affectedCreature->valOfBonuses(selector);
 			ret /= 100;
 		}