Micro AIs: clean up loading of Lua files
Consistently use wesnoth.require, avoid wesnoth.dofile. Move commands as close to beginning of file as possible in order to facilitate custom modifications of MAIs.
This commit is contained in:
parent
ab61fdf521
commit
bb5ed2e5a2
15 changed files with 23 additions and 23 deletions
|
@ -1,7 +1,7 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local LS = wesnoth.require "lua/location_set.lua"
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
|
||||
local ca_big_animals = {}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ local H = wesnoth.require "lua/helper.lua"
|
|||
local LS = wesnoth.require "lua/location_set.lua"
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
|
||||
local MAISD = wesnoth.dofile "ai/micro_ais/micro_ai_self_data.lua"
|
||||
local MAISD = wesnoth.require "ai/micro_ais/micro_ai_self_data.lua"
|
||||
|
||||
local ca_bottleneck_move = {}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ local H = wesnoth.require "lua/helper.lua"
|
|||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
|
||||
local LS = wesnoth.require "lua/location_set.lua"
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAISD = wesnoth.dofile "ai/micro_ais/micro_ai_self_data.lua"
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAISD = wesnoth.require "ai/micro_ais/micro_ai_self_data.lua"
|
||||
|
||||
local ca_goto = {}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local LS = wesnoth.require "lua/location_set.lua"
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAISD = wesnoth.dofile "ai/micro_ais/micro_ai_self_data.lua"
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAISD = wesnoth.require "ai/micro_ais/micro_ai_self_data.lua"
|
||||
|
||||
local ca_hang_out = {}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
|
||||
local ca_herding_herd_sheep = {}
|
||||
|
||||
local herding_area = wesnoth.require "ai/micro_ais/cas/ca_herding_f_herding_area.lua"
|
||||
|
||||
local ca_herding_herd_sheep = {}
|
||||
|
||||
function ca_herding_herd_sheep:evaluation(ai, cfg)
|
||||
-- If dogs have moves left, and there is a sheep with moves left outside the
|
||||
-- herding area, chase it back
|
||||
|
|
|
@ -2,10 +2,10 @@ local H = wesnoth.require "lua/helper.lua"
|
|||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local LS = wesnoth.require "lua/location_set.lua"
|
||||
|
||||
local ca_herding_sheep_move = {}
|
||||
|
||||
local herding_area = wesnoth.require "ai/micro_ais/cas/ca_herding_f_herding_area.lua"
|
||||
|
||||
local ca_herding_sheep_move = {}
|
||||
|
||||
function ca_herding_sheep_move:evaluation(ai, cfg)
|
||||
-- If nothing else is to be done, the sheep do a random move
|
||||
local sheep = wesnoth.get_units { side = wesnoth.current.side, {"and", cfg.filter_second}, formula = '$this_unit.moves > 0' }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local W = H.set_wml_action_metatable {}
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
|
||||
local ca_hunter = {}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
|
||||
local ca_messenger_attack = {}
|
||||
|
||||
local messenger_next_waypoint = wesnoth.require "ai/micro_ais/cas/ca_messenger_f_next_waypoint.lua"
|
||||
|
||||
local ca_messenger_attack = {}
|
||||
|
||||
local function messenger_find_enemies_in_way(unit, goal_x, goal_y)
|
||||
-- Returns the first unit on or next to the path of the messenger
|
||||
-- unit: proxy table for the messenger unit
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local LS = wesnoth.require "lua/location_set.lua"
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
|
||||
local ca_messenger_escort_move = {}
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
|
||||
local messenger_next_waypoint = wesnoth.require "ai/micro_ais/cas/ca_messenger_f_next_waypoint.lua"
|
||||
|
||||
local ca_messenger_escort_move = {}
|
||||
|
||||
function ca_messenger_escort_move:evaluation(ai, cfg)
|
||||
-- Move escort units close to messengers, and in between messengers and enemies
|
||||
-- The messengers have moved at this time, so we don't need to exclude them,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
|
||||
return function(cfg)
|
||||
-- Calculate next waypoint and rating for all messengers
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
|
||||
local ca_messenger_move = {}
|
||||
|
||||
local messenger_next_waypoint = wesnoth.require "ai/micro_ais/cas/ca_messenger_f_next_waypoint.lua"
|
||||
|
||||
local ca_messenger_move = {}
|
||||
|
||||
function ca_messenger_move:evaluation(ai, cfg)
|
||||
-- Move the messenger toward goal, attack adjacent unit if possible
|
||||
-- without retaliation or little expected damage with high chance of killing the enemy
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
|
||||
local ca_patrol = {}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local W = H.set_wml_action_metatable {}
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local LS = wesnoth.require "lua/location_set.lua"
|
||||
local WMPF = wesnoth.require "ai/micro_ais/cas/ca_wolves_multipacks_functions.lua"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local W = H.set_wml_action_metatable {}
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
|
||||
local wolves_multipacks_functions = {}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local H = wesnoth.require "lua/helper.lua"
|
||||
local W = H.set_wml_action_metatable {}
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local MAIUV = wesnoth.dofile "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
|
||||
local LS = wesnoth.require "lua/location_set.lua"
|
||||
local WMPF = wesnoth.require "ai/micro_ais/cas/ca_wolves_multipacks_functions.lua"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue