public static ArrayList<AmmoType> getMunitionsFor(Entity entity, AmmoType cur_atype, int techLvl) { ArrayList<AmmoType> atypes = new ArrayList<AmmoType>(); for(AmmoType atype : AmmoType.getMunitionsFor(cur_atype.getAmmoType())) { && !atype.canAeroUse()) { continue; int lvl = atype.getTechLevel(entity.getTechLevelYear()); if(lvl < 0) { lvl = 0; if(TechConstants.isClan(cur_atype.getTechLevel(entity.getTechLevelYear())) != TechConstants.isClan(lvl)) { continue; if (atype.hasFlag(AmmoType.F_PROTOMECH) && !(entity instanceof Protomech)) { continue; && atype.hasFlag(AmmoType.F_MG) && !atype.hasFlag(AmmoType.F_PROTOMECH)) { continue; if (atype.hasFlag(AmmoType.F_NUCLEAR) && atype.hasFlag(AmmoType.F_CAP_MISSILE) && !entity.getGame().getOptions().booleanOption(OptionsConstants.ADVAERORULES_AT2_NUKES)) { continue; if ((atype.getRackSize() == cur_atype.getRackSize()) && (atype.hasFlag(AmmoType.F_BATTLEARMOR) == cur_atype.hasFlag(AmmoType.F_BATTLEARMOR)) && (atype.hasFlag(AmmoType.F_ENCUMBERING) == cur_atype.hasFlag(AmmoType.F_ENCUMBERING)) && ((atype.getTonnage(entity) == cur_atype.getTonnage(entity))
private boolean includeMunition(AmmoType atype) { if (!atype.canAeroUse() || (atype.getAmmoType() != at) || (atype.getRackSize() != rackSize) || ((atype.getTechBase() != techBase) && (atype.getTechBase() != AmmoType.TECH_BASE_ALL) && (techBase != AmmoType.TECH_BASE_ALL)) || !atype.isLegal(game.getOptions().intOption(OptionsConstants.ALLOWED_YEAR), SimpleTechLevel.getGameTechLevel(game), techBase == AmmoType.TECH_BASE_CLAN, false)) { return false; } if (atype.hasFlag(AmmoType.F_NUCLEAR) && !game.getOptions().booleanOption( OptionsConstants.ADVAERORULES_AT2_NUKES)) { return false; } if ((atype.getMunitionType() & AmmoType.M_ARTEMIS_CAPABLE) != 0) { return entity.hasWorkingMisc(MiscType.F_ARTEMIS) || entity.hasWorkingMisc(MiscType.F_ARTEMIS_PROTO); } if ((atype.getMunitionType() & AmmoType.M_ARTEMIS_V_CAPABLE) != 0) { return entity.hasWorkingMisc(MiscType.F_ARTEMIS_V); } return true; }
/** * Tries to load the specified weapon with the specified ammo. Returns true * if successful, false otherwise. */ public boolean loadWeaponWithSameAmmo(Mounted mounted, Mounted mountedAmmo) { AmmoType atype = (AmmoType) mountedAmmo.getType(); Mounted oldammo = mounted.getLinked(); if ((oldammo != null) && (!((AmmoType) oldammo.getType()).equals(atype) || (((AmmoType) oldammo .getType()).getMunitionType() != atype .getMunitionType()))) { return false; } return loadWeapon(mounted, mountedAmmo); }
@Override public double getTonnage() { if(((AmmoType)type).getKgPerShot() > 0) { return ((AmmoType)type).getKgPerShot() * shots/1000.0; } return ((double)shots / ((AmmoType)type).getShots()); }
public static boolean canDeliverMinefield(AmmoType at) { if ((at != null) && ((at.getAmmoType() == T_LRM) || (at.getAmmoType() == AmmoType.T_LRM_IMP) || (at.getAmmoType() == AmmoType.T_MML)) && ((at.getMunitionType() == M_THUNDER) || (at.getMunitionType() == M_THUNDER_INFERNO) || (at.getMunitionType() == M_THUNDER_AUGMENTED) || (at.getMunitionType() == M_THUNDER_VIBRABOMB) || (at.getMunitionType() == M_THUNDER_ACTIVE))) { return true; } return false; }
protected int getCritMod(AmmoType atype) { if (atype == null || atype.getAmmoType() == AmmoType.T_PIRANHA) { return 0; } if (atype.getAmmoType() == AmmoType.T_WHITE_SHARK || atype.hasFlag(AmmoType.F_AR10_WHITE_SHARK) // Santa Anna, per IO rules || atype.hasFlag(AmmoType.F_SANTA_ANNA)) { return 9; } else if (atype.getAmmoType() == AmmoType.T_KRAKEN_T || atype.getAmmoType() == AmmoType.T_KRAKENM // Peacemaker, per IO rules || atype.hasFlag(AmmoType.F_PEACEMAKER)) { return 8; } else if (atype.getAmmoType() == AmmoType.T_KILLER_WHALE || atype.hasFlag(AmmoType.F_AR10_KILLER_WHALE) || atype.getAmmoType() == AmmoType.T_MANTA_RAY || atype.getAmmoType() == AmmoType.T_ALAMO) { return 10; } else if (atype.getAmmoType() == AmmoType.T_STINGRAY) { return 12; } else { return 11; } }
AmmoType at = (AmmoType) m.getType(); ArrayList<AmmoType> vTypes = new ArrayList<AmmoType>(); Vector<AmmoType> vAllTypes = AmmoType.getMunitionsFor(at .getAmmoType()); if (vAllTypes == null) { continue; && !((at.getAmmoType() == AmmoType.T_MML) || (at.getAmmoType() == AmmoType.T_SRM) || (at.getAmmoType() == AmmoType.T_LRM) || (at.getAmmoType() == AmmoType.T_MRM) || (at.getAmmoType() == AmmoType.T_ATM) || (at.getAmmoType() == AmmoType.T_IATM))) { continue; && !atCheck.canAeroUse()) { continue; boolean bTechMatch = false; if (game.getOptions().booleanOption(OptionsConstants.ALLOWED_ERA_BASED)) { bTechMatch = atCheck.isLegal(gameYear, legalLevel, entity.isClan(), entity.isMixedTech()); } else { bTechMatch = atCheck.getStaticTechLevel().ordinal() <= legalLevel.ordinal(); long muniType = atCheck.getMunitionType(); muniType &= ~AmmoType.M_INCENDIARY_LRM; if (!gameOpts.booleanOption(OptionsConstants.ALLOWED_CLAN_IGNORE_EQ_LIMITS) //$NON-NLS-1$
/** * Checks to ensure that the given ammunition type is compatible with the given weapon type. Performs the following * tests:<br/> * {@code ammoType} != null<br/> * {@link AmmoType#getAmmoType()} == {@link WeaponType#getAmmoType()}<br/> * {@link AmmoType#getRackSize()} == {@link WeaponType#getRackSize()} * * @param ammoType The type of ammo to be tested. * @param weaponType The type of weapon the ammo is to be used with. * @return TRUE if the ammo type and weapon type are compatible. */ public static boolean isAmmoValid(AmmoType ammoType, WeaponType weaponType) { if (ammoType == null) { return false; } if (ammoType.getAmmoType() != weaponType.getAmmoType()) { return false; } if (ammoType.getRackSize() != weaponType.getRackSize()) { return false; } return true; } }
AmmoType munition = new AmmoType(); munition.setTonnage(base.getTonnage(null)); nameBuf.insert(index, ' '); nameBuf.insert(index, name); munition.setInternalName(nameBuf.toString()); munition.shortName = munition.name; munition.addBeforeString(base, "Ammo", name + " "); nameBuf.insert(index, ' '); nameBuf.insert(index, name); munition.setInternalName(nameBuf.toString()); munition.shortName = munition.name; munition.addBeforeString(base, "Ammo", name + " "); index = base.internalName.lastIndexOf("Ammo"); nameBuf.insert(index, name); munition.setInternalName(nameBuf.toString()); munition.shortName = munition.name; munition.setInternalName(base.internalName + nameBuf.toString()); munition.addToEnd(base, nameBuf.toString()); internalName = new StringBuffer(base.getInternalName()); munition.setInternalName(internalName.insert( internalName.lastIndexOf("Ammo"), name + " ") .toString());
ArrayList<Mounted> ammo_list) { AmmoType bin_type = new AmmoType(); int ammo_filter = weapon.getAmmoType(); if ((bin_type.getAmmoType() == ammo_filter) && (bin_type.getRackSize() == weapon.getRackSize())) { if (bin_type.getMunitionType() == AmmoType.M_HIGH_EXPLOSIVE) { range_flags[0] = true; } else { if (bin_type.getMunitionType() == AmmoType.M_EXTENDED_RANGE) { range_flags[2] = true; } else { if (bin_type.getShortName().contains("SRM")) { range_flags[0] = true; } else { if (bin_type.getShortName().contains("LRM") && !AmmoType.canDeliverMinefield(bin_type)) { range_flags[2] = true;
&& !mLinker.isBreached() && mLinker.getType().hasFlag( MiscType.F_ARTEMIS)) && atype.getMunitionType() == AmmoType.M_ARTEMIS_CAPABLE) { bonus = (int) Math.ceil(atype.getRackSize() / 5.0); if ((atype.getAmmoType() == AmmoType.T_SRM) || (atype.getAmmoType() == AmmoType.T_SRM_IMP)) { bonus = 2; && !mLinker.isBreached() && mLinker.getType().hasFlag( MiscType.F_ARTEMIS_V)) && (atype.getMunitionType() == AmmoType.M_ARTEMIS_V_CAPABLE)) { bonus = (int) Math.ceil(atype.getRackSize() / 5.0); if ((atype.getAmmoType() == AmmoType.T_SRM) || (atype.getAmmoType() == AmmoType.T_SRM_IMP)) { bonus = 2; if (atype.getMunitionType() == AmmoType.M_CLUSTER) { current_av = Math.floor(0.6 * current_av); } else if (AmmoType.T_ATM == atype.getAmmoType()) { if (atype.getMunitionType() == AmmoType.M_EXTENDED_RANGE) { current_av = bayWType.getShortAV() / 2; } else if (atype.getMunitionType() == AmmoType.M_HIGH_EXPLOSIVE) { current_av = 1.5 * current_av; if (range > WeaponType.RANGE_SHORT) { } else if (atype.getAmmoType() == AmmoType.T_MML && !atype.hasFlag(AmmoType.F_MML_LRM)) { current_av = 2 * current_av; if (range > WeaponType.RANGE_SHORT) {
if ((target.getTargetType() == Targetable.TYPE_MINEFIELD_DELIVER) && !AmmoType.canDeliverMinefield(atype)) { return "Weapon can't deliver minefields"; && ((atype.getAmmoType() == AmmoType.T_LRM) || (atype.getAmmoType() == AmmoType.T_MML) || (atype.getAmmoType() == AmmoType.T_LRM_IMP) || (atype.getAmmoType() == AmmoType.T_MEK_MORTAR)) && (atype.getMunitionType() == AmmoType.M_FLARE))) { return "Weapon can't deliver flares"; && ((atype.getAmmoType() == AmmoType.T_LRM) || (atype.getAmmoType() == AmmoType.T_LRM_IMP) || (atype.getAmmoType() == AmmoType.T_MML) || (atype.getAmmoType() == AmmoType.T_MEK_MORTAR)) && ((atype.getMunitionType() == AmmoType.M_THUNDER) || (atype.getMunitionType() == AmmoType.M_THUNDER_ACTIVE) || (atype.getMunitionType() == AmmoType.M_THUNDER_INFERNO) || (atype.getMunitionType() == AmmoType.M_THUNDER_VIBRABOMB) || (atype.getMunitionType() == AmmoType.M_THUNDER_AUGMENTED)) && (target.getTargetType() != Targetable.TYPE_MINEFIELD_DELIVER)) { return "Weapon can only deliver minefields"; if ((atype != null) && ((atype.getAmmoType() == AmmoType.T_LRM) || (atype.getAmmoType() == AmmoType.T_LRM_IMP) || (atype.getAmmoType() == AmmoType.T_MML)) && (atype.getMunitionType() == AmmoType.M_FLARE) && (target.getTargetType() != Targetable.TYPE_FLARE_DELIVER)) { return "Weapon can only deliver flares";
private String createMunitionLabel(AmmoType atype) { if (atype.getAmmoType() == AmmoType.T_MML) { if ((atype.getMunitionType() & (AmmoType.M_ARTEMIS_CAPABLE | AmmoType.M_ARTEMIS_V_CAPABLE)) == 0) { return Messages.getString(atype.hasFlag(AmmoType.F_MML_LRM)? "CustomMechDialog.LRM" : "CustomMechDialog.SRM"); //$NON-NLS-1$ //$NON-NLS-2$ } else { return Messages.getString(atype.hasFlag(AmmoType.F_MML_LRM)? "CustomMechDialog.LRMArtemis" : "CustomMechDialog.SRMArtemis"); //$NON-NLS-1$ //$NON-NLS-2$ if (atype.hasFlag(AmmoType.F_CAP_MISSILE)) { String tele = atype.hasFlag(AmmoType.F_TELE_MISSILE)? "-T":""; if (atype.hasFlag(AmmoType.F_PEACEMAKER)) { return Messages.getString("CustomMechDialog.Peacemaker") + tele; //$NON-NLS-1$ } else if (atype.hasFlag(AmmoType.F_SANTA_ANNA)) { return Messages.getString("CustomMechDialog.SantaAnna") + tele; //$NON-NLS-1$ } else if (atype.hasFlag(AmmoType.F_AR10_KILLER_WHALE)) { return Messages.getString("CustomMechDialog.KillerWhale") + tele; //$NON-NLS-1$ } else if (atype.hasFlag(AmmoType.F_AR10_WHITE_SHARK)) { return Messages.getString("CustomMechDialog.WhiteShark") + tele; //$NON-NLS-1$ } else if (atype.hasFlag(AmmoType.F_AR10_BARRACUDA)) { return Messages.getString("CustomMechDialog.Barracuda") + tele; //$NON-NLS-1$ if ((atype.getMunitionType() == AmmoType.M_ARTEMIS_CAPABLE) || (atype.getMunitionType() == AmmoType.M_ARTEMIS_V_CAPABLE)) { return Messages.getString("CustomMechDialog.Artemis"); //$NON-NLS-1$
if (((at.getAmmoType() == T_LRM) || (at.getAmmoType() == T_LRM_IMP) || (at.getAmmoType() == T_LRM_STREAK) || (at.getAmmoType() == T_EXLRM) || (at.getAmmoType() == T_PXLRM) || (at.getAmmoType() == T_MRM) || (at.getAmmoType() == T_MRM_STREAK) || (at.getAmmoType() == T_ROCKET_LAUNCHER)) && (at.getRackSize() >= 20) && ((at.getMunitionType() == M_STANDARD) || (at.getMunitionType() == M_ARTEMIS_CAPABLE) || (at.getMunitionType() == M_ARTEMIS_V_CAPABLE) || (at.getMunitionType() == M_NARC_CAPABLE))) { return true; if ((at.getAmmoType() == T_ATM) && ((at.getRackSize() >= 12 && at.getMunitionType() != M_EXTENDED_RANGE) || (at.getRackSize() >= 9 && at.getMunitionType() == M_HIGH_EXPLOSIVE))) { return true; if (((at.getAmmoType() == T_ARROW_IV) || (at.getAmmoType() == T_LONG_TOM) || (at.getAmmoType() == T_SNIPER) || (at.getAmmoType() == T_THUMPER)) && (at.getMunitionType() == M_STANDARD)) { return true;
if (getAmmoType() == T_MML) { if (hasFlag(F_MML_LRM) != ((AmmoType) other).hasFlag(F_MML_LRM)) { return false; if (getAmmoType() == T_AR10) { if (hasFlag(F_AR10_BARRACUDA) != ((AmmoType) other) .hasFlag(F_AR10_BARRACUDA)) { return false; if (hasFlag(F_AR10_WHITE_SHARK) != ((AmmoType) other) .hasFlag(F_AR10_WHITE_SHARK)) { return false; if (hasFlag(F_AR10_KILLER_WHALE) != ((AmmoType) other) .hasFlag(F_AR10_KILLER_WHALE)) { return false; return ((getAmmoType() == ((AmmoType) other).getAmmoType()) && (getRackSize() == ((AmmoType) other) .getRackSize()));
if(aType.equals(curType) && curType.getMunitionType() == aType.getMunitionType()) { a = (AmmoStorage)part; if (amount < 0 && campaign.getCampaignOptions().useAmmoByType() && a.getShots() < Math.abs(amount)) { swapAmmoFromCompatible(Math.abs(amount) * aType.getRackSize(), a); } else if (a == null && amount < 0 && campaign.getCampaignOptions().useAmmoByType() && AmmoBin.ALLOWED_BY_TYPE.contains(curType.getAmmoType())) { campaign.addPart(new AmmoStorage(1 , curType ,0, campaign), 0); changeAmountAvailable(amount, curType);
public int getExplosionDamage() { if (type instanceof AmmoType) { AmmoType atype = (AmmoType) type; int rackSize = atype.getRackSize(); int damagePerShot = atype.getDamagePerShot(); if (atype.getAmmoType() == AmmoType.T_SCREEN_LAUNCHER) { rackSize = 1; damagePerShot = 15; long mType = atype.getMunitionType(); || (mType == AmmoType.M_TANDEM_CHARGE)) { damagePerShot++; } else if (atype.getAmmoType() == AmmoType.T_TASER) { damagePerShot = 6; if (atype.getAmmoType() == AmmoType.T_MEK_MORTAR) { if ((mType == AmmoType.M_AIRBURST) || (mType == AmmoType.M_FLARE) Mounted link = getLinked(); AmmoType atype = ((AmmoType) link.getType()); int damagePerShot = atype.getDamagePerShot(); if (atype.getAmmoType() == AmmoType.M_DEAD_FIRE) { damagePerShot++;
for (int x = 0; e.hasNext(); x++) { AmmoType at = e.next(); m_choice.addItem(at.getName()); if (at.getInternalName() == curType.getInternalName()) { m_choice.setSelectedIndex(x); int shotsPerTon = curType.getShots(); if (curType.getAmmoType() == AmmoType.T_BA_TUBE) { shotsPerTon = TestBattleArmor.NUM_SHOTS_PER_CRIT_TA; stepSize = 2; if (clientgui.getClient().getGame().getOptions().booleanOption( OptionsConstants.ADVCOMBAT_TACOPS_HOTLOAD) && curType.hasFlag(AmmoType.F_HOTLOAD)) { add(labHotLoad, GBC.std()); add(chHotLoad, GBC.eol()); && curType.hasFlag(AmmoType.F_HOTLOAD)) { add(labHotLoad, GBC.std()); add(chHotLoad, GBC.eol());
public AmmoStorage(int tonnage, EquipmentType et, int shots, Campaign c) { super(tonnage, et, -1, c); this.shots = shots; if(null != type && type instanceof AmmoType) { this.munition = ((AmmoType)type).getMunitionType(); } }
final long muniType = ((AmmoType) newAmmoType).getMunitionType() & ~AmmoType.M_INCENDIARY_LRM; if((muniType == AmmoType.M_SEMIGUIDED) || (muniType == AmmoType.M_SWARM_I) if(AmmoType.canDeliverMinefield((AmmoType) newAmmoType) if((((AmmoType) newAmmoType).getRackSize() == ((AmmoType) currentAmmoType).getRackSize()) && (newAmmoType.hasFlag(AmmoType.F_BATTLEARMOR) == currentAmmoType.hasFlag(AmmoType.F_BATTLEARMOR)) && (newAmmoType.hasFlag(AmmoType.F_ENCUMBERING) == currentAmmoType.hasFlag(AmmoType.F_ENCUMBERING)) && (newAmmoType.getTonnage(e) == currentAmmoType.getTonnage(e)) && (((AmmoType) newAmmoType).getAmmoType() == weaponAmmoType)) { return (AmmoType) newAmmoType; } else {