Messenger MAI: add optional invert_order= key

In the default configuration, the AI moves the messenger which has
advanced the furthest through the waypoints first.  If this key is set,
the rearmost messenger is moved first.
This commit is contained in:
mattsc 2014-03-27 14:36:32 -07:00
parent 62f709aaa3
commit c72c8e7ff2
2 changed files with 8 additions and 1 deletions

View file

@ -40,6 +40,13 @@ return function(cfg)
-- For now, this is simply a "forward rating"
local rating = wp_i - dist_wp / 1000.
-- If invert_order= key is set, we want to move the rearmost messenger first.
-- We still want to keep the rating value positive (mostly, this is not strict)
-- and of the same order of magnitude.
if cfg.invert_order then
rating = #waypoint_x - rating
end
m.variables.wp_rating = rating
-- Find the messenger with the highest rating that has MP left

View file

@ -90,7 +90,7 @@ function wesnoth.wml_actions.micro_ai(cfg)
H.wml_error("Messenger [micro_ai] tag requires either id= key or [filter] tag")
end
required_keys = { "waypoint_x", "waypoint_y" }
optional_keys = { "id", "enemy_death_chance", "filter", "filter_second", "messenger_death_chance" }
optional_keys = { "id", "enemy_death_chance", "filter", "filter_second", "invert_order", "messenger_death_chance" }
local score = cfg.ca_score or 300000
CA_parms = {
{ ca_id = 'mai_messenger_attack', location = CA_path .. 'ca_messenger_attack.lua', score = score },