Class WeaponAttackAction

All Implemented Interfaces:
Serializable, AttackAction, EntityAction
Direct Known Subclasses:
ArtilleryAttackAction

public class WeaponAttackAction extends AbstractAttackAction
Represents intention to fire a weapon at the target.
See Also:
  • Field Details

    • DEFAULT_VELOCITY

      public static int DEFAULT_VELOCITY
    • UNASSIGNED

      public static int UNASSIGNED
    • STRATOPS_SENSOR_SHADOW_WEIGHT_DIFF

      public static final int STRATOPS_SENSOR_SHADOW_WEIGHT_DIFF
      See Also:
    • launchVelocity

      protected int launchVelocity
    • isStrafingFirstShot

      protected boolean isStrafingFirstShot
      Boolean flag that determines if this shot was the first one by a particular weapon in a strafing run. Used to ensure that heat is only added once.
    • isPointblankShot

      protected boolean isPointblankShot
      Boolean flag that determines if this shot was fired as part of a pointblank shot from a hidden unit. In this case, to-hit numbers should not be modified for terrain or movement. See TW pg 260
    • isHomingShot

      protected boolean isHomingShot
      Boolean flag that determines if this shot was fired using homing ammunition. Can be checked to allow casting of attack handlers to the proper homing handler.
  • Constructor Details

    • WeaponAttackAction

      public WeaponAttackAction(int entityId, int targetId, int weaponId)
    • WeaponAttackAction

      public WeaponAttackAction(int entityId, int targetType, int targetId, int weaponId)
    • WeaponAttackAction

      public WeaponAttackAction(WeaponAttackAction other)
  • Method Details

    • getWeaponId

      public int getWeaponId()
    • getAmmoId

      public int getAmmoId()
    • getAmmoMunitionType

      public EnumSet<AmmoType.Munitions> getAmmoMunitionType()
    • getAmmoCarrier

      public int getAmmoCarrier()
      Returns the entity id of the unit carrying the ammo used by this attack
      Returns:
    • getAimedLocation

      public int getAimedLocation()
    • getCounterEquipment

      public List<WeaponMounted> getCounterEquipment()
    • setWeaponId

      public void setWeaponId(int weaponId)
    • setAmmoId

      public void setAmmoId(int ammoId)
    • setAmmoMunitionType

      public void setAmmoMunitionType(EnumSet<AmmoType.Munitions> ammoMunitionType)
    • setAmmoCarrier

      public void setAmmoCarrier(int entityId)
      Sets the entity id of the ammo carrier for this shot, if different than the firing entity
      Parameters:
      entityId -
    • setAimedLocation

      public void setAimedLocation(int aimedLocation)
    • getAimingMode

      public AimingMode getAimingMode()
    • setAimingMode

      public void setAimingMode(AimingMode aimMode)
    • addCounterEquipment

      public void addCounterEquipment(WeaponMounted m)
    • setOtherAttackInfo

      public void setOtherAttackInfo(int newInfo)
    • getOtherAttackInfo

      public int getOtherAttackInfo()
    • isAirToGround

      public boolean isAirToGround(Game game)
    • isAirToAir

      public boolean isAirToAir(Game game)
    • isGroundToAir

      public boolean isGroundToAir(Game game)
    • isDiveBomb

      public boolean isDiveBomb(Game game)
    • getAltitudeLoss

      public int getAltitudeLoss(Game game)
    • toHit

      public ToHitData toHit(Game game)
    • toHit

      public ToHitData toHit(Game game, boolean evenIfAlreadyFired)
      Parameters:
      game -
      evenIfAlreadyFired - false: an already fired weapon will return a ToHitData with value IMPOSSIBLE true: an already fired weapon will return a ToHitData with the value of its chance to hit
    • toHit

      public ToHitData toHit(Game game, List<ECMInfo> allECMInfo)
    • toHit

      public static ToHitData toHit(Game game, int attackerId, Targetable target, int weaponId, boolean isStrafing)
    • toHit

      public static ToHitData toHit(Game game, int attackerId, Targetable target, int weaponId, int aimingAt, AimingMode aimingMode, boolean isStrafing)
    • toHit

      public static ToHitData toHit(Game game, int attackerId, Targetable target, int weaponId, int aimingAt, AimingMode aimingMode, boolean isNemesisConfused, boolean exchangeSwarmTarget, Targetable oldTarget, Targetable originalTarget, boolean isStrafing, boolean isPointblankShot, int ammoId, int ammoCarrier)
    • toHit

      public static ToHitData toHit(Game game, int attackerId, Targetable target, int weaponId, int aimingAt, AimingMode aimingMode, boolean isNemesisConfused, boolean exchangeSwarmTarget, Targetable oldTarget, Targetable originalTarget, boolean isStrafing, boolean isPointblankShot, boolean evenIfAlreadyFired, int ammoId, int ammoCarrier)
    • toHit

      public static ToHitData toHit(Game game, int attackerId, Targetable target)
      To-hit number for attacker firing a generic weapon at the target. Does not factor in any special weapon or ammo considerations, including range modifiers. Also does not include gunnery skill.
      Parameters:
      game - The current Game
    • isNemesisConfused

      public boolean isNemesisConfused()
      Returns:
      Returns the nemesisConfused.
    • setNemesisConfused

      public void setNemesisConfused(boolean nemesisConfused)
      Parameters:
      nemesisConfused - The nemesisConfused to set.
    • isSwarmingMissiles

      public boolean isSwarmingMissiles()
    • setSwarmingMissiles

      public void setSwarmingMissiles(boolean swarmingMissiles)
    • setOldTargetId

      public void setOldTargetId(int id)
    • getOldTargetId

      public int getOldTargetId()
    • setOldTargetType

      public void setOldTargetType(int t)
    • getOldTargetType

      public int getOldTargetType()
    • setOriginalTargetId

      public void setOriginalTargetId(int id)
    • getOriginalTargetId

      public int getOriginalTargetId()
    • setOriginalTargetType

      public void setOriginalTargetType(int t)
    • getOriginalTargetType

      public int getOriginalTargetType()
    • getSwarmMissiles

      public int getSwarmMissiles()
    • setSwarmMissiles

      public void setSwarmMissiles(int swarmMissiles)
    • getBombPayload

      public int[] getBombPayload()
    • getBombPayloads

      public HashMap<String,int[]> getBombPayloads()
    • setBombPayloads

      public void setBombPayloads(HashMap<String,int[]> bpls)
      Parameters:
      bpls - These are the "bomb payload" for internal and external bomb stores. It's a HashMap of two arrays, each indexed by the constants declared in BombType. Each element indicates how many types of that bomb should be fired.
    • isStrafing

      public boolean isStrafing()
    • setStrafing

      public void setStrafing(boolean isStrafing)
    • isStrafingFirstShot

      public boolean isStrafingFirstShot()
    • setStrafingFirstShot

      public void setStrafingFirstShot(boolean isStrafingFirstShot)
    • isPointblankShot

      public boolean isPointblankShot()
    • setPointblankShot

      public void setPointblankShot(boolean isPointblankShot)
    • isHomingShot

      public boolean isHomingShot()
    • setHomingShot

      public void setHomingShot(boolean isHomingShot)
    • setLaunchVelocity

      public void setLaunchVelocity(int velocity)
      Needed by teleoperated missiles
      Parameters:
      velocity - - an integer representing initial velocity
    • updateTurnsTilHit

      public void updateTurnsTilHit(Game game)
    • targetInShortCoverBuilding

      public static boolean targetInShortCoverBuilding(Targetable target)
      Quick routine to determine if the target should be treated as being in a short building.
    • processAttackerQuirks

      public static ToHitData processAttackerQuirks(ToHitData toHit, Entity ae, Targetable target, Mounted<?> weapon)
    • processAttackerSPAs

      public static ToHitData processAttackerSPAs(ToHitData toHit, Entity ae, Targetable target, WeaponMounted weapon, Game game)
    • processDefenderSPAs

      public static ToHitData processDefenderSPAs(ToHitData toHit, Entity ae, Entity te, Mounted<?> weapon, Game game)
    • toAccessibilityDescription

      public String toAccessibilityDescription(Client client)
      Description copied from interface: EntityAction
      Returns a full description of the action that is (only) to be used in the AccessibilityWindow as a textual representation of the action. By default, this method returns the value of toString().
      Specified by:
      toAccessibilityDescription in interface EntityAction
      Overrides:
      toAccessibilityDescription in class AbstractAttackAction
      Parameters:
      client - The local client to obtain any necessary information for the description
      Returns:
      A string describing the action
      See Also:
    • toSummaryString

      public String toSummaryString(Game game)
      Description copied from interface: EntityAction
      Returns a short one-line description of the action that is used in the UI, e.g. on attack arrows in the BoardView and in the action summary in TurnDetailsOverlay.
      Parameters:
      game - The game object to get information from
      Returns:
      A short String describing the action
      See Also: