mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Remove copy-pasted code
This commit is contained in:
@@ -731,55 +731,6 @@ bool BattleEvaluator::attemptCastingSpell(const CStack * activeStack)
|
|||||||
|
|
||||||
ps.value = scoreEvaluator.evaluateExchange(updatedAttack, cachedAttack.turn, *targets, innerCache, state);
|
ps.value = scoreEvaluator.evaluateExchange(updatedAttack, cachedAttack.turn, *targets, innerCache, state);
|
||||||
}
|
}
|
||||||
//! Some units may be dead alltogether. So if they existed before but not now, we know they were killed by the spell
|
|
||||||
for (const auto& unit : all)
|
|
||||||
{
|
|
||||||
if (!unit->isValidTarget())
|
|
||||||
continue;
|
|
||||||
bool isDead = true;
|
|
||||||
for (const auto& remainingUnit : allUnits)
|
|
||||||
{
|
|
||||||
if (remainingUnit->unitId() == unit->unitId())
|
|
||||||
isDead = false;
|
|
||||||
}
|
|
||||||
if (isDead)
|
|
||||||
{
|
|
||||||
auto newHealth = 0;
|
|
||||||
auto oldHealth = vstd::find_or(healthOfStack, unit->unitId(), 0);
|
|
||||||
if (oldHealth != newHealth)
|
|
||||||
{
|
|
||||||
auto damage = std::abs(oldHealth - newHealth);
|
|
||||||
auto originalDefender = cb->getBattle(battleID)->battleGetUnitByID(unit->unitId());
|
|
||||||
auto dpsReduce = AttackPossibility::calculateDamageReduce(
|
|
||||||
nullptr,
|
|
||||||
originalDefender && originalDefender->alive() ? originalDefender : unit,
|
|
||||||
damage,
|
|
||||||
innerCache,
|
|
||||||
state);
|
|
||||||
auto ourUnit = unit->unitSide() == side ? 1 : -1;
|
|
||||||
auto goodEffect = newHealth > oldHealth ? 1 : -1;
|
|
||||||
if (ourUnit * goodEffect == 1)
|
|
||||||
{
|
|
||||||
if (ourUnit && goodEffect && (unit->isClone() || unit->isGhost()))
|
|
||||||
continue;
|
|
||||||
ps.value += dpsReduce * scoreEvaluator.getPositiveEffectMultiplier();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ps.value -= 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);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(const auto & unit : allUnits)
|
for(const auto & unit : allUnits)
|
||||||
{
|
{
|
||||||
if(!unit->isValidTarget(true))
|
if(!unit->isValidTarget(true))
|
||||||
|
|||||||
Reference in New Issue
Block a user