Micro AIs: fix bug requiring unnecessary keys for MAI removal

MAIs which take either [filter] or id= used to throw an error message
if neither was given even for MAI removal.
This commit is contained in:
mattsc 2014-03-31 07:49:56 -07:00
parent 84b1234835
commit 7c3d9093fb

View file

@ -86,7 +86,7 @@ function wesnoth.wml_actions.micro_ai(cfg)
--------- Messenger Escort Micro AI ------------------------------------
elseif (cfg.ai_type == 'messenger_escort') then
if (not cfg.id) and (not H.get_child(cfg, "filter")) then
if (cfg.action ~= 'delete') and (not cfg.id) and (not H.get_child(cfg, "filter")) then
H.wml_error("Messenger [micro_ai] tag requires either id= key or [filter] tag")
end
required_keys = { "waypoint_x", "waypoint_y" }
@ -190,7 +190,7 @@ function wesnoth.wml_actions.micro_ai(cfg)
--------- Micro AI Guardian -----------------------------------
elseif (cfg.ai_type == 'stationed_guardian') then
if (not cfg.id) and (not H.get_child(cfg, "filter")) then
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" }
@ -198,7 +198,7 @@ function wesnoth.wml_actions.micro_ai(cfg)
CA_parms = { { ca_id = 'mai_stationed_guardian', location = CA_path .. 'ca_stationed_guardian.lua', score = cfg.ca_score or 300000 } }
elseif (cfg.ai_type == 'zone_guardian') then
if (not cfg.id) and (not H.get_child(cfg, "filter")) then
if (cfg.action ~= 'delete') and (not cfg.id) and (not H.get_child(cfg, "filter")) then
H.wml_error("Zone Guardian [micro_ai] tag requires either id= key or [filter] tag")
end
required_keys = { "filter_location" }
@ -206,7 +206,7 @@ function wesnoth.wml_actions.micro_ai(cfg)
CA_parms = { { ca_id = 'mai_zone_guardian', location = CA_path .. 'ca_zone_guardian.lua', score = cfg.ca_score or 300000 } }
elseif (cfg.ai_type == 'return_guardian') then
if (not cfg.id) and (not H.get_child(cfg, "filter")) then
if (cfg.action ~= 'delete') and (not cfg.id) and (not H.get_child(cfg, "filter")) then
H.wml_error("Return Guardian [micro_ai] tag requires either id= key or [filter] tag")
end
required_keys = { "return_x", "return_y" }
@ -214,7 +214,7 @@ function wesnoth.wml_actions.micro_ai(cfg)
CA_parms = { { ca_id = 'mai_return_guardian', location = CA_path .. 'ca_return_guardian.lua', score = cfg.ca_score or 100010 } }
elseif (cfg.ai_type == 'coward') then
if (not cfg.id) and (not H.get_child(cfg, "filter")) then
if (cfg.action ~= 'delete') and (not cfg.id) and (not H.get_child(cfg, "filter")) then
H.wml_error("Coward [micro_ai] tag requires either id= key or [filter] tag")
end
required_keys = { "distance" }
@ -320,7 +320,7 @@ function wesnoth.wml_actions.micro_ai(cfg)
}
elseif (cfg.ai_type == 'hunter') then
if (not cfg.id) and (not H.get_child(cfg, "filter")) then
if (cfg.action ~= 'delete') and (not cfg.id) and (not H.get_child(cfg, "filter")) then
H.wml_error("Hunter [micro_ai] tag requires either id= key or [filter] tag")
end
required_keys = { "home_x", "home_y" }
@ -329,7 +329,7 @@ function wesnoth.wml_actions.micro_ai(cfg)
--------- Patrol Micro AI ------------------------------------
elseif (cfg.ai_type == 'patrol') then
if (not cfg.id) and (not H.get_child(cfg, "filter")) then
if (cfg.action ~= 'delete') and (not cfg.id) and (not H.get_child(cfg, "filter")) then
H.wml_error("Patrol [micro_ai] tag requires either id= key or [filter] tag")
end
required_keys = { "waypoint_x", "waypoint_y" }