Browse Source

Working FIRST_STRIKE ability

Dydzio 8 years ago
parent
commit
1df939bf70
3 changed files with 23 additions and 3 deletions
  1. 8 3
      config/bonuses_texts.json
  2. 1 0
      lib/HeroBonus.h
  3. 14 0
      server/CGameHandler.cpp

+ 8 - 3
config/bonuses_texts.json

@@ -150,10 +150,15 @@
 		"description": "Immune to all Fire school spells"
 		"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":
 	"FEAR":

+ 1 - 0
lib/HeroBonus.h

@@ -236,6 +236,7 @@ private:
 	BONUS_NAME(RANGED_RETALIATION) /*allows shooters to perform ranged retaliation*/\
 	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(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(WIDE_BREATH) /* Kuririn skill */\
+	BONUS_NAME(FIRST_STRIKE) /* Witchking skill */\
 	/* end of list */
 	/* end of list */
 
 
 
 

+ 14 - 0
server/CGameHandler.cpp

@@ -3935,6 +3935,19 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
 
 
 			for (int i = 0; i < totalAttacks; ++i)
 			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 &&
 				if (stack &&
 					stack->alive() && //move can cause death, eg. by walking into the moat
 					stack->alive() && //move can cause death, eg. by walking into the moat
 					destinationStack->alive())
 					destinationStack->alive())
@@ -3950,6 +3963,7 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
 				//counterattack
 				//counterattack
 				if (i == 0 && destinationStack
 				if (i == 0 && destinationStack
 					&& !stack->hasBonusOfType(Bonus::BLOCKS_RETALIATION)
 					&& !stack->hasBonusOfType(Bonus::BLOCKS_RETALIATION)
+					&& !destinationStack->hasBonusOfType(Bonus::FIRST_STRIKE)
 					&& destinationStack->ableToRetaliate()
 					&& destinationStack->ableToRetaliate()
 					&& stack->alive()) //attacker may have died (fire shield)
 					&& stack->alive()) //attacker may have died (fire shield)
 				{
 				{