1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Introduce new bonus for limiting range

This commit is contained in:
Dydzio 2023-01-12 16:27:21 +01:00 committed by Nordsoft91
parent c22ab5ec9e
commit cf1674d0ca
2 changed files with 5 additions and 4 deletions

View File

@ -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 */

View File

@ -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)