2
0
Эх сурвалжийг харах

Fixed interface freezes for some mass-target spells.
How comes no one has reported it before?

DjWarmonger 14 жил өмнө
parent
commit
92006b53f1

+ 35 - 20
lib/BattleState.cpp

@@ -1912,8 +1912,41 @@ SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance
 		if (spell->positiveness == 1 && subject->hasBonusOfType(Bonus::RECEPTIVE)) //accept all positive spells
 			return SpellCasting::OK;
 
-		if ((spell->id == 41 || spell->id == 42) && subject->hasBonusOfType(Bonus::UNDEAD)) //undeads are immune to bless & curse
-			return SpellCasting::STACK_IMMUNE_TO_SPELL; //TODO: more general logic for new spells?
+		switch (spell->id) //TODO: more general logic for new spells?
+		{
+			case 25: //Destroy Undead
+				if (!subject->hasBonusOfType(Bonus::UNDEAD))
+					return SpellCasting::STACK_IMMUNE_TO_SPELL;
+				break;
+			case 24: // Death Ripple
+			case 41:
+			case 42: //undeads are immune to bless & curse
+				if (subject->hasBonusOfType(Bonus::UNDEAD))
+					return SpellCasting::STACK_IMMUNE_TO_SPELL; 
+				break;
+			case 61: //Forgetfulness
+				if (!subject->hasBonusOfType(Bonus::SHOOTER))
+					return SpellCasting::STACK_IMMUNE_TO_SPELL;
+				break;
+			case 78:	//dispel helpful spells
+			{
+				boost::shared_ptr<BonusList> spellBon = subject->getSpellBonuses();
+				bool hasPositiveSpell = false;
+				BOOST_FOREACH(const Bonus * b, *spellBon)
+				{
+					if(VLC->spellh->spells[b->sid]->positiveness > 0)
+					{
+						hasPositiveSpell = true;
+						break;
+					}
+				}
+				if(!hasPositiveSpell)
+				{
+					return SpellCasting::NO_SPELLS_TO_DISPEL;
+				}
+			}
+				break;
+		}
 		
 		bool damageSpell = (VLC->spellh->damageSpells.find(spell->id) != VLC->spellh->damageSpells.end());
 
@@ -1953,24 +1986,6 @@ SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance
 		{ 
 			return SpellCasting::STACK_IMMUNE_TO_SPELL;
 		}
-		//dispel helpful spells
-		if(spell->id == 78)
-		{
-			boost::shared_ptr<BonusList> spellBon = subject->getSpellBonuses();
-			bool hasPositiveSpell = false;
-			BOOST_FOREACH(const Bonus * b, *spellBon)
-			{
-				if(VLC->spellh->spells[b->sid]->positiveness > 0)
-				{
-					hasPositiveSpell = true;
-					break;
-				}
-			}
-			if(!hasPositiveSpell)
-			{
-				return SpellCasting::NO_SPELLS_TO_DISPEL;
-			}
-		}
 	}
 	else
 	{

+ 2 - 0
lib/CSpellHandler.cpp

@@ -325,6 +325,8 @@ void CSpellHandler::loadSpells()
 	}
 	ast.close();
 	spells.push_back(spells[80]); //clone Acid Breath attributes for Acid Breath damage effect
+	//forgetfulness needs to get targets automaticlaly on expert level
+	boost::replace_first(spells[61]->attributes, "CREATURE_TARGET", "CREATURE_TARGET_2"); //TODO: use flags instead?
 
 	damageSpells += 11, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 57, 77;
 }