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:
mattsc 2013-11-14 19:05:56 -08:00
parent c46d8459d6
commit 5f39a7d2dc

View file

@ -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