diff --git a/data/ai/micro_ais/cas/ca_healer_initialize.lua b/data/ai/micro_ais/cas/ca_healer_initialize.lua index 9ac7a19ce6c9..2cd96ff266a5 100644 --- a/data/ai/micro_ais/cas/ca_healer_initialize.lua +++ b/data/ai/micro_ais/cas/ca_healer_initialize.lua @@ -1,5 +1,4 @@ local H = wesnoth.require "lua/helper.lua" -local W = H.set_wml_action_metatable {} local ca_healer_initialize = {} @@ -12,9 +11,9 @@ function ca_healer_initialize:evaluation() end function ca_healer_initialize:execution(cfg, data) - W.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[no_healers_attack]") + wesnoth.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[no_healers_attack]") - W.add_ai_component(wesnoth.current.side, "aspect[attacks].facet", + wesnoth.add_ai_component(wesnoth.current.side, "aspect[attacks].facet", { name = "ai_default_rca::aspect_attacks", id = "no_healers_attack", diff --git a/data/ai/micro_ais/cas/ca_healer_may_attack.lua b/data/ai/micro_ais/cas/ca_healer_may_attack.lua index 5ce10c8e50bd..ea694e92535b 100644 --- a/data/ai/micro_ais/cas/ca_healer_may_attack.lua +++ b/data/ai/micro_ais/cas/ca_healer_may_attack.lua @@ -1,5 +1,4 @@ local H = wesnoth.require "lua/helper.lua" -local W = H.set_wml_action_metatable {} local ca_healer_may_attack = {} @@ -12,7 +11,7 @@ function ca_healer_may_attack:evaluation() end function ca_healer_may_attack:execution(cfg, data) - W.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[no_healers_attack]") + wesnoth.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[no_healers_attack]") -- Once combat (by other units) is done, set the healer move score so that it -- now happens before combat (of the healers which were so far excluded from combat) diff --git a/data/ai/micro_ais/engines/priority_target_engine.lua b/data/ai/micro_ais/engines/priority_target_engine.lua index 6d6f0b3dab3e..12749edb1df5 100644 --- a/data/ai/micro_ais/engines/priority_target_engine.lua +++ b/data/ai/micro_ais/engines/priority_target_engine.lua @@ -39,15 +39,15 @@ return { end -- Always delete the attacks aspect first, so that we do not end up with 100 copies of the facet - W.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[limited_attack]") + wesnoth.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[limited_attack]") -- Also delete aggression, caution - for the same reason - W.delete_ai_component(wesnoth.current.side, "aspect[aggression].facet[*]") - W.delete_ai_component(wesnoth.current.side, "aspect[caution].facet[*]") + wesnoth.delete_ai_component(wesnoth.current.side, "aspect[aggression].facet[*]") + wesnoth.delete_ai_component(wesnoth.current.side, "aspect[caution].facet[*]") -- If the target can be attacked, set the attacks aspect accordingly if attack_locs[1] then - W.add_ai_component(wesnoth.current.side, "aspect[attacks].facet", + wesnoth.add_ai_component(wesnoth.current.side, "aspect[attacks].facet", { name = "ai_default_rca::aspect_attacks", id = "limited_attack", @@ -58,7 +58,7 @@ return { -- We also want to set aggression=1 and caution=0, -- otherwise there could be turns on which nothing happens - W.append_ai{ aggression = 1, caution = 0 } + wesnoth.append_ai{ aggression = 1, caution = 0 } end return 0 diff --git a/data/ai/micro_ais/mai-defs/fast.lua b/data/ai/micro_ais/mai-defs/fast.lua index b4a5e32273b7..1f1a59941213 100644 --- a/data/ai/micro_ais/mai-defs/fast.lua +++ b/data/ai/micro_ais/mai-defs/fast.lua @@ -1,5 +1,4 @@ local H = wesnoth.require "lua/helper.lua" -local W = H.set_wml_action_metatable {} function wesnoth.micro_ais.fast_ai(cfg) local optional_keys = { @@ -18,7 +17,7 @@ function wesnoth.micro_ais.fast_ai(cfg) -- Also need to delete/add some default CAs if (cfg.action == 'delete') then -- This can be done independently of whether these were removed earlier - W.add_ai_component(cfg.side, "stage[main_loop].candidate_action", + wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action", { id="combat", engine="cpp", @@ -28,7 +27,7 @@ function wesnoth.micro_ais.fast_ai(cfg) } ) - W.add_ai_component(cfg.side, "stage[main_loop].candidate_action", + wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action", { id="villages", engine="cpp", @@ -38,7 +37,7 @@ function wesnoth.micro_ais.fast_ai(cfg) } ) - W.add_ai_component(cfg.side, "stage[main_loop].candidate_action", + wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action", { id="retreat", engine="cpp", @@ -48,7 +47,7 @@ function wesnoth.micro_ais.fast_ai(cfg) } ) - W.add_ai_component(cfg.side, "stage[main_loop].candidate_action", + wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action", { id="move_to_targets", engine="cpp", @@ -59,8 +58,8 @@ function wesnoth.micro_ais.fast_ai(cfg) ) else if (not cfg.skip_combat_ca) then - W.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[high_xp_attack]") - W.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[combat]") + wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[high_xp_attack]") + wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[combat]") else for i,parm in ipairs(CA_parms) do if (parm.ca_id == 'combat') or (parm.ca_id == 'combat_leader') then @@ -70,11 +69,11 @@ function wesnoth.micro_ais.fast_ai(cfg) end if (not cfg.skip_move_ca) then - W.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[villages]") + wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[villages]") - W.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[retreat]") + wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[retreat]") - W.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[move_to_targets]") + wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[move_to_targets]") else for i,parm in ipairs(CA_parms) do if (parm.ca_id == 'move') then diff --git a/data/ai/micro_ais/mai-defs/protect.lua b/data/ai/micro_ais/mai-defs/protect.lua index 9f0b31dafe4a..f88a038e8974 100644 --- a/data/ai/micro_ais/mai-defs/protect.lua +++ b/data/ai/micro_ais/mai-defs/protect.lua @@ -1,5 +1,4 @@ local H = wesnoth.require "lua/helper.lua" -local W = H.set_wml_action_metatable {} local MAIH = wesnoth.require("ai/micro_ais/micro_ai_helper.lua") function wesnoth.micro_ais.protect_unit(cfg) @@ -28,7 +27,7 @@ function wesnoth.micro_ais.protect_unit(cfg) -- Optional key disable_move_leader_to_keep: needs to be dealt with -- separately as it affects a default CA if cfg.disable_move_leader_to_keep then - W.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[move_leader_to_keep]") + wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[move_leader_to_keep]") end -- attacks aspects also needs to be set separately @@ -52,7 +51,7 @@ function wesnoth.micro_ais.protect_unit(cfg) MAIH.delete_aspects(cfg.side, aspect_parms) -- We also need to add the move_leader_to_keep CA back in -- This works even if it was not removed, it simply overwrites the existing CA - W.add_ai_component(side, "stage[main_loop].candidate_action", + wesnoth.add_ai_component(side, "stage[main_loop].candidate_action", { id="move_leader_to_keep", engine="cpp", diff --git a/data/ai/micro_ais/mai-defs/recruiting.lua b/data/ai/micro_ais/mai-defs/recruiting.lua index c4d4ad91b0e1..cdff152ed698 100644 --- a/data/ai/micro_ais/mai-defs/recruiting.lua +++ b/data/ai/micro_ais/mai-defs/recruiting.lua @@ -1,14 +1,13 @@ local H = wesnoth.require "lua/helper.lua" -local W = H.set_wml_action_metatable {} local function handle_default_recruitment(cfg) -- Also need to delete/add the default recruitment CA if cfg.action == 'add' then - W.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[recruitment]") + wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[recruitment]") elseif cfg.action == 'delete' then -- We need to add the recruitment CA back in -- This works even if it was not removed, it simply overwrites the existing CA - W.add_ai_component(cfg.side, "stage[main_loop].candidate_action", + wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action", { id="recruitment", engine="cpp", diff --git a/data/ai/micro_ais/micro_ai_helper.lua b/data/ai/micro_ais/micro_ai_helper.lua index 8dde7a1e61f0..800072745d5a 100644 --- a/data/ai/micro_ais/micro_ai_helper.lua +++ b/data/ai/micro_ais/micro_ai_helper.lua @@ -1,5 +1,4 @@ local H = wesnoth.require "lua/helper.lua" -local W = H.set_wml_action_metatable {} local T = H.set_wml_tag_metatable {} local AH = wesnoth.require("ai/lua/ai_helper.lua") local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua" @@ -93,7 +92,7 @@ function micro_ai_helper.add_CAs(side, ca_id_core, CA_parms, CA_cfg) CA.location = parms.location table.insert(CA, T.args(CA_cfg)) - W.add_ai_component(side, "stage[main_loop].candidate_action", CA) + wesnoth.add_ai_component(side, "stage[main_loop].candidate_action", CA) end end @@ -110,7 +109,7 @@ function micro_ai_helper.delete_CAs(side, ca_id_core, CA_parms) for _,parms in ipairs(CA_parms) do local ca_id = ca_id_core .. '_' .. parms.ca_id - W.delete_ai_component(side, "stage[main_loop].candidate_action[" .. ca_id .. "]") + wesnoth.delete_ai_component(side, "stage[main_loop].candidate_action[" .. ca_id .. "]") -- Also need to delete variable stored in all units of the side, so that later MAIs can use these units local units = wesnoth.get_units { side = side } @@ -142,7 +141,7 @@ function micro_ai_helper.add_aspects(side, aspect_parms) -- } for _,parms in ipairs(aspect_parms) do - W.add_ai_component(side, "aspect[" .. parms.aspect .. "].facet", parms.facet) + wesnoth.add_ai_component(side, "aspect[" .. parms.aspect .. "].facet", parms.facet) end end @@ -153,7 +152,7 @@ function micro_ai_helper.delete_aspects(side, aspect_parms) -- aspect_parms.aspect_id field is needed for _,parms in ipairs(aspect_parms) do - W.delete_ai_component(side, "aspect[attacks].facet[" .. parms.facet.id .. "]") + wesnoth.delete_ai_component(side, "aspect[attacks].facet[" .. parms.facet.id .. "]") end end