mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Fix attack targeting selection for double-wide units
This commit is contained in:
parent
8aebe404e3
commit
b8c5a32b9b
@ -543,7 +543,6 @@ void BattleStacksController::stackMoved(const CStack *stack, std::vector<BattleH
|
||||
bool BattleStacksController::shouldAttackFacingRight(const CStack * attacker, const CStack * defender)
|
||||
{
|
||||
bool mustReverse = owner.curInt->cb->isToReverse(
|
||||
attacker->getPosition(),
|
||||
attacker,
|
||||
defender);
|
||||
|
||||
|
@ -1470,8 +1470,7 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const battl
|
||||
if (!defender)
|
||||
return at; // can't attack thin air
|
||||
|
||||
//FIXME: dragons or cerbers can rotate before attack, making their base hex different (#1124)
|
||||
bool reverse = isToReverse(destinationTile, attacker, defender);
|
||||
bool reverse = isToReverse(attacker, defender);
|
||||
if(reverse && attacker->doubleWide())
|
||||
{
|
||||
hex = attacker->occupiedHex(hex); //the other hex stack stands on
|
||||
@ -1622,13 +1621,14 @@ static bool isHexInFront(BattleHex hex, BattleHex testHex, BattleSide::Type side
|
||||
}
|
||||
|
||||
//TODO: this should apply also to mechanics and cursor interface
|
||||
bool CBattleInfoCallback::isToReverse (BattleHex attackerHex, const battle::Unit * attacker, const battle::Unit * defender) const
|
||||
bool CBattleInfoCallback::isToReverse (const battle::Unit * attacker, const battle::Unit * defender) const
|
||||
{
|
||||
BattleHex attackerHex = attacker->getPosition();
|
||||
BattleHex defenderHex = defender->getPosition();
|
||||
|
||||
if (attackerHex < 0 ) //turret
|
||||
return false;
|
||||
|
||||
BattleHex defenderHex = defender->getPosition();
|
||||
|
||||
if (isHexInFront(attackerHex, defenderHex, BattleSide::Type(attacker->unitSide())))
|
||||
return false;
|
||||
|
||||
|
@ -137,7 +137,7 @@ public:
|
||||
AttackableTiles getPotentiallyShootableHexes(const battle::Unit* attacker, BattleHex destinationTile, BattleHex attackerPos) const;
|
||||
std::vector<const battle::Unit *> getAttackedBattleUnits(const battle::Unit* attacker, BattleHex destinationTile, bool rangedAttack, BattleHex attackerPos = BattleHex::INVALID) const; //calculates range of multi-hex attacks
|
||||
std::set<const CStack*> getAttackedCreatures(const CStack* attacker, BattleHex destinationTile, bool rangedAttack, BattleHex attackerPos = BattleHex::INVALID) const; //calculates range of multi-hex attacks
|
||||
bool isToReverse(BattleHex attackerHex, const battle::Unit *attacker, const battle::Unit *defender) const; //determines if attacker standing at attackerHex should reverse in order to attack defender
|
||||
bool isToReverse(const battle::Unit *attacker, const battle::Unit *defender) const; //determines if attacker standing at attackerHex should reverse in order to attack defender
|
||||
|
||||
ReachabilityInfo getReachability(const battle::Unit * unit) const;
|
||||
ReachabilityInfo getReachability(const ReachabilityInfo::Parameters & params) const;
|
||||
|
Loading…
Reference in New Issue
Block a user