1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00

Spellcasting-bug-fix

Fixed a bug that prevented the AI from using spells when attacking an enemy settlement that has towers.
The bug was caused by noticing how greatly effective spells would be against towers but not being able to actually target them.
By skipping invalid targets, this no longer is an issue.
This commit is contained in:
Xilmi 2024-07-09 22:55:39 +02:00
parent 3367298a2a
commit 13bbb573bd

View File

@ -623,6 +623,9 @@ bool BattleEvaluator::attemptCastingSpell(const CStack * activeStack)
for(const auto & unit : allUnits) for(const auto & unit : allUnits)
{ {
if (!unit->isValidTarget())
continue;
auto newHealth = unit->getAvailableHealth(); auto newHealth = unit->getAvailableHealth();
auto oldHealth = vstd::find_or(healthOfStack, unit->unitId(), 0); // old health value may not exist for newly summoned units auto oldHealth = vstd::find_or(healthOfStack, unit->unitId(), 0); // old health value may not exist for newly summoned units