Wolves MAI: add optional parameter attack_only_prey=

By default, the wolves attack any enemy unit they can reach.  If this
key is set, only prey units are attacked.
This commit is contained in:
mattsc 2014-01-19 12:06:20 -08:00
parent a5a451834b
commit ed4fe91b44
2 changed files with 23 additions and 2 deletions

View file

@ -1,4 +1,6 @@
Version 1.11.8+dev:
* AI:
* Wolves Micro AI: new optional parameter attack_only_prey=
* Campaigns:
* Heir to the Throne:
* Gave Li'sar a new ability "initiative" (grants adjacent allies first

View file

@ -346,14 +346,33 @@ function wesnoth.wml_actions.micro_ai(cfg)
elseif (cfg.ai_type == 'wolves') then
required_keys = { "filter", "filter_second" }
optional_keys = { "avoid_type" }
optional_keys = { "attack_only_prey", "avoid_type" }
local score = cfg.ca_score or 90000
CA_parms = {
{ ca_id = "mai_wolves_move", location = 'ai/micro_ais/cas/ca_wolves_move.lua', score = score },
{ ca_id = "mai_wolves_wander", location = 'ai/micro_ais/cas/ca_wolves_wander.lua', score = score - 1 }
}
if cfg.avoid_type then
if cfg.attack_only_prey then
local wolves_aspects = {
{
aspect = "attacks",
facet = {
name = "ai_default_rca::aspect_attacks",
id = "dont_attack",
invalidate_on_gamestate_change = "yes",
{ "filter_enemy", {
{ "and", H.get_child(cfg, "filter_second") }
} }
}
}
}
if (cfg.action == "delete") then
delete_aspects(cfg.side, wolves_aspects)
else
add_aspects(cfg.side, wolves_aspects)
end
elseif cfg.avoid_type then
local wolves_aspects = {
{
aspect = "attacks",