mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Fix taking double damage from the same moat.
When stack move to the double moat in the fortress, he will be damaged twice. I fixed it like in original h3, now stack will be damaged once a time.
This commit is contained in:
parent
45a63e003c
commit
ce09da783a
@ -1409,24 +1409,24 @@ int CGameHandler::moveStack(int stack, BattleHex dest)
|
||||
}
|
||||
|
||||
//handling obstacle on the final field (separate, because it affects both flying and walking stacks)
|
||||
if (curStack->alive())
|
||||
if(curStack->alive())
|
||||
{
|
||||
auto theLastObstacle = battleGetAllObstaclesOnPos(curStack->position, false);
|
||||
for(auto & i : theLastObstacle)
|
||||
if(curStack->alive())
|
||||
handleDamageFromObstacle(*i, curStack);
|
||||
}
|
||||
|
||||
if (curStack->alive() && curStack->doubleWide())
|
||||
{
|
||||
BattleHex otherHex = curStack->occupiedHex(curStack->position);
|
||||
if (otherHex.isValid())
|
||||
if(curStack->doubleWide())
|
||||
{
|
||||
//two hex creature hit obstacle by backside
|
||||
auto theLastObstacle = battleGetAllObstaclesOnPos(otherHex, false);
|
||||
for(auto & i : theLastObstacle)
|
||||
if(curStack->alive())
|
||||
BattleHex otherHex = curStack->occupiedHex(curStack->position);
|
||||
if(otherHex.isValid())
|
||||
for(auto & i : battleGetAllObstaclesOnPos(otherHex, false))
|
||||
theLastObstacle.push_back(i);
|
||||
}
|
||||
bool containDamageFromMoat = false;
|
||||
for(auto & i : theLastObstacle)
|
||||
{
|
||||
if(curStack->alive())
|
||||
if(i->obstacleType != CObstacleInstance::MOAT || !containDamageFromMoat)
|
||||
handleDamageFromObstacle(*i, curStack);
|
||||
if(i->obstacleType == CObstacleInstance::MOAT)
|
||||
containDamageFromMoat = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user