Browse Source

Introduce new bonus for limiting range

Dydzio 2 years ago
parent
commit
cf1674d0ca
2 changed files with 5 additions and 4 deletions
  1. 2 1
      lib/HeroBonus.h
  2. 3 3
      lib/battle/CBattleInfoCallback.cpp

+ 2 - 1
lib/HeroBonus.h

@@ -330,7 +330,8 @@ public:
 	BONUS_NAME(GARGOYLE) /* gargoyle is special than NON_LIVING, cannot be rised or healed */ \
 	BONUS_NAME(SPECIAL_ADD_VALUE_ENCHANT) /*specialty spell like Aenin has, increased effect of spell, additionalInfo = value to add*/\
 	BONUS_NAME(SPECIAL_FIXED_VALUE_ENCHANT) /*specialty spell like Melody has, constant spell effect (i.e. 3 luck), additionalInfo = value to fix.*/\
-	BONUS_NAME(TOWN_MAGIC_WELL) /*one-time pseudo-bonus to implement Magic Well in the town*/ \
+	BONUS_NAME(TOWN_MAGIC_WELL) /*one-time pseudo-bonus to implement Magic Well in the town*/\
+    BONUS_NAME(LIMITED_SHOOTING_RANGE) /*limits range of shooting creatures, doesn't adjust any other mechanics (half vs full damage etc). val - range in hexes*/\
 	/* end of list */
 
 

+ 3 - 3
lib/battle/CBattleInfoCallback.cpp

@@ -702,13 +702,13 @@ bool CBattleInfoCallback::battleCanShoot(const battle::Unit * attacker, BattleHe
 	{
 		if(battleCanShoot(attacker))
 		{
-			auto shooterBonus = attacker->getBonus(Selector::type()(Bonus::SHOOTER));
-			if(shooterBonus->additionalInfo == CAddInfo::NONE)
+			auto limitedRangeBonus = attacker->getBonus(Selector::type()(Bonus::LIMITED_SHOOTING_RANGE));
+			if(limitedRangeBonus == nullptr)
 			{
 				return true;
 			}
 
-			int shootingRange = shooterBonus->additionalInfo[0];
+			int shootingRange = limitedRangeBonus->val;
 			int distanceBetweenHexes = BattleHex::getDistance(attacker->getPosition(), dest);
 
 			if(distanceBetweenHexes <= shootingRange)