Package megamek.common

Examples of megamek.common.WeaponType


        // Offensive characterization - damage potentials
        for (Mounted m : entity.getWeaponList()) {

            int arc = entity.getWeaponArc(entity.getEquipmentNum(m));

            WeaponType weapon = (WeaponType) m.getType();

            // Don't count weapons that don't have ammo, are destroyed/jammed
            if (m.isDestroyed()) {
                continue;
            }
            if (m.isJammed()) {
                continue;
            }
            if (weapon.getName() == "Stop Swarm Attack") {
                // attack
                continue;
            }

            if ((m.getLinked() == null)
                    & (weapon.getAmmoType() != AmmoType.T_NA)) {
                continue;
            }

            num_weapons++;
            heat_total += weapon.getHeat();

            int min = weapon.getMinimumRange();
            int lr = weapon.getExtremeRange();

            double ed;
            int gunnery = entity.getCrew().getGunnery();
            if (entity.getTaserFeedBackRounds() > 0) {
                gunnery += 1;
            }
            // Range used to start at 1; updated to account for stacking
            for (int curRange = 0; (curRange <= lr) && (curRange <= MAX_RANGE); curRange++) {

                ed = CEntity.getExpectedDamage(entity, m, curRange, gunnery);
                if ((curRange <= min) & (curRange <= MIN_BRACKET)) {
                    minRangeMods[curRange] += 1 + min - curRange;
                }

                // Weapons that generate heat are derated based on the
                // units current heat level, 'cause building more heat is bad
                addDamage(arc, entity.isSecondaryArcWeapon(entity
                        .getEquipmentNum(m)), curRange, ed
                        * ((weapon.getHeat() > 0) ? heat_mod : 1));
            }
            long_range = Math
                    .max(long_range, Math.min(lr, MAX_RANGE));
        }

