1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Fix assert and condition for counting spell hexes

This commit is contained in:
Dydzio 2024-09-22 18:25:18 +02:00
parent bf9a9283a4
commit bb69ab1a1a
4 changed files with 5 additions and 4 deletions

View File

@ -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);

View File

@ -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());
}

View File

@ -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;
}

View File

@ -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);
}