Răsfoiți Sursa

Fixed creatures casting aimed spells at dead stacks.

DjWarmonger 13 ani în urmă
părinte
comite
18b1b83c8a
2 a modificat fișierele cu 12 adăugiri și 6 ștergeri
  1. 3 3
      client/BattleInterface/CBattleInterface.cpp
  2. 9 3
      lib/BattleState.cpp

+ 3 - 3
client/BattleInterface/CBattleInterface.cpp

@@ -1754,7 +1754,7 @@ void CBattleInterface::hexLclicked(int whichOne)
 	{
 		if(!myTurn)
 			return; //we are not permit to do anything
-		if(spellDestSelectMode) //TODO: choose target for area creature spell
+		if(spellDestSelectMode) //select spell target //TODO: choose target for area creature spell
 		{
 			//checking destination
 			bool allowCasting = true;
@@ -1788,7 +1788,7 @@ void CBattleInterface::hexLclicked(int whichOne)
 				endCastingSpell();
 			}
 		}
-		else //we don't aim for spell target area
+		else //creature casting
 		{
 			bool walkableTile = false;
 			bool spellCast = false;
@@ -1805,7 +1805,7 @@ void CBattleInterface::hexLclicked(int whichOne)
 						{
 							const CSpell * spell =  CGI->spellh->spells[creatureSpellToCast];
 
-							if (curInt->cb->battleCanCastThisSpell(spell, BattleHex(whichOne)) == ESpellCastProblem::OK)
+							if (curInt->cb->battleCanCreatureCastThisSpell(spell, BattleHex(whichOne)) == ESpellCastProblem::OK)
 							{
 								if ((!spell->isNegative() && ourStack) || (!spell->isPositive() && !ourStack))
 								{

+ 9 - 3
lib/BattleState.cpp

@@ -2100,7 +2100,13 @@ bool BattleInfo::battleTestElementalImmunity(const CStack * subject, const CSpel
 
 ESpellCastProblem::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, BattleHex dest) const
 {
-	const CStack * subject = getStackT(dest, false);
+	const CStack * subject;
+	bool risingSpell = vstd::contains(VLC->spellh->risingSpells, spell->id);
+	if (risingSpell)
+		subject = getStackT(dest, false); //including dead stacks
+	else
+		subject = getStackT(dest, true); //only alive
+
 	if(subject)
 	{
 		if (spell->isPositive() && subject->hasBonusOfType(Bonus::RECEPTIVE)) //accept all positive spells
@@ -2191,7 +2197,7 @@ ESpellCastProblem::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInst
 				return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
 		}
 
-		if (vstd::contains(VLC->spellh->risingSpells, spell->id))
+		if (risingSpell)
 		{
 			if (subject->count >= subject->baseAmount) //TODO: calculate potential hp raised
 				return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
@@ -2210,7 +2216,7 @@ ESpellCastProblem::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInst
 			return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
 		}
 	}
-	else
+	else //no target stack on this tile
 	{
 		if(spell->getTargetType() == CSpell::CREATURE ||
 			(spell->getTargetType() == CSpell::CREATURE_EXPERT_MASSIVE && mode == ECastingMode::HERO_CASTING && caster && caster->getSpellSchoolLevel(spell) < 3))