Stationed Guardian Micro AI: make guard_x/y optional keys

If not provided, they now default to stationed_x/y.
This commit is contained in:
mattsc 2014-06-15 11:59:31 -07:00
parent 5f6487c4e5
commit ded53dd332
2 changed files with 3 additions and 3 deletions

View File

@ -40,7 +40,7 @@ function ca_stationed_guardian:execution(ai, cfg)
local min_dist, target = 9e99
for _,enemy in ipairs(enemies) do
local dist_s = H.distance_between(cfg.station_x, cfg.station_y, enemy.x, enemy.y)
local dist_g = H.distance_between(cfg.guard_x, cfg.guard_y, enemy.x, enemy.y)
local dist_g = H.distance_between(cfg.guard_x or cfg.station_x, cfg.guard_y or cfg.station_y, enemy.x, enemy.y)
-- If valid target found, save the one with the shortest distance from (g_x, g_y)
if (dist_s <= cfg.distance) and (dist_g <= cfg.distance) and (dist_g < min_dist) then

View File

@ -200,8 +200,8 @@ function wesnoth.wml_actions.micro_ai(cfg)
if (cfg.action ~= 'delete') and (not cfg.id) and (not H.get_child(cfg, "filter")) then
H.wml_error("Stationed Guardian [micro_ai] tag requires either id= key or [filter] tag")
end
required_keys = { "distance", "station_x", "station_y", "guard_x", "guard_y" }
optional_keys = { "id", "filter" }
required_keys = { "distance", "station_x", "station_y" }
optional_keys = { "id", "filter", "guard_x", "guard_y" }
CA_parms = {
ai_id = 'mai_stationed_guardian',
{ ca_id = 'move', location = CA_path .. 'ca_stationed_guardian.lua', score = cfg.ca_score or 300000 }