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:
parent
a07274d849
commit
1a4cd8dd4b
2 changed files with 10 additions and 0 deletions
|
@ -9,6 +9,7 @@ Version 1.11.17+dev:
|
|||
* Miscellaneous and bug fixes:
|
||||
* Bug fix: another instance of "overlapping messages", this time with
|
||||
the planning mode activiation hotkey
|
||||
* Lurkers Micro AI: fix bug in wander terrain selection
|
||||
|
||||
Version 1.11.17:
|
||||
* Add-ons server:
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Add table
Reference in a new issue