mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
defending, when not possible to attack invincible
This commit is contained in:
parent
b36c05df1d
commit
a1384bf47f
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user