ai_helper: fix visibility bug in get_attackable_enemies()

The passed filter needs to be enclosed in an [and] tag, otherwise the check for visibility might not work correctly, for example if the filter contains a top level [or] tag.
This commit is contained in:
mattsc 2022-06-04 09:08:16 -07:00
parent ac346b86c8
commit 19ecc3dc61

View file

@ -1188,7 +1188,10 @@ function ai_helper.get_attackable_enemies(filter, side, cfg)
local filter_plus_vision = {}
if filter then filter_plus_vision = ai_helper.table_copy(filter) end
if (not ignore_visibility) then
table.insert(filter_plus_vision, { "filter_vision", { side = viewing_side, visible = 'yes' } })
filter_plus_vision = {
{ "and", filter_plus_vision },
{ "filter_vision", { side = viewing_side, visible = 'yes' } }
}
end
local enemies = {}