Lurkers Micro AI: fix bug in wander terrain selection

Need to verify that the goal hex for the wander is not occupied by an
ally, otherwise the unit might end up on the wrong type of terrain.
This commit is contained in:
mattsc 2014-10-16 13:16:24 -07:00
parent d09ce1ca87
commit b2581bcb7c
2 changed files with 10 additions and 0 deletions

View file

@ -14,6 +14,7 @@ Version 1.13.0-dev:
* Stationed Guardian Micro AI: make guard_x/y= optional keys
* Messenger Escort Micro AI: bug fix for escort units blocking messenger's
progress
* Lurkers Micro AI: fix bug in wander terrain selection
* Several Micro AIs: fix a variety of rarely occurring but serious bugs, such
as invalid savegames or disabling the AI from working for the rest of the
turn or after changing the Micro AI settings.

View file

@ -73,6 +73,15 @@ function ca_lurkers:execution(ai, cfg)
})
reachable_wander_terrain:inter(reach)
-- Need to restrict that to reachable and not occupied by an ally (except own position)
local reachable_wander_terrain = reachable_wander_terrain:filter(function(x, y, v)
local occ_hex = wesnoth.get_units {
x = x, y = y,
{ "not", { x = lurker.x, y = lurker.y } }
}[1]
return not occ_hex
end)
if (reachable_wander_terrain:size() > 0) then
local dst = reachable_wander_terrain:to_stable_pairs()
local rand = math.random(1, reachable_wander_terrain:size())