Package megamek.common

Examples of megamek.common.WeaponType


         *
         * @param weapon
         * @return
         */
        public boolean allowAimedShotWith(Mounted weapon) {
            WeaponType wtype = (WeaponType) weapon.getType();
            boolean isWeaponInfantry = wtype.hasFlag(WeaponType.F_INFANTRY);
            boolean usesAmmo = (wtype.getAmmoType() != AmmoType.T_NA)
                    && !isWeaponInfantry;
            Mounted ammo = usesAmmo ? weapon.getLinked() : null;
            AmmoType atype = ammo == null ? null : (AmmoType) ammo.getType();

            // Leg and swarm attacks can't be aimed.
            if (wtype.getInternalName().equals(Infantry.LEG_ATTACK)
                    || wtype.getInternalName().equals(Infantry.SWARM_MEK)) {
                return false;
            }
            switch (aimingMode) {
            case (IAimingModes.AIM_MODE_NONE):
                return false;
            case (IAimingModes.AIM_MODE_IMMOBILE):
                if (atype != null) {
                    switch (atype.getAmmoType()) {
                    case (AmmoType.T_SRM_STREAK):
                    case (AmmoType.T_LRM_STREAK):
                    case (AmmoType.T_LRM):
                    case (AmmoType.T_LRM_TORPEDO):
                    case (AmmoType.T_SRM):
                    case (AmmoType.T_SRM_TORPEDO):
                    case (AmmoType.T_MRM):
                    case (AmmoType.T_NARC):
                    case (AmmoType.T_AMS):
                    case (AmmoType.T_ARROW_IV):
                    case (AmmoType.T_LONG_TOM):
                    case (AmmoType.T_SNIPER):
                    case (AmmoType.T_THUMPER):
                    case (AmmoType.T_SRM_ADVANCED):
                    case (AmmoType.T_LRM_TORPEDO_COMBO):
                    case (AmmoType.T_ATM):
                    case (AmmoType.T_MML):
                    case (AmmoType.T_EXLRM):
                    case AmmoType.T_TBOLT_5:
                    case AmmoType.T_TBOLT_10:
                    case AmmoType.T_TBOLT_15:
                    case AmmoType.T_TBOLT_20:
                    case AmmoType.T_PXLRM:
                    case AmmoType.T_HSRM:
                    case AmmoType.T_MRM_STREAK:
                        return false;
                    }
                    if (((atype.getAmmoType() == AmmoType.T_AC_LBX) || (atype
                            .getAmmoType() == AmmoType.T_AC_LBX_THB))
                            && (atype.getMunitionType() == AmmoType.M_CLUSTER)) {
                        return false;
                    }
                }
                break;
            case (IAimingModes.AIM_MODE_TARG_COMP):
                if (!wtype.hasFlag(WeaponType.F_DIRECT_FIRE)
                        || wtype.hasFlag(WeaponType.F_PULSE)) {
                    return false;
                }
                if (weapon.getCurrentShots() > 1) {
                    return false;
                }
View Full Code Here


        /**
         * Adds a weapon to this attack
         */
        public void addWeapon(WeaponAttackAction attack) {
            final Entity entity = game.getEntity(attack.getEntityId());
            final WeaponType wtype = (WeaponType) entity.getEquipment(
                    attack.getWeaponId()).getType();
            final String roll = attack.toHit(game).getValueAsString();
            final String table = attack.toHit(game).getTableDesc();
            weaponDescs
            .add(wtype.getName()
                    + Messages.getString("BoardView1.needs") + roll + " " + table); //$NON-NLS-1$
        }
View Full Code Here

        r.subject = entity.getId();
        r.addDesc(entity);
        addReport(r);
        for (Mounted mounted : entity.getTotalWeaponList()) {
            if (mounted.isJammed()) {
                WeaponType wtype = (WeaponType) mounted.getType();
                if (wtype.getAmmoType() == AmmoType.T_AC_ROTARY) {
                    int roll = Compute.d6(2);
                    r = new Report(3030);
                    r.indent();
                    r.subject = entity.getId();
                    r.add(wtype.getName());
                    r.add(TN);
                    r.add(roll);
                    if (roll >= TN) {
                        r.choose(true);
                        mounted.setJammed(false);
View Full Code Here

        } catch (NumberFormatException ne) {
        }
        if (weapon1 > -1) {
            weaponLine1Active = true;
            for (int i = 0; i < entity.getWeaponList().size(); i++) {
                WeaponType wt = (WeaponType) (entity.getWeaponList().get(i))
                        .getType();
                if (wt.getName().equals(m_cWeapons1.getSelectedItem())) {
                    count++;
                }
            }
            if (count >= weapon1)
                foundWeapon1 = true;
        }

        count = 0;
        int weapon2 = -1;
        try {
            weapon2 = Integer.parseInt(m_tWeapons2.getText());
        } catch (NumberFormatException ne) {
        }
        if (weapon2 > -1) {
            weaponLine2Active = true;
            for (int i = 0; i < entity.getWeaponList().size(); i++) {
                WeaponType wt = (WeaponType) (entity.getWeaponList().get(i))
                        .getType();
                if (wt.getName().equals(m_cWeapons2.getSelectedItem())) {
                    count++;
                }
            }
            if (count >= weapon2)
                foundWeapon2 = true;
View Full Code Here

                return Math.round(getWeight() / 25.0f);
            }
        } else if (mt.hasFlag(MiscType.F_TARGCOMP)) {
            float fTons = 0.0f;
            for (Mounted mo : getEntity().getWeaponList()) {
                WeaponType wt = (WeaponType) mo.getType();
                if (wt.hasFlag(WeaponType.F_DIRECT_FIRE)) {
                    fTons += wt.getTonnage(getEntity());
                }
            }
            if (mt.getInternalName().equals("ISTargeting Computer")) {
                return ceil(fTons / 4.0f, getWeightCeilingTargComp());
            } else if (mt.getInternalName().equals("CLTargeting Computer")) {
View Full Code Here

    }

    public float getWeightWeapon() {
        float weight = 0.0f;
        for (Mounted m : getEntity().getWeaponList()) {
            WeaponType mt = (WeaponType) m.getType();
            weight += mt.getTonnage(getEntity());
        }
        return weight;
    }
View Full Code Here

        return printWeapon(buff, 20, getPrintSize());
    }

    public StringBuffer printWeapon(StringBuffer buff, int posLoc, int posWeight) {
        for (Mounted m : getEntity().getWeaponList()) {
            WeaponType mt = (WeaponType) m.getType();

            // Don't think this can happen, but ...
            if (m.getLocation() == Entity.LOC_NONE) {
                continue;
            }

            buff.append(StringUtil.makeLength(mt.getName(), 20));
            buff.append(
                    StringUtil.makeLength(getLocationAbbr(m.getLocation()),
                            getPrintSize() - 5 - 20)).append(
                    makeWeightString(mt.getTonnage(getEntity()))).append("\n");
        }
        return buff;
    }
View Full Code Here

                return Math.round(getWeight() / 25.0f);
            }
        } else if (mt.hasFlag(MiscType.F_TARGCOMP)) {
            float fTons = 0.0f;
            for (Mounted mo : getEntity().getWeaponList()) {
                WeaponType wt = (WeaponType) mo.getType();
                if (wt.hasFlag(WeaponType.F_DIRECT_FIRE)) {
                    fTons += wt.getTonnage(getEntity());
                }
            }
            float weight = 0.0f;
            if (mt.getInternalName().equals("ISTargeting Computer")) {
                weight = ceil(fTons / 4.0f, getWeightCeilingTargComp());
View Full Code Here

        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();
                } else if (range == WeaponType.RANGE_LONG) {
                    av = av + bayWType.getLongAV();
                } else if (range == WeaponType.RANGE_EXT) {
                    av = av + bayWType.getExtAV();
                }
            }
        }
        return (int)Math.ceil(av);
    }
View Full Code Here

            // never get here
        }
        if (weapon1 > -1) {
            weaponLine1Active = true;
            for (int i = 0; i < entity.getWeaponList().size(); i++) {
                WeaponType wt = (WeaponType) (entity.getWeaponList().get(i))
                        .getType();
                if (wt.getName().equals(m_cWeapons1.getSelectedItem())) {
                    count++;
                }
            }
            if (count >= weapon1) {
                foundWeapon1 = true;
            }
        }

        count = 0;
        int weapon2 = -1;
        try {
            weapon2 = Integer.parseInt(m_tWeapons2.getText());
        } catch (NumberFormatException ne) {
            // never get here
        }
        if (weapon2 > -1) {
            weaponLine2Active = true;
            for (int i = 0; i < entity.getWeaponList().size(); i++) {
                WeaponType wt = (WeaponType) (entity.getWeaponList().get(i))
                        .getType();
                if (wt.getName().equals(m_cWeapons2.getSelectedItem())) {
                    count++;
                }
            }
            if (count >= weapon2) {
                foundWeapon2 = true;
View Full Code Here

TOP

Related Classes of megamek.common.WeaponType

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.