mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-09 21:29:00 +00:00
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:
parent
5f6487c4e5
commit
ded53dd332
@ -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
|
||||
|
@ -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 }
|
||||
|
Loading…
x
Reference in New Issue
Block a user