next_hop(): bug fix for ignoring units when ignore_units=true is set
A bug in the previous version let to them not being ignored when the were on the last hex of the next hop.
This commit is contained in:
parent
9366aa2a9c
commit
03c1b97802
1 changed files with 10 additions and 6 deletions
|
@ -927,13 +927,17 @@ function ai_helper.next_hop(unit, x, y, cfg)
|
|||
local sub_path, sub_cost = wesnoth.find_path( unit, path[i][1], path[i][2], cfg)
|
||||
|
||||
if sub_cost <= unit.moves then
|
||||
local unit_in_way = wesnoth.get_unit(path[i][1], path[i][2])
|
||||
-- Check for unit in way only if cfg.ignore_units is not set
|
||||
local unit_in_way
|
||||
if (not cfg) or (not cfg.ignore_units) then
|
||||
unit_in_way = wesnoth.get_unit(path[i][1], path[i][2])
|
||||
|
||||
-- If ignore_own_units is set, ignore own side units that can move out of the way
|
||||
if cfg and cfg.ignore_own_units then
|
||||
if unit_in_way and (unit_in_way.side == unit.side) then
|
||||
local reach = ai_helper.get_reachable_unocc(unit_in_way)
|
||||
if (reach:size() > 1) then unit_in_way = nil end
|
||||
-- If ignore_own_units is set, ignore own side units that can move out of the way
|
||||
if cfg and cfg.ignore_own_units then
|
||||
if unit_in_way and (unit_in_way.side == unit.side) then
|
||||
local reach = ai_helper.get_reachable_unocc(unit_in_way)
|
||||
if (reach:size() > 1) then unit_in_way = nil end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue