lastTargetID = -1;
int rangeToX = ce().getPosition().distance(entX.getPosition()); int rangeToY = ce().getPosition().distance(entY.getPosition());
      private void cacheVisibleTargets() {        clearVisibleTargets();                Vector vec = client.game.getEnemyEntities( ce() );        Coords myPos = ce().getPosition();        boolean flipLocs = false;                lastTargetID = -1;                visibleTargets = new Entity[vec.size()];        vec.copyInto(visibleTargets);                butNextTarg.setEnabled(visibleTargets.length > 0);                for ( int i = 0; i < visibleTargets.length - 1; i++ ) {          Entity entI = (Entity)visibleTargets[i];                    if (entI == ce()) {              continue;          }                    int rangeToI = myPos.distance(entI.getPosition());                    for ( int j = i + 1; j < visibleTargets.length; j++ ) {            flipLocs = false;                        Entity entJ = (Entity)visibleTargets[j];            int rangeToJ = myPos.distance(entJ.getPosition());                        if ( rangeToJ < rangeToI )              flipLocs = true;            else if ( (rangeToJ == rangeToI) && (entJ.getId() < entI.getId()) )              flipLocs = true;                          if ( flipLocs ) {              visibleTargets[i] = entJ;              visibleTargets[j] = entI;            }          }        }      }