if (!tempEntity.getTargetedBySwarm(aeId, weaponId)) {
if (!tempEntity.getTargetedBySwarm(aeId, weaponId) && !attacker.equals(tempEntity)) {
    public static Entity getSwarmTarget(IGame game, int aeId, Entity te,            int weaponId) {        Coords coords = te.getPosition();        Entity newTarget = null;        Entity tempEntity = null;        // first, check the hex of the original target        Enumeration entities = game.getEnemyEntities(coords, te);        while (entities.hasMoreElements()) {            tempEntity = (Entity) entities.nextElement();            if (!tempEntity.getTargetedBySwarm(aeId, weaponId)) {                // we found a target                return tempEntity;            }        }        // loop through adjacent hexes        for (int dir = 0; dir <= 5; dir++) {            Coords tempcoords = coords.translated(dir);            if (!game.getBoard().contains(tempcoords)) {                continue;            }            if (coords.equals(tempcoords)) {                continue;            }            entities = game.getEnemyEntities(tempcoords, te);            if (entities.hasMoreElements()) {                tempEntity = (Entity) entities.nextElement();                if (!tempEntity.getTargetedBySwarm(aeId, weaponId)) {                    // we found a target                    return tempEntity;                }            }            entities = game.getFriendlyEntities(tempcoords, te);            if (entities.hasMoreElements()) {                tempEntity = (Entity) entities.nextElement();                if (!tempEntity.getTargetedBySwarm(aeId, weaponId)) {                    // we found a target                    return tempEntity;                }            }        }        return newTarget;    }