Bottleneck Micro AI: add [filter] as optional parameter
This commit is contained in:
parent
a90964fd41
commit
a78150e366
3 changed files with 7 additions and 6 deletions
|
@ -7,6 +7,7 @@ local ca_bottleneck_attack = {}
|
|||
function ca_bottleneck_attack:evaluation(cfg, data)
|
||||
local attackers = AH.get_units_with_attacks {
|
||||
side = wesnoth.current.side,
|
||||
{ "and", wml.get_child(cfg, "filter") },
|
||||
{ "filter_adjacent", {
|
||||
{ "filter_side", { { "enemy_of", {side = wesnoth.current.side} } } }
|
||||
} }
|
||||
|
@ -63,7 +64,7 @@ end
|
|||
|
||||
function ca_bottleneck_attack:execution(cfg, data)
|
||||
if BD_bottleneck_attacks_done then
|
||||
local units = AH.get_units_with_attacks { side = wesnoth.current.side }
|
||||
local units = AH.get_units_with_attacks { side = wesnoth.current.side, { "and", wml.get_child(cfg, "filter") } }
|
||||
for _,unit in ipairs(units) do
|
||||
AH.checked_stopunit_attacks(ai, unit)
|
||||
end
|
||||
|
|
|
@ -230,9 +230,9 @@ function ca_bottleneck_move:evaluation(cfg, data)
|
|||
|
||||
local units = {}
|
||||
if MAISD.get_mai_self_data(data, cfg.ai_id, "side_leader_activated") then
|
||||
units = AH.get_units_with_moves { side = wesnoth.current.side }
|
||||
units = AH.get_units_with_moves { side = wesnoth.current.side, { "and", wml.get_child(cfg, "filter") } }
|
||||
else
|
||||
units = AH.get_units_with_moves { side = wesnoth.current.side, canrecruit = 'no' }
|
||||
units = AH.get_units_with_moves { side = wesnoth.current.side, canrecruit = 'no', { "and", wml.get_child(cfg, "filter") } }
|
||||
end
|
||||
if (not units[1]) then return 0 end
|
||||
|
||||
|
@ -469,9 +469,9 @@ function ca_bottleneck_move:execution(cfg, data)
|
|||
if BD_bottleneck_moves_done then
|
||||
local units = {}
|
||||
if MAISD.get_mai_self_data(data, cfg.ai_id, "side_leader_activated") then
|
||||
units = AH.get_units_with_moves { side = wesnoth.current.side }
|
||||
units = AH.get_units_with_moves { side = wesnoth.current.side, { "and", wml.get_child(cfg, "filter") } }
|
||||
else
|
||||
units = AH.get_units_with_moves { side = wesnoth.current.side, canrecruit = 'no' }
|
||||
units = AH.get_units_with_moves { side = wesnoth.current.side, canrecruit = 'no', { "and", wml.get_child(cfg, "filter") } }
|
||||
end
|
||||
|
||||
for _,unit in ipairs(units) do
|
||||
|
|
|
@ -7,7 +7,7 @@ function wesnoth.micro_ais.bottleneck_defense(cfg)
|
|||
end
|
||||
|
||||
local required_keys = {}
|
||||
local optional_keys = { "location_id", "x", "y", "enemy_loc", "enemy_x", "enemy_y",
|
||||
local optional_keys = { "location_id", "x", "y", "enemy_loc", "enemy_x", "enemy_y", "[filter]",
|
||||
"healer_loc", "healer_x", "healer_y", "leadership_loc","leadership_x", "leadership_y", "active_side_leader"
|
||||
}
|
||||
local score = cfg.ca_score or 300000
|
||||
|
|
Loading…
Add table
Reference in a new issue