battle_calcs.best_defense_map(): add parameter ignore_these_units
This is a table of enemy units whose ZoC is to be ignored for route finding. It is useful for determing where the enemy can move while ignoring own units (enemies of the enemy) that have not moved yet.
This commit is contained in:
parent
526debf3e9
commit
554a95749a
1 changed files with 9 additions and 0 deletions
|
@ -1322,11 +1322,16 @@ function battle_calcs.best_defense_map(units, cfg)
|
|||
-- For each hex, the value is the maximum of any of the units that can reach that hex
|
||||
-- cfg: table with config parameters
|
||||
-- max_moves: if set use max_moves for units (this setting is always used for units on other sides)
|
||||
-- ignore_these_units: table of enemy units whose ZoC is to be ignored for route finding
|
||||
|
||||
cfg = cfg or {}
|
||||
|
||||
local defense_map = LS.create()
|
||||
|
||||
if cfg.ignore_these_units then
|
||||
for i,u in ipairs(cfg.ignore_these_units) do wesnoth.extract_unit(u) end
|
||||
end
|
||||
|
||||
for i,u in ipairs(units) do
|
||||
-- Set max_moves according to the cfg value
|
||||
local max_moves = cfg.max_moves
|
||||
|
@ -1346,6 +1351,10 @@ function battle_calcs.best_defense_map(units, cfg)
|
|||
end
|
||||
end
|
||||
|
||||
if cfg.ignore_these_units then
|
||||
for i,u in ipairs(cfg.ignore_these_units) do wesnoth.put_unit(u.x, u.y, u) end
|
||||
end
|
||||
|
||||
return defense_map
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue