Browse Source

Add support for overwriting default range via additional info

Dydzio 2 years ago
parent
commit
f64d6bc1bc
1 changed files with 7 additions and 1 deletions
  1. 7 1
      lib/battle/CBattleInfoCallback.cpp

+ 7 - 1
lib/battle/CBattleInfoCallback.cpp

@@ -1609,7 +1609,13 @@ bool CBattleInfoCallback::battleHasDistancePenalty(const IBonusBearer * shooter,
 	if(auto target = battleGetUnitByPos(destHex, true))
 	{
 		//If any hex of target creature is within range, there is no penalty
-		if(isEnemyUnitWithinSpecifiedRange(shooterPosition, target, GameConstants::BATTLE_PENALTY_DISTANCE))
+		int range = GameConstants::BATTLE_PENALTY_DISTANCE;
+
+		auto bonus = shooter->getBonus(Selector::type()(Bonus::LIMITED_SHOOTING_RANGE));
+		if(bonus != nullptr && bonus->additionalInfo != CAddInfo::NONE)
+			range = bonus->additionalInfo[0];
+
+		if(isEnemyUnitWithinSpecifiedRange(shooterPosition, target, range))
 			return false;
 	}
 	else