浏览代码

fix sphereOfPermanence

AlexVinS 10 年之前
父节点
当前提交
5f41ec912f
共有 1 个文件被更改,包括 20 次插入6 次删除
  1. 20 6
      lib/spells/BattleSpellMechanics.cpp

+ 20 - 6
lib/spells/BattleSpellMechanics.cpp

@@ -191,16 +191,30 @@ void DispellMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast *
 
 ESpellCastProblem::ESpellCastProblem DispellMechanics::isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const
 {
-	//DISPELL ignores all immunities, so do not call default
-	std::stringstream cachingStr;
-	cachingStr << "source_" << Bonus::SPELL_EFFECT;
-
-	if(obj->hasBonus(Selector::sourceType(Bonus::SPELL_EFFECT), cachingStr.str()))
 	{
-		return ESpellCastProblem::OK;
+		//just in case
+		if(!obj->alive())
+			return ESpellCastProblem::WRONG_SPELL_TARGET;			
+	}
+	//DISPELL ignores all immunities, except specific absolute immunity 
+	{
+		//SPELL_IMMUNITY absolute case
+		std::stringstream cachingStr;
+		cachingStr << "type_" << Bonus::SPELL_IMMUNITY << "subtype_" << owner->id.toEnum() << "addInfo_1";
+		if(obj->hasBonus(Selector::typeSubtypeInfo(Bonus::SPELL_IMMUNITY, owner->id.toEnum(), 1), cachingStr.str()))
+			return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
 	}
+	{
+		std::stringstream cachingStr;
+		cachingStr << "source_" << Bonus::SPELL_EFFECT;
 
+		if(obj->hasBonus(Selector::sourceType(Bonus::SPELL_EFFECT), cachingStr.str()))
+		{
+			return ESpellCastProblem::OK;
+		}		
+	}
 	return ESpellCastProblem::WRONG_SPELL_TARGET;
+	//any other immunities are ignored - do not execute default algorithm
 }
 
 void DispellMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const