View Full Code Here


        if (!(attacker instanceof Infantry) & (range == 0)) {
            return 0.0;
        }

        double fDamage = 0.0;
        WeaponType wt = (WeaponType) weapon.getType();

        // The "Stop Swarm Attack" really isn't one

        if (wt.getName() == "Stop Swarm Attack") {
            return 0.0;
        }

        // Get the range modifier for the weapon

        if (range <= wt.getMinimumRange()) {
            total_mod = total_mod + 1 + (wt.getMinimumRange() - range);
        } else {
            if (range > wt.getShortRange()) {
                total_mod += 2;
            }
            if (range > wt.getMediumRange()) {
                total_mod += 2;
            }
            if (range > wt.getLongRange()) {
                total_mod += 4;
            }
            if (range > wt.getExtremeRange()) {
                return 0.0;
            }
        }

        // Get the weapon to-hit mod

        total_mod += wt.getToHitModifier();

        // Some weapons use multiple hits, as determined by the missile
        // hits table. This method is used for an approximation, so
        // assume LBX cannon are using cluster rounds, Ultra-cannon
        // are firing double rate, and RACs are fired in quad mode.
        if ((wt.getDamage() == WeaponType.DAMAGE_MISSILE)
                && ((wt.getAmmoType() != AmmoType.T_TBOLT_5) ||
                    (wt.getAmmoType() != AmmoType.T_TBOLT_10) ||
                    (wt.getAmmoType() != AmmoType.T_TBOLT_15) ||
                    (wt.getAmmoType() != AmmoType.T_TBOLT_20))) {
            use_table = true;
        }
        if ((wt.getAmmoType() == AmmoType.T_AC_LBX)
                || (wt.getAmmoType() == AmmoType.T_AC_LBX_THB)) {
            use_table = true;
            total_mod -= 1;
        }

        if ((wt.getAmmoType() == AmmoType.T_AC_ULTRA)
                || (wt.getAmmoType() == AmmoType.T_AC_ULTRA_THB)
                || (wt.getAmmoType() == AmmoType.T_AC_ROTARY)) {
            use_table = true;
        }

        // Kinda cheap, but lets use the missile hits table for Battle armor
        // weapons too

        if (attacker instanceof BattleArmor) {
            if ((wt.getInternalName() != Infantry.SWARM_MEK)
                    & (wt.getInternalName() != Infantry.LEG_ATTACK)
                    & !(wt.hasFlag(WeaponType.F_INFANTRY))) {
                use_table = true;
            }
        }

        if (use_table == true) {
            double fHits = 0.0;
            if (!(attacker instanceof BattleArmor)) {
                if (weapon.getLinked() == null) {
                    return 0.0;
                }
            }
            AmmoType at = null;
            if (weapon.getLinked() != null) {
                at = (AmmoType) weapon.getLinked().getType();
                // Override damage by ammo type for some items
                // Set LRM and MRM damage at 1.0, SRM types at 2.0,
                // and ATMs at 2.4 (2.0 nominal x 1.2 for built-in
                // Artemis)

                fDamage = at.getDamagePerShot();
                if ((wt.getAmmoType() == AmmoType.T_SRM_STREAK)
                        || (wt.getAmmoType() == AmmoType.T_SRM)) {
                    fDamage = 2.0;
                }
                if (wt.getAmmoType() == AmmoType.T_ATM) {
                    fDamage = 2.4;
                }
                if ((wt.getAmmoType() == AmmoType.T_LRM_STREAK)
                        || (wt.getAmmoType() == AmmoType.T_LRM)
                        || (wt.getAmmoType() == AmmoType.T_MRM)) {
                    fDamage = 1.0;
                }
            }
            if ((wt.getRackSize() != 40) && (wt.getRackSize() != 30)) {
                fHits = expectedHitsByRackSize[wt.getRackSize()];
            } else {
                fHits = 2.0f * expectedHitsByRackSize[wt.getRackSize() / 2];
            }
            if ((wt.getAmmoType() == AmmoType.T_SRM_STREAK)
                    || (wt.getAmmoType() == AmmoType.T_LRM_STREAK)) {
                fHits = wt.getRackSize();
            }
            if ((wt.getAmmoType() == AmmoType.T_AC_ULTRA)
                    || (wt.getAmmoType() == AmmoType.T_AC_ULTRA_THB)) {
                fHits = expectedHitsByRackSize[2];
            }
            if (wt.getAmmoType() == AmmoType.T_AC_ROTARY) {
                fHits = expectedHitsByRackSize[4];
            }
            if ((wt.getAmmoType() == AmmoType.T_AC_LBX)
                    || (wt.getAmmoType() == AmmoType.T_AC_LBX_THB)) {
                fHits = expectedHitsByRackSize[wt.getDamage()];
            }
            if ((wt.getAmmoType() == AmmoType.T_LRM)
                    || (wt.getAmmoType() == AmmoType.T_SRM)) {
                lnk_guide = weapon.getLinkedBy();
                if ((lnk_guide != null)
                        && (lnk_guide.getType() instanceof MiscType)
                        && !lnk_guide.isDestroyed() && !lnk_guide.isMissing()
                        && !lnk_guide.isBreached()
                        && lnk_guide.getType().hasFlag(MiscType.F_ARTEMIS)) {
                    fHits *= 1.2f;
                }
            }

            if (wt.getAmmoType() == AmmoType.T_MRM) {
                lnk_guide = weapon.getLinkedBy();
                if ((lnk_guide != null)
                        && (lnk_guide.getType() instanceof MiscType)
                        && !lnk_guide.isDestroyed() && !lnk_guide.isMissing()
                        && !lnk_guide.isBreached()
                        && lnk_guide.getType().hasFlag(MiscType.F_APOLLO)) {
                    fHits *= .9f;
                }
            }
            // Most Battle Armor units have a weapon per trooper, plus their
            // weapons do odd things when mounting multiples
            if (attacker instanceof BattleArmor) {
                // The number of troopers hitting
                fHits = expectedHitsByRackSize[ba_attacker
                        .getShootingStrength()];
                if (wt.getDamage() == WeaponType.DAMAGE_MISSILE) {
                    fHits *= expectedHitsByRackSize[wt.getRackSize()];
                }
                if (wt.getDamage() != WeaponType.DAMAGE_MISSILE) {
                    if (wt.getDamage() != WeaponType.DAMAGE_VARIABLE) {
                        fDamage = wt.getDamage();
                    } else {
                        fDamage = wt.getRackSize();
                    }
                }
                if (wt.hasFlag(WeaponType.F_MISSILE_HITS)) {
                    fHits *= expectedHitsByRackSize[wt.getRackSize()];
                }
            }

            fDamage *= fHits;

            if ((wt.getAmmoType() == AmmoType.T_AC_ULTRA)
                    || (wt.getAmmoType() == AmmoType.T_AC_ULTRA_THB)
                    || (wt.getAmmoType() == AmmoType.T_AC_ROTARY)) {
                fDamage = fHits * wt.getDamage();
            }

        } else {

            // Direct fire weapons just do a single shot
            // so they don't use the missile hits table

            fDamage = wt.getDamage();

            // Heavy gauss and Thunderbolt LRMs do odd things with range

            if (wt.getAmmoType() == AmmoType.T_GAUSS_HEAVY) {
                fDamage = 25.0;
                if (range > 6) {
                    fDamage = 20.0;
                }
                if (range > 13) {
                    fDamage = 10.0;
                }
            }
            if ((wt.getAmmoType() == AmmoType.T_TBOLT_5) ||
                (wt.getAmmoType() == AmmoType.T_TBOLT_10) ||
                (wt.getAmmoType() == AmmoType.T_TBOLT_15) ||
                (wt.getAmmoType() == AmmoType.T_TBOLT_20)) {
                if (range <= wt.getMinimumRange()) {
                    fDamage *= 0.5;
                }
            }

            // Infantry follow some special rules, but do fixed amounts of
            // damage
            if (attacker instanceof Infantry) {

                if (wt.hasFlag(WeaponType.F_INFANTRY)) {
                    // Weapons fielded by conventional infantry and light BA
                    // Field guns should be handled under the normal weapons
                    // section
                    /*
                     * fDamage = 0.6f * inf_attacker.getDamage(inf_attacker.
                     * getShootingStrength());
                     */
                    // TODO: fix me
                    fDamage = 1;
                    if (attacker instanceof BattleArmor) {
                        /*
                         * fDamage = inf_attacker.getDamage(ba_attacker.
                         * getShootingStrength());
                         */
                        // TODO: fix me
                        fDamage = 1;
                    }
                }

                if (wt.getInternalName() == Infantry.LEG_ATTACK) {
                    // Odds change based on number of troopers. Make an
                    // estimate.
                    if (!(attacker instanceof BattleArmor)) {
                        total_mod = 4 + 2 * (inf_attacker.getOInternal(0) - inf_attacker
                                .getShootingStrength()) / 5;
                    } else {
                        total_mod = 8 - ba_attacker.getShootingStrength();
                    }
                    fDamage = 10.0; // Damage is actually 5 plus chance at crits
                }

                if (wt.getInternalName() == Infantry.SWARM_MEK) {
                    // Odds change based on number of troopers. Make an
                    // estimate.
                    // Damage is same as conventional weapons, but with chance
                    // for crits
                    if (!(attacker instanceof BattleArmor)) {
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

        // damage field guns on infantry platoons if there arent enough men left
        // to man it
        if (isPlatoon) {
            float tons = 0.0f;
            for (Mounted weap : te.getWeaponList()) {
                WeaponType wtype = (WeaponType) weap.getType();
                if (!wtype.hasFlag(WeaponType.F_INFANTRY)) {
                    tons += wtype.getTonnage(te);
                    if (tons > te.getInternal(Infantry.LOC_INFANTRY)) {
                        weap.setDestroyed(true);
                    }
                }
            }
View Full Code Here

                    Mounted weapon = weapons.get(Compute.randomInt(weapons.size()));
                    // possibly check for an ammo explosion
                    // don't allow ammo explosions on fighter squadrons
                    if (game.getOptions().booleanOption("ammo_explosions") && !(a instanceof FighterSquadron) && (weapon.getType() instanceof WeaponType)) {
                        // does it use Ammo?
                        WeaponType wtype = (WeaponType) weapon.getType();
                        if (wtype.getAmmoType() != AmmoType.T_NA) {
                            Mounted m = weapon.getLinked();
                            int ammoroll = Compute.d6(2);
                            if (ammoroll >= 10) {
                                r = new Report(9151);
                                r.subject = a.getId();
View Full Code Here

            Mounted ammo = mounted.getLinked();
            if ((ammo == null) || !(ammo.getType() instanceof AmmoType) || (((AmmoType) ammo.getType()).getMunitionType() != AmmoType.M_INCENDIARY_AC)) {
                return vDesc;
            }

            WeaponType wtype = (WeaponType) mounted.getType();
            if ((wtype.getAmmoType() == AmmoType.T_LRM) || (wtype.getAmmoType() == AmmoType.T_LRM_STREAK) || (wtype.getAmmoType() == AmmoType.T_LRM_TORPEDO) || (wtype.getAmmoType() == AmmoType.T_LRM_TORPEDO_COMBO)) {
                return vDesc;
            }

        }
View Full Code Here

       
        String label = "?";
       
        if (aa instanceof WeaponAttackAction) {
            WeaponAttackAction action = (WeaponAttackAction)aa;
            final WeaponType wtype = (WeaponType)game.getEntity(aa.getEntityId()).getEquipment(action.getWeaponId()).getType();
            label = wtype.getName()+Messages.getString("BoardView1.needs")+
                action.toHit(game).getValueAsString()+" "+action.toHit(game).getTableDesc();
        } else if (aa instanceof KickAttackAction) {
            KickAttackAction action = (KickAttackAction)aa;
            switch (action.getLeg()) {
            case KickAttackAction.BOTH:
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.