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:
parent
14570a0a96
commit
500ccde573
1 changed files with 14 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue