1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

defending, when not possible to attack invincible

This commit is contained in:
Laserlicht 2024-09-19 20:54:50 +02:00
parent b36c05df1d
commit a1384bf47f
2 changed files with 12 additions and 1 deletions

View File

@ -337,7 +337,10 @@ BattleAction BattleEvaluator::moveOrAttack(const CStack * stack, BattleHex hex,
}
else
{
return BattleAction::makeMove(stack, hex);
if(stack->position == hex)
return BattleAction::makeDefend(stack);
else
return BattleAction::makeMove(stack, hex);
}
}

View File

@ -296,7 +296,11 @@ BattleAction CStupidAI::goTowards(const BattleID & battleID, const CStack * stac
for(auto hex : hexes)
{
if(vstd::contains(avHexes, hex))
{
if(stack->position == hex)
return BattleAction::makeDefend(stack);
return BattleAction::makeMove(stack, hex);
}
if(stack->coversPos(hex))
{
@ -336,7 +340,11 @@ BattleAction CStupidAI::goTowards(const BattleID & battleID, const CStack * stac
}
if(vstd::contains(avHexes, currentDest))
{
if(stack->position == currentDest)
return BattleAction::makeDefend(stack);
return BattleAction::makeMove(stack, currentDest);
}
currentDest = reachability.predecessors[currentDest];
}