Search in sources :

Example 1 with ArtilleryWeapon

use of megamek.common.weapons.artillery.ArtilleryWeapon in project megameklab by MegaMek.

the class StringUtils method getEquipmentInfo.

public static String getEquipmentInfo(Aero unit, Mounted mount) {
    String info = "";
    if (mount.getType() instanceof WeaponType) {
        WeaponType weapon = (WeaponType) mount.getType();
        if (weapon instanceof InfantryWeapon) {
            info = Integer.toString(weapon.getDamage());
            if (weapon.hasFlag(WeaponType.F_BALLISTIC)) {
                info += " (B)";
            } else if (weapon.hasFlag(WeaponType.F_ENERGY)) {
                info += " (E)";
            } else if (weapon.hasFlag(WeaponType.F_MISSILE)) {
                info += " (M)";
            } else if (weapon.hasFlag(WeaponType.F_INF_POINT_BLANK)) {
                info += " (P)";
            }
            if (weapon.hasFlag(WeaponType.F_INF_BURST)) {
                info += "B";
            }
            if (weapon.hasFlag(WeaponType.F_INF_AA)) {
                info += "A";
            }
            if (weapon.hasFlag(WeaponType.F_FLAMER)) {
                info += "F";
            }
            if (weapon.hasFlag(WeaponType.F_INF_NONPENETRATING)) {
                info += "N";
            }
        } else if (weapon.hasFlag(WeaponType.F_MGA)) {
            info = "[T]";
        } else if (weapon instanceof ISC3M) {
            info = "[E]";
        } else if (weapon.getDamage() < 0) {
            if (weapon instanceof SRMWeapon) {
                info = "[M,C]";
            } else if ((weapon instanceof LRMWeapon) || (weapon instanceof MekMortarWeapon)) {
                info = "[M,C,S]";
            } else if ((weapon instanceof MRMWeapon) || (weapon instanceof RLWeapon)) {
                info = "[M,C]";
            } else if ((weapon instanceof ISSnubNosePPC) || (weapon instanceof ISBombastLaser)) {
                info = "[DE,V]";
            } else if (weapon instanceof ISVariableSpeedPulseLaserSmall) {
                info = "[P,V]";
            } else if (weapon instanceof ISVariableSpeedPulseLaserMedium) {
                info = "[P,V]";
            } else if (weapon instanceof ISVariableSpeedPulseLaserLarge) {
                info = "[P,V]";
            } else if (weapon instanceof ISHGaussRifle) {
                info = "[DB,X]";
            } else if (weapon instanceof ISPlasmaRifle) {
                info = "[DE,H,AI]";
            } else if (weapon instanceof CLPlasmaCannon) {
                info = "[DE,H,AI]";
            } else if (weapon instanceof HAGWeapon) {
                info = "[C,F]";
            } else if (weapon instanceof ArtilleryWeapon) {
                info = "[AE,S,F]";
            } else if (weapon instanceof ArtilleryCannonWeapon) {
                info = "[DB,AE]";
            } else if (weapon instanceof ThunderBoltWeapon) {
                info = "[M]";
            } else if (weapon instanceof NarcWeapon) {
                info = "[M]";
            } else {
                info = "";
            }
        } else if (weapon instanceof UACWeapon) {
            info = "[DB,R/C]";
        } else {
            info = " [";
            if (weapon.hasFlag(WeaponType.F_BALLISTIC)) {
                info += "DB,";
            }
            if (UnitUtil.isAMS(weapon) || (weapon instanceof BPodWeapon)) {
                info += "PD,";
            } else if (weapon.hasFlag(WeaponType.F_PULSE)) {
                info += "P,";
            } else if (weapon.hasFlag(WeaponType.F_ENERGY)) {
                info += "DE,";
            }
            if ((weapon instanceof LBXACWeapon) || (weapon instanceof ISSilverBulletGauss)) {
                info += "C/F,";
            }
            if (UnitUtil.hasSwitchableAmmo(weapon)) {
                info += "S,";
            }
            if ((weapon instanceof MGWeapon) || (weapon instanceof BPodWeapon) || (weapon instanceof CLERPulseLaserSmall) || (weapon instanceof ISXPulseLaserSmall) || (weapon instanceof ISPulseLaserSmall) || (weapon instanceof CLPulseLaserSmall) || (weapon instanceof CLPulseLaserMicro)) {
                info += "AI,";
            }
            if (weapon instanceof FlamerWeapon) {
                info += "H,AI,";
            }
            if (weapon.isExplosive(mount) && !(weapon instanceof ACWeapon) && (!(weapon instanceof PPCWeapon) || ((mount.getLinkedBy() != null) && mount.getLinkedBy().getType().hasFlag(MiscType.F_PPC_CAPACITOR)))) {
                info += "X,";
            }
            if (weapon.hasFlag(WeaponType.F_ONESHOT)) {
                info += "OS,";
            }
            info = info.substring(0, info.length() - 1) + "]";
        }
    } else {
        info = "[E]";
    }
    return info;
}
Also used : ISVariableSpeedPulseLaserSmall(megamek.common.weapons.lasers.ISVariableSpeedPulseLaserSmall) StreakSRMWeapon(megamek.common.weapons.srms.StreakSRMWeapon) SRMWeapon(megamek.common.weapons.srms.SRMWeapon) ISSnubNosePPC(megamek.common.weapons.ppc.ISSnubNosePPC) BPodWeapon(megamek.common.weapons.defensivepods.BPodWeapon) CLPulseLaserSmall(megamek.common.weapons.lasers.CLPulseLaserSmall) PPCWeapon(megamek.common.weapons.ppc.PPCWeapon) NarcWeapon(megamek.common.weapons.other.NarcWeapon) MGWeapon(megamek.common.weapons.mgs.MGWeapon) HAGWeapon(megamek.common.weapons.gaussrifles.HAGWeapon) ArtilleryWeapon(megamek.common.weapons.artillery.ArtilleryWeapon) CLERPulseLaserSmall(megamek.common.weapons.lasers.CLERPulseLaserSmall) CLPlasmaCannon(megamek.common.weapons.ppc.CLPlasmaCannon) ISPulseLaserSmall(megamek.common.weapons.lasers.ISPulseLaserSmall) ISHGaussRifle(megamek.common.weapons.gaussrifles.ISHGaussRifle) RLWeapon(megamek.common.weapons.missiles.RLWeapon) ISPlasmaRifle(megamek.common.weapons.ppc.ISPlasmaRifle) InfantryWeapon(megamek.common.weapons.infantry.InfantryWeapon) ISVariableSpeedPulseLaserMedium(megamek.common.weapons.lasers.ISVariableSpeedPulseLaserMedium) StreakLRMWeapon(megamek.common.weapons.lrms.StreakLRMWeapon) LRMWeapon(megamek.common.weapons.lrms.LRMWeapon) ISBombastLaser(megamek.common.weapons.lasers.ISBombastLaser) ISVariableSpeedPulseLaserLarge(megamek.common.weapons.lasers.ISVariableSpeedPulseLaserLarge) ISSilverBulletGauss(megamek.common.weapons.gaussrifles.ISSilverBulletGauss) CLPulseLaserMicro(megamek.common.weapons.lasers.CLPulseLaserMicro) UACWeapon(megamek.common.weapons.autocannons.UACWeapon) MRMWeapon(megamek.common.weapons.missiles.MRMWeapon) FlamerWeapon(megamek.common.weapons.flamers.FlamerWeapon) ISXPulseLaserSmall(megamek.common.weapons.lasers.ISXPulseLaserSmall) WeaponType(megamek.common.WeaponType) ISC3M(megamek.common.weapons.other.ISC3M) MekMortarWeapon(megamek.common.weapons.mortars.MekMortarWeapon) ArtilleryCannonWeapon(megamek.common.weapons.artillery.ArtilleryCannonWeapon) ThunderBoltWeapon(megamek.common.weapons.missiles.ThunderBoltWeapon) LBXACWeapon(megamek.common.weapons.autocannons.LBXACWeapon) LBXACWeapon(megamek.common.weapons.autocannons.LBXACWeapon) UACWeapon(megamek.common.weapons.autocannons.UACWeapon) ACWeapon(megamek.common.weapons.autocannons.ACWeapon)

