Fast Micro AI ai_helper functions: fix rarely occurring bug

When the AI moves a unit out of the way for another unit’s move, it is
occasionally possible for the former unit to use up all its movement
points (e.g. if it has few MP or on narrow crowded maps). If that unit
is on the list to be moved later during the same sequence, this caused
ai_helper.robust_move_and_attack() to return nil, which then made the
Fast Micro AI produce an error message.
This commit is contained in:
mattsc 2017-11-08 22:33:24 -08:00
parent 8d2a3d369b
commit 3b2077fdc3

View file

@ -329,7 +329,7 @@ function ai_helper.robust_move_and_attack(ai, src, dst, target_loc, cfg)
end
local gamestate_changed = false
local move_result
local move_result = ai_helper.dummy_check_action(false, false, 'robust_move_and_attack::NO_ACTION')
if (unit.moves > 0) then
if (src_x == dst_x) and (src_y == dst_y) then
move_result = ai.stopunit_moves(unit)