Class AmmoType

All Implemented Interfaces:
ITechnology
Direct Known Subclasses:
BombType, SmallWeaponAmmoType

public class AmmoType extends EquipmentType
  • Field Details

    • ALLOWED_BY_TYPE

      public static final Set<AmmoType.AmmoTypeEnum> ALLOWED_BY_TYPE
      Contains the set of AmmoTypes which could share ammo (e.g., SRM 2 and SRM 6, both fire SRM rounds), and conceptually can share ammo.
    • F_MG

      public static final AmmoTypeFlag F_MG
    • F_BATTLEARMOR

      public static final AmmoTypeFlag F_BATTLEARMOR
    • F_PROTOMEK

      public static final AmmoTypeFlag F_PROTOMEK
    • F_HOTLOAD

      public static final AmmoTypeFlag F_HOTLOAD
    • F_ENCUMBERING

      public static final AmmoTypeFlag F_ENCUMBERING
    • F_MML_LRM

      public static final AmmoTypeFlag F_MML_LRM
    • F_AR10_WHITE_SHARK

      public static final AmmoTypeFlag F_AR10_WHITE_SHARK
    • F_AR10_KILLER_WHALE

      public static final AmmoTypeFlag F_AR10_KILLER_WHALE
    • F_AR10_BARRACUDA

      public static final AmmoTypeFlag F_AR10_BARRACUDA
    • F_NUCLEAR

      public static final AmmoTypeFlag F_NUCLEAR
    • F_SANTA_ANNA

      public static final AmmoTypeFlag F_SANTA_ANNA
    • F_PEACEMAKER

      public static final AmmoTypeFlag F_PEACEMAKER
    • F_TELE_MISSILE

      public static final AmmoTypeFlag F_TELE_MISSILE
    • F_CAP_MISSILE

      public static final AmmoTypeFlag F_CAP_MISSILE
    • F_SPACE_BOMB

      public static final AmmoTypeFlag F_SPACE_BOMB
    • F_GROUND_BOMB

      public static final AmmoTypeFlag F_GROUND_BOMB
    • F_MML_SRM

      public static final AmmoTypeFlag F_MML_SRM
    • F_OTHER_BOMB

      public static final AmmoTypeFlag F_OTHER_BOMB
    • F_CRUISE_MISSILE

      public static final AmmoTypeFlag F_CRUISE_MISSILE
    • F_SCREEN

      public static final AmmoTypeFlag F_SCREEN
    • F_INTERNAL_BOMB

      public static final AmmoTypeFlag F_INTERNAL_BOMB
    • SMOKE_MUNITIONS

      public static final EnumSet<AmmoType.Munitions> SMOKE_MUNITIONS
    • FLARE_MUNITIONS

      public static final EnumSet<AmmoType.Munitions> FLARE_MUNITIONS
    • MINE_MUNITIONS

      public static final EnumSet<AmmoType.Munitions> MINE_MUNITIONS
    • damagePerShot

      protected int damagePerShot
    • rackSize

      protected int rackSize
    • ammoType

      protected AmmoType.AmmoTypeEnum ammoType
    • munitionType

      protected EnumSet<AmmoType.Munitions> munitionType
    • shots

      protected int shots
    • base

      protected AmmoType base
    • blastRadius

      public static final Map<String,Integer> blastRadius
    • heat

      protected int heat
    • range

      protected RangeType range
    • tech

      protected int tech
    • capital

      protected boolean capital
  • Constructor Details

    • AmmoType

      public AmmoType()
  • Method Details

    • getMunitionsFor

      public static Vector<AmmoType> getMunitionsFor(AmmoType.AmmoTypeEnum ammoType)
    • getBaseAmmo

      public AmmoType getBaseAmmo()
      Returns the base ammo type, if any.
    • equalsAmmoTypeOnly

      public boolean equalsAmmoTypeOnly(Object other)
      When comparing AmmoTypes, look at the ammoType only.
      Parameters:
      other - the Object to compare to this one.
      Returns:
      true if the other is an AmmoType object of the same ammoType as this object. N.B. different munition types are still equal.
    • isCompatibleWith

      public boolean isCompatibleWith(AmmoType other)
      Gets a value indicating whether this AmmoType is compatible with another AmmoType.

      this roughly means the same ammo type and munition type, but not rack size.

      Parameters:
      other - The other AmmoType to determine compatibility with.
    • getAmmoType

      public AmmoType.AmmoTypeEnum getAmmoType()
    • getToHitModifier

      public int getToHitModifier()
    • hasFlag

      public boolean hasFlag(EquipmentFlag flag)
      Description copied from class: EquipmentType
      Returns true when this EquipmentType has the given flag. NOTE: Even though EquipmentFlags are enums, checking e.g. a WeaponType if it has a MiscTypeFlag may return an incorrect true result, as the actual test is made using EquipmentBitSet, i.e. a number comparison.

      Example: EquipmentType.get("BAArmoredGlove").hasFlag(WeaponType.F_VGL) returns true, as WeaponType.F_VGL has the same ordinal as MiscType.F_ARMORED_GLOVE. Therefore, always make sure to test only MiscTypes against MiscTypeFlags, WeaponTypes against WeaponTypeFlags and AmmoTypes against AmmoTypeFlags. This method will log a warning if the rule is not followed.

      Overrides:
      hasFlag in class EquipmentType
      Parameters:
      flag - The EquipmentFlag to check
      Returns:
      True when this EquipmentType has the given flag
      See Also:
    • getFireTN

      public int getFireTN()
      Analog to WeaponType.getFireTNRoll(), but based on munitions. See TO:AR pg 42
      Returns:
      TN Roll
    • is

      public boolean is(AmmoType.AmmoTypeEnum ammoType)
      Gets a value indicating whether this is a certain ammo type.
      Parameters:
      ammoType - The ammo type to compare against.
    • canBeInterceptedBy

      public boolean canBeInterceptedBy(@Nullable WeaponMounted amsWeapon, @Nullable GameOptions gameOptions)
      Checks if this ammo can be intercepted by AMS (or PD). TODO: rules need to be checked
      Parameters:
      amsWeapon - The AMS weapon to check against, if null an AMS is assumed to be available.
      gameOptions - The game options, used to check for special rules. If null, standard rules are assumed.
      Returns:
      true if this ammo is affected by AMS, false otherwise
    • countsAsFlak

      public boolean countsAsFlak()
      We need a way to quickly determine if a given ammo type / munition counts as "Flak"

      Note, not _is_ Flak (as in the case of M_FLAK) but can be considered Flak by TW/TO/IO rules.

      Arrow IV missiles with M_CLUSTER, M_ADA, or M_STANDARD (not M_HOMING) count as Flak (TO:AU&E pp166-167, 224)

      Returns:
      counts true if this ammo can be considered Flak in some situations
    • getMunitionType

      public EnumSet<AmmoType.Munitions> getMunitionType()
    • notAllowedByClanRules

      @Deprecated(since="0.50.06", forRemoval=true) public boolean notAllowedByClanRules()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 0.50.06, the rules that don't allow some ammo for clan units should be based on tech access/availability, not a hardcoded list of ammo types. As soon as the tech rules for munition variations are working completely then this will be removed.
      Returns:
      true if this munition type is not allowed by clan rules
    • getDamagePerShot

      public int getDamagePerShot()
    • getRackSize

      public int getRackSize()
    • getShots

      public int getShots()
    • getAmmoRatio

      public double getAmmoRatio()
    • isCapital

      public boolean isCapital()
    • hasCustomKgPerShot

      public boolean hasCustomKgPerShot()
    • getKgPerShot

      public double getKgPerShot()
      Used by units that are constructed using per-shot weights (BA and ProtoMeks). Some ammo is defined in the rules rounded to a set number of decimal places.
      Returns:
      KG per Shot
    • canAeroUse

      public boolean canAeroUse()
      Aerospace units cannot use specialty munitions except Artemis and LBX cluster (but not standard). ATM ER and HE rounds are considered standard munitions. AR10 missiles are designed for aerospace units and all munition types are available.
      Returns:
      true if the munition can be used by aerospace units
    • canAeroUse

      public boolean canAeroUse(boolean option)
      Aerospace units cannot use specialty munitions except Artemis and LBX cluster (but not standard). ATM ER and HE rounds are considered standard munitions. AR10 missiles are designed for aerospace units and all munition types are available.
      Parameters:
      option - True if unofficial game option allowing alternate munitions for artillery bays is enabled
      Returns:
      true if the munition can be used by aerospace units
    • getOneshotAmmo

      @Nullable public static AmmoType getOneshotAmmo(Mounted<?> mounted)
      Parameters:
      mounted - Mounted Weapon/Item
      Returns:
      the first usable ammo type for the given one shot launcher
    • initializeTypes

      public static void initializeTypes()
    • toString

      public String toString()
      Overrides:
      toString in class EquipmentType
    • canClearMinefield

      public static boolean canClearMinefield(AmmoType at)
    • canDeliverMinefield

      public static boolean canDeliverMinefield(AmmoType at)
    • getKgPerShotBV

      public double getKgPerShotBV(int shots)
      Returns:
      The battle value for ProtoMek or BA ammo loads.
    • getBaseName

      public String getBaseName()
    • getSubMunitionName

      public String getSubMunitionName()
    • isAmmoValid

      public static boolean isAmmoValid(Mounted<?> ammo, WeaponType weaponType)
      Checks to ensure that the given ammo can be used with the given weapon type. Performs the following tests:
      ammo != null
      Mounted.getType() instanceof AmmoType
      Mounted.isAmmoUsable()
      isAmmoValid(AmmoType, WeaponType).
      Parameters:
      ammo - The ammunition to be tested.
      weaponType - The weapon the ammo is to be used with.
      Returns:
      TRUE if the ammo and weapon are compatible.
    • isAmmoValid

      public static boolean isAmmoValid(AmmoType ammoType, WeaponType weaponType)
      Checks to ensure that the given ammunition type is compatible with the given weapon type. Performs the following tests:
      ammoType != null
      getAmmoType() == WeaponType.getAmmoType()
      getRackSize() == WeaponType.getRackSize()
      Parameters:
      ammoType - The type of ammo to be tested.
      weaponType - The type of weapon the ammo is to be used with.
      Returns:
      TRUE if the ammo type and weapon type are compatible.
    • canSwitchToAmmo

      public static boolean canSwitchToAmmo(WeaponMounted weapon, AmmoType otherAmmo)
      Whether the given weapon can switch to the given ammo type
      Parameters:
      weapon - The weapon being considered
      otherAmmo - The other ammo type being considered
      Returns:
      true/false - null arguments or linked ammo bin for the weapon result in false
    • isArmorable

      public boolean isArmorable()
      Overrides:
      isArmorable in class EquipmentType
      Returns:
      True if this equipment type is eligible for being an armored component, TO:AUE p.95
    • getYamlData

      public Map<String,Object> getYamlData()
      Description copied from class: EquipmentType
      Constructs a map containing the YAML-serializable data for this equipment type.
      Overrides:
      getYamlData in class EquipmentType
      Returns:
      A map containing the YAML-serializable data for this equipment type.