mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fixed #1329.
This commit is contained in:
@@ -1617,22 +1617,21 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
|
|||||||
if(!spell->combatSpell)
|
if(!spell->combatSpell)
|
||||||
return ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL;
|
return ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL;
|
||||||
|
|
||||||
//TODO?
|
if(spell->isNegative() || spell->hasEffects())
|
||||||
//if(NBonus::hasOfType(heroes[1-cside], Bonus::SPELL_IMMUNITY, spell->id)) //non - casting hero provides immunity for this spell
|
|
||||||
// return ESpellCastProblem::SECOND_HEROS_SPELL_IMMUNITY;
|
|
||||||
if(spell->isNegative())
|
|
||||||
{
|
{
|
||||||
bool allEnemiesImmune = true;
|
bool allStacksImmune = true;
|
||||||
for(auto enemyStack : battleAliveStacks(!side))
|
//we are interested only in enemy stacks when casting offensive spells
|
||||||
|
auto stacks = spell->isNegative() ? battleAliveStacks(!side) : battleAliveStacks();
|
||||||
|
for(auto stack : stacks)
|
||||||
{
|
{
|
||||||
if(!enemyStack->hasBonusOfType(Bonus::SPELL_IMMUNITY, spell->id))
|
if(!battleIsImmune(castingHero, spell, mode, stack->position))
|
||||||
{
|
{
|
||||||
allEnemiesImmune = false;
|
allStacksImmune = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(allEnemiesImmune)
|
if(allStacksImmune)
|
||||||
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
|
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user