1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Initial version of limiting shooters range feature

This commit is contained in:
Dydzio
2023-01-12 15:25:12 +01:00
committed by Nordsoft91
parent 672bcb488b
commit c22ab5ec9e

View File

@@ -699,7 +699,28 @@ bool CBattleInfoCallback::battleCanShoot(const battle::Unit * attacker, BattleHe
return false;
if(battleMatchOwner(attacker, defender) && defender->alive())
return battleCanShoot(attacker);
{
if(battleCanShoot(attacker))
{
auto shooterBonus = attacker->getBonus(Selector::type()(Bonus::SHOOTER));
if(shooterBonus->additionalInfo == CAddInfo::NONE)
{
return true;
}
int shootingRange = shooterBonus->additionalInfo[0];
int distanceBetweenHexes = BattleHex::getDistance(attacker->getPosition(), dest);
if(distanceBetweenHexes <= shootingRange)
{
return true;
}
else
{
return false;
}
}
}
return false;
}