Messenger MAI: minor bug fix to messenger attack behavior

The syntax of the waypoint_x/y parameter was changed recently, without
adapting its treatment here.  As a result, the messenger did "unsafe"
attacks whenever it ended up next to an enemy and not only on the last
waypoint as it is supposed to.
This commit is contained in:
mattsc 2013-08-29 11:11:23 -07:00
parent 14570a0a96
commit 500ccde573

View file

@ -284,17 +284,22 @@ return {
end
end
local target = wesnoth.get_units {
x = cfg.waypoint_x[#cfg.waypoint_x],
y = cfg.waypoint_y[#cfg.waypoint_y],
{ "filter_side", { {"enemy_of", {side = wesnoth.current.side} } } },
{ "filter_adjacent", { id = cfg.id } }
}[1]
if max_rating > -9e99 then
ai.attack(messenger, best_tar, best_weapon)
elseif target then
ai.attack(messenger, target)
else
-- Otherwise, always attack enemy on last waypoint
local waypoint_x = AH.split(cfg.waypoint_x, ",")
local waypoint_y = AH.split(cfg.waypoint_y, ",")
local target = wesnoth.get_units {
x = tonumber(waypoint_x[#waypoint_x]),
y = tonumber(waypoint_y[#waypoint_y]),
{ "filter_side", { {"enemy_of", {side = wesnoth.current.side} } } },
{ "filter_adjacent", { id = cfg.id } }
}[1]
if target then
ai.attack(messenger, target)
end
end
-- Finally, make sure unit is really done after this