mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Implemented SHOOTS_ALL_ADJACENT
This commit is contained in:
parent
5c17e172b6
commit
59764d8349
@ -1129,16 +1129,6 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack
|
||||
AttackableTiles at;
|
||||
RETURN_IF_NOT_BATTLE(at);
|
||||
|
||||
/*if(rangedAttack)
|
||||
{
|
||||
if(attacker->hasBonusOfType(Bonus::SHOOTS_ALL_ADJACENT) && !vstd::contains(attackerPos.neighbouringTiles(), destinationTile))
|
||||
{
|
||||
std::vector<BattleHex> targetHexes = destinationTile.neighbouringTiles();
|
||||
targetHexes.push_back(destinationTile);
|
||||
boost::copy(targetHexes, vstd::set_inserter(at.hostileCreaturePositions));
|
||||
}
|
||||
}*/
|
||||
|
||||
const int WN = GameConstants::BFIELD_WIDTH;
|
||||
BattleHex hex = (attackerPos != BattleHex::INVALID) ? attackerPos.hex : attacker->position.hex; //real or hypothetical (cursor) position
|
||||
|
||||
@ -1218,12 +1208,34 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack
|
||||
return at;
|
||||
}
|
||||
|
||||
AttackableTiles CBattleInfoCallback::getPotentiallyShootableHexes(const CStack * attacker, BattleHex destinationTile, BattleHex attackerPos) const
|
||||
{
|
||||
//does not return hex attacked directly
|
||||
AttackableTiles at;
|
||||
RETURN_IF_NOT_BATTLE(at);
|
||||
|
||||
if(attacker->hasBonusOfType(Bonus::SHOOTS_ALL_ADJACENT) && !vstd::contains(attackerPos.neighbouringTiles(), destinationTile))
|
||||
{
|
||||
std::vector<BattleHex> targetHexes = destinationTile.neighbouringTiles();
|
||||
targetHexes.push_back(destinationTile);
|
||||
boost::copy(targetHexes, vstd::set_inserter(at.hostileCreaturePositions));
|
||||
}
|
||||
|
||||
return at;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if(rangedAttack)
|
||||
at = getPotentiallyShootableHexes(attacker, destinationTile, attackerPos);
|
||||
else
|
||||
at = getPotentiallyAttackableHexes(attacker, destinationTile, attackerPos);
|
||||
|
||||
for (BattleHex tile : at.hostileCreaturePositions) //all around & three-headed attack
|
||||
{
|
||||
const CStack * st = battleGetStackByPos(tile, true);
|
||||
|
@ -93,6 +93,7 @@ public:
|
||||
si8 battleGetTacticDist() const; //returns tactic distance for calling player or 0 if this player is not in tactic phase (for ALL_KNOWING actual distance for tactic side)
|
||||
|
||||
AttackableTiles getPotentiallyAttackableHexes(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos) const; //TODO: apply rotation to two-hex attacker
|
||||
AttackableTiles getPotentiallyShootableHexes(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos) const;
|
||||
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 hexFrom, BattleHex hexTo, bool curDir /*if true, creature is in attacker's direction*/, bool toDoubleWide, bool toDir) const; //determines if creature should be reversed (it stands on hexFrom and should 'see' hexTo)
|
||||
bool isToReverseHlp(BattleHex hexFrom, BattleHex hexTo, bool curDir) const; //helper for isToReverse
|
||||
|
Loading…
Reference in New Issue
Block a user