Example 2 with ArtilleryWeapon

use of megamek.common.weapons.artillery.ArtilleryWeapon in project megameklab by MegaMek.

the class PrintInfantry method printImage.

public void printImage(Graphics2D g2d, PageFormat pageFormat) {
    if ((null == g2d) || (null == infantry)) {
        return;
    }
    SVGDiagram diagram;
    int stop = Math.min(4, infantryList.size() - currentPosition);
    if (stop > 3) {
        diagram = ImageHelper.loadSVGImage(new File("data/images/recordsheets/Conventional_Infantry_no_tables.svg"));
    } else {
        diagram = ImageHelper.loadSVGImage(new File("data/images/recordsheets/Conventional_Infantry_tables.svg"));
    }
    try {
        Tspan tspan = (Tspan) diagram.getElement("text_copyright");
        tspan.setText(String.format(tspan.getText(), Calendar.getInstance().get(Calendar.YEAR)));
        ((Text) tspan.getParent()).rebuild();
        diagram.render(g2d);
        for (int pos = 0; pos < stop; pos++) {
            diagram = ImageHelper.loadSVGImage(new File("data/images/recordsheets/Conventional_Infantry_platoon_" + (pos + 1) + ".svg"));
            infantry = infantryList.get(pos + currentPosition);
            tspan = (Tspan) diagram.getElement(ID_PLATOON_NAME);
            String name = infantry.getChassis();
            if (infantry.getModel().length() > 0) {
                name += " " + infantry.getModel();
            }
            if (name.length() > 48) {
                tspan.setText(infantry.getChassis());
            } else {
                tspan.setText(name);
            }
            ((Text) tspan.getParent()).rebuild();
            tspan = (Tspan) diagram.getElement(ID_ARMOR_KIT);
            EquipmentType armor = infantry.getArmorKit();
            if (armor != null) {
                tspan.setText(armor.getName());
                ((Text) tspan.getParent()).rebuild();
            } else if (infantry.hasDEST()) {
                tspan.setText("DEST");
                ((Text) tspan.getParent()).rebuild();
            } else {
                StringJoiner sj = new StringJoiner("/");
                if (infantry.hasSneakCamo()) {
                    sj.add("Camo");
                }
                if (infantry.hasSneakIR()) {
                    sj.add("IR");
                }
                if (infantry.hasSneakECM()) {
                    sj.add("ECM");
                }
                if (sj.length() > 0) {
                    tspan.setText("Sneak(" + sj.toString() + ")");
                    ((Text) tspan.getParent()).rebuild();
                }
            }
            tspan = (Tspan) diagram.getElement(ID_ARMOR_DIVISOR);
            tspan.setText(String.valueOf(infantry.getDamageDivisor() + (infantry.isArmorEncumbering() ? "E" : "")));
            ((Text) tspan.getParent()).rebuild();
            for (int j = 1; j <= 30; j++) {
                if (j > infantry.getShootingStrength()) {
                    diagram.getElement(ID_SOLDIER + j).addAttribute("display", AnimationElement.AT_XML, "none");
                    diagram.getElement(ID_NO_SOLDIER + j).removeAttribute("display", AnimationElement.AT_XML);
                } else {
                    tspan = (Tspan) diagram.getElement(ID_DAMAGE + j);
                    tspan.setText(String.valueOf((int) Math.round(infantry.getDamagePerTrooper() * j)));
                    ((Text) tspan.getParent()).rebuild();
                }
            }
            diagram.updateTime(0);
            InfantryWeapon rangeWeapon = infantry.getPrimaryWeapon();
            if (infantry.getSecondaryWeapon() != null && infantry.getSecondaryN() > 1 && !infantry.getSecondaryWeapon().hasFlag(WeaponType.F_TAG)) {
                rangeWeapon = infantry.getSecondaryWeapon();
            }
            boolean scuba = infantry.getMovementMode() == EntityMovementMode.INF_UMU || infantry.getMovementMode() == EntityMovementMode.SUBMARINE;
            if (scuba) {
                diagram.getElement(ID_UW_LABEL).removeAttribute("display", AnimationElement.AT_XML);
            }
            InfantryWeapon singleSecondary = (infantry.getSecondaryN() == 1) ? infantry.getSecondaryWeapon() : null;
            for (int j = 0; j <= 21; j++) {
                tspan = (Tspan) diagram.getElement(ID_RANGE_MOD + j);
                tspan.setText(rangeMod(j, rangeWeapon, singleSecondary, false));
                if (scuba) {
                    tspan = (Tspan) diagram.getElement(ID_UW_RANGE_MOD + j);
                    tspan.setText(rangeMod(j, rangeWeapon, singleSecondary, true));
                }
                ((Text) tspan.getParent()).rebuild();
            }
            int numGuns = 0;
            int numShots = 0;
            WeaponType gun = null;
            for (Mounted m : infantry.getEquipment()) {
                if (m.getLocation() == Infantry.LOC_FIELD_GUNS) {
                    if (m.getType() instanceof WeaponType) {
                        gun = (WeaponType) m.getType();
                        numGuns++;
                    } else if (m.getType() instanceof AmmoType) {
                        numShots += ((AmmoType) m.getType()).getShots();
                    }
                }
            }
            if (gun == null) {
                diagram.getElement(ID_FIELD_GUN_COLUMNS).addAttribute("display", AnimationElement.AT_XML, "none");
            } else {
                tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_QTY);
                tspan.setText(Integer.toString(numGuns));
                ((Text) tspan.getParent()).rebuild();
                tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_TYPE);
                tspan.setText(gun.getName());
                ((Text) tspan.getParent()).rebuild();
                /* We don't use StringUnits.getEquipmentInfo() to format the damage
					 * string because gauss explosion flags do not apply, and switchable
					 * only applies for non-LBX.
					 */
                tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_DMG);
                if (gun instanceof ArtilleryWeapon) {
                    tspan.setText(gun.getRackSize() + " [AE,S,F]");
                } else {
                    StringBuilder sb = new StringBuilder(Integer.toString(gun.getDamage()));
                    switch(gun.getAmmoType()) {
                        case AmmoType.T_AC_ULTRA:
                        case AmmoType.T_AC_ULTRA_THB:
                            sb.append("/Sht, R2 [DB,R/S/C]");
                            break;
                        case AmmoType.T_AC_ROTARY:
                            sb.append("/Sht, R6 [DB,R/S/C]");
                            break;
                        case AmmoType.T_AC:
                        case AmmoType.T_AC_PRIMITIVE:
                        case AmmoType.T_LAC:
                            sb.append(" [DB,C/S/F]");
                            break;
                        case AmmoType.T_AC_LBX:
                        case AmmoType.T_AC_LBX_THB:
                            sb.append(" [DB,C/F]");
                            break;
                        default:
                            sb.append(" [DB]");
                    }
                    tspan.setText(sb.toString());
                }
                ((Text) tspan.getParent()).rebuild();
                tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_MIN_RANGE);
                if (gun.getMinimumRange() > 0) {
                    tspan.setText(Integer.toString(gun.getMinimumRange()));
                } else {
                    tspan.setText("—");
                }
                ((Text) tspan.getParent()).rebuild();
                tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_SHORT);
                tspan.setText(Integer.toString(gun.getShortRange()));
                ((Text) tspan.getParent()).rebuild();
                tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_MED);
                tspan.setText(Integer.toString(gun.getMediumRange()));
                ((Text) tspan.getParent()).rebuild();
                tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_LONG);
                tspan.setText(Integer.toString(gun.getLongRange()));
                ((Text) tspan.getParent()).rebuild();
                tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_AMMO);
                tspan.setText(Integer.toString(numShots));
                ((Text) tspan.getParent()).rebuild();
                tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_CREW);
                tspan.setText(Integer.toString((int) Math.ceil(gun.getTonnage(infantry))));
                ((Text) tspan.getParent()).rebuild();
            }
            if (infantry.hasDEST()) {
                diagram.getElement(ID_DEST_MODS).removeAttribute("display", AnimationElement.AT_XML);
                diagram.getElement(ID_SNEAK_IR_MODS).removeAttribute("display", AnimationElement.AT_XML);
            } else if (infantry.hasSneakCamo()) {
                diagram.getElement(ID_SNEAK_CAMO_MODS).removeAttribute("display", AnimationElement.AT_XML);
            }
            if (infantry.hasSneakIR()) {
                diagram.getElement(ID_SNEAK_IR_MODS).removeAttribute("display", AnimationElement.AT_XML);
            }
            tspan = (Tspan) diagram.getElement(ID_BV);
            tspan.setText(Integer.toString(infantry.calculateBattleValue()));
            ((Text) tspan.getParent()).rebuild();
            tspan = (Tspan) diagram.getElement(ID_TRANSPORT_WT);
            tspan.setText(String.format("%.1f tons", infantry.getWeight()));
            ((Text) tspan.getParent()).rebuild();
            Tspan mp1 = (Tspan) diagram.getElement(ID_MP_1);
            Tspan mode1 = (Tspan) diagram.getElement(ID_MODE_1);
            Tspan mp2 = (Tspan) diagram.getElement(ID_MP_2);
            Tspan mode2 = (Tspan) diagram.getElement(ID_MODE_2);
            switch(infantry.getMovementMode()) {
                case INF_JUMP:
                    mp1.setText(Integer.toString(infantry.getJumpMP(false)));
                    mode1.setText("Jump");
                    mp2.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
                    mode2.setText("Ground");
                    ((Text) mp2.getParent()).rebuild();
                    ((Text) mode2.getParent()).rebuild();
                    break;
                case INF_UMU:
                    mp1.setText(Integer.toString(infantry.getActiveUMUCount()));
                    if (infantry.getOriginalJumpMP() > 1) {
                        mode1.setText("SCUBA (Motorized)");
                    } else {
                        mode1.setText("SCUBA");
                    }
                    mp2.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
                    mode2.setText("Ground");
                    ((Text) mp2.getParent()).rebuild();
                    ((Text) mode2.getParent()).rebuild();
                    break;
                case HOVER:
                    mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
                    mode1.setText("Mechanized Hover");
                    break;
                case TRACKED:
                    mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
                    mode1.setText("Mechanized Tracked");
                    break;
                case WHEELED:
                    mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
                    mode1.setText("Mechanized Wheeled");
                    break;
                case VTOL:
                    mp1.setText(Integer.toString(infantry.getJumpMP(false)));
                    if (infantry.hasMicrolite()) {
                        mode1.setText("VTOL (Microlite)");
                    } else {
                        mode1.setText("VTOL (Micro-copter)");
                    }
                    break;
                case SUBMARINE:
                    mp1.setText(Integer.toString(infantry.getActiveUMUCount()));
                    mode1.setText("Mechanized SCUBA");
                    break;
                case INF_MOTORIZED:
                    mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
                    mode1.setText("Motorized");
                    break;
                case INF_LEG:
                default:
                    mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
                    mode1.setText("Ground");
                    break;
            }
            if (mp1.getText().equals("0")) {
                mp1.setText("0*");
            }
            ((Text) mp1.getParent()).rebuild();
            ((Text) mode1.getParent()).rebuild();
            List<String> notes = new ArrayList<>();
            if (infantry.isMechanized() || infantry.isArmorEncumbering()) {
                notes.add("Cannot make anti-'Mech attacks.");
            }
            if (infantry.hasSpaceSuit()) {
                notes.add("Can operate in vacuum.");
            }
            if (rangeWeapon.hasFlag(WeaponType.F_INF_BURST)) {
                notes.add("+1D6 damage vs. conventional infantry.");
            }
            if (rangeWeapon.hasFlag(WeaponType.F_INF_NONPENETRATING)) {
                notes.add("Can only damage conventional infantry.");
            }
            if (infantry.getPrimaryWeapon().hasFlag(WeaponType.F_INFERNO) || (infantry.getSecondaryWeapon() != null && infantry.getSecondaryWeapon().hasFlag(WeaponType.F_INFERNO))) {
                notes.add("Flame-based weapon.");
            } else {
                for (int i = 0; i < infantry.getPrimaryWeapon().getModesCount(); i++) {
                    if (infantry.getPrimaryWeapon().getMode(i).equals("Heat")) {
                        notes.add("Flame-based weapon.");
                        break;
                    }
                }
                if (infantry.getSecondaryWeapon() != null) {
                    for (int i = 0; i < infantry.getSecondaryWeapon().getModesCount(); i++) {
                        if (infantry.getSecondaryWeapon().getMode(i).equals("Heat")) {
                            notes.add("Flame-based weapon.");
                        }
                    }
                }
            }
            if (infantry.getPrimaryWeapon().hasFlag(WeaponType.F_INF_AA) || (infantry.getSecondaryWeapon() != null && infantry.getSecondaryWeapon().hasFlag(WeaponType.F_INF_AA))) {
                notes.add("Can attack airborn units.");
            }
            if (infantry.hasSpecialization(Infantry.BRIDGE_ENGINEERS)) {
                notes.add("Bridge-building equipment");
            }
            if (infantry.hasSpecialization(Infantry.DEMO_ENGINEERS)) {
                notes.add("Equipped with demolition gear");
            }
            if (infantry.hasSpecialization(Infantry.FIRE_ENGINEERS)) {
                notes.add("Firefighting equipment");
            }
            if (infantry.hasSpecialization(Infantry.MINE_ENGINEERS)) {
                notes.add("Minesweeper equipment");
            }
            if (infantry.hasSpecialization(Infantry.TRENCH_ENGINEERS)) {
                notes.add("Trench/Fieldwork equipment");
            }
            if (infantry.hasSpecialization(Infantry.MARINES)) {
                notes.add("No penalties for vacuum or zero-G");
            }
            if (infantry.hasSpecialization(Infantry.MOUNTAIN_TROOPS)) {
                notes.add("Mountain climbing equipment");
            }
            if (infantry.hasSpecialization(Infantry.PARAMEDICS)) {
                notes.add("Paramedic equipment.");
            }
            if (infantry.hasSpecialization(Infantry.PARATROOPS)) {
                notes.add("Can make atmospheric drops.");
            }
            if (infantry.hasSpecialization(Infantry.SENSOR_ENGINEERS)) {
                notes.add("Surveillance and communication equipment");
            }
            if (infantry.hasSpecialization(Infantry.TAG_TROOPS)) {
                notes.add("Equipped with TAG (Range 3/6/9)");
            }
            if (infantry.hasSneakECM()) {
                notes.add("Invisible to standard/light active probes.");
            }
            for (int i = 0; i < Math.min(8, notes.size()); i++) {
                tspan = (Tspan) diagram.getElement(ID_NOTE_LINE + i);
                tspan.setText(notes.get(i));
            }
            ((Text) diagram.getElement(ID_NOTES)).rebuild();
            diagram.updateTime(0);
            diagram.render(g2d);
        }
    } catch (SVGException ex) {
        ex.printStackTrace();
    }
    g2d.scale(pageFormat.getImageableWidth(), pageFormat.getImageableHeight());
}
Also used : SVGException(com.kitfox.svg.SVGException) ArrayList(java.util.ArrayList) Text(com.kitfox.svg.Text) Tspan(com.kitfox.svg.Tspan) EquipmentType(megamek.common.EquipmentType) AmmoType(megamek.common.AmmoType) SVGDiagram(com.kitfox.svg.SVGDiagram) ArtilleryWeapon(megamek.common.weapons.artillery.ArtilleryWeapon) Mounted(megamek.common.Mounted) WeaponType(megamek.common.WeaponType) File(java.io.File) StringJoiner(java.util.StringJoiner) InfantryWeapon(megamek.common.weapons.infantry.InfantryWeapon)

