Search in sources :

Example 1 with PPCWeapon

use of megamek.common.weapons.ppc.PPCWeapon in project megameklab by MegaMek.

the class DropTargetCriticalList method mousePressed.

public void mousePressed(MouseEvent e) {
    if (buildView) {
        if (e.getButton() == MouseEvent.BUTTON2) {
            setSelectedIndex(locationToIndex(e.getPoint()));
            removeCrit();
        } else if (e.getButton() == MouseEvent.BUTTON3) {
            setSelectedIndex(locationToIndex(e.getPoint()));
            if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
                removeCrit();
                return;
            }
            int location = getCritLocation();
            JPopupMenu popup = new JPopupMenu();
            CriticalSlot cs = getCrit();
            final Mounted mount = getMounted();
            if ((e.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
                changeWeaponFacing(!mount.isRearMounted());
                return;
            }
            if (mount != null && (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0) {
                changeOmniMounting(!mount.isOmniPodMounted());
                return;
            }
            if (mount != null && !((getUnit().getEntityType() & Entity.ETYPE_QUADVEE) == Entity.ETYPE_QUADVEE && mount.getType() instanceof MiscType && mount.getType().hasFlag(MiscType.F_TRACKS))) {
                JMenuItem info;
                if (!UnitUtil.isFixedLocationSpreadEquipment(mount.getType())) {
                    popup.setAutoscrolls(true);
                    info = new JMenuItem("Remove " + mount.getName());
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            removeCrit();
                        }
                    });
                    popup.add(info);
                }
                info = new JMenuItem("Delete " + mount.getName());
                info.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        removeMount();
                    }
                });
                if (!((getUnit() instanceof BattleArmor) && UnitUtil.isFixedLocationSpreadEquipment(mount.getType()))) {
                    popup.add(info);
                }
                // Allow making this a sort weapon
                if ((mount.getType() instanceof WeaponType) && !mount.isSquadSupportWeapon() && mount.getLocation() == BattleArmor.LOC_SQUAD && (getUnit() instanceof BattleArmor) && ((BattleArmor) getUnit()).getChassisType() != BattleArmor.CHASSIS_TYPE_QUAD) {
                    info = new JMenuItem("Mount as squad support weapon");
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            mount.setSquadSupportWeapon(true);
                            if (refresh != null) {
                                refresh.refreshAll();
                            }
                        }
                    });
                    popup.add(info);
                }
                // Adding ammo as a squad support mount is slightly different
                if ((mount.getType() instanceof AmmoType) && !mount.getType().hasFlag(WeaponType.F_MISSILE) && !mount.isSquadSupportWeapon() && mount.getLocation() == BattleArmor.LOC_SQUAD && (getUnit() instanceof BattleArmor) && ((BattleArmor) getUnit()).getChassisType() != BattleArmor.CHASSIS_TYPE_QUAD) {
                    boolean enabled = false;
                    for (Mounted weapon : getUnit().getWeaponList()) {
                        WeaponType wtype = (WeaponType) weapon.getType();
                        if (weapon.isSquadSupportWeapon() && AmmoType.isAmmoValid(mount, wtype)) {
                            enabled = true;
                        }
                    }
                    info = new JMenuItem("Mount as squad support weapon");
                    info.setEnabled(enabled);
                    info.setToolTipText("Ammo can only be squad mounted along " + "with a weapon that uses it");
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            mount.setSquadSupportWeapon(true);
                            if (refresh != null) {
                                refresh.refreshAll();
                            }
                        }
                    });
                    popup.add(info);
                }
                // Allow removing squad support weapon
                if (mount.isSquadSupportWeapon()) {
                    info = new JMenuItem("Remove squad support weapon mount");
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            mount.setSquadSupportWeapon(false);
                            // squad support weapon
                            for (Mounted ammo : getUnit().getAmmo()) {
                                ammo.setSquadSupportWeapon(false);
                            }
                            if (refresh != null) {
                                refresh.refreshAll();
                            }
                        }
                    });
                    popup.add(info);
                }
                // Right-clicked on a DWP that has an attached weapon
                if (mount.getType().hasFlag(MiscType.F_DETACHABLE_WEAPON_PACK) && mount.getLinked() != null) {
                    info = new JMenuItem("Remove attached weapon");
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            Mounted attached = mount.getLinked();
                            attached.setDWPMounted(false);
                            mount.setLinked(null);
                            mount.setLinkedBy(null);
                            attached.setLinked(null);
                            attached.setLinkedBy(null);
                            if (refresh != null) {
                                refresh.refreshAll();
                            }
                        }
                    });
                    popup.add(info);
                }
                // Right-clicked on a AP Mount that has an attached weapon
                if (mount.getType().hasFlag(MiscType.F_AP_MOUNT) && mount.getLinked() != null) {
                    info = new JMenuItem("Remove attached weapon");
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            Mounted attached = mount.getLinked();
                            attached.setAPMMounted(false);
                            mount.setLinked(null);
                            mount.setLinkedBy(null);
                            attached.setLinked(null);
                            attached.setLinkedBy(null);
                            if (refresh != null) {
                                refresh.refreshAll();
                            }
                        }
                    });
                    popup.add(info);
                }
                if ((mount.getLocation() != Mech.LOC_LARM) && (mount.getLocation() != Mech.LOC_RARM)) {
                    if (mount.getType() instanceof WeaponType) {
                        if (getUnit().hasWorkingMisc(MiscType.F_QUAD_TURRET, -1, mount.getLocation()) || getUnit().hasWorkingMisc(MiscType.F_SHOULDER_TURRET, -1, mount.getLocation()) || (getUnit().hasWorkingMisc(MiscType.F_HEAD_TURRET, -1, Mech.LOC_CT) && (mount.getLocation() == Mech.LOC_HEAD))) {
                            if (!mount.isMechTurretMounted()) {
                                info = new JMenuItem("Mount " + mount.getName() + " in Turret");
                                info.addActionListener(new ActionListener() {

                                    public void actionPerformed(ActionEvent e) {
                                        changeTurretMount(true);
                                    }
                                });
                                popup.add(info);
                            } else {
                                info = new JMenuItem("Remove " + mount.getName() + " from Turret");
                                info.addActionListener(new ActionListener() {

                                    public void actionPerformed(ActionEvent e) {
                                        changeTurretMount(false);
                                    }
                                });
                                popup.add(info);
                            }
                        }
                    }
                    if (!(getUnit() instanceof BattleArmor) && ((mount.getType() instanceof WeaponType) || ((mount.getType() instanceof MiscType) && mount.getType().hasFlag(MiscType.F_LIFTHOIST)))) {
                        if (!mount.isRearMounted()) {
                            info = new JMenuItem("Make " + mount.getName() + " Rear Facing");
                            info.addActionListener(new ActionListener() {

                                public void actionPerformed(ActionEvent e) {
                                    changeWeaponFacing(true);
                                }
                            });
                            popup.add(info);
                        } else {
                            info = new JMenuItem("Make " + mount.getName() + " Forward Facing");
                            info.addActionListener(new ActionListener() {

                                public void actionPerformed(ActionEvent e) {
                                    changeWeaponFacing(false);
                                }
                            });
                            popup.add(info);
                        }
                    }
                }
                // Allow number of shots selection
                if ((getUnit() instanceof BattleArmor) && mount.getType() instanceof AmmoType) {
                    AmmoType at = (AmmoType) mount.getType();
                    int maxNumShots = TestBattleArmor.NUM_SHOTS_PER_CRIT;
                    int stepSize = 1;
                    if (at.getAmmoType() == AmmoType.T_BA_TUBE) {
                        maxNumShots = TestBattleArmor.NUM_SHOTS_PER_CRIT_TA;
                        stepSize = 2;
                    }
                    for (int i = at.getShots(); i <= maxNumShots; i += stepSize) {
                        if (i == mount.getBaseShotsLeft()) {
                            continue;
                        }
                        info = new JMenuItem("Set Shots: " + i);
                        final int shots = i;
                        info.addActionListener(new ActionListener() {

                            public void actionPerformed(ActionEvent e) {
                                mount.setShotsLeft(shots);
                                if (refresh != null) {
                                    refresh.refreshAll();
                                }
                            }
                        });
                        popup.add(info);
                    }
                }
                if (getUnit().isOmni() && !mount.getType().isOmniFixedOnly()) {
                    if (mount.isOmniPodMounted()) {
                        info = new JMenuItem("Change to fixed mount");
                        info.addActionListener(ev -> changeOmniMounting(false));
                        popup.add(info);
                    } else if (UnitUtil.canPodMount(getUnit(), mount)) {
                        info = new JMenuItem("Change to pod mount");
                        info.addActionListener(ev -> changeOmniMounting(true));
                        popup.add(info);
                    }
                }
            }
            if ((getUnit() instanceof BipedMech || getUnit() instanceof TripodMech) && ((location == Mech.LOC_LARM) || (location == Mech.LOC_RARM))) {
                boolean canHaveLowerArm = true;
                if (getUnit().isOmni()) {
                    int numCrits = getUnit().getNumberOfCriticals(location);
                    for (int slot = 0; slot < numCrits; slot++) {
                        CriticalSlot crit = getUnit().getCritical(location, slot);
                        if (crit == null) {
                            continue;
                        }
                        if (crit.getType() == CriticalSlot.TYPE_SYSTEM) {
                            continue;
                        }
                        Mounted m = crit.getMount();
                        if ((m.getType() instanceof GaussWeapon) || (m.getType() instanceof ACWeapon) || (m.getType() instanceof UACWeapon) || (m.getType() instanceof LBXACWeapon) || (m.getType() instanceof PPCWeapon)) {
                            canHaveLowerArm = false;
                        }
                    }
                }
                popup.addSeparator();
                popup.setAutoscrolls(true);
                if (canHaveLowerArm && ((getUnit().getCritical(location, 3) == null) || (getUnit().getCritical(location, 3).getType() != CriticalSlot.TYPE_SYSTEM))) {
                    JMenuItem info = new JMenuItem("Add Hand");
                    info.setActionCommand(Integer.toString(location));
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            addHand(Integer.parseInt(e.getActionCommand()));
                        }
                    });
                    popup.add(info);
                } else if ((getUnit().getCritical(location, 3) != null) && (getUnit().getCritical(location, 3).getType() == CriticalSlot.TYPE_SYSTEM)) {
                    JMenuItem info = new JMenuItem("Remove Hand");
                    info.setActionCommand(Integer.toString(location));
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            removeHand(Integer.parseInt(e.getActionCommand()));
                        }
                    });
                    popup.add(info);
                }
                if (canHaveLowerArm && ((getUnit().getCritical(location, 2) == null) || (getUnit().getCritical(location, 2).getType() != CriticalSlot.TYPE_SYSTEM))) {
                    JMenuItem info = new JMenuItem("Add Lower Arm");
                    info.setActionCommand(Integer.toString(location));
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            addArm(Integer.parseInt(e.getActionCommand()));
                        }
                    });
                    popup.add(info);
                } else if ((getUnit().getCritical(location, 2) != null) && (getUnit().getCritical(location, 2).getType() == CriticalSlot.TYPE_SYSTEM)) {
                    JMenuItem info = new JMenuItem("Remove Lower Arm");
                    info.setActionCommand(Integer.toString(location));
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            removeArm(Integer.parseInt(e.getActionCommand()));
                        }
                    });
                    popup.add(info);
                }
            }
            if (UnitUtil.isArmorable(cs) && !(getUnit() instanceof BattleArmor) && eSource.getTechManager().isLegal(Entity.getArmoredComponentTechAdvancement())) {
                popup.addSeparator();
                if (cs.isArmored()) {
                    JMenuItem info = new JMenuItem("Remove Armoring");
                    info.setActionCommand(Integer.toString(location));
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            changeArmoring();
                        }
                    });
                    popup.add(info);
                } else if (!(getUnit() instanceof Mech && ((Mech) getUnit()).isSuperHeavy())) {
                    JMenuItem info = new JMenuItem("Add Armoring");
                    info.setActionCommand(Integer.toString(location));
                    info.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            changeArmoring();
                        }
                    });
                    popup.add(info);
                }
            }
            if (popup.getComponentCount() > 0) {
                popup.show(this, e.getX(), e.getY());
            }
        }
    }
}
Also used : InputEvent(java.awt.event.InputEvent) ActionListener(java.awt.event.ActionListener) CritListCellRenderer(megameklab.com.util.CritListCellRenderer) CriticalSlot(megamek.common.CriticalSlot) EntityLoadingException(megamek.common.loaders.EntityLoadingException) EntitySource(megameklab.com.ui.EntitySource) Vector(java.util.Vector) BattleArmor(megamek.common.BattleArmor) JMenuItem(javax.swing.JMenuItem) BipedMech(megamek.common.BipedMech) Mounted(megamek.common.Mounted) UnitUtil(megameklab.com.util.UnitUtil) TestBattleArmor(megamek.common.verifier.TestBattleArmor) MouseListener(java.awt.event.MouseListener) MechFileParser(megamek.common.MechFileParser) AmmoType(megamek.common.AmmoType) Mech(megamek.common.Mech) GaussWeapon(megamek.common.weapons.gaussrifles.GaussWeapon) JPopupMenu(javax.swing.JPopupMenu) JList(javax.swing.JList) ActionEvent(java.awt.event.ActionEvent) MouseEvent(java.awt.event.MouseEvent) LBXACWeapon(megamek.common.weapons.autocannons.LBXACWeapon) WeaponType(megamek.common.WeaponType) PPCWeapon(megamek.common.weapons.ppc.PPCWeapon) MiscType(megamek.common.MiscType) TripodMech(megamek.common.TripodMech) ACWeapon(megamek.common.weapons.autocannons.ACWeapon) UACWeapon(megamek.common.weapons.autocannons.UACWeapon) Entity(megamek.common.Entity) RefreshListener(megameklab.com.util.RefreshListener) TripodMech(megamek.common.TripodMech) CriticalSlot(megamek.common.CriticalSlot) ActionEvent(java.awt.event.ActionEvent) MiscType(megamek.common.MiscType) UACWeapon(megamek.common.weapons.autocannons.UACWeapon) PPCWeapon(megamek.common.weapons.ppc.PPCWeapon) JPopupMenu(javax.swing.JPopupMenu) AmmoType(megamek.common.AmmoType) ActionListener(java.awt.event.ActionListener) Mounted(megamek.common.Mounted) WeaponType(megamek.common.WeaponType) GaussWeapon(megamek.common.weapons.gaussrifles.GaussWeapon) BipedMech(megamek.common.BipedMech) Mech(megamek.common.Mech) TripodMech(megamek.common.TripodMech) LBXACWeapon(megamek.common.weapons.autocannons.LBXACWeapon) JMenuItem(javax.swing.JMenuItem) BipedMech(megamek.common.BipedMech) LBXACWeapon(megamek.common.weapons.autocannons.LBXACWeapon) ACWeapon(megamek.common.weapons.autocannons.ACWeapon) UACWeapon(megamek.common.weapons.autocannons.UACWeapon) BattleArmor(megamek.common.BattleArmor) TestBattleArmor(megamek.common.verifier.TestBattleArmor)

