Here's how I think the problem can be solved:
1) Find Hero's threat (move+attack squares)
For each target within threat area do following:
2) For each square in valid moves, calculate Manhattan distance to a particular target
3) If the (distance <= attack range) AND square is within valid moves, Hero can attack target from that square
In my particular case, I allow melee heroes to attack all 8 squares around them (connexity 8), so they will behave like a king in chess and instead of manhattan distance will calculate Chebushev distance