@@ -937,7 +937,7 @@ void CPlayerInterface::battleAttack(const BattleID & battleID, const BattleAttac
info.secondaryDefender.push_back(cb->getBattle(battleID)->battleGetStackByID(elem.stackAttacked));
}
- assert(info.defender != nullptr);
+ assert(info.defender != nullptr || (info.spellEffect != SpellID::NONE && info.indirectAttack));
assert(info.attacker != nullptr);
battleInt->stackAttacking(info);
@@ -532,7 +532,7 @@ std::string BattleActionsController::actionGetStatusMessage(PossiblePlayerBattle
if(targetStack == nullptr) //should be true only for spell-like attack
{
auto spellLikeAttackBonus = owner.stacksController->getActiveStack()->getBonus(Selector::type()(BonusType::SPELL_LIKE_ATTACK));
- assert(bonus != nullptr);
+ assert(spellLikeAttackBonus != nullptr);
return boost::str(boost::format(CGI->generaltexth->allTexts[26]) % spellLikeAttackBonus->subtype.as<SpellID>().toSpell()->getNameTranslated());
@@ -740,8 +740,8 @@ bool CBattleInfoCallback::battleCanTargetEmptyHex(const battle::Unit * attacker)
if(spell->isDamage())
spells::BattleCast cast(this, attacker, spells::Mode::SPELL_LIKE_ATTACK, spell);
-
- if(vstd::find(spell->battleMechanics(&cast)->getTargetTypes(), spells::AimType::LOCATION) != spell->battleMechanics(&cast)->getTargetTypes().end())
+ BattleHex dummySpellTarget = BattleHex(50); //check arbitrary hex for general spell range since currently there is no general way to access amount of hexes
+ if(spell->battleMechanics(&cast)->rangeInHexes(dummySpellTarget).size() > 1)
return true;
@@ -164,6 +164,7 @@ EffectTarget UnitEffect::transformTargetByRange(const Mechanics * m, const Targe
if(m->alwaysHitFirstTarget())
+ //TODO: examine if adjustments needed related to INVINCIBLE bonus
if(!aimPoint.empty() && aimPoint.front().unitValue)
targets.insert(aimPoint.front().unitValue);