I have noticed a patern in the back and forth problem. It seams that there are 2 targets. Target A is closer so the bot targets A but while navigating to A, target B comes into range. Since B is now closer, the bot changes targets to B but while navigating to B, Target A becomes closer so the bot then retargets to A creating a loop. If you added priority to the bots targets and diss allowed target change for the same or lower target priority, the bot would not retarget B when navigating to A because they would have the same priority. But, if it encountered a mob(higher priority) it would retarget.
An example list of target priorities, The mob priorities would be 0 if the mob is out of the item pick up safe range
nothing? Unexplored chest/pot drop item (scroll currency/item) white mob blue mob rare mob unique/boss Invincible aura mobs/shrine
Example:
Target unexplored(2)
chest - Target swited to chest(3)
new chest that is closer(3) - target remain origonal chest
white mob in range(5) - target switch to mob
drop item found(4) - target remain mob
mob dead - target closest next priority target( would be the drop item(4) since the chests are priority3
This would help with boss farming like dominus as well, because the rares first would be targeted first instead of the never ending stream of chaff. meelee splash like aoe would take care of the chaff. The only type of build where these priorities would not work would be an elem prolif build.
Just an idea.