Example 2 with PPCWeapon

use of megamek.common.weapons.ppc.PPCWeapon 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 3 with PPCWeapon

use of megamek.common.weapons.ppc.PPCWeapon 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 PPCWeapon

use of megamek.common.weapons.ppc.PPCWeapon in project megameklab by MegaMek.

the class UnitUtil method removeOmniArmActuators.

public static void removeOmniArmActuators(Mech mech) {
    if ((mech instanceof BipedMech) || (mech instanceof TripodMech)) {
        boolean leftACGaussPPC = false;
        boolean rightACGaussPPC = false;
        for (Mounted weapon : mech.getWeaponList()) {
            if ((weapon.getLocation() == Mech.LOC_LARM) && ((weapon.getType() instanceof ACWeapon) || (weapon.getType() instanceof GaussWeapon) || (weapon.getType() instanceof LBXACWeapon) || (weapon.getType() instanceof UACWeapon) || (weapon.getType() instanceof PPCWeapon))) {
                leftACGaussPPC = true;
            }
            if ((weapon.getLocation() == Mech.LOC_RARM) && ((weapon.getType() instanceof ACWeapon) || (weapon.getType() instanceof GaussWeapon) || (weapon.getType() instanceof LBXACWeapon) || (weapon.getType() instanceof UACWeapon) || (weapon.getType() instanceof PPCWeapon))) {
                rightACGaussPPC = true;
            }
        }
        if (leftACGaussPPC) {
            removeArm(mech, Mech.LOC_LARM);
            UnitUtil.compactCriticals(mech, Mech.LOC_LARM);
        }
        if (rightACGaussPPC) {
            removeArm(mech, Mech.LOC_RARM);
            UnitUtil.compactCriticals(mech, Mech.LOC_RARM);
        }
    }
}
Also used : TripodMech(megamek.common.TripodMech) Mounted(megamek.common.Mounted) GaussWeapon(megamek.common.weapons.gaussrifles.GaussWeapon) LBXACWeapon(megamek.common.weapons.autocannons.LBXACWeapon) UACWeapon(megamek.common.weapons.autocannons.UACWeapon) PPCWeapon(megamek.common.weapons.ppc.PPCWeapon) BipedMech(megamek.common.BipedMech) HVACWeapon(megamek.common.weapons.autocannons.HVACWeapon) LBXACWeapon(megamek.common.weapons.autocannons.LBXACWeapon) UACWeapon(megamek.common.weapons.autocannons.UACWeapon) ACWeapon(megamek.common.weapons.autocannons.ACWeapon)

Example 5 with PPCWeapon

use of megamek.common.weapons.ppc.PPCWeapon in project megameklab by MegaMek.

the class BayWeaponCriticalTree method isValidDropLocation.

/**
 * Determines whether the equipment can be dropped here. In the case of ammo or weapon
 * enhancement, there must be a matching weapon in the bay. A weapon that doesn't fit the
 * bay will be placed in a new bay.
 *
 * @param loc The drop location from the TransferSupport object passed to the TransferHandler
 * @param eq  The equipment to be dropped
 * @return    Whether the equipment can be dropped in the location
 */
public boolean isValidDropLocation(JTree.DropLocation loc, Mounted eq) {
    if (!eSource.getEntity().usesWeaponBays()) {
        return true;
    }
    Mounted bay = null;
    TreePath path = loc.getPath();
    if (null != path) {
        // without a capacitor.
        if ((eq.getType() instanceof MiscType) && eq.getType().hasFlag(MiscType.F_PPC_CAPACITOR) && (path.getLastPathComponent() instanceof EquipmentNode)) {
            EquipmentNode node = (EquipmentNode) path.getLastPathComponent();
            if (node.getMounted().getType() instanceof PPCWeapon) {
                return node.getMounted().getLinkedBy() == null;
            } else if (node.getMounted().getType() instanceof PPCBayWeapon) {
                for (Integer eqNum : node.getMounted().getBayWeapons()) {
                    if (eSource.getEntity().getEquipment(eqNum).getLinkedBy() == null) {
                        return true;
                    }
                }
                return false;
            }
        }
        bay = getBayFromPath(path);
    }
    // disallow dropping a bay into its current arc or a weapon or ammo into its current bay
    if (null != bay) {
        if ((eq == bay) || ((eq.getType() instanceof WeaponType) && (bay.getBayWeapons().contains(eSource.getEntity().getEquipmentNum(eq)))) || ((eq.getType() instanceof AmmoType) && (bay.getBayAmmo().contains(eSource.getEntity().getEquipmentNum(eq))))) {
            return false;
        }
    }
    if (eq.getType() instanceof AmmoType) {
        return (null != bay) && canTakeEquipment(bay, eq);
    }
    if (UnitUtil.isWeaponEnhancement(eq.getType())) {
        if ((null != bay) && canTakeEquipment(bay, eq)) {
            for (Integer eqNum : bay.getBayWeapons()) {
                if (eSource.getEntity().getEquipment(eqNum) == eq.getLinked()) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }
    return true;
}
Also used : AmmoType(megamek.common.AmmoType) TreePath(javax.swing.tree.TreePath) Mounted(megamek.common.Mounted) MiscType(megamek.common.MiscType) WeaponType(megamek.common.WeaponType) PPCWeapon(megamek.common.weapons.ppc.PPCWeapon) PPCBayWeapon(megamek.common.weapons.bayweapons.PPCBayWeapon)

Aggregations

PPCWeapon (megamek.common.weapons.ppc.PPCWeapon)5 WeaponType (megamek.common.WeaponType)4 ACWeapon (megamek.common.weapons.autocannons.ACWeapon)4 LBXACWeapon (megamek.common.weapons.autocannons.LBXACWeapon)4 UACWeapon (megamek.common.weapons.autocannons.UACWeapon)4 MiscType (megamek.common.MiscType)3 Mounted (megamek.common.Mounted)3 AmmoType (megamek.common.AmmoType)2 BipedMech (megamek.common.BipedMech)2 TripodMech (megamek.common.TripodMech)2 ArtilleryCannonWeapon (megamek.common.weapons.artillery.ArtilleryCannonWeapon)2 ArtilleryWeapon (megamek.common.weapons.artillery.ArtilleryWeapon)2 BPodWeapon (megamek.common.weapons.defensivepods.BPodWeapon)2 GaussWeapon (megamek.common.weapons.gaussrifles.GaussWeapon)2 HAGWeapon (megamek.common.weapons.gaussrifles.HAGWeapon)2 ISHGaussRifle (megamek.common.weapons.gaussrifles.ISHGaussRifle)2 ISSilverBulletGauss (megamek.common.weapons.gaussrifles.ISSilverBulletGauss)2 InfantryWeapon (megamek.common.weapons.infantry.InfantryWeapon)2 CLERPulseLaserSmall (megamek.common.weapons.lasers.CLERPulseLaserSmall)2 CLPulseLaserMicro (megamek.common.weapons.lasers.CLPulseLaserMicro)2