Class ASDamageConverter

java.lang.Object
megamek.common.alphaStrike.conversion.ASDamageConverter
Direct Known Subclasses:
ASArcedDamageConverter, ASBattleArmorDamageConverter, ASConvInfantryDamageConverter

public class ASDamageConverter extends Object
  • Field Details

    • TROOP_FACTOR

      protected static final int[] TROOP_FACTOR
    • rdUp

      protected static final String rdUp
      See Also:
    • rdNm

      protected static final String rdNm
      See Also:
    • entity

      protected Entity entity
    • element

      protected AlphaStrikeElement element
    • report

      protected CalculationReport report
    • locations

      protected ASSpecialAbilityCollection[] locations
    • locationNames

      protected String[] locationNames
    • rearLocation

      protected int rearLocation
    • turretLocation

      protected int turretLocation
    • hasTargetingComputer

      protected final boolean hasTargetingComputer
    • weaponsList

      protected List<WeaponMounted> weaponsList
    • rawSDamage

      protected double rawSDamage
    • needsHeatAdjustment

      protected boolean needsHeatAdjustment
    • heatAdjustFactor

      protected double heatAdjustFactor
    • heatAdjustFactorLE

      protected double heatAdjustFactorLE
    • heatAdjustFactorREAR

      protected double heatAdjustFactorREAR
    • finalSDamage

      protected ASDamage finalSDamage
    • finalMDamage

      protected ASDamage finalMDamage
    • finalLDamage

      protected ASDamage finalLDamage
    • finalEDamage

      protected ASDamage finalEDamage
  • Constructor Details

    • ASDamageConverter

      protected ASDamageConverter(Entity entity, AlphaStrikeElement element, CalculationReport report)
      Do not call this directly. Use the static getASDamageConverter instead. Constructs a damage converter for ground units.
      Parameters:
      entity - The entity to convert damage for
      element - The partially-converted element corresponding to the entity
      report - The calculation report to write to
  • Method Details

    • processSpecialAbilities

      protected void processSpecialAbilities()
    • processDamage

      protected void processDamage()
    • processTurrets

      protected void processTurrets()
    • calculateHeatAdjustment

      protected void calculateHeatAdjustment()
    • assembleFrontDamage

      protected double assembleFrontDamage(int range)
      Sums up the front-facing damage values for the given range and reports the counted weapons. Includes modifiers for low ammo, AES etc. and the location multiplier (0.5 for some Aero arcs)
      Parameters:
      range - The range, e.g. AlphaStrikeElement.MEDIUM_RANGE
      Returns:
      The raw damage sum
    • determineDamage

      protected double determineDamage(Mounted<?> weapon, int range)
      Returns the damage value to be used for the given weapon at the given range. Overridden for special treatment and possibly ignoring some weapons.
      Parameters:
      weapon - The weapon Mounted
      range - The range value (not bracket)
      Returns:
      the damage to be used
    • processSDamage

      protected void processSDamage()
    • processMDamage

      protected void processMDamage()
    • processLDamage

      protected void processLDamage()
    • processEDamage

      protected void processEDamage()
    • getDamageMultiplier

      protected double getDamageMultiplier(Mounted<?> weapon, WeaponType weaponType)
    • assembleAmmoCounts

      protected void assembleAmmoCounts()
    • assignSpecialAbilities

      protected void assignSpecialAbilities(Mounted<?> weapon, WeaponType weaponType)
    • processNarc

      protected void processNarc(Mounted<?> weapon, WeaponType weaponType)
    • processTaser

      protected void processTaser(Mounted<?> weapon, WeaponType weaponType)
    • processAMS

      protected void processAMS(Mounted<?> weapon, WeaponType weaponType)
    • processArtillery

      protected void processArtillery(Mounted<?> weapon, WeaponType weaponType)
    • assignToLocations

      protected void assignToLocations(Mounted<?> weapon, BattleForceSUA sua)
      Checks the location multiplier for all locations and assigns the given SUA to any location where the multiplier is not zero, i.e. to any location that the weapon is counted towards.
      Parameters:
      weapon - The weapon to check
      sua - The special unit ability to add
    • assignToLocations

      protected void assignToLocations(Mounted<?> weapon, BattleForceSUA sua, int abilityValue)
      Checks the location multiplier for all locations and assigns the given SUA with the given ability value to any location where the multiplier is not zero, i.e. to any location that the weapon is counted towards. If the SUA is already present, the ability value is added.
      Parameters:
      weapon - The weapon to check
      sua - The special unit ability to add
      abilityValue - The ability value to add
    • reportAssignToLocations

      protected void reportAssignToLocations(Mounted<?> weapon, BattleForceSUA sua, String abilityValue, int loc)
    • processHT

      protected void processHT()
      Determines if the element has the HT ability and what the value is. Overridden for CI.
    • processHT

      protected void processHT(int location)
      Determines if the element has the HT ability and what the value is. Overridden for CI.
    • assembleHeatDamage

      protected int[] assembleHeatDamage(int location)
    • determineFinalHT

      protected void determineFinalHT(int[] heatDamageValues, int location)
    • processFrontSpecialDamage

      protected void processFrontSpecialDamage(BattleForceSUA dmgType)
      Processes damage values for special abilities such as LRM, but not REAR and not TUR.
    • processSpecialDamage

      protected void processSpecialDamage(BattleForceSUA dmgType, int location)
      Processes damage values. The dmgType indicates the special ability for which this is (LRM, REAR, etc.). location indicates the target of this damage, i.e. if it is the unit's standard damage and standard ability block, the REAR ability or the TUR block, see ASLocationMapper. When the location is rearLocation, dmgType must be REAR (as REAR has no LRM damage or the like) When the location is turretLocation, TUR indicates it's the TUR's standard damage, LRM indicates it's the LRM damage within the TUR block.
    • assembleSpecialDamage

      protected double[] assembleSpecialDamage(BattleForceSUA dmgType, int location)
      Sums up the damage values for all ranges and reports the counted weapons. The dmgType indicates the special ability for which this sum is (LRM, REAR, etc.). location indicates the target of this damage, i.e. if it is the unit's standard damage and standard ability block, the REAR ability or the TUR block, see ASLocationMapper. When the location is rearLocation, dmgType must be REAR (as REAR has no LRM damage or the like) When the location is turretLocation, TUR indicates it's the TUR's standard damage, LRM indicates it's the LRM damage within the TUR block.
      Returns:
      The raw damage sums for the four ranges
    • determineSpecialsDamage

      protected double determineSpecialsDamage(WeaponType weaponType, Mounted<?> linked, int range, BattleForceSUA dmgType)
    • qualifiesForSpecial

      protected static boolean qualifiesForSpecial(double[] damage, BattleForceSUA dmgType)
      Returns true when the heat-adjusted and tenth-rounded damage values in the List allow the given spa. Only used for the damage specials LRM, SRM, TOR, IATM, AC, FLK
    • rangesForSpecial

      protected int rangesForSpecial(BattleForceSUA dmgType)
    • formatAsVector

      protected String formatAsVector(double s, double m, double l, double e, BattleForceSUA dmgType)
    • formatAsVector

      protected String formatAsVector(double... damage)
    • countsForSpecial

      protected boolean countsForSpecial(Mounted<?> weapon, BattleForceSUA dmgType)
    • isArtilleryCannon

      protected static boolean isArtilleryCannon(WeaponType weapon)
    • getArtilleryType

      protected static BattleForceSUA getArtilleryType(WeaponType weaponType)
      Translates an Artillery WeaponType to the AlphaStrike Special Unit Ability, if any can be found.
    • roundUpToTenth

      public static double roundUpToTenth(double number)
      Returns the given number, rounded up to the nearest tenth. ASC Converting Heat Errata v1.2: A value of 0.401 -> 0.5; i.e. any fraction will make it round up, not just the second digit.
    • getRearLocation

      protected int getRearLocation()
    • getTurretLocation

      protected int getTurretLocation()
    • getHeatGeneration

      protected int getHeatGeneration(boolean onlyRear, boolean onlyLongRange)
      Returns the total generated heat (weapons and movement) for a Mek or Aero for the purpose of finding OV / OVL values. If onlyRear is true, only rear-facing weapons are included, otherwise only front-facing weapons are included! If onlyLongRange is true, only weapons with an L damage value are included.
    • weaponHeat

      protected int weaponHeat(Mounted<?> weapon, boolean onlyRear, boolean onlyLongRange)
    • weaponHeat

      protected static int weaponHeat(WeaponType weaponType)
    • getHeatCapacity

      protected int getHeatCapacity()
      Returns the heat dissipation for Meks and AFs, according to ASC - Converting Heat Errata v1.2.
    • getWeaponDesc

      protected String getWeaponDesc(Mounted<?> weapon)
    • writeLocationsToElement

      protected void writeLocationsToElement()