If the weapon range is larger than 6 (listed as 28/56/84 in mecha scale) you get a -1 per each scare inside half the minimun range range.
So said range 7 weapon will get:
-3 to hit if both mechas are in contiguous squares
-2 to hit if 2 squares appart
-1 to hit if 3 squares appart
Weapons with larger range get larger penalties. Weapons with 10 range get penalty starting at 5 squares.
PS: I could be wrong with the half range rounding. Click R (shift+r) in a game combat while using a long range weapon to check it for sure.