|
|
@@ -186,7 +186,7 @@ std::set<BattleHex> CBattleInfoCallback::battleGetAttackedHexes(const CStack* at
|
|
|
{
|
|
|
std::set<BattleHex> attackedHexes;
|
|
|
RETURN_IF_NOT_BATTLE(attackedHexes);
|
|
|
-
|
|
|
+
|
|
|
AttackableTiles at = getPotentiallyAttackableHexes(attacker, destinationTile, attackerPos);
|
|
|
|
|
|
for (BattleHex tile : at.hostileCreaturePositions)
|
|
|
@@ -1120,7 +1120,7 @@ ReachabilityInfo CBattleInfoCallback::getFlyingReachability(const ReachabilityIn
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos) const
|
|
|
+AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos, bool rangedAttack) const
|
|
|
{
|
|
|
//does not return hex attacked directly
|
|
|
//TODO: apply rotation to two-hex attackers
|
|
|
@@ -1129,210 +1129,221 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack
|
|
|
AttackableTiles at;
|
|
|
RETURN_IF_NOT_BATTLE(at);
|
|
|
|
|
|
- const int WN = GameConstants::BFIELD_WIDTH;
|
|
|
- BattleHex hex = (attackerPos != BattleHex::INVALID) ? attackerPos.hex : attacker->position.hex; //real or hypothetical (cursor) position
|
|
|
-
|
|
|
- //FIXME: dragons or cerbers can rotate before attack, making their base hex different (#1124)
|
|
|
- bool reverse = isToReverse (hex, destinationTile, isAttacker, attacker->doubleWide(), isAttacker);
|
|
|
- if (reverse && attacker->doubleWide())
|
|
|
- {
|
|
|
- hex = attacker->occupiedHex(hex); //the other hex stack stands on
|
|
|
- }
|
|
|
- if (attacker->hasBonusOfType(Bonus::ATTACKS_ALL_ADJACENT))
|
|
|
- {
|
|
|
- boost::copy (attacker->getSurroundingHexes (attackerPos), vstd::set_inserter (at.hostileCreaturePositions));
|
|
|
- }
|
|
|
- if (attacker->hasBonusOfType(Bonus::THREE_HEADED_ATTACK))
|
|
|
+ if(rangedAttack)
|
|
|
{
|
|
|
- std::vector<BattleHex> hexes = attacker->getSurroundingHexes(attackerPos);
|
|
|
- for (BattleHex tile : hexes)
|
|
|
+ if(attacker->hasBonusOfType(Bonus::SHOOTS_ALL_ADJACENT) && !vstd::contains(attackerPos.neighbouringTiles(), destinationTile))
|
|
|
{
|
|
|
- if ((BattleHex::mutualPosition(tile, destinationTile) > -1 && BattleHex::mutualPosition (tile, hex) > -1)) //adjacent both to attacker's head and attacked tile
|
|
|
- {
|
|
|
- const CStack * st = battleGetStackByPos(tile, true);
|
|
|
- if(st && st->owner != attacker->owner) //only hostile stacks - does it work well with Berserk?
|
|
|
- {
|
|
|
- at.hostileCreaturePositions.insert(tile);
|
|
|
- }
|
|
|
- }
|
|
|
+ std::vector<BattleHex> targetHexes = destinationTile.neighbouringTiles();
|
|
|
+ targetHexes.push_back(destinationTile);
|
|
|
+ boost::copy(targetHexes, vstd::set_inserter(at.hostileCreaturePositions));
|
|
|
}
|
|
|
}
|
|
|
- if (attacker->hasBonusOfType(Bonus::WIDE_BREATH))
|
|
|
+
|
|
|
+ else
|
|
|
{
|
|
|
- std::vector<BattleHex> hexes;
|
|
|
const int WN = GameConstants::BFIELD_WIDTH;
|
|
|
- // atack stand
|
|
|
- if (hex == destinationTile.cloneInDirection(BattleHex::EDir::LEFT, false)) {
|
|
|
- if (destinationTile.getY() % 2 == 0)
|
|
|
- {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + (2 * WN) - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + (2 * WN), hexes);
|
|
|
- }
|
|
|
- else {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + (2 * WN) - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + (2 * WN), hexes);
|
|
|
- }
|
|
|
+ BattleHex hex = (attackerPos != BattleHex::INVALID) ? attackerPos.hex : attacker->position.hex; //real or hypothetical (cursor) position
|
|
|
|
|
|
+ //FIXME: dragons or cerbers can rotate before attack, making their base hex different (#1124)
|
|
|
+ bool reverse = isToReverse(hex, destinationTile, isAttacker, attacker->doubleWide(), isAttacker);
|
|
|
+ if(reverse && attacker->doubleWide())
|
|
|
+ {
|
|
|
+ hex = attacker->occupiedHex(hex); //the other hex stack stands on
|
|
|
}
|
|
|
- if (hex == destinationTile.cloneInDirection(BattleHex::EDir::RIGHT, false)) {
|
|
|
- if (destinationTile.getY() % 2 == 0)
|
|
|
- {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + (2 * WN), hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + (2 * WN) + 1, hexes);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + (2 * WN), hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + (2 * WN) + 1, hexes);
|
|
|
- }
|
|
|
+ if(attacker->hasBonusOfType(Bonus::ATTACKS_ALL_ADJACENT))
|
|
|
+ {
|
|
|
+ boost::copy(attacker->getSurroundingHexes(attackerPos), vstd::set_inserter(at.hostileCreaturePositions));
|
|
|
}
|
|
|
- // atack down
|
|
|
- if (hex == destinationTile.cloneInDirection(BattleHex::EDir::TOP_LEFT, false)) {
|
|
|
- if (destinationTile.getY() % 2 == 1)
|
|
|
+ if(attacker->hasBonusOfType(Bonus::THREE_HEADED_ATTACK))
|
|
|
+ {
|
|
|
+ std::vector<BattleHex> hexes = attacker->getSurroundingHexes(attackerPos);
|
|
|
+ for(BattleHex tile : hexes)
|
|
|
{
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - 2, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN - 2, hexes);
|
|
|
- }
|
|
|
- else {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - 2, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
+ if((BattleHex::mutualPosition(tile, destinationTile) > -1 && BattleHex::mutualPosition(tile, hex) > -1)) //adjacent both to attacker's head and attacked tile
|
|
|
+ {
|
|
|
+ const CStack * st = battleGetStackByPos(tile, true);
|
|
|
+ if(st && st->owner != attacker->owner) //only hostile stacks - does it work well with Berserk?
|
|
|
+ {
|
|
|
+ at.hostileCreaturePositions.insert(tile);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if (hex == destinationTile.cloneInDirection(BattleHex::EDir::TOP_RIGHT, false)) {
|
|
|
+ if(attacker->hasBonusOfType(Bonus::WIDE_BREATH))
|
|
|
+ {
|
|
|
+ std::vector<BattleHex> hexes;
|
|
|
+ // attack stand
|
|
|
+ if(hex == destinationTile.cloneInDirection(BattleHex::EDir::LEFT, false)) {
|
|
|
+ if(destinationTile.getY() % 2 == 0)
|
|
|
+ {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + (2 * WN) - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + (2 * WN), hexes);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + (2 * WN) - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + (2 * WN), hexes);
|
|
|
+ }
|
|
|
|
|
|
- if (destinationTile.getY() % 2 == 1)
|
|
|
- {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + 2, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + 2, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN + 2, hexes);
|
|
|
+ if(hex == destinationTile.cloneInDirection(BattleHex::EDir::RIGHT, false)) {
|
|
|
+ if(destinationTile.getY() % 2 == 0)
|
|
|
+ {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + (2 * WN), hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + (2 * WN) + 1, hexes);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + (2 * WN), hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + (2 * WN) + 1, hexes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // attack down
|
|
|
+ if(hex == destinationTile.cloneInDirection(BattleHex::EDir::TOP_LEFT, false)) {
|
|
|
+ if(destinationTile.getY() % 2 == 1)
|
|
|
+ {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - 2, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN - 2, hexes);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - 2, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
+ }
|
|
|
}
|
|
|
+ if(hex == destinationTile.cloneInDirection(BattleHex::EDir::TOP_RIGHT, false)) {
|
|
|
+
|
|
|
+ if(destinationTile.getY() % 2 == 1)
|
|
|
+ {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + 2, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + 2, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN + 2, hexes);
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- // attack up
|
|
|
- if (hex == destinationTile.cloneInDirection(BattleHex::EDir::BOTTOM_LEFT, false)) {
|
|
|
- if (destinationTile.getY() % 2 == 1)
|
|
|
- {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - WN - 1, hexes);
|
|
|
}
|
|
|
- else {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN + 2, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - WN + 1, hexes);
|
|
|
+ // attack up
|
|
|
+ if(hex == destinationTile.cloneInDirection(BattleHex::EDir::BOTTOM_LEFT, false)) {
|
|
|
+ if(destinationTile.getY() % 2 == 1)
|
|
|
+ {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - WN - 1, hexes);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN + 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN + 2, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - WN + 1, hexes);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (hex == destinationTile.cloneInDirection(BattleHex::EDir::BOTTOM_RIGHT, false)) {
|
|
|
+ if(hex == destinationTile.cloneInDirection(BattleHex::EDir::BOTTOM_RIGHT, false)) {
|
|
|
+
|
|
|
+ if(destinationTile.getY() % 2 == 1)
|
|
|
+ {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN - 2, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - WN - 1, hexes);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - WN, hexes);
|
|
|
+ BattleHex::checkAndPush(destinationTile - WN + 1, hexes);
|
|
|
+ }
|
|
|
|
|
|
- if (destinationTile.getY() % 2 == 1)
|
|
|
- {
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN - 2, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - WN - 1, hexes);
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ for(BattleHex tile : hexes)
|
|
|
{
|
|
|
- BattleHex::checkAndPush(destinationTile, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile + WN - 1, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - WN, hexes);
|
|
|
- BattleHex::checkAndPush(destinationTile - WN + 1, hexes);
|
|
|
+ //friendly stacks can also be damaged by Dragon Breath
|
|
|
+ if(battleGetStackByPos(tile, true))
|
|
|
+ at.friendlyCreaturePositions.insert(tile);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- for (BattleHex tile : hexes)
|
|
|
- {
|
|
|
- //friendly stacks can also be damaged by Dragon Breath
|
|
|
- if (battleGetStackByPos(tile, true))
|
|
|
- at.friendlyCreaturePositions.insert(tile);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- else if (attacker->hasBonusOfType(Bonus::TWO_HEX_ATTACK_BREATH) && BattleHex::mutualPosition(destinationTile.hex, hex) > -1) //only adjacent hexes are subject of dragon breath calculation
|
|
|
- {
|
|
|
- std::vector<BattleHex> hexes; //only one, in fact
|
|
|
- int pseudoVector = destinationTile.hex - hex;
|
|
|
- switch (pseudoVector)
|
|
|
- {
|
|
|
- case 1:
|
|
|
- case -1:
|
|
|
- BattleHex::checkAndPush(destinationTile.hex + pseudoVector, hexes);
|
|
|
- break;
|
|
|
- case WN: //17 //left-down or right-down
|
|
|
- case -WN: //-17 //left-up or right-up
|
|
|
- case WN + 1: //18 //right-down
|
|
|
- case -WN + 1: //-16 //right-up
|
|
|
- BattleHex::checkAndPush(destinationTile.hex + pseudoVector + (((hex / WN) % 2) ? 1 : -1), hexes);
|
|
|
- break;
|
|
|
- case WN - 1: //16 //left-down
|
|
|
- case -WN - 1: //-18 //left-up
|
|
|
- BattleHex::checkAndPush(destinationTile.hex + pseudoVector + (((hex / WN) % 2) ? 1 : 0), hexes);
|
|
|
- break;
|
|
|
- }
|
|
|
- for (BattleHex tile : hexes)
|
|
|
+ else if(attacker->hasBonusOfType(Bonus::TWO_HEX_ATTACK_BREATH) && BattleHex::mutualPosition(destinationTile.hex, hex) > -1) //only adjacent hexes are subject of dragon breath calculation
|
|
|
{
|
|
|
- //friendly stacks can also be damaged by Dragon Breath
|
|
|
- if (battleGetStackByPos(tile, true))
|
|
|
- at.friendlyCreaturePositions.insert(tile);
|
|
|
+ std::vector<BattleHex> hexes; //only one, in fact
|
|
|
+ int pseudoVector = destinationTile.hex - hex;
|
|
|
+ switch(pseudoVector)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ case -1:
|
|
|
+ BattleHex::checkAndPush(destinationTile.hex + pseudoVector, hexes);
|
|
|
+ break;
|
|
|
+ case WN: //17 //left-down or right-down
|
|
|
+ case -WN: //-17 //left-up or right-up
|
|
|
+ case WN + 1: //18 //right-down
|
|
|
+ case -WN + 1: //-16 //right-up
|
|
|
+ BattleHex::checkAndPush(destinationTile.hex + pseudoVector + (((hex / WN) % 2) ? 1 : -1), hexes);
|
|
|
+ break;
|
|
|
+ case WN - 1: //16 //left-down
|
|
|
+ case -WN - 1: //-18 //left-up
|
|
|
+ BattleHex::checkAndPush(destinationTile.hex + pseudoVector + (((hex / WN) % 2) ? 1 : 0), hexes);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for(BattleHex tile : hexes)
|
|
|
+ {
|
|
|
+ //friendly stacks can also be damaged by Dragon Breath
|
|
|
+ if(battleGetStackByPos(tile, true))
|
|
|
+ at.friendlyCreaturePositions.insert(tile);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return at;
|
|
|
}
|
|
|
|
|
|
-std::set<const CStack*> CBattleInfoCallback::getAttackedCreatures(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos) const
|
|
|
+std::set<const CStack*> CBattleInfoCallback::getAttackedCreatures(const CStack* attacker, BattleHex destinationTile, bool rangedAttack, BattleHex attackerPos) const
|
|
|
{
|
|
|
std::set<const CStack*> attackedCres;
|
|
|
RETURN_IF_NOT_BATTLE(attackedCres);
|
|
|
|
|
|
- AttackableTiles at = getPotentiallyAttackableHexes(attacker, destinationTile, attackerPos);
|
|
|
+ AttackableTiles at = getPotentiallyAttackableHexes(attacker, destinationTile, attackerPos, rangedAttack);
|
|
|
for (BattleHex tile : at.hostileCreaturePositions) //all around & three-headed attack
|
|
|
{
|
|
|
const CStack * st = battleGetStackByPos(tile, true);
|