Example 3 with ArtilleryWeapon

use of megamek.common.weapons.artillery.ArtilleryWeapon in project megameklab by MegaMek.

the class StringUtils method getEquipmentInfo.

public static String getEquipmentInfo(Entity unit, Mounted mount) {
    String info = "";
    if (mount.getType() instanceof WeaponType) {
        WeaponType weapon = (WeaponType) mount.getType();
        if (weapon instanceof InfantryWeapon) {
            info = Integer.toString(weapon.getDamage());
            if (weapon.hasFlag(WeaponType.F_BALLISTIC)) {
                info += " (B)";
            } else if (weapon.hasFlag(WeaponType.F_ENERGY)) {
                info += " (E)";
            } else if (weapon.hasFlag(WeaponType.F_MISSILE)) {
                info += " (M)";
            } else if (weapon.hasFlag(WeaponType.F_INF_POINT_BLANK)) {
                info += " (P)";
            }
            if (weapon.hasFlag(WeaponType.F_INF_BURST)) {
                info += "B";
            }
            if (weapon.hasFlag(WeaponType.F_INF_AA)) {
                info += "A";
            }
            if (weapon.hasFlag(WeaponType.F_FLAMER)) {
                info += "F";
            }
            if (weapon.hasFlag(WeaponType.F_INF_NONPENETRATING)) {
                info += "N";
            }
        } else if (weapon.hasFlag(WeaponType.F_MGA)) {
            info = "  [T]";
        } else if ((weapon instanceof ISC3M) || (weapon instanceof TAGWeapon)) {
            info = "  [E]";
        } else if (weapon instanceof ISC3RemoteSensorLauncher) {
            info = "  [M,E]";
        } else if (weapon.getDamage() < 0) {
            if (weapon instanceof StreakSRMWeapon) {
                info = "2/Msl [M,C]";
            } else if ((weapon instanceof SRMWeapon) || (weapon instanceof MekMortarWeapon)) {
                info = "2/Msl [M,C,S]";
            } else if ((weapon instanceof StreakLRMWeapon)) {
                info = "1/Msl [M,C]";
            } else if ((weapon instanceof LRMWeapon)) {
                info = "1/Msl [M,C,S]";
            } else if ((weapon instanceof MRMWeapon) || (weapon instanceof RLWeapon)) {
                info = "1/Msl [M,C]";
            } else if (weapon instanceof ISSnubNosePPC) {
                info = "10/8/5 [DE,V]";
            } else if ((weapon instanceof ISBALaserVSPSmall) || (weapon instanceof ISBALaserVSPSmall)) {
                info = "5/4/3 [P,V]";
            } else if ((weapon instanceof ISBALaserVSPMedium) || (weapon instanceof ISBALaserVSPMedium)) {
                info = "9/7/5 [P,V]";
            } else if (weapon instanceof ISVariableSpeedPulseLaserLarge) {
                info = "11/9/7 [P,V]";
            } else if (weapon instanceof ISHGaussRifle) {
                info = "25/20/10 [DB,X]";
            } else if (weapon instanceof ISPlasmaRifle) {
                info = "10 [DE,H,AI]";
            } else if (weapon instanceof CLPlasmaCannon) {
                info = "[DE,H,AI]";
            } else if (weapon instanceof HAGWeapon) {
                info = Integer.toString(weapon.getRackSize());
                info += " [C,F,X]";
            } else if (weapon instanceof ArtilleryWeapon) {
                info = Integer.toString(weapon.getRackSize());
                info += "[AE,S,F]";
            } else if (weapon instanceof ArtilleryCannonWeapon) {
                info = Integer.toString(weapon.getRackSize());
                info += "[DB,AE]";
            } else if (weapon instanceof ThunderBoltWeapon) {
                if (weapon instanceof ISThunderBolt5) {
                    info = "5";
                } else if (weapon instanceof ISThunderBolt10) {
                    info = "10";
                } else if (weapon instanceof ISThunderBolt15) {
                    info = "15";
                } else if (weapon instanceof ISThunderBolt20) {
                    info = "20";
                }
                info += "[M]";
            } else if (weapon instanceof NarcWeapon) {
                info = "[M]";
            } else if (weapon instanceof ISBAPopUpMineLauncher) {
                info = "4";
            } else {
                info = Integer.toString(weapon.getRackSize());
            }
        } else if (weapon instanceof UACWeapon) {
            info = Integer.toString(weapon.getDamage());
            info += "/Sht [DB,R/C]";
        } else if ((weapon instanceof ISVehicularGrenadeLauncher) || (weapon instanceof CLVehicularGrenadeLauncher)) {
            info = "[AE,OS]";
        } else {
            if (!UnitUtil.isAMS(weapon)) {
                info = Integer.toString(weapon.getDamage());
            }
            info += " [";
            if (weapon.hasFlag(WeaponType.F_BALLISTIC) && !UnitUtil.isAMS(weapon)) {
                info += "DB,";
            }
            if (UnitUtil.isAMS(weapon) || (weapon.hasFlag(WeaponType.F_B_POD))) {
                info += "PD,";
            } else if (weapon.hasFlag(WeaponType.F_PULSE)) {
                info += "P,";
            } else if (weapon.hasFlag(WeaponType.F_ENERGY) || weapon.hasFlag(WeaponType.F_PLASMA)) {
                info += "DE,";
            }
            if (weapon instanceof ISBombastLaser) {
                info += "V,";
            }
            if ((weapon instanceof LBXACWeapon) || (weapon instanceof ISSilverBulletGauss)) {
                info += "C/F/";
            }
            if (weapon instanceof CLBALBX) {
                info += "C,F,";
            }
            if (UnitUtil.hasSwitchableAmmo(weapon)) {
                info += "S,";
            }
            if (weapon.hasFlag(WeaponType.F_FLAMER) || weapon.hasFlag(WeaponType.F_PLASMA)) {
                info += "H,";
            }
            if ((weapon instanceof MGWeapon) || (weapon instanceof BPodWeapon) || (weapon instanceof CLERPulseLaserSmall) || (weapon instanceof CLBAERPulseLaserSmall) || (weapon instanceof ISXPulseLaserSmall) || (weapon instanceof ISPulseLaserSmall) || (weapon instanceof ISBALaserPulseSmall) || (weapon instanceof CLPulseLaserSmall) || (weapon instanceof CLBAPulseLaserSmall) || (weapon instanceof CLPulseLaserMicro) || (weapon instanceof CLBAPulseLaserMicro) || (weapon.hasFlag(WeaponType.F_FLAMER) || (weapon.hasFlag(WeaponType.F_BURST_FIRE)))) {
                info += "AI,";
            }
            if (weapon.isExplosive(mount) && !(weapon instanceof ACWeapon) && (!(weapon instanceof PPCWeapon) || ((mount.getLinkedBy() != null) && mount.getLinkedBy().getType().hasFlag(MiscType.F_PPC_CAPACITOR)))) {
                info += "X,";
            }
            if (weapon.hasFlag(WeaponType.F_ONESHOT)) {
                info += "OS,";
            }
            info = info.substring(0, info.length() - 1) + "]";
        }
    } else if ((mount.getType() instanceof MiscType) && (mount.getType().hasFlag(MiscType.F_CLUB) || mount.getType().hasFlag(MiscType.F_HAND_WEAPON))) {
        if (mount.getType().hasSubType(MiscType.S_VIBRO_LARGE) || mount.getType().hasSubType(MiscType.S_VIBRO_MEDIUM) || mount.getType().hasSubType(MiscType.S_VIBRO_SMALL)) {
            // manually set vibros to active to get correct damage
            mount.setMode(1);
        }
        if (mount.getType().hasSubType(MiscType.S_CLAW) || mount.getType().hasSubType(MiscType.S_CLAW_THB)) {
            info = Integer.toString((int) Math.ceil(unit.getWeight() / 7.0));
        } else {
            info = Integer.toString(ClubAttackAction.getDamageFor(unit, mount, false));
        }
    } else if ((mount.getType() instanceof MiscType) && (mount.getType().hasFlag(MiscType.F_AP_POD))) {
        info = "[PD,OS,AI]";
    } else if ((mount.getType() instanceof MiscType) && mount.getType().hasFlag(MiscType.F_TALON)) {
        info = Integer.toString(KickAttackAction.getDamageFor(unit, Mech.LOC_LLEG, false));
    } else {
        info = "  [E]";
    }
    return info;
}
Also used : ISBALaserPulseSmall(megamek.common.weapons.battlearmor.ISBALaserPulseSmall) StreakSRMWeapon(megamek.common.weapons.srms.StreakSRMWeapon) ISC3RemoteSensorLauncher(megamek.common.weapons.other.ISC3RemoteSensorLauncher) ISThunderBolt5(megamek.common.weapons.missiles.ISThunderBolt5) CLBALBX(megamek.common.weapons.battlearmor.CLBALBX) ISSnubNosePPC(megamek.common.weapons.ppc.ISSnubNosePPC) BPodWeapon(megamek.common.weapons.defensivepods.BPodWeapon) PPCWeapon(megamek.common.weapons.ppc.PPCWeapon) ISBAPopUpMineLauncher(megamek.common.weapons.battlearmor.ISBAPopUpMineLauncher) CLBAPulseLaserMicro(megamek.common.weapons.battlearmor.CLBAPulseLaserMicro) CLBAPulseLaserSmall(megamek.common.weapons.battlearmor.CLBAPulseLaserSmall) MGWeapon(megamek.common.weapons.mgs.MGWeapon) ArtilleryWeapon(megamek.common.weapons.artillery.ArtilleryWeapon) CLERPulseLaserSmall(megamek.common.weapons.lasers.CLERPulseLaserSmall) CLPlasmaCannon(megamek.common.weapons.ppc.CLPlasmaCannon) ISPulseLaserSmall(megamek.common.weapons.lasers.ISPulseLaserSmall) TAGWeapon(megamek.common.weapons.tag.TAGWeapon) InfantryWeapon(megamek.common.weapons.infantry.InfantryWeapon) ISVariableSpeedPulseLaserLarge(megamek.common.weapons.lasers.ISVariableSpeedPulseLaserLarge) CLPulseLaserMicro(megamek.common.weapons.lasers.CLPulseLaserMicro) MRMWeapon(megamek.common.weapons.missiles.MRMWeapon) ISBALaserVSPMedium(megamek.common.weapons.battlearmor.ISBALaserVSPMedium) ISThunderBolt20(megamek.common.weapons.missiles.ISThunderBolt20) ISXPulseLaserSmall(megamek.common.weapons.lasers.ISXPulseLaserSmall) WeaponType(megamek.common.WeaponType) ISC3M(megamek.common.weapons.other.ISC3M) ThunderBoltWeapon(megamek.common.weapons.missiles.ThunderBoltWeapon) CLVehicularGrenadeLauncher(megamek.common.weapons.mortars.CLVehicularGrenadeLauncher) StreakSRMWeapon(megamek.common.weapons.srms.StreakSRMWeapon) SRMWeapon(megamek.common.weapons.srms.SRMWeapon) CLPulseLaserSmall(megamek.common.weapons.lasers.CLPulseLaserSmall) ISVehicularGrenadeLauncher(megamek.common.weapons.mortars.ISVehicularGrenadeLauncher) ISThunderBolt15(megamek.common.weapons.missiles.ISThunderBolt15) ISThunderBolt10(megamek.common.weapons.missiles.ISThunderBolt10) NarcWeapon(megamek.common.weapons.other.NarcWeapon) HAGWeapon(megamek.common.weapons.gaussrifles.HAGWeapon) ISHGaussRifle(megamek.common.weapons.gaussrifles.ISHGaussRifle) RLWeapon(megamek.common.weapons.missiles.RLWeapon) ISPlasmaRifle(megamek.common.weapons.ppc.ISPlasmaRifle) StreakLRMWeapon(megamek.common.weapons.lrms.StreakLRMWeapon) LRMWeapon(megamek.common.weapons.lrms.LRMWeapon) ISBombastLaser(megamek.common.weapons.lasers.ISBombastLaser) ISBALaserVSPSmall(megamek.common.weapons.battlearmor.ISBALaserVSPSmall) ISSilverBulletGauss(megamek.common.weapons.gaussrifles.ISSilverBulletGauss) MiscType(megamek.common.MiscType) StreakLRMWeapon(megamek.common.weapons.lrms.StreakLRMWeapon) UACWeapon(megamek.common.weapons.autocannons.UACWeapon) CLBAERPulseLaserSmall(megamek.common.weapons.battlearmor.CLBAERPulseLaserSmall) MekMortarWeapon(megamek.common.weapons.mortars.MekMortarWeapon) ArtilleryCannonWeapon(megamek.common.weapons.artillery.ArtilleryCannonWeapon) LBXACWeapon(megamek.common.weapons.autocannons.LBXACWeapon) LBXACWeapon(megamek.common.weapons.autocannons.LBXACWeapon) UACWeapon(megamek.common.weapons.autocannons.UACWeapon) ACWeapon(megamek.common.weapons.autocannons.ACWeapon)

