Messenger MAI Lua code: change proxy unit location directly

(cherry-picked from commit b3058e8e8e)
This commit is contained in:
mattsc 2018-08-27 07:13:18 -07:00
parent 25b2024ee8
commit 5bc44fcc0d

View file

@ -59,17 +59,17 @@ function ca_messenger_move:execution(cfg)
if (unit_in_way == messenger) then unit_in_way = nil end
if unit_in_way then unit_in_way:extract() end
wesnoth.put_unit(messenger, next_hop[1], next_hop[2])
messenger.loc = { next_hop[1], next_hop[2] }
local _, cost1 = AH.find_path_with_shroud(messenger, x, y, { ignore_units = 'yes' })
local unit_in_way2 = wesnoth.get_unit(optimum_hop[1], optimum_hop[2])
if (unit_in_way2 == messenger) then unit_in_way2 = nil end
if unit_in_way2 then unit_in_way2:extract() end
wesnoth.put_unit(messenger, optimum_hop[1], optimum_hop[2])
messenger.loc = { optimum_hop[1], optimum_hop[2] }
local _, cost2 = AH.find_path_with_shroud(messenger, x, y, { ignore_units = 'yes' })
wesnoth.put_unit(messenger, x_current, y_current)
messenger.loc = { x_current, y_current }
if unit_in_way then unit_in_way:to_map() end
if unit_in_way2 then unit_in_way2:to_map() end