mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Made onlyAlive flag a part of TargetInfo
This commit is contained in:
@@ -2029,8 +2029,7 @@ std::set<const CStack*> 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<const CStack*> 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<const CStack*> 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<const CStack*> 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);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -60,6 +60,7 @@ public:
|
||||
ETargetType type;
|
||||
bool smart;
|
||||
bool massive;
|
||||
bool onlyAlive;
|
||||
};
|
||||
|
||||
SpellID id;
|
||||
|
Reference in New Issue
Block a user