mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-24 03:47:18 +02:00
Updated catapult spell effect to match new code
This commit is contained in:
parent
fb9ee9ddf7
commit
07cf59592b
@ -86,6 +86,8 @@ void Catapult::apply(BattleStateProxy * battleState, RNG & rng, const Mechanics
|
||||
CatapultAttack ca;
|
||||
ca.attacker = -1;
|
||||
|
||||
BattleUnitsChanged removeUnits;
|
||||
|
||||
for(int i = 0; i < targetsToAttack; i++)
|
||||
{
|
||||
//Any destructible part can be hit regardless of its HP. Multiple hit on same target is allowed.
|
||||
@ -120,9 +122,8 @@ void Catapult::apply(BattleStateProxy * battleState, RNG & rng, const Mechanics
|
||||
break;
|
||||
}
|
||||
|
||||
if(posRemove != BattleHex::INVALID)
|
||||
if(posRemove != BattleHex::INVALID && state - attackInfo.damageDealt <= 0) //HP enum subtraction not intuitive, consider using SiegeInfo::applyDamage
|
||||
{
|
||||
BattleUnitsChanged removeUnits;
|
||||
auto all = m->cb->battleGetUnitsIf([=](const battle::Unit * unit)
|
||||
{
|
||||
return !unit->isGhost();
|
||||
@ -136,12 +137,13 @@ void Catapult::apply(BattleStateProxy * battleState, RNG & rng, const Mechanics
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!removeUnits.changedStacks.empty())
|
||||
battleState->apply(&removeUnits);
|
||||
}
|
||||
}
|
||||
|
||||
battleState->apply(&ca);
|
||||
|
||||
if(!removeUnits.changedStacks.empty())
|
||||
battleState->apply(&removeUnits);
|
||||
}
|
||||
|
||||
void Catapult::serializeJsonEffect(JsonSerializeFormat & handler)
|
||||
|
@ -4363,7 +4363,7 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
|
||||
logGlobal->trace("Catapult attacks %d dealing %d damage", (int)attack.attackedPart, (int)attack.damageDealt);
|
||||
|
||||
//removing creatures in turrets / keep if one is destroyed
|
||||
if (currentHP.at(attackedPart) - attack.damageDealt <= 0 && (attackedPart == EWallPart::KEEP ||
|
||||
if (currentHP.at(attackedPart) - attack.damageDealt <= 0 && (attackedPart == EWallPart::KEEP || //HP enum subtraction not intuitive, consider using SiegeInfo::applyDamage
|
||||
attackedPart == EWallPart::BOTTOM_TOWER || attackedPart == EWallPart::UPPER_TOWER))
|
||||
{
|
||||
int posRemove = -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user