Package megamek.common

Examples of megamek.common.Mounted


     * queue.
     */
    private void fire() {
        // get the selected weaponnum
        int weaponNum = clientgui.mechD.wPan.getSelectedWeaponNum();
        Mounted mounted = ce().getEquipment(weaponNum);

        // validate
        if (ce() == null || target == null || mounted == null
                || !(mounted.getType() instanceof WeaponType)) {
            throw new IllegalArgumentException(
                    "current fire parameters are invalid"); //$NON-NLS-1$
        }

        // declare searchlight, if possible
        if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
            doSearchlight();
        }

        WeaponAttackAction waa = new WeaponAttackAction(cen, target
                .getTargetType(), target.getTargetId(), weaponNum);
        if (mounted.getType().hasFlag(WeaponType.F_ARTILLERY)) {
            waa = new ArtilleryAttackAction(cen, target.getTargetType(), target
                    .getTargetId(), weaponNum, client.game);
        }
        if (null != mounted.getLinked()
                && ((WeaponType) mounted.getType()).getAmmoType() != AmmoType.T_NA) {
            Mounted ammoMount = mounted.getLinked();
            waa.setAmmoId(ce().getEquipmentNum(ammoMount));
            if (((AmmoType) ammoMount.getType()).getMunitionType() == AmmoType.M_VIBRABOMB_IV) {
                VibrabombSettingDialog vsd = new VibrabombSettingDialog(
                        clientgui.frame);
                vsd.setVisible(true);
                waa.setOtherAttackInfo(vsd.getSetting());
            }
View Full Code Here


        int distance = ae.getPosition().distance(target.getPosition());
        double av = 0;
        int range = RangeType.rangeBracket(distance, wtype.getATRanges(), true);
       
        for(int wId: weapon.getBayWeapons()) {
            Mounted m = ae.getEquipment(wId);
            if(!m.isBreached() && !m.isDestroyed() && !m.isJammed()) {
                WeaponType bayWType = ((WeaponType)m.getType());
                //need to cycle through weapons and add av
                if(range == WeaponType.RANGE_SHORT) {
                    av = av + bayWType.getShortAV();
                } else if(range == WeaponType.RANGE_MED) {
                    av = av + bayWType.getMedAV();
View Full Code Here

   
    protected void addHeat() {
        if (!(toHit.getValue() == TargetRoll.IMPOSSIBLE)) {
            if(game.getOptions().booleanOption("heat_by_bay")) {
                for(int wId:weapon.getBayWeapons()) {
                    Mounted m = ae.getEquipment(wId);
                    ae.heatBuildup += m.getCurrentHeat();
                }
            } else {          
                int loc = weapon.getLocation();
                boolean rearMount = weapon.isRearMounted();
                if(!ae.hasArcFired(loc, rearMount)) {
View Full Code Here

                                }
                            }
                            boolean rearMounted = (equipment instanceof WeaponType)
                                    && isRearMounted(critical);
                            if (equipment.isSpreadable()) {
                                Mounted m = spreadEquipment.get(equipment);
                                if (m != null) {
                                    CriticalSlot criticalSlot = new CriticalSlot(
                                            CriticalSlot.TYPE_EQUIPMENT, mech
                                                    .getEquipmentNum(m),
                                            equipment.isHittable(), m);
                                    mech.addCritical(location, criticalSlot);
                                    if (criticalName
                                            .equalsIgnoreCase("Armored Cowl")) {
                                        mech.setCowl(5); // Initialize
                                        // armored cowl
                                    }

                                } else {
                                    m = mech.addEquipment(equipment, location,
                                            rearMounted);
                                    spreadEquipment.put(equipment, m);
                                }
                            } else if ((equipment instanceof WeaponType)
                                    && equipment
                                            .hasFlag(WeaponType.F_SPLITABLE)) {
                                // do we already have this one in this or an
                                // outer location?
                                Mounted m = null;
                                boolean bFound = false;
                                for (int x = 0, n = vSplitWeapons.size(); x < n; x++) {
                                    m = vSplitWeapons.elementAt(x);
                                    int nLoc = m.getLocation();
                                    if (((nLoc == location) || (location == Mech
                                            .getInnerLocation(nLoc)))
                                            && m.getType().equals(equipment)) {
                                        bFound = true;
                                        break;
                                    }
                                }
                                if (bFound) {
                                    m.setFoundCrits(m.getFoundCrits() + 1);
                                    if (m.getFoundCrits() >= equipment
                                            .getCriticals(mech)) {
                                        vSplitWeapons.removeElement(m);
                                    }
                                    // if we're in a new location, set the
                                    // weapon as split
                                    if (location != m.getLocation()) {
                                        m.setSplit(true);
                                    }
                                    // give the most restrictive location for
                                    // arcs
                                    int help = m.getLocation();
                                    m.setLocation(Mech.mostRestrictiveLoc(
                                            location, help));
                                    if (location != help) {
                                        m.setSecondLocation(Mech
                                                .leastRestrictiveLoc(location,
                                                        help));
                                    }
                                } else {
                                    // make a new one
                                    m = new Mounted(mech, equipment);
                                    m.setFoundCrits(1);
                                    vSplitWeapons.addElement(m);
                                }
                                mech.addEquipment(m, location, rearMounted);
                            } else {
                                mech.addEquipment(equipment, location,
View Full Code Here

     * @see megamek.common.weapons.Weapon#getCorrectHandler(megamek.common.ToHitData,
     *      megamek.common.actions.WeaponAttackAction, megamek.common.Game)
     */
    protected AttackHandler getCorrectHandler(ToHitData toHit,
            WeaponAttackAction waa, IGame game, Server server) {
        Mounted weapon = game.getEntity(waa.getEntityId()).getEquipment(
                waa.getWeaponId());
        if (weapon.curMode().equals("Ultra")) {
            return new UltraWeaponHandler(toHit, waa, game, server);
        } else {
            return super.getCorrectHandler(toHit, waa, game, server);
        }
    }
View Full Code Here

     *
     * @see megamek.common.weapons.UltraWeaponHandler#doChecks(java.util.Vector)
     */
    protected boolean doChecks(Vector<Report> vPhaseReport) {
        for(int wId: weapon.getBayWeapons()) {   
            Mounted bayW = ae.getEquipment(wId);
            WeaponType bayWType = ((WeaponType)bayW.getType());
            int ammoUsed = bayW.getCurrentShots();
            if(bayWType.getAmmoType() == AmmoType.T_AC_ROTARY) {
                boolean jams = false;
                switch (ammoUsed) {
                    case 6:
                        if (roll <= 4) {
                            jams = true;
                        }
                        break;
                    case 5:
                    case 4:
                        if (roll <= 3) {
                            jams = true;
                        }
                        break;
                    case 3:
                    case 2:
                        if (roll <= 2) {
                            jams = true;
                        }
                        break;
                    default:
                        break;
                }
                if (jams) {
                    r = new Report(3170);
                    r.subject = subjectId;
                    r.add(" shot(s)");
                    r.newlines = 0;
                    vPhaseReport.addElement(r);
                    bayW.setJammed(true);
                }
            }
            else if (bayWType.getAmmoType() == AmmoType.T_AC_ULTRA) {
                if (roll == 2 && ammoUsed == 2) {
                    r = new Report();
                    r.subject = subjectId;
                    r.messageId = 3160;
                    r.newlines = 0;
                    bayW.setJammed(true);
                    bayW.setHit(true);
                    vPhaseReport.addElement(r);
                }
            }
        }
       
View Full Code Here

        if (clubs.size() == 1) {
            return clubs.get(0);
        } else if (clubs.size() > 1) {
            String[] names = new String[clubs.size()];
            for (int loop = 0; loop < names.length; loop++) {
                Mounted club = clubs.get(loop);
                names[loop] = Messages
                        .getString(
                                "PhysicalDisplay.ChooseClubDialog.line",
                                new Object[] {
                                        club.getName(),
                                        ClubAttackAction.toHit(client.game,
                                                cen, target, club,
                                                ash.getAimTable())
                                                .getValueAsString(),
                                        ClubAttackAction
View Full Code Here

    /**
     * Club that target!
     */
    void club() {
        Mounted club = chooseClub();
        if (null == club) {
            return;
        }
        ToHitData toHit = ClubAttackAction.toHit(client.game, cen, target,
                club, ash.getAimTable());
View Full Code Here

        // does it have a club?
        String clubLabel = null;
        for (Iterator<Mounted> clubs = entity.getClubs().iterator(); clubs
                .hasNext();) {
            Mounted club = clubs.next();
            String thisLab;
            if (club.getName().endsWith("Club")) { //$NON-NLS-1$
                thisLab = Messages.getString("PhysicalDisplay.Club"); //$NON-NLS-1$
            } else {
                thisLab = club.getName();
            }
            if (clubLabel == null) {
                clubLabel = thisLab;
            } else {
                clubLabel = clubLabel + "/" + thisLab;
View Full Code Here

        if (clubs.size() == 1) {
            return clubs.get(0);
        } else if (clubs.size() > 1) {
            String[] names = new String[clubs.size()];
            for (int loop = 0; loop < names.length; loop++) {
                Mounted club = clubs.get(loop);
                names[loop] = Messages.getString(
                        "PhysicalDisplay.ChooseClubDialog.line", new Object[] {
                                club.getName(),
                                ClubAttackAction.toHit(client.game, cen,
                                        target, club, ash.getAimTable())
                                        .getValueAsString(),
                                ClubAttackAction.getDamageFor(ce(), club,
                                        (target instanceof Infantry) &&
View Full Code Here

TOP

Related Classes of megamek.common.Mounted

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.