Remove unnecessary inclusions of helper.set_wml_action_metatable {}
(cherry-picked from commit 1684e2f5da
)
This commit is contained in:
parent
49b1ef9549
commit
cb1bc56478
8 changed files with 17 additions and 25 deletions
|
@ -24,7 +24,6 @@ return {
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
|
|
||||||
local H = wesnoth.require "helper"
|
local H = wesnoth.require "helper"
|
||||||
local W = H.set_wml_action_metatable {}
|
|
||||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||||
local LS = wesnoth.require "location_set"
|
local LS = wesnoth.require "location_set"
|
||||||
local M = wesnoth.map
|
local M = wesnoth.map
|
||||||
|
@ -443,7 +442,7 @@ return {
|
||||||
end
|
end
|
||||||
|
|
||||||
function ai_cas:recruit_rushers_exec()
|
function ai_cas:recruit_rushers_exec()
|
||||||
if AH.show_messages() then W.message { speaker = 'narrator', message = 'Recruiting' } end
|
if AH.show_messages() then wesnoth.wml_actions.message { speaker = 'narrator', message = 'Recruiting' } end
|
||||||
|
|
||||||
local enemy_counts = recruit_data.recruit.enemy_counts
|
local enemy_counts = recruit_data.recruit.enemy_counts
|
||||||
local enemy_types = recruit_data.recruit.enemy_types
|
local enemy_types = recruit_data.recruit.enemy_types
|
||||||
|
|
|
@ -7,7 +7,6 @@ return {
|
||||||
-- More generic grunt rush (and can, in fact, be used with other unit types as well)
|
-- More generic grunt rush (and can, in fact, be used with other unit types as well)
|
||||||
|
|
||||||
local H = wesnoth.require "helper"
|
local H = wesnoth.require "helper"
|
||||||
local W = H.set_wml_action_metatable {}
|
|
||||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||||
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
|
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
|
||||||
local LS = wesnoth.require "location_set"
|
local LS = wesnoth.require "location_set"
|
||||||
|
@ -256,7 +255,7 @@ return {
|
||||||
local leader = wesnoth.get_units { side = wesnoth.current.side, canrecruit = 'yes' }[1]
|
local leader = wesnoth.get_units { side = wesnoth.current.side, canrecruit = 'yes' }[1]
|
||||||
|
|
||||||
if AH.print_exec() then print_time(' Executing castle_switch CA') end
|
if AH.print_exec() then print_time(' Executing castle_switch CA') end
|
||||||
if AH.show_messages() then W.message { speaker = leader.id, message = 'Switching castles' } end
|
if AH.show_messages() then wesnoth.wml_actions.message { speaker = leader.id, message = 'Switching castles' } end
|
||||||
|
|
||||||
AH.checked_move(ai, leader, self.data.leader_target[1], self.data.leader_target[2])
|
AH.checked_move(ai, leader, self.data.leader_target[1], self.data.leader_target[2])
|
||||||
self.data.leader_target = nil
|
self.data.leader_target = nil
|
||||||
|
@ -395,7 +394,7 @@ return {
|
||||||
|
|
||||||
function generic_rush:grab_villages_exec()
|
function generic_rush:grab_villages_exec()
|
||||||
if AH.print_exec() then print_time(' Executing grab_villages CA') end
|
if AH.print_exec() then print_time(' Executing grab_villages CA') end
|
||||||
if AH.show_messages() then W.message { speaker = self.data.unit.id, message = 'Grab villages' } end
|
if AH.show_messages() then wesnoth.wml_actions.message { speaker = self.data.unit.id, message = 'Grab villages' } end
|
||||||
|
|
||||||
AH.movefull_stopunit(ai, self.data.unit, self.data.village)
|
AH.movefull_stopunit(ai, self.data.unit, self.data.village)
|
||||||
self.data.unit, self.data.village = nil, nil
|
self.data.unit, self.data.village = nil, nil
|
||||||
|
@ -492,7 +491,7 @@ return {
|
||||||
local is_poisoner, poison_weapon = AH.has_weapon_special(attacker, "poison")
|
local is_poisoner, poison_weapon = AH.has_weapon_special(attacker, "poison")
|
||||||
|
|
||||||
if AH.print_exec() then print_time(' Executing spread_poison CA') end
|
if AH.print_exec() then print_time(' Executing spread_poison CA') end
|
||||||
if AH.show_messages() then W.message { speaker = attacker.id, message = 'Poison attack' } end
|
if AH.show_messages() then wesnoth.wml_actions.message { speaker = attacker.id, message = 'Poison attack' } end
|
||||||
|
|
||||||
AH.robust_move_and_attack(ai, attacker, self.data.attack.dst, self.data.attack.target, { weapon = poison_weapon })
|
AH.robust_move_and_attack(ai, attacker, self.data.attack.dst, self.data.attack.target, { weapon = poison_weapon })
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local H = wesnoth.require "helper"
|
local H = wesnoth.require "helper"
|
||||||
local W = H.set_wml_action_metatable {}
|
|
||||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||||
local LS = wesnoth.require "location_set"
|
local LS = wesnoth.require "location_set"
|
||||||
local M = wesnoth.map
|
local M = wesnoth.map
|
||||||
|
@ -45,9 +44,9 @@ function ca_forest_animals_move:execution(cfg)
|
||||||
local enemies = AH.get_attackable_enemies()
|
local enemies = AH.get_attackable_enemies()
|
||||||
|
|
||||||
-- Get the locations of all the rabbit holes
|
-- Get the locations of all the rabbit holes
|
||||||
W.store_items { variable = 'holes_wml' }
|
wesnoth.wml_actions.store_items { variable = 'holes_wml' }
|
||||||
local all_items = wml.array_access.get('holes_wml')
|
local all_items = wml.array_access.get('holes_wml')
|
||||||
W.clear_variable { name = 'holes_wml' }
|
wesnoth.wml_actions.clear_variable { name = 'holes_wml' }
|
||||||
|
|
||||||
-- If cfg.rabbit_hole_img is set, only items with that image or halo count as holes
|
-- If cfg.rabbit_hole_img is set, only items with that image or halo count as holes
|
||||||
local holes
|
local holes
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local H = wesnoth.require "helper"
|
local H = wesnoth.require "helper"
|
||||||
local W = H.set_wml_action_metatable {}
|
|
||||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||||
local T = wml.tag
|
local T = wml.tag
|
||||||
|
|
||||||
|
@ -18,9 +17,9 @@ function ca_forest_animals_new_rabbit:execution(cfg)
|
||||||
local rabbit_enemy_distance = cfg.rabbit_enemy_distance or 3
|
local rabbit_enemy_distance = cfg.rabbit_enemy_distance or 3
|
||||||
|
|
||||||
-- Get the locations of all items on that map (which could be rabbit holes)
|
-- Get the locations of all items on that map (which could be rabbit holes)
|
||||||
W.store_items { variable = 'holes_wml' }
|
wesnoth.wml_actions.store_items { variable = 'holes_wml' }
|
||||||
local all_items = wml.array_access.get('holes_wml')
|
local all_items = wml.array_access.get('holes_wml')
|
||||||
W.clear_variable { name = 'holes_wml' }
|
wesnoth.wml_actions.clear_variable { name = 'holes_wml' }
|
||||||
|
|
||||||
-- Eliminate all holes that have an enemy within 'rabbit_enemy_distance' hexes
|
-- Eliminate all holes that have an enemy within 'rabbit_enemy_distance' hexes
|
||||||
-- We also add a random number to the ones we keep, for selection of the holes later
|
-- We also add a random number to the ones we keep, for selection of the holes later
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local H = wesnoth.require "helper"
|
local H = wesnoth.require "helper"
|
||||||
local W = H.set_wml_action_metatable {}
|
|
||||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||||
local M = wesnoth.map
|
local M = wesnoth.map
|
||||||
|
@ -121,7 +120,7 @@ function ca_hunter:execution(cfg)
|
||||||
MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars)
|
MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars)
|
||||||
|
|
||||||
if cfg.show_messages then
|
if cfg.show_messages then
|
||||||
W.message { speaker = hunter.id, message = 'Now that I have eaten, I will go back home.' }
|
wesnoth.wml_actions.message { speaker = hunter.id, message = 'Now that I have eaten, I will go back home.' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ function ca_hunter:execution(cfg)
|
||||||
local enemy = wesnoth.get_unit(cfg.home_x, cfg.home_y)
|
local enemy = wesnoth.get_unit(cfg.home_x, cfg.home_y)
|
||||||
if AH.is_attackable_enemy(enemy) then
|
if AH.is_attackable_enemy(enemy) then
|
||||||
if cfg.show_messages then
|
if cfg.show_messages then
|
||||||
W.message { speaker = hunter.id, message = 'Get out of my home!' }
|
wesnoth.wml_actions.message { speaker = hunter.id, message = 'Get out of my home!' }
|
||||||
end
|
end
|
||||||
|
|
||||||
AH.checked_attack(ai, hunter, enemy)
|
AH.checked_attack(ai, hunter, enemy)
|
||||||
|
@ -162,7 +161,7 @@ function ca_hunter:execution(cfg)
|
||||||
MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars)
|
MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars)
|
||||||
|
|
||||||
if cfg.show_messages then
|
if cfg.show_messages then
|
||||||
W.message { speaker = hunter.id, message = 'I made it home - resting now until the end of Turn ' .. hunter_vars.resting_until .. ' or until fully healed.' }
|
wesnoth.wml_actions.message { speaker = hunter.id, message = 'I made it home - resting now until the end of Turn ' .. hunter_vars.resting_until .. ' or until fully healed.' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -185,7 +184,7 @@ function ca_hunter:execution(cfg)
|
||||||
MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars)
|
MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars)
|
||||||
|
|
||||||
if cfg.show_messages then
|
if cfg.show_messages then
|
||||||
W.message { speaker = hunter.id, message = 'I am done resting. It is time to go hunting again next turn.' }
|
wesnoth.wml_actions.message { speaker = hunter.id, message = 'I am done resting. It is time to go hunting again next turn.' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
[lua]
|
[lua]
|
||||||
code = <<
|
code = <<
|
||||||
H = wesnoth.dofile("lua/helper.lua")
|
H = wesnoth.dofile("lua/helper.lua")
|
||||||
W = H.set_wml_action_metatable({})
|
|
||||||
local tests_table = {}
|
local tests_table = {}
|
||||||
function register_test(_name, _description)
|
function register_test(_name, _description)
|
||||||
tests_table[_name] = _description
|
tests_table[_name] = _description
|
||||||
|
@ -69,7 +68,7 @@
|
||||||
name="_replace_ai_2"
|
name="_replace_ai_2"
|
||||||
[/fire_event]
|
[/fire_event]
|
||||||
[lua]
|
[lua]
|
||||||
code= << W.fire_event {name=wml.variables["test_id"] } >>
|
code= << wesnoth.wml_actions.fire_event {name=wml.variables["test_id"] } >>
|
||||||
[/lua]
|
[/lua]
|
||||||
[/command]
|
[/command]
|
||||||
[/set_menu_item]
|
[/set_menu_item]
|
||||||
|
@ -153,7 +152,7 @@
|
||||||
local cmd = { "command", {{ "set_variable", {name="test_id", value= k } } } }
|
local cmd = { "command", {{ "set_variable", {name="test_id", value= k } } } }
|
||||||
table.insert(opts, { "option", { label = v, cmd } } )
|
table.insert(opts, { "option", { label = v, cmd } } )
|
||||||
end
|
end
|
||||||
W.message { speaker="narrator", message="Which test do you wish to run, O Mighty AI Developer?", table.unpack(opts) }
|
wesnoth.wml_actions.message { speaker="narrator", message="Which test do you wish to run, O Mighty AI Developer?", table.unpack(opts) }
|
||||||
>>
|
>>
|
||||||
[/lua]
|
[/lua]
|
||||||
[command]
|
[command]
|
||||||
|
@ -162,7 +161,7 @@
|
||||||
[/fire_event]
|
[/fire_event]
|
||||||
[/command]
|
[/command]
|
||||||
[lua]
|
[lua]
|
||||||
code= << W.fire_event {name=wml.variables["test_id"] } >>
|
code= << wesnoth.wml_actions.fire_event {name=wml.variables["test_id"] } >>
|
||||||
[/lua]
|
[/lua]
|
||||||
[/event]
|
[/event]
|
||||||
|
|
||||||
|
|
|
@ -655,7 +655,6 @@
|
||||||
code= <<
|
code= <<
|
||||||
local ai_helper = wesnoth.require "ai/lua/ai_helper.lua"
|
local ai_helper = wesnoth.require "ai/lua/ai_helper.lua"
|
||||||
local H = wesnoth.require "helper"
|
local H = wesnoth.require "helper"
|
||||||
local W = H.set_wml_action_metatable {}
|
|
||||||
local delf = wesnoth.get_units { id = 'Delfador' }[1]
|
local delf = wesnoth.get_units { id = 'Delfador' }[1]
|
||||||
local sceptre_loc= wesnoth.special_locations.sceptre
|
local sceptre_loc= wesnoth.special_locations.sceptre
|
||||||
local path = wesnoth.find_path(delf, sceptre_loc[1], sceptre_loc[2], {ignore_units = true, viewing_side = 0}) -- # wmllint: noconvert
|
local path = wesnoth.find_path(delf, sceptre_loc[1], sceptre_loc[2], {ignore_units = true, viewing_side = 0}) -- # wmllint: noconvert
|
||||||
|
@ -672,7 +671,7 @@
|
||||||
|
|
||||||
local goal = { x = path[6][1], y = path[6][2] }
|
local goal = { x = path[6][1], y = path[6][2] }
|
||||||
|
|
||||||
W.message{ speaker = 'Delfador', message= dirs[ai_helper.get_direction_index(delf, goal, 8, true)]}
|
wesnoth.wml_actions.message{ speaker = 'Delfador', message= dirs[ai_helper.get_direction_index(delf, goal, 8, true)]}
|
||||||
>>
|
>>
|
||||||
# wmllint: markcheck on
|
# wmllint: markcheck on
|
||||||
[/lua]
|
[/lua]
|
||||||
|
|
|
@ -77,9 +77,8 @@
|
||||||
[lua]
|
[lua]
|
||||||
code=<<
|
code=<<
|
||||||
local H = wesnoth.require "helper"
|
local H = wesnoth.require "helper"
|
||||||
local A = H.set_wml_action_metatable{}
|
|
||||||
local function continue()
|
local function continue()
|
||||||
A.continue{}
|
wesnoth.wml_actions.continue{}
|
||||||
end
|
end
|
||||||
-- Use pcall() to trap the WML error raised by continue in global scope
|
-- Use pcall() to trap the WML error raised by continue in global scope
|
||||||
local err, res = pcall(continue)
|
local err, res = pcall(continue)
|
||||||
|
|
Loading…
Add table
Reference in a new issue