Class AreaEffectHelper

java.lang.Object
megamek.common.weapons.handlers.AreaEffectHelper

public class AreaEffectHelper extends Object
Class containing functionality that helps out with area effect weapons.
  • Constructor Details

    • AreaEffectHelper

      public AreaEffectHelper()
  • Method Details

    • getFuelAirBlastRadiusIndex

      public static int getFuelAirBlastRadiusIndex(String name)
      Get the blast radius of a particular equipment type, given the internal name.
    • processFuelAirDamage

      public static void processFuelAirDamage(Entity target, Coords center, EquipmentType ordnanceType, Entity attacker, Vector<Report> vPhaseReport, TWGameManager gameManager)
      Helper function that processes damage for fuel-air explosives. Single-entity version.
    • processFuelAirDamage

      public static Vector<Integer> processFuelAirDamage(Coords center, int height, AmmoType ammo, Entity attacker, Vector<Report> vPhaseReport, TWGameManager gameManager)
    • processFuelAirDamage

      public static Vector<Integer> processFuelAirDamage(Coords center, int boardId, int height, AmmoType ammo, Entity attacker, Vector<Report> vPhaseReport, TWGameManager gameManager)
      Helper function that processes damage for fuel-air explosives.
    • checkInfantryDestruction

      public static void checkInfantryDestruction(Coords coords, int distFromCenter, Entity attacker, Vector<Integer> alreadyHit, Vector<Report> vPhaseReport, Game game, TWGameManager gameManager)
      Worker function that checks for and implements instant infantry destruction due to fuel air ordnance, if necessary. Checks all units at given coords.
    • checkInfantryDestruction

      public static void checkInfantryDestruction(Entity entity, int distFromCenter, Entity attacker, Vector<Integer> alreadyHit, Vector<Report> vPhaseReport, Game game, TWGameManager gameManager)
      Worker function that checks for and implements instant infantry destruction due to fuel air ordnance, if necessary. Single-entity version.
    • clearMineFields

      public static void clearMineFields(Coords targetPos, int targetNum, Entity ae, Vector<Report> vPhaseReport, Game game, TWGameManager gameManager)
      Worker function that clears minefields.
    • artilleryDamageEntity

      public static void artilleryDamageEntity(Entity entity, int damage, IBuilding bldg, int bldgAbsorbs, boolean variableDamage, boolean asfFlak, boolean flak, int altitude, Coords attackSource, AmmoType ammo, Coords coords, boolean isFuelAirBomb, Entity killer, Hex hex, int subjectId, Vector<Report> vPhaseReport, TWGameManager gameManager)
      Worker function that does artillery damage to an entity. Extracted from Server.artilleryDamageHex()
      Parameters:
      entity - The entity to damage
      damage - The amount of damage to do
      bldg - The building, if any, in that hex
      bldgAbsorbs - How much damage, if any, the building will absorb
      variableDamage - Whether to roll a d6 for the number of hits
      asfFlak - Whether we are making a flak attack against an aerospace unit
      flak - Whether we are making a flak attack
      altitude - Altitude of the attack
      attackSource - The coordinates at which the shell was targeted, for hit table resolution
      ammo - The ammo type used
      coords - The coordinates where the shell actually landed
      isFuelAirBomb - Whether we are making a fuel-air attack
      killer - The entity that initiated the attack
      hex - The hex, if any, where the shell landed
      subjectId - The ID of the entity carrying out the attack, for reporting in double-blind games
      vPhaseReport - Vector of reports to which we append reports
      gameManager - GameManager object for invocation of various methods
    • calculateDamageFallOff

      public static DamageFalloff calculateDamageFallOff(AmmoType ammo, int attackingBA, boolean mineClear)
      Calculate the damage and falloff for a particular ammo type, taking into account whether the attack is being carried out by a battle armor squad or a mine clearance attack. Also sets a "cluster munitions" flag as appropriate.
      Parameters:
      ammo - AmmoType being used for the attack
      attackingBA - How many BA suits are in the squad if this is a BA Tube arty attack, -1 otherwise
      mineClear - Whether we're clearing a minefield
      Returns:
      A DamageFalloff object containing the damage and falloff values and if it is cluster or not
    • doNuclearExplosion

      public static void doNuclearExplosion(Entity entity, Coords coords, int nukeType, Vector<Report> vPhaseReport, TWGameManager gameManager)
      Abbreviated nuclear explosion logic when the weapon is targeted at a single off-board entity.
    • applyExplosionClusterDamageToEntity

      public static void applyExplosionClusterDamageToEntity(Entity entity, int damage, int clusterAmt, Coords position, Vector<Report> vDesc, TWGameManager gameManager)
      Apply a series of cluster hits to the given entity, as from an explosion at a particular position. Generate reports for each cluster.
    • getNukeStats

      public static NukeStats getNukeStats(int nukeType)
      Helper function that retrieves the stat block for a particular type of nuke, or null if such a type is not defined.
    • shapeBlast

      public static HashMap<Map.Entry<Integer,Coords>,Integer> shapeBlast(AmmoType ammo, Coords center, int height, boolean artillery, boolean flak, boolean asfFlak, Game game, boolean excludeCenter)
      Computes the semi-3D blast shapes of AE and Artillery explosions using rules from: - Total Warfare pp. 173, XXX, and - Tactical Operations: Advanced Rules pp. 150, YYY

      The shape of an Area Effect explosion always includes a ring, but may have radius 0. In this case only units in the hit hex are affected. Additionally, an AE attack that hits a building or water hex deals damage above and below the level that was hit: - For R0 AE attacks: 1/2 to the level above, and 1/2 damage to the level below, the level that was hit/targeted in the central hex. E.g. a WiGE vehicle at elevation 1 in a water hex would take 1/2 damage from any AE attack that targeted and hit that hex. Any underwater vehicle at depth 1 below the surface, likewise. - For R1 and larger: full damage to 1 level above and below the targeted level in that hex. 1/2 damage to the levels 2 above and 2 below the level hit. Also, 1/2 damage in an R1 ring at 1 level above and 1 level below.

      Further, cumulatively, Artillery attacks deal extra damage above the hexes they hit no matter what type of hex they are (except Building and Mobile Structures): - For any Artillery: apply base damage - (10 * level) for every level above the base hex until no damage would be dealt. Each unit hit can only be hit once by this damage - For Flak Artillery: apply base damage - (10 * level) for every level below the target's elevation as well.

      We do not currently support artillery flak fire at Low-Altitude units.

      Specific edge cases to consider: 1. Counter-battery fire - only worry about the ring at surface level.

      Parameters:
      ammo - AmmoType of the attack.
      center - Coordinates of center of blast.
      height - Elevation/level of target, or Altitude if firing on ASFs
      artillery - true if artillery attack; false if other AE attack
      flak - true if flak attack.
      asfFlak - true if flak attack on an Aerospace unit.
      game - Reference to game, for terrain checks
      excludeCenter - Used for creating all height, hex values but the center
      Returns:
      (height, Coords): damage map.
    • shapeBlast

      public static HashMap<Map.Entry<Integer,Coords>,Integer> shapeBlast(@Nullable AmmoType ammo, Coords center, DamageFalloff falloff, int height, boolean artillery, boolean flak, boolean asfFlak, Game game, boolean excludeCenter)
    • shapeBlast

      public static HashMap<Map.Entry<Integer,Coords>,Integer> shapeBlast(@Nullable AmmoType ammo, Coords center, int boardId, DamageFalloff falloff, int height, boolean artillery, boolean flak, boolean asfFlak, Game game, boolean excludeCenter)
      Parameters:
      ammo - AmmoType of the attack.
      center - Coordinates of center of blast.
      falloff - Preset falloff to use for this blast; mainly for BA Tube attack.
      height - Elevation/level of target, or Altitude if firing on ASFs
      artillery - true if artillery attack; false if other AE attack
      flak - true if flak attack.
      asfFlak - true if flak attack on an Aerospace unit.
      game - Reference to game, for terrain checks
      excludeCenter - Used for creating all height, hex values but the center
      Returns:
      (height, Coords): damage map.
    • shapeBlastRing

      public static HashMap<Map.Entry<Integer,Coords>,Integer> shapeBlastRing(Coords center, DamageFalloff falloff, int height, boolean excludeCenter)