|
@@ -768,15 +768,31 @@ bool BattleEvaluator::attemptCastingSpell(const CStack * activeStack)
|
|
|
ps.value -= 4 * dpsReduce * scoreEvaluator.getNegativeEffectMultiplier();
|
|
|
|
|
|
#if BATTLE_TRACE_LEVEL >= 1
|
|
|
- logAi->trace(
|
|
|
- "Spell %s to %d affects %s (%d), dps: %2f oldHealth: %d newHealth: %d",
|
|
|
- ps.spell->getNameTranslated(),
|
|
|
- ps.dest.at(0).hexValue.hex,
|
|
|
- unit->creatureId().toCreature()->getNameSingularTranslated(),
|
|
|
- unit->getCount(),
|
|
|
- dpsReduce,
|
|
|
- oldHealth,
|
|
|
- newHealth);
|
|
|
+ // Ensure ps.dest is not empty before accessing the first element
|
|
|
+ if (!ps.dest.empty())
|
|
|
+ {
|
|
|
+ logAi->trace(
|
|
|
+ "Spell %s to %d affects %s (%d), dps: %2f oldHealth: %d newHealth: %d",
|
|
|
+ ps.spell->getNameTranslated(),
|
|
|
+ ps.dest.at(0).hexValue.hex, // Safe to access .at(0) now
|
|
|
+ unit->creatureId().toCreature()->getNameSingularTranslated(),
|
|
|
+ unit->getCount(),
|
|
|
+ dpsReduce,
|
|
|
+ oldHealth,
|
|
|
+ newHealth);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Handle the case where ps.dest is empty
|
|
|
+ logAi->trace(
|
|
|
+ "Spell %s has no destination, affects %s (%d), dps: %2f oldHealth: %d newHealth: %d",
|
|
|
+ ps.spell->getNameTranslated(),
|
|
|
+ unit->creatureId().toCreature()->getNameSingularTranslated(),
|
|
|
+ unit->getCount(),
|
|
|
+ dpsReduce,
|
|
|
+ oldHealth,
|
|
|
+ newHealth);
|
|
|
+ }
|
|
|
#endif
|
|
|
}
|
|
|
}
|