Skip to content

Commit

Permalink
ai_helper: get_unit functions should only return live units
Browse files Browse the repository at this point in the history
Live beiing defined as in get_live_units(), that is, non-petrified units

(cherry-picked from commit a7d8024)
  • Loading branch information
mattsc committed Oct 7, 2018
1 parent f09160a commit 44ceaa1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions data/ai/lua/ai_helper.lua
Expand Up @@ -901,12 +901,20 @@ end

function ai_helper.get_units_with_moves(filter)
-- Note: the order of the filters and the [and] tags are important for speed reasons
return wesnoth.get_units { { "and", { formula = "moves > 0" } }, { "and", filter } }
return wesnoth.get_units {
{ "and", { formula = "moves > 0" } },
{ "not", { status = "petrified" } },
{ "and", filter }
}
end

function ai_helper.get_units_with_attacks(filter)
-- Note: the order of the filters and the [and] tags are important for speed reasons
return wesnoth.get_units { { "and", { formula = "attacks_left > 0 and size(attacks) > 0" } }, { "and", filter } }
return wesnoth.get_units {
{ "and", { formula = "attacks_left > 0 and size(attacks) > 0" } },
{ "not", { status = "petrified" } },
{ "and", filter }
}
end

function ai_helper.get_visible_units(viewing_side, filter)
Expand Down

0 comments on commit 44ceaa1

Please sign in to comment.