1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Working FIRST_STRIKE ability

This commit is contained in:
Dydzio 2017-08-19 20:39:24 +02:00
parent 5ba8d64b63
commit 1df939bf70
3 changed files with 23 additions and 3 deletions

View File

@ -150,10 +150,15 @@
"description": "Immune to all Fire school spells"
},
"FIRE_SHIELD":
"FIRE_SHIELD": {
"name": "Fire Shield (${val}%)",
"description": "Reflects part of melee damage"
},
"FIRST_STRIKE":
{
"name": "Fire Shield (${val}%)",
"description": "Reflects part of melee damage"
"name": "First Strike",
"description": "This creature attacks first instead of retaliating"
},
"FEAR":

View File

@ -236,6 +236,7 @@ private:
BONUS_NAME(RANGED_RETALIATION) /*allows shooters to perform ranged retaliation*/\
BONUS_NAME(BLOCKS_RANGED_RETALIATION) /*disallows ranged retaliation for shooter unit, BLOCKS_RETALIATION bonus is for melee retaliation only*/\
BONUS_NAME(WIDE_BREATH) /* Kuririn skill */\
BONUS_NAME(FIRST_STRIKE) /* Witchking skill */\
/* end of list */

View File

@ -3935,6 +3935,19 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
for (int i = 0; i < totalAttacks; ++i)
{
//first strike
if(i == 0 && destinationStack
&& destinationStack->hasBonusOfType(Bonus::FIRST_STRIKE)
&& destinationStack->ableToRetaliate()
&& stack->alive()) //probably not needed
{
BattleAttack bat;
prepareAttack(bat, destinationStack, stack, 0, stack->position);
bat.flags |= BattleAttack::COUNTER;
sendAndApply(&bat);
handleAfterAttackCasting(bat);
}
if (stack &&
stack->alive() && //move can cause death, eg. by walking into the moat
destinationStack->alive())
@ -3950,6 +3963,7 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
//counterattack
if (i == 0 && destinationStack
&& !stack->hasBonusOfType(Bonus::BLOCKS_RETALIATION)
&& !destinationStack->hasBonusOfType(Bonus::FIRST_STRIKE)
&& destinationStack->ableToRetaliate()
&& stack->alive()) //attacker may have died (fire shield)
{