Coward Micro AI: add optional tag [filter_second]

This tag determines from which units the coward flees.  It defaults to
all enemy units, but can be set to enemy and/or allied units if
specified.
This commit is contained in:
mattsc 2014-01-03 19:02:56 -08:00
parent c55f9215cf
commit f856cadff6
3 changed files with 5 additions and 2 deletions

View file

@ -9,6 +9,7 @@ Version 1.11.7+dev:
conversion errors and stalling clients (bug #20893).
* AI:
* RCA AI: fix bug #21334: surrounded units don't attack
* Coward Micro AI: new optional parameter [filter_second]
* Simple Attack Micro AI: new optional parameter weapon=
* Wolves Micro AI: fix bug that sometimes kept predators from attacking
* Lua AI: new replay-safe action ai.synced_command()

View file

@ -35,9 +35,11 @@ function ca_coward:execution(ai, cfg)
end
local reach = wesnoth.find_reach(unit)
-- enemy units within reach
local filter_second = cfg.filter_second or { { "filter_side", {{"enemy_of", {side = wesnoth.current.side} }} } }
local enemies = wesnoth.get_units {
{ "filter_side", {{"enemy_of", {side = wesnoth.current.side} }} },
{ "and", filter_second },
{ "filter_location", {x = unit.x, y = unit.y, radius = cfg.distance} }
}

View file

@ -335,7 +335,7 @@ function wesnoth.wml_actions.micro_ai(cfg)
H.wml_error("Coward [micro_ai] tag requires either id= key or [filter] tag")
end
required_keys = { "distance" }
optional_keys = { "id", "filter", "seek_x", "seek_y","avoid_x","avoid_y" }
optional_keys = { "id", "filter", "filter_second", "seek_x", "seek_y","avoid_x","avoid_y" }
CA_parms = { { ca_id = 'mai_coward', location = 'ai/micro_ais/cas/ca_coward.lua', score = cfg.ca_score or 300000 } }
--------- Micro AI Animals ------------------------------------