Skip to content

Commit

Permalink
Stationed Guardian Micro AI: make guard_x/y optional keys
Browse files Browse the repository at this point in the history
If not provided, they now default to stationed_x/y.
  • Loading branch information
mattsc committed Jun 15, 2014
1 parent 5f6487c commit ded53dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_stationed_guardian.lua
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/micro_ai_wml_tag.lua
Expand Up @@ -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 }
Expand Down

0 comments on commit ded53dd

Please sign in to comment.