diff --git a/lib/CBattleCallback.cpp b/lib/CBattleCallback.cpp index b06e4fe27..c66c0d60a 100644 --- a/lib/CBattleCallback.cpp +++ b/lib/CBattleCallback.cpp @@ -2029,8 +2029,7 @@ std::set CBattleInfoCallback::getAffectedCreatures(const CSpell * const ui8 attackerSide = playerToSide(attackerOwner) == 1; const auto attackedHexes = spell->rangeInHexes(destinationTile, skillLevel, attackerSide); - const bool onlyAlive = !spell->isRisingSpell(); //when casting resurrection or animate dead we should be allow to select dead stack - + const CSpell::TargetInfo ti = spell->getTargetInfo(skillLevel); //TODO: more generic solution for mass spells if (spell->id == SpellID::CHAIN_LIGHTNING) @@ -2068,7 +2067,7 @@ std::set CBattleInfoCallback::getAffectedCreatures(const CSpell * { for(BattleHex hex : attackedHexes) { - if(const CStack * st = battleGetStackByPos(hex, onlyAlive)) + if(const CStack * st = battleGetStackByPos(hex, ti.onlyAlive)) { if (spell->id == SpellID::DEATH_CLOUD) //Death Cloud //TODO: fireball and fire immunity { @@ -2087,7 +2086,7 @@ std::set CBattleInfoCallback::getAffectedCreatures(const CSpell * auto predicate = [=](const CStack * s){ const bool positiveToAlly = spell->isPositive() && s->owner == attackerOwner; const bool negativeToEnemy = spell->isNegative() && s->owner != attackerOwner; - const bool validTarget = s->isValidTarget(!onlyAlive); //todo: this should be handled by spell class + const bool validTarget = s->isValidTarget(!ti.onlyAlive); //todo: this should be handled by spell class //for single target spells select stacks covering destination tile const bool rangeCovers = ti.massive || s->coversPos(destinationTile); @@ -2128,7 +2127,7 @@ std::set CBattleInfoCallback::getAffectedCreatures(const CSpell * { for(BattleHex hex : attackedHexes) { - if(const CStack * st = battleGetStackByPos(hex, onlyAlive)) + if(const CStack * st = battleGetStackByPos(hex, ti.onlyAlive)) attackedCres.insert(st); } } diff --git a/lib/CSpellHandler.cpp b/lib/CSpellHandler.cpp index b2a94d2ee..11c4e9ac7 100644 --- a/lib/CSpellHandler.cpp +++ b/lib/CSpellHandler.cpp @@ -287,6 +287,7 @@ const CSpell::TargetInfo CSpell::getTargetInfo(const int level) const info.type = getTargetType(); info.smart = levelInfo.smartTarget; info.massive = levelInfo.range == "X"; + info.onlyAlive = !isRisingSpell(); return info; } diff --git a/lib/CSpellHandler.h b/lib/CSpellHandler.h index fb291c453..ea7fd0d29 100644 --- a/lib/CSpellHandler.h +++ b/lib/CSpellHandler.h @@ -60,6 +60,7 @@ public: ETargetType type; bool smart; bool massive; + bool onlyAlive; }; SpellID id;