mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
UnitState has getRangedFullDamageDistance()
This commit is contained in:
@@ -402,12 +402,7 @@ std::vector<BattleHex> BattleFieldController::getRangedFullDamageHexes()
|
|||||||
if(!(hoveredStack && hoveredStack->isShooter()))
|
if(!(hoveredStack && hoveredStack->isShooter()))
|
||||||
return rangedFullDamageHexes;
|
return rangedFullDamageHexes;
|
||||||
|
|
||||||
auto rangedFullDamageDistance = GameConstants::BATTLE_PENALTY_DISTANCE;
|
auto rangedFullDamageDistance = hoveredStack->getRangedFullDamageDistance();
|
||||||
|
|
||||||
// overwrite full ranged damage distance from Additional info field of LIMITED_SHOOTING_RANGE bonus
|
|
||||||
auto bonus = hoveredStack->getBonus(Selector::type()(BonusType::LIMITED_SHOOTING_RANGE));
|
|
||||||
if(bonus != nullptr && bonus->additionalInfo != CAddInfo::NONE)
|
|
||||||
rangedFullDamageDistance = bonus->additionalInfo[0];
|
|
||||||
|
|
||||||
// get only battlefield hexes that are in full range damage distance
|
// get only battlefield hexes that are in full range damage distance
|
||||||
std::set<BattleHex> fullRangeLimit;
|
std::set<BattleHex> fullRangeLimit;
|
||||||
@@ -428,15 +423,11 @@ std::vector<BattleHex> BattleFieldController::getRangedFullDamageLimitHexes(std:
|
|||||||
// if not a hovered arcer unit -> return
|
// if not a hovered arcer unit -> return
|
||||||
auto hoveredHex = getHoveredHex();
|
auto hoveredHex = getHoveredHex();
|
||||||
const CStack * hoveredStack = owner.curInt->cb->battleGetStackByPos(hoveredHex, true);
|
const CStack * hoveredStack = owner.curInt->cb->battleGetStackByPos(hoveredHex, true);
|
||||||
|
|
||||||
if(!(hoveredStack && hoveredStack->isShooter()))
|
if(!(hoveredStack && hoveredStack->isShooter()))
|
||||||
return rangedFullDamageLimitHexes;
|
return rangedFullDamageLimitHexes;
|
||||||
|
|
||||||
auto rangedFullDamageDistance = GameConstants::BATTLE_PENALTY_DISTANCE;
|
auto rangedFullDamageDistance = hoveredStack->getRangedFullDamageDistance();
|
||||||
|
|
||||||
// overwrite full ranged damage distance from Additional info field of LIMITED_SHOOTING_RANGE bonus
|
|
||||||
auto bonus = hoveredStack->getBonus(Selector::type()(BonusType::LIMITED_SHOOTING_RANGE));
|
|
||||||
if(bonus != nullptr && bonus->additionalInfo != CAddInfo::NONE)
|
|
||||||
rangedFullDamageDistance = bonus->additionalInfo[0];
|
|
||||||
|
|
||||||
// from ranged full damage hexes get only the ones at the limit
|
// from ranged full damage hexes get only the ones at the limit
|
||||||
for(auto & hex : rangedFullDamageHexes)
|
for(auto & hex : rangedFullDamageHexes)
|
||||||
|
@@ -591,6 +591,24 @@ int32_t CUnitState::getInitiative(int turn) const
|
|||||||
return valOfBonuses(Selector::type()(BonusType::STACKS_SPEED).And(Selector::turns(turn)));
|
return valOfBonuses(Selector::type()(BonusType::STACKS_SPEED).And(Selector::turns(turn)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t CUnitState::getRangedFullDamageDistance() const
|
||||||
|
{
|
||||||
|
if(!isShooter())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint8_t rangedFullDamageDistance = GameConstants::BATTLE_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)))
|
||||||
|
{
|
||||||
|
auto bonus = this->getBonus(Selector::type()(BonusType::LIMITED_SHOOTING_RANGE));
|
||||||
|
if(bonus != nullptr && bonus->additionalInfo != CAddInfo::NONE)
|
||||||
|
rangedFullDamageDistance = bonus->additionalInfo[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return rangedFullDamageDistance;
|
||||||
|
}
|
||||||
|
|
||||||
bool CUnitState::canMove(int turn) const
|
bool CUnitState::canMove(int turn) const
|
||||||
{
|
{
|
||||||
return alive() && !hasBonus(Selector::type()(BonusType::NOT_ACTIVE).And(Selector::turns(turn))); //eg. Ammo Cart or blinded creature
|
return alive() && !hasBonus(Selector::type()(BonusType::NOT_ACTIVE).And(Selector::turns(turn))); //eg. Ammo Cart or blinded creature
|
||||||
|
@@ -221,6 +221,7 @@ public:
|
|||||||
BattleHex getPosition() const override;
|
BattleHex getPosition() const override;
|
||||||
void setPosition(BattleHex hex) override;
|
void setPosition(BattleHex hex) override;
|
||||||
int32_t getInitiative(int turn = 0) const override;
|
int32_t getInitiative(int turn = 0) const override;
|
||||||
|
uint8_t getRangedFullDamageDistance() const;
|
||||||
|
|
||||||
bool canMove(int turn = 0) const override;
|
bool canMove(int turn = 0) const override;
|
||||||
bool defended(int turn = 0) const override;
|
bool defended(int turn = 0) const override;
|
||||||
|
Reference in New Issue
Block a user