I'm looking for an algorithm name or implementation that can give me valid positions from a list of valid moves from which I can attack a given target.
I have a 2D tile map and a hero who can move a certain number of moves and attack enemy at range. Because of obstacles on the map, hero's move area varies and can have holes in it:
In this question I have learned how to combine this move area with attack area to get the total "threat" range that my hero exerts on the game board. In this case, 2 enemies are within threat range and can be attacked:
I'm looking for a name or info on a generalized algorithm that will take :
- Threat area (yellow)
- Valid moves (orange)
- Target position (green)
And return all cells within orange area from which I can attack a given target. Because enemies exert a threat area of their own, I do not necessarily need the closest square - I will examine possible moves and pick the one with the least threat for my hero to move to for attacking.