1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-09 13:14:02 +02:00

Merge pull request #4642 from Laserlicht/invincible_improvements

Invincible bonus: only blocking non positive spells; counterstrike
This commit is contained in:
Ivan Savenko 2024-09-27 18:58:00 +03:00 committed by GitHub
commit 69d9e34ebf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 7 deletions

View File

@ -10,10 +10,6 @@
"cavalryChargeImmunity" :
{
"type" : "CHARGE_IMMUNITY"
},
"invincible" :
{
"type" : "INVINCIBLE"
}
},
"graphics" :

View File

@ -794,7 +794,7 @@ DamageEstimation CBattleInfoCallback::battleEstimateDamage(const BattleAttackInf
if (!bai.defender->ableToRetaliate())
return ret;
if (bai.attacker->hasBonusOfType(BonusType::BLOCKS_RETALIATION))
if (bai.attacker->hasBonusOfType(BonusType::BLOCKS_RETALIATION) || bai.attacker->hasBonusOfType(BonusType::INVINCIBLE))
return ret;
//TODO: rewrite using boost::numeric::interval

View File

@ -231,7 +231,7 @@ bool BattleSpellMechanics::canBeCastAt(const Target & target, Problem & problem)
if(mainTarget && mainTarget == caster)
return false; // can't cast on self
if(mainTarget && mainTarget->hasBonusOfType(BonusType::INVINCIBLE))
if(mainTarget && mainTarget->hasBonusOfType(BonusType::INVINCIBLE) && !getSpell()->getPositiveness())
return false;
}

View File

@ -276,7 +276,7 @@ bool BattleActionProcessor::doAttackAction(const CBattleInfoCallback & battle, c
for (int i = 0; i < totalAttacks; ++i)
{
//first strike
if(i == 0 && firstStrike && retaliation && !stack->hasBonusOfType(BonusType::BLOCKS_RETALIATION))
if(i == 0 && firstStrike && retaliation && !stack->hasBonusOfType(BonusType::BLOCKS_RETALIATION) && !stack->hasBonusOfType(BonusType::INVINCIBLE))
{
makeAttack(battle, destinationStack, stack, 0, stack->getPosition(), true, false, true);
}
@ -303,6 +303,7 @@ bool BattleActionProcessor::doAttackAction(const CBattleInfoCallback & battle, c
//we check retaliation twice, so if it unblocked during attack it will work only on next attack
if(stack->alive()
&& !stack->hasBonusOfType(BonusType::BLOCKS_RETALIATION)
&& !stack->hasBonusOfType(BonusType::INVINCIBLE)
&& (i == 0 && !firstStrike)
&& retaliation && destinationStack->ableToRetaliate())
{