Skip to content

Commit

Permalink
Big Animals MAI: bug fix for units sometimes not attacking
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsc committed Nov 27, 2014
1 parent ad93493 commit 051644b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changelog
Expand Up @@ -8,6 +8,8 @@ Version 1.13.0-dev:
* Major internal refactoring done.
* AI:
* New Micro AI: Fast AI
* Big Animals Micro AI: bug fix for units not attacking when [avoid_unit] is
not set
* Messenger Escort Micro AI: new optional parameters [filter],
[filter_second] and invert_order=
* Coward Micro AI: new optional key attack_if_trapped=
Expand Down
13 changes: 8 additions & 5 deletions data/ai/micro_ais/cas/ca_big_animals.lua
Expand Up @@ -23,11 +23,14 @@ function ca_big_animals:execution(ai, cfg)
-- and attack whatever is in their range (except for some units that they avoid)

local big_animals = get_big_animals(cfg)
local avoid_map = LS.of_pairs(wesnoth.get_locations { radius = 1,
{ "filter", { { "and", cfg.avoid_unit },
{ "filter_side", { { "enemy_of", { side = wesnoth.current.side } } } }
} }
})
local avoid_map = LS.create()
if cfg.avoid_unit then
avoid_map = LS.of_pairs(wesnoth.get_locations { radius = 1,
{ "filter", { { "and", cfg.avoid_unit },
{ "filter_side", { { "enemy_of", { side = wesnoth.current.side } } } }
} }
})
end

for _,unit in ipairs(big_animals) do
local goal = MAIUV.get_mai_unit_variables(unit, cfg.ai_id)
Expand Down

0 comments on commit 051644b

Please sign in to comment.