This fixes units ignoring range sometimes, as reported by #5530, introduced by rP22425, see this comment.
It was only discovered now as it could only trigger when the unit wouldn't chase the target, which happens for non-forced orders in defensive/standground stance. Straightforward fix.
This also fixes the concern raised on rP22425 by @Angen that targeting formations didn't work correctly.
While testing, I also think the walk then walk and fight behaviour should be changed to just walk and fight or units might just run towards enemies and not attack them, which looks rather odd.