ammo_slots = getEntity(entNum).getAmmo(); while (ammo_slots.hasMoreElements()) { Mounted mounted = (Mounted) ammo_slots.nextElement();
for (Mounted mounted :getEntity(entNum).getAmmo()) {
    protected void calculateDeployment() {        int weapon_count;        int hex_count, x_ave, y_ave, nDir;        double av_range;        Coords pointing_to = new Coords();        Entity test_ent;        Enumeration weapons, ammo_slots, valid_attackers, equips;        int entNum = game.getFirstDeployableEntityNum();        Coords[] cStart = getStartingCoordsArray();        Coords cDeploy = getCoordsAround(getEntity(entNum), cStart);        // Now that we have a location to deploy to, get a direction        // Using average long range of deploying unit, point towards the largest cluster of enemies in range        av_range = 0.0;        weapon_count = 0;        weapons = getEntity(entNum).getWeapons();        while (weapons.hasMoreElements()) {            Mounted mounted = (Mounted) weapons.nextElement();            WeaponType wtype = (WeaponType) mounted.getType();            if ((wtype.getName() != "ATM 3") && (wtype.getName() != "ATM 6") && (wtype.getName() != "ATM 9") && (wtype.getName() != "ATM 12")) {                if (getEntity(entNum).getC3Master() != null) {                    av_range += ((wtype.getLongRange()) * 1.25);                } else {                    av_range += wtype.getLongRange();                }                weapon_count = ++weapon_count;            }        }        ammo_slots = getEntity(entNum).getAmmo();        while (ammo_slots.hasMoreElements()) {            Mounted mounted = (Mounted) ammo_slots.nextElement();            AmmoType atype = (AmmoType) mounted.getType();            if (atype.getAmmoType() == AmmoType.T_ATM) {                weapon_count = ++weapon_count;                av_range += 15.0;                if ((atype.getAmmoType() == AmmoType.T_ATM)                        && atype.getMunitionType() == AmmoType.M_HIGH_EXPLOSIVE) {                    av_range -= 6;                }                if ((atype.getAmmoType() == AmmoType.T_ATM)                        && atype.getMunitionType() == AmmoType.M_EXTENDED_RANGE) {                    av_range += 12.0;                }            }        }        av_range = av_range / weapon_count;        hex_count = 0;        x_ave = 0;        y_ave = 0;        valid_attackers = game.getEntities();        while (valid_attackers.hasMoreElements()) {            test_ent = (Entity) valid_attackers.nextElement();            if (test_ent.isDeployed()) {                if (test_ent.isVisibleToEnemy()) {                    if (cDeploy.distance(test_ent.getPosition()) <= (int) av_range) {                        hex_count++;                        x_ave += test_ent.getPosition().x;                        y_ave += test_ent.getPosition().y;                    }                }            }        }        if (hex_count != 0) {            pointing_to = new Coords((x_ave / hex_count), (y_ave / hex_count));        } else {            pointing_to = new Coords(game.getBoard().getWidth() / 2, game.getBoard().getHeight() / 2);        }        nDir = cDeploy.direction(pointing_to);        // If unit has stealth armor, turn it on        if (getEntity(entNum) instanceof Mech &&                getEntity(entNum).getArmorType() == EquipmentType.T_ARMOR_STEALTH) {            for (equips = getEntity(entNum).getMisc(); equips.hasMoreElements();) {                Mounted test_equip = (Mounted) equips.nextElement();                MiscType test_type = (MiscType) test_equip.getType();                if (Mech.STEALTH.equals(test_type.getInternalName())) {                    if (test_equip.curMode().getName() != "On") {                        test_equip.setMode("On");                        super.sendModeChange(entNum, getEntity(entNum).getEquipmentNum(test_equip), 1);                    }                }            }        }        Entity ce = game.getEntity(entNum);        megamek.debug.Assert.assertTrue(!ce.isHexProhibited(game.getBoard().getHex(cDeploy)));        deploy(entNum, cDeploy, nDir);    }