“It should probably be changed to consider whether the attacker is in vision for the counterattack. ”
That might not be a good idea, Mikel. Bandits have the same skills as military NPC's, correct? If so they will have a very low or nonexistent perception skill. There are only two bandit fitouts that have macrobinoculars and neither fitout has a weapon with a range greater than 6.
Meaning a player/squad equipped with any weapon that has a range of 7+ would be able to kill bandits without being counterattacked. It is not perfect but allowing counterattacks regardless of vision range is a more balanced mechanic. Otherwise the bandit's vision range would need to be adjusted to be equal to the maximum range of their furthest shooting weapon.