Skip to content

Commit

Permalink
fixup 0f01f97 (GNA25615)
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Mar 23, 2017
1 parent cada1d2 commit f45d795
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 31 deletions.
5 changes: 2 additions & 3 deletions 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 = {}

Expand All @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions 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 = {}

Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions data/ai/micro_ais/engines/priority_target_engine.lua
Expand Up @@ -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",
Expand All @@ -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
Expand Down
19 changes: 9 additions & 10 deletions 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 = {
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions 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)
Expand Down Expand Up @@ -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
Expand All @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions 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",
Expand Down
9 changes: 4 additions & 5 deletions 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"
Expand Down Expand Up @@ -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

Expand All @@ -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 }
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit f45d795

Please sign in to comment.