1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

* correct handling of flying creatures in battles

* minor changes
This commit is contained in:
mateuszb
2009-03-07 16:05:53 +00:00
parent 329eab2f6a
commit 9eb6128b27
10 changed files with 144 additions and 83 deletions

View File

@@ -1574,15 +1574,31 @@ void CGameHandler::moveStack(int stack, int dest)
//if(dists[dest] > curStack->creature->speed && !(stackAtEnd && dists[dest] == curStack->creature->speed+1)) //we can attack a stack if we can go to adjacent hex
// return false;
std::vector<int> path = gs->curB->getPath(curStack->position,dest,accessibility);
int tilesToMove = std::max((int)(path.size() - curStack->speed()), 0);
for(int v=path.size()-1; v>=tilesToMove; --v)
std::pair< std::vector<int>, int > path = gs->curB->getPath(curStack->position, dest, accessibility, curStack->creature->isFlying());
if(curStack->creature->isFlying())
{
//inform clients about move
BattleStackMoved sm;
sm.stack = curStack->ID;
sm.tile = path[v];
sendAndApply(&sm);
if(path.second <= curStack->speed() && path.first.size() > 0)
{
//inform clients about move
BattleStackMoved sm;
sm.stack = curStack->ID;
sm.tile = path.first[0];
sm.distance = path.second;
sendAndApply(&sm);
}
}
else //for non-flying creatures
{
int tilesToMove = std::max((int)(path.first.size() - curStack->speed()), 0);
for(int v=path.first.size()-1; v>=tilesToMove; --v)
{
//inform clients about move
BattleStackMoved sm;
sm.stack = curStack->ID;
sm.tile = path.first[v];
sm.distance = path.second;
sendAndApply(&sm);
}
}
}
CGameHandler::CGameHandler(void)