diff --git a/data/ai/micro_ais/cas/ca_assassin_move.lua b/data/ai/micro_ais/cas/ca_assassin_move.lua index 3ffec2fe607..5c53344e6cc 100644 --- a/data/ai/micro_ais/cas/ca_assassin_move.lua +++ b/data/ai/micro_ais/cas/ca_assassin_move.lua @@ -149,7 +149,7 @@ function ca_assassin_move:execution(cfg) -- We need to pick the farthest reachable hex along that path local farthest_hex = path[1] for i = 2,#path do - local sub_path, sub_cost = wesnoth.find_path(unit, path[i][1], path[i][2]) + local sub_path, sub_cost = AH.find_path_with_shroud(unit, path[i][1], path[i][2]) if sub_cost <= unit.moves then local unit_in_way = wesnoth.get_unit(path[i][1], path[i][2]) if (not AH.is_visible_unit(wesnoth.current.side, unit_in_way)) then diff --git a/data/ai/micro_ais/cas/ca_bottleneck_move.lua b/data/ai/micro_ais/cas/ca_bottleneck_move.lua index 28cf39f8d3d..8019c3054f7 100644 --- a/data/ai/micro_ais/cas/ca_bottleneck_move.lua +++ b/data/ai/micro_ais/cas/ca_bottleneck_move.lua @@ -26,7 +26,7 @@ local function bottleneck_is_my_territory(map, enemy_map) -- Find lowest movement cost to own front-line hexes local min_cost, best_path = 9e99 map:iter(function(xm, ym, v) - local path, cost = wesnoth.find_path(dummy_unit, xm, ym, { ignore_units = true }) + local path, cost = AH.find_path_with_shroud(dummy_unit, xm, ym, { ignore_units = true }) if (cost < min_cost) then min_cost, best_path = cost, path end @@ -35,7 +35,7 @@ local function bottleneck_is_my_territory(map, enemy_map) -- And the same to the enemy front line local min_cost_enemy, best_path_enemy = 9e99 enemy_map:iter(function(xm, ym, v) - local path, cost = wesnoth.find_path(dummy_unit, xm, ym, { ignore_units = true }) + local path, cost = AH.find_path_with_shroud(dummy_unit, xm, ym, { ignore_units = true }) if (cost < min_cost_enemy) then min_cost_enemy, best_path_enemy = cost, path end diff --git a/data/ai/micro_ais/cas/ca_fast_move.lua b/data/ai/micro_ais/cas/ca_fast_move.lua index 28fff7f7f35..5c8434116aa 100644 --- a/data/ai/micro_ais/cas/ca_fast_move.lua +++ b/data/ai/micro_ais/cas/ca_fast_move.lua @@ -147,8 +147,8 @@ function ca_fast_move:execution(cfg) for _,unit_info in ipairs(goal) do if (not unit_info.cost) then local _,cost = - wesnoth.find_path( - units[unit_info.i_unit].x, units[unit_info.i_unit].y, + AH.find_path_with_shroud( + units[unit_info.i_unit], goal.x, goal.y, { ignore_units = true } ) @@ -172,13 +172,13 @@ function ca_fast_move:execution(cfg) -- We now want the hex that is 2 steps beyond the next hop for the unit -- on its way toward the goal, ignoring any unit along the way - local path = wesnoth.find_path(unit, goal.x, goal.y, { ignore_units = true }) + local path = AH.find_path_with_shroud(unit, goal.x, goal.y, { ignore_units = true }) -- Use current unit position as default local short_goal, index = { unit.x, unit.y }, 1 for i = 2,#path do - local _, sub_cost = wesnoth.find_path(unit, path[i][1], path[i][2], { ignore_units = true }) + local _, sub_cost = AH.find_path_with_shroud(unit, path[i][1], path[i][2], { ignore_units = true }) if (sub_cost <= unit.moves) then short_goal, index = path[i], i @@ -254,7 +254,7 @@ function ca_fast_move:execution(cfg) if (pre_rating.rating <= max_rating) then break end unit.x, unit.y = pre_rating.x, pre_rating.y - local _,cost = wesnoth.find_path(unit, short_goal[1], short_goal[2]) + local _,cost = AH.find_path_with_shroud(unit, short_goal[1], short_goal[2]) local rating = - cost + pre_rating.other_rating diff --git a/data/ai/micro_ais/cas/ca_forest_animals_new_rabbit.lua b/data/ai/micro_ais/cas/ca_forest_animals_new_rabbit.lua index 0e6581772ac..dc75f6ef3e6 100644 --- a/data/ai/micro_ais/cas/ca_forest_animals_new_rabbit.lua +++ b/data/ai/micro_ais/cas/ca_forest_animals_new_rabbit.lua @@ -65,6 +65,10 @@ function ca_forest_animals_new_rabbit:execution(cfg) .. "' }, x1, y1)" ai.synced_command(command, x, y) end + + if wesnoth.sides[wesnoth.current.side].shroud then + wesnoth.wml_actions.redraw { side = wesnoth.current.side } + end end return ca_forest_animals_new_rabbit diff --git a/data/ai/micro_ais/cas/ca_goto.lua b/data/ai/micro_ais/cas/ca_goto.lua index 555fd23bbb3..3771df3fe86 100644 --- a/data/ai/micro_ais/cas/ca_goto.lua +++ b/data/ai/micro_ais/cas/ca_goto.lua @@ -152,7 +152,7 @@ function ca_goto:execution(cfg, data) enemy_at_goal = nil end end - path, cost = wesnoth.find_path(unit, loc[1], loc[2], { ignore_units = cfg.ignore_units }) + path, cost = AH.find_path_with_shroud(unit, loc[1], loc[2], { ignore_units = cfg.ignore_units }) if enemy_at_goal then wesnoth.put_unit(enemy_at_goal) --- Give massive penalty for this goal hex @@ -193,13 +193,13 @@ function ca_goto:execution(cfg, data) -- rather than using ai_helper.next_hop for standard pathfinding -- Also, straight-line does not produce a path, so we do that first if not best_path then - best_path = wesnoth.find_path(best_unit, closest_hex[1], closest_hex[2]) + best_path = AH.find_path_with_shroud(best_unit, closest_hex[1], closest_hex[2]) end -- Now go through the hexes along that path, use normal path finding closest_hex = best_path[1] for i = 2,#best_path do - local sub_path, sub_cost = wesnoth.find_path(best_unit, best_path[i][1], best_path[i][2], cfg) + local sub_path, sub_cost = AH.find_path_with_shroud(best_unit, best_path[i][1], best_path[i][2], cfg) if sub_cost <= best_unit.moves then local unit_in_way = wesnoth.get_unit(best_path[i][1], best_path[i][2]) if (not AH.is_visible_unit(wesnoth.current.side, unit_in_way)) then diff --git a/data/ai/micro_ais/cas/ca_messenger_attack.lua b/data/ai/micro_ais/cas/ca_messenger_attack.lua index c1f276f53f0..54d5c872664 100644 --- a/data/ai/micro_ais/cas/ca_messenger_attack.lua +++ b/data/ai/micro_ais/cas/ca_messenger_attack.lua @@ -10,7 +10,7 @@ local function messenger_find_enemies_in_way(messenger, goal_x, goal_y) -- @goal_x,@goal_y: coordinates of the goal toward which the messenger moves -- Returns proxy table for the first unit found, or nil if none was found - local path, cost = wesnoth.find_path(messenger, goal_x, goal_y, { ignore_units = true }) + local path, cost = AH.find_path_with_shroud(messenger, goal_x, goal_y, { ignore_units = true }) if cost >= 42424242 then return end -- The second path hex is the first that is important for the following analysis @@ -23,7 +23,7 @@ local function messenger_find_enemies_in_way(messenger, goal_x, goal_y) -- After that, go through adjacent hexes of all the other path hexes for i = 2,#path do - local sub_path, sub_cost = wesnoth.find_path(messenger, path[i][1], path[i][2], { ignore_units = true }) + local sub_path, sub_cost = AH.find_path_with_shroud(messenger, path[i][1], path[i][2], { ignore_units = true }) if (sub_cost <= messenger.moves) then for xa,ya in H.adjacent_tiles(path[i][1], path[i][2]) do local enemy = wesnoth.get_unit(xa, ya) diff --git a/data/ai/micro_ais/cas/ca_messenger_move.lua b/data/ai/micro_ais/cas/ca_messenger_move.lua index 596dee3c072..528bf8ed38b 100644 --- a/data/ai/micro_ais/cas/ca_messenger_move.lua +++ b/data/ai/micro_ais/cas/ca_messenger_move.lua @@ -30,10 +30,10 @@ function ca_messenger_move:execution(cfg) if (not next_hop) then next_hop = { messenger.x, messenger.y } end -- Compare this to the "ideal path" - local path = wesnoth.find_path(messenger, x, y, { ignore_units = 'yes' }) + local path = AH.find_path_with_shroud(messenger, x, y, { ignore_units = 'yes' }) local optimum_hop, optimum_cost = { messenger.x, messenger.y }, 0 for _,step in ipairs(path) do - local sub_path, sub_cost = wesnoth.find_path(messenger, step[1], step[2]) + local sub_path, sub_cost = AH.find_path_with_shroud(messenger, step[1], step[2]) if sub_cost > messenger.moves then break else @@ -61,14 +61,14 @@ function ca_messenger_move:execution(cfg) if unit_in_way then wesnoth.extract_unit(unit_in_way) end wesnoth.put_unit(messenger, next_hop[1], next_hop[2]) - local _, cost1 = wesnoth.find_path(messenger, x, y, { ignore_units = 'yes' }) + 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 wesnoth.extract_unit(unit_in_way2) end wesnoth.put_unit(messenger, optimum_hop[1], optimum_hop[2]) - local _, cost2 = wesnoth.find_path(messenger, x, y, { ignore_units = 'yes' }) + local _, cost2 = AH.find_path_with_shroud(messenger, x, y, { ignore_units = 'yes' }) wesnoth.put_unit(messenger, x_current, y_current) if unit_in_way then wesnoth.put_unit(unit_in_way) end diff --git a/data/ai/micro_ais/cas/ca_protect_unit_finish.lua b/data/ai/micro_ais/cas/ca_protect_unit_finish.lua index 35b6101655b..029dae7ab27 100644 --- a/data/ai/micro_ais/cas/ca_protect_unit_finish.lua +++ b/data/ai/micro_ais/cas/ca_protect_unit_finish.lua @@ -8,7 +8,7 @@ function ca_protect_unit_finish:evaluation(cfg) for u in H.child_range(cfg, "unit") do local unit = AH.get_units_with_moves { id = u.id }[1] if unit then - local path, cost = wesnoth.find_path(unit, u.goal_x, u.goal_y) + local path, cost = AH.find_path_with_shroud(unit, u.goal_x, u.goal_y) if (cost <= unit.moves) and ((unit.x ~= u.goal_x) or (unit.y ~= u.goal_y)) then PU_unit = unit PU_goal = { u.goal_x, u.goal_y }