Examples of EquipmentType


Examples of megamek.common.EquipmentType

        // Handle critical hits on equipment slots.
        else if (CriticalSlot.TYPE_EQUIPMENT == cs.getType()) {
            cs.setHit(true);
            Mounted mounted = en.getEquipment(cs.getIndex());
            EquipmentType eqType = mounted.getType();
            boolean hitBefore = mounted.isHit();

            r = new Report(6225);
            r.subject = en.getId();
            r.indent(3);
            r.add(mounted.getDesc());
            r.newlines = 0;
            vDesc.addElement(r);

            // Shield objects are not useless when they take one crit.
            // Shields can be critted and still be usable.
            if ((eqType instanceof MiscType) && ((MiscType) eqType).isShield()) {
                mounted.setHit(false);
            } else {
                mounted.setHit(true);
            }

            if ((eqType instanceof MiscType) && eqType.hasFlag(MiscType.F_HARJEL)) {
                r = new Report(6254);
                r.subject = en.getId();
                r.indent(2);
                vDesc.add(r);
                vDesc.addAll(breachLocation(en, loc, null, true));
            }

            // If the item is the ECM suite of a Mek Stealth system
            // then it's destruction turns off the stealth.
            if (!hitBefore && (eqType instanceof MiscType) && eqType.hasFlag(MiscType.F_ECM) && (mounted.getLinkedBy() != null)) {
                Mounted stealth = mounted.getLinkedBy();
                r = new Report(6255);
                r.subject = en.getId();
                r.indent(2);
                r.add(stealth.getType().getName());
                r.newlines = 0;
                vDesc.addElement(r);
                stealth.setMode("Off");
            }

            // Handle equipment explosions.
            // Equipment explosions are secondary effects and
            // do not occur when loading from a scenario.
            if (((secondaryEffects && eqType.isExplosive()) || mounted.isHotLoaded() || mounted.hasChargedCapacitor()) && !hitBefore) {
                vDesc.addAll(explodeEquipment(en, loc, mounted));
            }

            // Make sure that ammo in this slot is exhaused.
            if (mounted.getShotsLeft() > 0) {
View Full Code Here

Examples of megamek.common.EquipmentType

    public boolean hasIllegalTechLevels(StringBuffer buff, boolean ignoreAmmo) {
        boolean retVal = false;
        int eTechLevel = getEntity().getTechLevel();
        for (Mounted mounted : getEntity().getEquipment()) {
            EquipmentType nextE = mounted.getType();
            if ((ignoreAmmo) && (nextE instanceof AmmoType)) {
                continue;
            } else if (!(TechConstants.isLegal(eTechLevel,
                    nextE.getTechLevel(), true))) {
                if (!retVal) {
                    buff.append("Equipment illegal at unit's tech level:\n");
                }
                retVal = true;
                buff.append(nextE.getName()).append("\n");
            }
        }
        return retVal;
    }
View Full Code Here

Examples of megamek.common.EquipmentType

            //TODO: disallow the weapons on quads, except unless it's one per
            // side torso
            for (int loc = Mech.LOC_RARM; loc <= Mech.LOC_LARM; loc++) {
                if (mech.hasSystem(Mech.ACTUATOR_HAND, loc)) {
                    for (Mounted m : mech.getMisc()) {
                        EquipmentType et = m.getType();
                        if ((m.getLocation() == loc) &&
                                (et.hasSubType(MiscType.S_CHAINSAW)
                                || et.hasSubType(MiscType.S_BACKHOE)
                                || et.hasSubType(MiscType.S_DUAL_SAW)
                                || et.hasSubType(MiscType.S_COMBINE)
                                || et.hasSubType(MiscType.S_PILE_DRIVER)
                                || et.hasSubType(MiscType.S_MINING_DRILL)
                                || et.hasSubType(MiscType.S_ROCK_CUTTER)
                                || et.hasSubType(MiscType.S_SPOT_WELDER)
                                || et.hasSubType(MiscType.S_WRECKING_BALL)
                                || et.hasFlag(MiscType.F_SALVAGE_ARM))) {
                            buff.append("Unit mounts hand-actuator incompatible system in arm with hand\n");
                            illegal = true;
                        }
                    }
                }
View Full Code Here

Examples of megamek.common.EquipmentType

            }

            // If the attacker has Assault claws, give a -1 modifier.
            // We can stop looking when we find our first match.
            for (Mounted mount : ae.getMisc()) {
                EquipmentType equip = mount.getType();
                if (BattleArmor.ASSAULT_CLAW.equals(equip.getInternalName())) {
                    toHit.addModifier(-1, "attacker has assault claws");
                    break;
                }
            }
        } else if (Infantry.SWARM_MEK.equals(wtype.getInternalName())) {
            toHit = Compute.getSwarmMekBaseToHit(ae, te);
            if (toHit.getValue() == TargetRoll.IMPOSSIBLE) {
                return toHit;
            }

            if (te instanceof Tank) {
                toHit.addModifier(-2, "target is vehicle");
            }

            // If the attacker has assault claws, give a -1 modifier.
            // We can stop looking when we find our first match.
            for (Mounted mount : ae.getMisc()) {
                EquipmentType equip = mount.getType();
                if (BattleArmor.ASSAULT_CLAW.equals(equip.getInternalName())) {
                    toHit.addModifier(-1, "attacker has assault claws");
                    break;
                }
            }
View Full Code Here

Examples of megamek.common.EquipmentType

                        ex.printStackTrace(System.err);
                        System.err.println("... aborting entity loading.");
                        throw new EntityLoadingException(ex.getMessage());
                    }
                } else if (criticalName != null) {
                    EquipmentType equipment = null;
                    try {
                        equipment = EquipmentType.get(criticalName);
                        if (equipment != null) {
                            // for experimental or unofficial equipment, we need
                            // to adjust the mech's techlevel, because HMP only
                            // knows lvl1/2/3
                            if ((equipment.getTechLevel() > mech.getTechLevel())
                                    && (mech.getTechLevel() >= TechConstants.T_IS_ADVANCED)) {
                                boolean isClan = mech.isClan();
                                if ((equipment.getTechLevel() == TechConstants.T_IS_EXPERIMENTAL) ||
                                        (equipment.getTechLevel() == TechConstants.T_CLAN_EXPERIMENTAL)) {
                                    mech.setTechLevel(isClan?TechConstants.T_CLAN_EXPERIMENTAL:TechConstants.T_IS_EXPERIMENTAL);
                                } else if ((equipment.getTechLevel() == TechConstants.T_IS_UNOFFICIAL) ||
                                        (equipment.getTechLevel() == TechConstants.T_CLAN_UNOFFICIAL)) {
                                    mech.setTechLevel(isClan?TechConstants.T_CLAN_UNOFFICIAL:TechConstants.T_IS_UNOFFICIAL);
                                }
                            }
                            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,
                                        rearMounted);
                            }
                        } else {
                            if (!criticalName.equals("-Empty-")) {
                                // Can't load this piece of equipment!
                                // Add it to the list so we can show the user.
                                mech.addFailedEquipment(criticalName);
                                // Make the failed equipment an empty slot
                                crits[i] = 0;
                                // Compact criticals again
                                compactCriticals(crits);
                                // Re-parse the same slot, since the compacting
                                // could have moved new equipment to this slot
                                i--;
                            }
                        }
                    } catch (LocationFullException ex) {
                        System.err.print("Location was full when adding ");
                        System.err.print(equipment.getInternalName());
                        System.err.print(" to slot #");
                        System.err.print(i);
                        System.err.print(" of location ");
                        System.err.println(location);
                        ex.printStackTrace(System.err);
View Full Code Here

Examples of megamek.common.EquipmentType

        m_chkEquipment.setSelected(false);
        int nType = m_chType.getSelectedIndex();
        int nUnitType = m_chUnitType.getSelectedIndex();
        for (Enumeration<EquipmentType> e = EquipmentType.getAllTypes(); e
                .hasMoreElements();) {
            EquipmentType et = e.nextElement();
            if (et instanceof WeaponType
                    && (et.getTechLevel() == nType
                            || ((nType == TechConstants.T_TW_ALL) && ((et
                                    .getTechLevel() == TechConstants.T_INTRO_BOXSET)
                                    || (et.getTechLevel() == TechConstants.T_IS_TW_NON_BOX) || (et
                                    .getTechLevel() == TechConstants.T_CLAN_TW))) || ((nType == TechConstants.T_IS_TW_ALL || nType == TechConstants.T_IS_TW_NON_BOX) && ((et
                            .getTechLevel() == TechConstants.T_INTRO_BOXSET) || (et
                            .getTechLevel() == TechConstants.T_IS_TW_NON_BOX))))) {
                if (!(nUnitType == UnitType.SIZE)
                        && ((UnitType.getTypeName(nUnitType).equals("Mek") || UnitType
                                .getTypeName(nUnitType).equals("Tank")) && (et
                                .hasFlag(WeaponType.F_INFANTRY)))) {
                    continue;
                }
                weapons.add(et.getName());
                if (et.hasFlag(WeaponType.F_C3M)
                        && (nType == TechConstants.T_TW_ALL
                                || nType == TechConstants.T_IS_TW_NON_BOX || nType == TechConstants.T_IS_TW_ALL)) {
                    equipment.add(et.getName());
                }
            }
            if (et instanceof MiscType
                    && (et.getTechLevel() == nType
                            || ((nType == TechConstants.T_TW_ALL) && ((et
                                    .getTechLevel() == TechConstants.T_INTRO_BOXSET)
                                    || (et.getTechLevel() == TechConstants.T_IS_TW_NON_BOX) || (et
                                    .getTechLevel() == TechConstants.T_CLAN_TW))) || ((nType == TechConstants.T_IS_TW_ALL || nType == TechConstants.T_IS_TW_NON_BOX) && ((et
                            .getTechLevel() == TechConstants.T_INTRO_BOXSET) || (et
                            .getTechLevel() == TechConstants.T_IS_TW_NON_BOX))))) {
                equipment.add(et.getName());
            }
        }
        for (String weaponName : weapons) {
            m_cWeapons1.addItem(weaponName);
            m_cWeapons2.addItem(weaponName);
View Full Code Here

Examples of megamek.common.EquipmentType

        }

        count = 0;
        if (m_chkEquipment.isSelected()) {
            for (Mounted m : entity.getEquipment()) {
                EquipmentType mt = m.getType();
                if (mt.getName().equals(m_cEquipment.getSelectedItem())) {
                    count++;
                }
            }
            if (count < 1) {
                return false;
View Full Code Here

Examples of megamek.common.EquipmentType

        m_chkEquipment.setState(false);
        int nType = m_chType.getSelectedIndex();
        int nUnitType = m_chUnitType.getSelectedIndex();
        for (Enumeration<EquipmentType> e = EquipmentType.getAllTypes(); e
                .hasMoreElements();) {
            EquipmentType et = e.nextElement();
            if (et instanceof WeaponType
                    && (et.getTechLevel() == nType
                            || ((nType == TechConstants.T_TW_ALL) && ((et
                                    .getTechLevel() == TechConstants.T_INTRO_BOXSET)
                                    || (et.getTechLevel() == TechConstants.T_IS_TW_NON_BOX) || (et
                                    .getTechLevel() == TechConstants.T_CLAN_TW))) || ((nType == TechConstants.T_IS_TW_ALL || nType == TechConstants.T_IS_TW_NON_BOX) && ((et
                            .getTechLevel() == TechConstants.T_INTRO_BOXSET) || (et
                            .getTechLevel() == TechConstants.T_IS_TW_NON_BOX))))) {
                if (!(nUnitType == UnitType.SIZE)
                        && ((UnitType.getTypeName(nUnitType).equals("Mek") || UnitType
                                .getTypeName(nUnitType).equals("Tank")) && (et
                                .hasFlag(WeaponType.F_INFANTRY)))) {
                    continue;
                }
                weapons.add(et.getName());
                if (et.hasFlag(WeaponType.F_C3M)
                        && (nType == TechConstants.T_TW_ALL
                                || nType == TechConstants.T_IS_TW_NON_BOX || nType == TechConstants.T_IS_TW_ALL)) {
                    equipment.add(et.getName());
                }
            }
            if (et instanceof MiscType
                    && (et.getTechLevel() == nType
                            || ((nType == TechConstants.T_TW_ALL) && ((et
                                    .getTechLevel() == TechConstants.T_INTRO_BOXSET)
                                    || (et.getTechLevel() == TechConstants.T_IS_TW_NON_BOX) || (et
                                    .getTechLevel() == TechConstants.T_CLAN_TW))) || ((nType == TechConstants.T_IS_TW_ALL || nType == TechConstants.T_IS_TW_NON_BOX) && ((et
                            .getTechLevel() == TechConstants.T_INTRO_BOXSET) || (et
                            .getTechLevel() == TechConstants.T_IS_TW_NON_BOX))))) {
                equipment.add(et.getName());
            }
        }
        for (String weaponName : weapons) {
            m_cWeapons1.add(weaponName);
            m_cWeapons2.add(weaponName);
View Full Code Here

Examples of megamek.common.EquipmentType

        }

        count = 0;
        if (m_chkEquipment.getState()) {
            for (Mounted m : entity.getEquipment()) {
                EquipmentType mt = m.getType();
                if (mt.getName().equals(m_cEquipment.getSelectedItem())) {
                    count++;
                }
            }
            if (count < 1)
                return false;
View Full Code Here

Examples of megamek.common.EquipmentType

                }

                // Strip the shots out of the ammo name.
                equipName = equipName.substring(0, ammoIndex + 4);
            }
            EquipmentType etype = EquipmentType.get(equipName);

            if (etype == null) {
                // try w/ prefix
                etype = EquipmentType.get(prefix + equipName);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.