player_sharpshooter_level is equal to the number of ranks of the sharpshooter perk, and is applied after the weapon perception modifier, so the perk works like giving a flat +8% bonus (except for the case of a crippled eye, where it works almost like that).
there is only one rank of sharpshooter afaik .
(attacker_is_player) dist-=(perception-2)*distmod1; here is perception calculated
it translates into this (x = distance)
x - (PER-2)*5 = x+10-50 = x+10-PER*5 (10 PER , scoped rifle)
at top of that sharpshooter is applied => x+10-PER*5-2*SS (SS stands for sharpshooter here)
now for every hex left 4% penalty is applied -> 4*X +40 - 20*PER - 8*SS
it makes SS idd lower the penalty by 8% however every point of perception lowers it by 20!! (16% in case of non scoped rifles)
where sharpshooter should be a +2 PER as in info . The only case when sharpshotoer equls to 2 PER bonus is for short range weapons where instead of 5 in the first PER*5 value of 2 is used making it -> 4*x+40 - 8*PER - 8*SS
someone failed in coding sharpshooter.. and all it would need is chaning where perception value is taken from globals to make it ..
perception = attacker_perception +2*player_sharpshooter_level
if (perception > 10) perception = 10;