Example 4 with ArtilleryWeapon

use of megamek.common.weapons.artillery.ArtilleryWeapon in project megameklab by MegaMek.

the class FieldGunView method actionPerformed.

public void actionPerformed(ActionEvent e) {
    if (e.getSource().equals(btnSetGun)) {
        int view = masterEquipmentTable.getSelectedRow();
        if (view < 0) {
            // selection got filtered away
            return;
        }
        int selected = masterEquipmentTable.convertRowIndexToModel(view);
        EquipmentType equip = masterEquipmentList.getType(selected);
        int num;
        if (equip instanceof ArtilleryWeapon || equip instanceof ArtilleryCannonWeapon) {
            num = 1;
        } else {
            int crewReq = Math.max(2, (int) Math.ceil(equip.getTonnage(getInfantry())));
            num = getInfantry().getShootingStrength() / crewReq;
        }
        UnitUtil.replaceFieldGun(getInfantry(), (WeaponType) equip, num);
    } else if (e.getSource().equals(btnRemoveGun)) {
        UnitUtil.replaceFieldGun(getInfantry(), null, 0);
    } else {
        return;
    }
    refresh.refreshAll();
}
Also used : ArtilleryWeapon(megamek.common.weapons.artillery.ArtilleryWeapon) ArtilleryCannonWeapon(megamek.common.weapons.artillery.ArtilleryCannonWeapon) EquipmentType(megamek.common.EquipmentType)

