1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fixed #1124. Probably also other bugs related to two-hex creatures (or they were already resolved).

This commit is contained in:
DjWarmonger 2012-11-30 14:06:22 +00:00
parent 52242692f1
commit 7be00e97a0
2 changed files with 8 additions and 14 deletions

View File

@ -1284,8 +1284,9 @@ ReachabilityInfo CBattleInfoCallback::getFlyingReachability(const ReachabilityIn
AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos) const
{
//does not return hex attacked directly
//TODO: apply rotation to two-hex attackers
auto side = playerToSide (attacker->owner);
bool isAttacker = attacker->attackerOwned;
AttackableTiles at;
RETURN_IF_NOT_BATTLE(at);
@ -1294,27 +1295,21 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack
ui16 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, side, attacker->doubleWide(), side);
if (reverse && attacker->doubleWide())
bool reverse = isToReverse (hex, destinationTile, isAttacker, attacker->doubleWide(), isAttacker);
if (reverse)
{
if (attacker->owner)
--hex; //move left
else
++hex; //move right
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));
// BOOST_FOREACH (BattleHex tile, attacker->getSurroundingHexes(attackerPos))
// at.hostileCreaturePositions.insert(tile);
boost::copy (attacker->getSurroundingHexes (attackerPos), vstd::set_inserter (at.hostileCreaturePositions));
}
if (attacker->hasBonusOfType(Bonus::THREE_HEADED_ATTACK))
{
std::vector<BattleHex> hexes = attacker->getSurroundingHexes(attackerPos);
BOOST_FOREACH (BattleHex tile, hexes)
{
if ((BattleHex::mutualPosition(tile, destinationTile) > -1 && BattleHex::mutualPosition (tile, hex) > -1) //adjacent both to attacker's head and attacked tile
|| tile == destinationTile) //or simply attacked directly
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?

View File

@ -775,8 +775,7 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
if (!bat.shot()) //multiple-hex attack - only in meele
{
std::set<const CStack*> attackedCreatures = gs->curB->getAttackedCreatures(att, targetHex);
//TODO: get exact attacked hex for defender
std::set<const CStack*> attackedCreatures = gs->curB->getAttackedCreatures(att, targetHex); //creatures other than primary target
BOOST_FOREACH(const CStack * stack, attackedCreatures)
{