Class WeaponType

java.lang.Object
megamek.common.equipment.EquipmentType
megamek.common.equipment.WeaponType
All Implemented Interfaces:
ITechnology
Direct Known Subclasses:
Weapon

public class WeaponType extends EquipmentType
A type of mek or vehicle weapon. There is only one instance of this weapon for all weapons of this type.
  • Field Details

  • Constructor Details

    • WeaponType

      public WeaponType()
  • Method Details

    • setDamage

      public void setDamage(int inD)
    • setName

      public void setName(String inN)
    • setMinimumRange

      public void setMinimumRange(int inMR)
    • setShortRange

      public void setShortRange(int inSM)
    • setMediumRange

      public void setMediumRange(int inMR)
    • setLongRange

      public void setLongRange(int inSM)
    • setAmmoType

      public void setAmmoType(AmmoType.AmmoTypeEnum inAT)
    • setRackSize

      public void setRackSize(int inRS)
    • getHeat

      public int getHeat()
      Description copied from class: EquipmentType
      This does not include heat generated by stealth armor, as that depends on whether it is installed as patchwork and does not appear in the equipment list of all unit types.
      Overrides:
      getHeat in class EquipmentType
      Returns:
      The amount of heat generated by the equipment
    • getHeatAdjustmentForBvCalculation

      public int getHeatAdjustmentForBvCalculation()
      Returns the adjustement of heat used for BV calculation
    • 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()
    • getDamage

      public int getDamage(int range)
    • getDamage

      public int getDamage()
    • getRackSize

      public int getRackSize()
    • getAmmoType

      public AmmoType.AmmoTypeEnum getAmmoType()
    • getRanges

      public int[] getRanges(Mounted<?> weapon)
    • getRanges

      public int[] getRanges(Mounted<?> weapon, Mounted<?> ammo)
    • getMinimumRange

      public int getMinimumRange()
    • getShortRange

      public int getShortRange()
    • getMediumRange

      public int getMediumRange()
    • getLongRange

      public int getLongRange()
    • getExtremeRange

      public int getExtremeRange()
    • getWRanges

      public int[] getWRanges()
    • getWShortRange

      public int getWShortRange()
    • getWMediumRange

      public int getWMediumRange()
    • getWLongRange

      public int getWLongRange()
    • getWExtremeRange

      public int getWExtremeRange()
    • getMaxRange

      public int getMaxRange(WeaponMounted weapon)
    • getMaxRange

      public int getMaxRange()
    • getMaxRange

      public int getMaxRange(WeaponMounted weapon, AmmoMounted ammo)
    • getInfantryDamageClass

      public int getInfantryDamageClass()
    • getBADamageClass

      public int getBADamageClass()
    • getATRanges

      public int[] getATRanges()
    • getMissileArmor

      public int getMissileArmor()
    • getShortAV

      public double getShortAV()
    • getRoundShortAV

      public int getRoundShortAV()
    • getMedAV

      public double getMedAV()
    • getRoundMedAV

      public int getRoundMedAV()
    • getLongAV

      public double getLongAV()
    • getRoundLongAV

      public int getRoundLongAV()
    • getExtAV

      public double getExtAV()
    • getRoundExtAV

      public int getRoundExtAV()
    • isCapital

      public boolean isCapital()
    • isSubCapital

      public boolean isSubCapital()
    • getAtClass

      public int getAtClass()
    • getBayType

      public EquipmentType getBayType()
      Returns:
      The type of weapon bay this weapon goes in
    • getBV

      public Double getBV()
      Returns:
      BV of the weapon
    • getBayType

      public EquipmentType getBayType(boolean capitalOnly)
      Parameters:
      capitalOnly - If true, this will return the equivalent capital bay for subcapital weapons.
      Returns:
      The type of weapon bay this weapon goes in
    • getBattleForceDamage

      public double getBattleForceDamage(int range)
      Damage calculation for BattleForce and AlphaStrike
      Parameters:
      range - The range in hexes
      Returns:
      Damage in BattleForce scale
    • getBattleForceDamage

      public double getBattleForceDamage(int range, Mounted<?> fcs)
      Damage calculation for BattleForce and AlphaStrike for missile weapons that may have advanced fire control
      Parameters:
      range - - the range in hexes
      fcs - - linked Artemis or Apollo FCS (null for none)
      Returns:
      - damage in BattleForce scale
    • adjustBattleForceDamageForMinRange

      public double adjustBattleForceDamageForMinRange(double damage)
    • getBattleForceDamage

      public double getBattleForceDamage(int range, int baSquadSize)
      BattleForce-scale damage for BattleArmor, using cluster hits table based on squad size. AlphaStrike uses a different method.
      Parameters:
      range - - the range in hexes
      baSquadSize - - the number of suits in the squad/point/level i
      Returns:
      - damage in BattleForce scale
    • getBattleForceClass

      public int getBattleForceClass()
      Returns:
      The class of weapons for those that are tracked separately from standard damage (AlphaStrike)
    • getAlphaStrikeHeat

      public int getAlphaStrikeHeat()
      Returns the weapon's heat for AlphaStrike conversion. Overridden where it differs from TW heat.
    • getAlphaStrikeHeatDamage

      public int getAlphaStrikeHeatDamage(int rangeBand)
      Returns the weapon's AlphaStrike heat damage for AlphaStrike conversion. ASC p.124.
    • hasIndirectFire

      public boolean hasIndirectFire()
      Returns true if this weapon type can be used for Total War LRM-type indirect fire.
    • isAlphaStrikeIndirectFire

      public boolean isAlphaStrikeIndirectFire()
      Returns true if this weapon type contributes to the AlphaStrike IF ability. This is identical to TW indirect fire for most but not all weapons (see e.g. IATMs)
    • isAlphaStrikePointDefense

      public boolean isAlphaStrikePointDefense()
      Returns true if this weapon type contributes to the AlphaStrike PNT ability. This is not identical to TW point defense, therefore implemented separately.
    • initializeTypes

      public static void initializeTypes()
      Add all the types of weapons we can create to the list

      When a weapon class extends another, the subclass must be listed first to avoid clobbering the name lookup when calling the constructor of the superclass.

    • getExplosionDamage

      public int getExplosionDamage()
    • getCost

      public double getCost(Entity entity, boolean isArmored, int loc, double size)
      Overrides:
      getCost in class EquipmentType
      Returns:
      The C-Bill cost of the piece of equipment.
    • isSplittableOverCriticalSlots

      public boolean isSplittableOverCriticalSlots()
    • toString

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

      protected String getYamlTypeName()
      Description copied from class: EquipmentType
      Returns the YAML type name for this equipment type. Subclasses should override this to return their specific type name.
      Overrides:
      getYamlTypeName in class EquipmentType
      Returns:
      The YAML type name (e.g., "weapon", "ammo", "misc", "armor")
    • addFlags

      protected void addFlags(Map<String,Object> data)
      Description copied from class: EquipmentType
      Adds equipment flags to the YAML data map. Subclasses should override this to add type-specific flags.
      Overrides:
      addFlags in class EquipmentType
      Parameters:
      data - The YAML data map to add flags to
    • getYamlData

      public Map<String,Object> getYamlData()
      Description copied from class: EquipmentType
      Constructs a map containing the YAML-serializable data for this equipment type. Subclasses should override this method to add type-specific data.
      Overrides:
      getYamlData in class EquipmentType
      Returns:
      A map containing the YAML-serializable data for this equipment type.
    • canBeMountedOnBaDwp

      public boolean canBeMountedOnBaDwp()
      Overrides:
      canBeMountedOnBaDwp in class EquipmentType
      Returns:
      True if this equipment type can be mounted on a BattleArmor Detachable Weapon Pack, TO:AUE p.99
    • relevantToTargetingComputer

      public boolean relevantToTargetingComputer()
      Overrides:
      relevantToTargetingComputer in class EquipmentType
      Returns:
      True if this equipment counts for the size and weight of a Targeting Computer, and benefits from it in the case of weapons. TM p.238, TO:AUE p.157