I think there is a bit of a bug in the script that is easy to fix. I noticed that as the script ran, I would bypass closer critters to go attack things that were farther away. The problem lies here:
The statement 'SET !_range 0' before 'goto enemyloop' doesn't do anything, since you execute it after you've exited the FOR loop, so !_range is going to immediately be SET to 1 when you go into the FOR loop again.
I made the following change:
By moving the command to 'SET !_range 0' inside the FOR loop, once I finish an attack on one target, I resume my search at distance 1 when the FOR loop increments the range variable on the next iteration of the loop. No more passing close targets to go after more distant targets.
Another change I have in mind is to check #findrep to make sure I don't accidentally attack someone's pet, and do an ignoreItem on it so it won't come up in the finditem search again. Also, within the attack loop, I want to check to make sure my weapon hasn't broken so I can autoload a spare when necessary. I hate having my weapon break in the middle of an attack.