mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
All multi-hex attacks and shots should now be fully functional.
This commit is contained in:
parent
e95ae22061
commit
08b7d0db17
@ -785,15 +785,15 @@ std::set<CStack*> BattleInfo::getAttackedCreatures(const CStack* attacker, THex
|
||||
std::vector<THex> hexes;
|
||||
if (attacker->attackerOwned)
|
||||
{
|
||||
THex::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes);
|
||||
THex::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes); //upper
|
||||
THex::checkAndPush(hex + 1, hexes);
|
||||
THex::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes);
|
||||
THex::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes); //lower
|
||||
}
|
||||
else
|
||||
{
|
||||
THex::checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), hexes);
|
||||
THex::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes);
|
||||
THex::checkAndPush(hex - 1, hexes);
|
||||
THex::checkAndPush(hex - ( (hex/WN)%2 ? WN-1 : WN ), hexes);
|
||||
THex::checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), hexes);
|
||||
}
|
||||
BOOST_FOREACH (THex tile, hexes)
|
||||
{
|
||||
|
@ -504,7 +504,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
|
||||
delete battleResult.data;
|
||||
}
|
||||
|
||||
void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CStack *def, int distance)
|
||||
void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CStack *def, int distance, int targetHex)
|
||||
{
|
||||
bat.bsa.clear();
|
||||
bat.stackAttacking = att->ID;
|
||||
@ -538,7 +538,7 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
|
||||
|
||||
if (!bat.shot()) //multiple-hex attack - only in meele
|
||||
{
|
||||
std::set<CStack*> attackedCreatures = gs->curB->getAttackedCreatures(att, def->position);
|
||||
std::set<CStack*> attackedCreatures = gs->curB->getAttackedCreatures(att, targetHex);
|
||||
//TODO: get exact attacked hex for defender
|
||||
|
||||
BOOST_FOREACH(CStack * stack, attackedCreatures)
|
||||
@ -556,7 +556,7 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
|
||||
bat.bsa.front().flags |= BattleStackAttacked::EFFECT;
|
||||
bat.bsa.front().effect = VLC->spellh->spells[bonus->subtype]->mainEffectAnim; //hopefully it does not interfere with any other effect?
|
||||
|
||||
std::set<CStack*> attackedCreatures = gs->curB->getAttackedCreatures(VLC->spellh->spells[bonus->subtype], bonus->val, att->owner, def->position);
|
||||
std::set<CStack*> attackedCreatures = gs->curB->getAttackedCreatures(VLC->spellh->spells[bonus->subtype], bonus->val, att->owner, targetHex);
|
||||
//TODO: get exact attacked hex for defender
|
||||
|
||||
BOOST_FOREACH(CStack * stack, attackedCreatures)
|
||||
@ -3053,7 +3053,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
|
||||
//attack
|
||||
BattleAttack bat;
|
||||
prepareAttack(bat, curStack, stackAtEnd, distance);
|
||||
prepareAttack(bat, curStack, stackAtEnd, distance, ba.additionalInfo);
|
||||
sendAndApply(&bat);
|
||||
handleAfterAttackCasting(bat);
|
||||
|
||||
@ -3064,7 +3064,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
&& !stackAtEnd->hasBonusOfType(Bonus::SIEGE_WEAPON)
|
||||
&& !stackAtEnd->hasBonusOfType(Bonus::HYPNOTIZED))
|
||||
{
|
||||
prepareAttack(bat, stackAtEnd, curStack, 0);
|
||||
prepareAttack(bat, stackAtEnd, curStack, 0, curStack->position);
|
||||
bat.flags |= BattleAttack::COUNTER;
|
||||
sendAndApply(&bat);
|
||||
handleAfterAttackCasting(bat);
|
||||
@ -3077,7 +3077,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
&& stackAtEnd->alive() )
|
||||
{
|
||||
bat.flags = 0;
|
||||
prepareAttack(bat, curStack, stackAtEnd, 0);
|
||||
prepareAttack(bat, curStack, stackAtEnd, 0, ba.additionalInfo);
|
||||
sendAndApply(&bat);
|
||||
handleAfterAttackCasting(bat);
|
||||
}
|
||||
@ -3103,7 +3103,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
|
||||
BattleAttack bat;
|
||||
bat.flags |= BattleAttack::SHOT;
|
||||
prepareAttack(bat, curStack, destStack, 0);
|
||||
prepareAttack(bat, curStack, destStack, 0, ba.destinationTile);
|
||||
sendAndApply(&bat);
|
||||
handleAfterAttackCasting(bat);
|
||||
|
||||
@ -3112,7 +3112,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
{
|
||||
BattleAttack bat2;
|
||||
bat2.flags |= BattleAttack::SHOT;
|
||||
prepareAttack(bat2, curStack, destStack, 0);
|
||||
prepareAttack(bat2, curStack, destStack, 0, ba.destinationTile);
|
||||
sendAndApply(&bat2);
|
||||
}
|
||||
|
||||
@ -3122,7 +3122,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
&& curStack->shots
|
||||
)
|
||||
{
|
||||
prepareAttack(bat, curStack, destStack, 0);
|
||||
prepareAttack(bat, curStack, destStack, 0, ba.destinationTile);
|
||||
sendAndApply(&bat);
|
||||
handleAfterAttackCasting(bat);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
bool visitObjectAfterVictory;
|
||||
//
|
||||
void endBattle(int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2); //ends battle
|
||||
void prepareAttack(BattleAttack &bat, const CStack *att, const CStack *def, int distance); //distance - number of hexes travelled before attacking
|
||||
void prepareAttack(BattleAttack &bat, const CStack *att, const CStack *def, int distance, int targetHex); //distance - number of hexes travelled before attacking
|
||||
void applyBattleEffects(BattleAttack &bat, const CStack *att, const CStack *def, int distance, bool secondary); //damage, drain life & fire shield
|
||||
void checkForBattleEnd( std::vector<CStack*> &stacks );
|
||||
void setupBattle(int3 tile, const CArmedInstance *armies[2], const CGHeroInstance *heroes[2], bool creatureBank, const CGTownInstance *town);
|
||||
|
Loading…
x
Reference in New Issue
Block a user