Goto/Assassin MAIs: fix AIs not always working with tunnels

The old syntax for using a custom cost function ignored teleports/tunnels. Using calculate= in the path options table allows also setting the ignore_teleports option (but in this syntax it defaults to 'false', so it does not need to be done specifically).
This commit is contained in:
mattsc 2018-12-30 16:26:18 -08:00
parent 7875f4fc08
commit 152eb37aec
3 changed files with 7 additions and 6 deletions

View file

@ -3,6 +3,7 @@
* Micro AIs
* Add [avoid] tag functionality to Multipack Wolves, Wolves, Swarm and Goto Micro AIs
* Support named locations for [micro_ai] tag location keys
* Goto and Assassin: fix MAIs not working with tunnels when using custom path finding cost functions
* Experimental AI
* Deprecate EXPERIMENTAL_AI macro: use ai_algorithm=experimental_ai in the [ai] tag instead
* Convert to using external candidate actions

View file

@ -138,11 +138,11 @@ function ca_assassin_move:execution(cfg)
end
end
local path, cost = wesnoth.find_path(unit, target.x, target.y,
function(x, y, current_cost)
local path, cost = wesnoth.find_path(unit, target.x, target.y, {
calculate = function(x, y, current_cost)
return custom_cost(x, y, unit, enemy_rating_map, prefer_map)
end
)
})
local path_map = LS.of_pairs(path)

View file

@ -150,11 +150,11 @@ function ca_goto:execution(cfg, data)
else -- Otherwise find the best path to take
local path, cost
if GO_avoid_map or cfg.avoid_enemies then
path, cost = wesnoth.find_path(unit, loc[1], loc[2],
function(x, y, current_cost)
path, cost = wesnoth.find_path(unit, loc[1], loc[2], {
calculate = function(x, y, current_cost)
return custom_cost(x, y, unit, GO_avoid_map, enemy_map, enemy_attack_map, cfg.avoid_enemies)
end
)
})
else
local enemy_at_goal
if cfg.ignore_enemy_at_goal then