Protect Unit Micro AI: ensure units are on AI side
In general, the units specified in the MAI setup should be on the AI side. However, that might change during a scenario, for example when there is an event that switches units to other sides.
This commit is contained in:
parent
0035b776d7
commit
043ee7a80b
3 changed files with 3 additions and 3 deletions
|
@ -10,7 +10,7 @@ function ca_protect_unit_attack:evaluation(cfg)
|
|||
|
||||
local units = {}
|
||||
for u in wml.child_range(cfg, "unit") do
|
||||
table.insert(units, AH.get_units_with_attacks { id = u.id }[1])
|
||||
table.insert(units, AH.get_units_with_attacks { id = u.id, side = wesnoth.current.side }[1])
|
||||
end
|
||||
if (not units[1]) then return 0 end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ local ca_protect_unit_finish, PU_unit, PU_goal = {}
|
|||
function ca_protect_unit_finish:evaluation(cfg)
|
||||
-- If a unit can make it to the goal, this is the first thing that happens
|
||||
for u in wml.child_range(cfg, "unit") do
|
||||
local unit = AH.get_units_with_moves { id = u.id }[1]
|
||||
local unit = AH.get_units_with_moves { id = u.id, side = wesnoth.current.side }[1]
|
||||
if unit then
|
||||
local goal = AH.get_named_loc_xy('goal', u)
|
||||
local path, cost = AH.find_path_with_shroud(unit, goal[1], goal[2])
|
||||
|
|
|
@ -6,7 +6,7 @@ local F = wesnoth.require "functional"
|
|||
local function get_protected_units(cfg)
|
||||
local units = {}
|
||||
for u in wml.child_range(cfg, "unit") do
|
||||
table.insert(units, AH.get_units_with_moves { id = u.id }[1])
|
||||
table.insert(units, AH.get_units_with_moves { id = u.id, side = wesnoth.current.side }[1])
|
||||
end
|
||||
return units
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue