Filter AI targets based on what it can actually attack. Fixes #3763.