It's one of the reasons why I don't like ranged units firing so fast by default or being so accurate by default. We have no room for techs to increase firing rate or accuracy if they're already machine guns.
Yeah, the feature would need some code and other logic. Like, there needs to be a min and max distance where they'll throw their pila, etc. But it would largely be automatic unless the player wants to use the APM to micro them a bit.
It wasn't a fix per se, but a desired feature. People wonder why the heck the arrows don't shoot at the unit they tell them to shoot at.
I think a more than acceptable middle ground would be 100% random by default, but focus-fire when re-targeted by the player.