ai_helper.get_enemy_dst_src: add optional parameter 'enemies'
If 'enemies' table is given, use it, otherwise use all enemy units.
This commit is contained in:
parent
c46d8459d6
commit
5f39a7d2dc
1 changed files with 7 additions and 5 deletions
|
@ -709,12 +709,14 @@ function ai_helper.get_dst_src(units)
|
|||
return ai_helper.get_dst_src_units(my_units)
|
||||
end
|
||||
|
||||
function ai_helper.get_enemy_dst_src()
|
||||
-- Produces the same output as ai.get_enemy_dst_src() (available in 1.11.0)
|
||||
function ai_helper.get_enemy_dst_src(enemies)
|
||||
-- If 'enemies' table is given, use it, otherwise use all enemy units
|
||||
|
||||
local enemies = wesnoth.get_units {
|
||||
{ "filter_side", { { "enemy_of", { side = wesnoth.current.side} } } }
|
||||
}
|
||||
if (not enemies) then
|
||||
enemies = wesnoth.get_units {
|
||||
{ "filter_side", { { "enemy_of", { side = wesnoth.current.side} } } }
|
||||
}
|
||||
end
|
||||
|
||||
return ai_helper.get_dst_src_units(enemies, { moves = 'max' })
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue