Przeglądaj źródła

Added constant for BATTLE_SHOOTING_RANGE_DISTANCE

krs 2 lat temu
rodzic
commit
756dd398c2

+ 2 - 1
lib/GameConstants.h

@@ -56,7 +56,8 @@ namespace GameConstants
 	constexpr int HERO_GOLD_COST = 2500;
 	constexpr int SPELLBOOK_GOLD_COST = 500;
 	constexpr int SKILL_GOLD_COST = 2000;
-	constexpr int BATTLE_PENALTY_DISTANCE = 10; //if the distance is > than this, then shooting stack has distance penalty
+	constexpr int BATTLE_SHOOTING_PENALTY_DISTANCE = 10; //if the distance is > than this, then shooting stack has distance penalty
+	constexpr int BATTLE_SHOOTING_RANGE_DISTANCE = std::numeric_limits<uint8_t>::max(); // used when shooting stack has no shooting range limit
 	constexpr int ARMY_SIZE = 7;
 	constexpr int SKILL_PER_HERO = 8;
 	constexpr ui32 HERO_HIGH_LEVEL = 10; // affects primary skill upgrade order

+ 2 - 2
lib/battle/CBattleInfoCallback.cpp

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

+ 2 - 2
lib/battle/CUnitState.cpp

@@ -596,7 +596,7 @@ uint8_t CUnitState::getRangedFullDamageDistance() const
 	if(!isShooter())
 		return 0;
 
-	uint8_t rangedFullDamageDistance = GameConstants::BATTLE_PENALTY_DISTANCE;
+	uint8_t rangedFullDamageDistance = GameConstants::BATTLE_SHOOTING_PENALTY_DISTANCE;
 
 	// overwrite full ranged damage distance with the value set in Additional info field of LIMITED_SHOOTING_RANGE bonus
 	if(this->hasBonus(Selector::type()(BonusType::LIMITED_SHOOTING_RANGE)))
@@ -614,7 +614,7 @@ uint8_t CUnitState::getSootingRangeDistance() const
 	if(!isShooter())
 		return 0;
 
-	uint8_t shootingRangeDistance = 255; // no range limit for shooters
+	uint8_t shootingRangeDistance = GameConstants::BATTLE_SHOOTING_RANGE_DISTANCE;
 
 	// overwrite full ranged damage distance with the value set in Additional info field of LIMITED_SHOOTING_RANGE bonus
 	if(this->hasBonus(Selector::type()(BonusType::LIMITED_SHOOTING_RANGE)))