Aggregations

ArtilleryWeapon (megamek.common.weapons.artillery.ArtilleryWeapon)4 WeaponType (megamek.common.WeaponType)3 ArtilleryCannonWeapon (megamek.common.weapons.artillery.ArtilleryCannonWeapon)3 InfantryWeapon (megamek.common.weapons.infantry.InfantryWeapon)3 EquipmentType (megamek.common.EquipmentType)2 ACWeapon (megamek.common.weapons.autocannons.ACWeapon)2 LBXACWeapon (megamek.common.weapons.autocannons.LBXACWeapon)2 UACWeapon (megamek.common.weapons.autocannons.UACWeapon)2 BPodWeapon (megamek.common.weapons.defensivepods.BPodWeapon)2 HAGWeapon (megamek.common.weapons.gaussrifles.HAGWeapon)2 ISHGaussRifle (megamek.common.weapons.gaussrifles.ISHGaussRifle)2 ISSilverBulletGauss (megamek.common.weapons.gaussrifles.ISSilverBulletGauss)2 CLERPulseLaserSmall (megamek.common.weapons.lasers.CLERPulseLaserSmall)2 CLPulseLaserMicro (megamek.common.weapons.lasers.CLPulseLaserMicro)2 CLPulseLaserSmall (megamek.common.weapons.lasers.CLPulseLaserSmall)2 ISBombastLaser (megamek.common.weapons.lasers.ISBombastLaser)2 ISPulseLaserSmall (megamek.common.weapons.lasers.ISPulseLaserSmall)2 ISVariableSpeedPulseLaserLarge (megamek.common.weapons.lasers.ISVariableSpeedPulseLaserLarge)2 ISXPulseLaserSmall (megamek.common.weapons.lasers.ISXPulseLaserSmall)2 LRMWeapon (megamek.common.weapons.lrms.LRMWeapon)2