wesnoth/data/ai/micro_ais/cas/ca_herding_dog_stopmove.lua
mattsc 1c88a6d8c8 Do not load helper.lua where it is not used any more
(cherry-picked from commit 4b6681a300f29eab3b5adcf3b12df8bc6ad455dd)
2018-10-07 03:21:10 +00:00

29 lines
750 B
Lua

local AH = wesnoth.require "ai/lua/ai_helper.lua"
local function get_dog(cfg)
local dogs = AH.get_units_with_moves {
side = wesnoth.current.side,
{ "and", wml.get_child(cfg, "filter") },
}
return dogs[1]
end
-- This CA simply takes moves away from all dogs with moves left. This is done
-- at the end of the AI moves in order to keep dogs adjacent to sheep where
-- they are and not have the default AI take over.
local ca_herding_dog_stopmove = {}
function ca_herding_dog_stopmove:evaluation(cfg)
if get_dog(cfg) then return cfg.ca_score end
return 0
end
function ca_herding_dog_stopmove:execution(cfg)
local dog = get_dog(cfg)
AH.checked_stopunit_moves(ai, dog)
end
return ca_herding_dog_stopmove