Package megamek.common.actions
Class WeaponAttackAction
java.lang.Object
megamek.common.actions.AbstractEntityAction
megamek.common.actions.AbstractAttackAction
megamek.common.actions.WeaponAttackAction
- All Implemented Interfaces:
Serializable,AttackAction,EntityAction
- Direct Known Subclasses:
ArtilleryAttackAction
Represents intention to fire a weapon at the target.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intprotected booleanBoolean flag that determines if this shot was fired using homing ammunition.protected booleanBoolean flag that determines if this shot was fired as part of a pointblank shot from a hidden unit.protected booleanBoolean flag that determines if this shot was the first one by a particular weapon in a strafing run.protected intstatic final intstatic int -
Constructor Summary
ConstructorsConstructorDescriptionWeaponAttackAction(int entityId, int targetId, int weaponId) WeaponAttackAction(int entityId, int targetType, int targetId, int weaponId) -
Method Summary
Modifier and TypeMethodDescriptionvoidintintgetAltitudeLoss(Game game) intReturns the entity id of the unit carrying the ammo used by this attackintintintintintintintintbooleanisAirToAir(Game game) booleanisAirToGround(Game game) booleanisDiveBomb(Game game) Deprecated, for removal: This API element is subject to removal in a future version.no indicated uses.booleanisGroundToAir(Game game) booleanDeprecated, for removal: This API element is subject to removal in a future version.booleanbooleanisOrbitToSurface(Game game) booleanbooleanbooleanbooleanvoidsetAimedLocation(int aimedLocation) voidsetAimingMode(AimingMode aimMode) voidsetAmmoCarrier(int entityId) Sets the entity id of the ammo carrier for this shot, if different from the firing entityvoidsetAmmoId(int ammoId) voidsetAmmoMunitionType(EnumSet<AmmoType.Munitions> ammoMunitionType) voidsetBombPayloads(HashMap<String, BombLoadout> bombPayloads) voidsetHomingShot(boolean isHomingShot) voidsetLaunchVelocity(int velocity) Needed by teleoperated missilesvoidsetNemesisConfused(boolean nemesisConfused) voidsetOldTargetId(int id) voidsetOldTargetType(int t) voidsetOriginalTargetId(int id) voidsetOriginalTargetType(int t) voidsetOtherAttackInfo(int newInfo) voidsetPointblankShot(boolean isPointblankShot) voidsetStrafing(boolean isStrafing) voidsetStrafingFirstShot(boolean isStrafingFirstShot) voidsetSwarmingMissiles(boolean swarmingMissiles) voidsetSwarmMissiles(int swarmMissiles) voidsetWeaponId(int weaponId) static booleantargetInShortCoverBuilding(Targetable target) Quick routine to determine if the target should be treated as being in a short building.toAccessibilityDescription(Client client) Returns a full description of the action that is (only) to be used in theAccessibilityDialogas a textual representation of the action.static ToHitDatatoHit(Game game, int attackerId, Targetable target) To-hit number for attacker firing a generic weapon at the target.static ToHitDatatoHit(Game game, int attackerId, Targetable target, int weaponId, boolean isStrafing) static ToHitDatatoHit(Game game, int attackerId, Targetable target, int weaponId, int aimingAt, AimingMode aimingMode, boolean isStrafing) static ToHitDatatoHit(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) static ToHitDatatoHit(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) toSummaryString(Game game) Returns a short one-line description of the action that is used in the UI, e.g.voidupdateTurnsTilHit(Game game) Methods inherited from class megamek.common.actions.AbstractAttackAction
getEntity, getEntity, getTarget, getTargetId, getTargetType, nightModifiers, setTargetId, setTargetType, toStringMethods inherited from class megamek.common.actions.AbstractEntityAction
getEntityIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface megamek.common.actions.EntityAction
getEntityId
-
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 isStrafingFirstShotBoolean 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 isPointblankShotBoolean 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 isHomingShotBoolean 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
-
-
Method Details
-
getWeaponId
public int getWeaponId() -
getAmmoId
public int getAmmoId() -
getAmmoMunitionType
-
getAmmoCarrier
public int getAmmoCarrier()Returns the entity id of the unit carrying the ammo used by this attack -
getAimedLocation
public int getAimedLocation() -
getCounterEquipment
-
setWeaponId
public void setWeaponId(int weaponId) -
setAmmoId
public void setAmmoId(int ammoId) -
setAmmoMunitionType
-
setAmmoCarrier
public void setAmmoCarrier(int entityId) Sets the entity id of the ammo carrier for this shot, if different from the firing entity -
setAimedLocation
public void setAimedLocation(int aimedLocation) -
getAimingMode
-
setAimingMode
-
addCounterEquipment
-
setOtherAttackInfo
public void setOtherAttackInfo(int newInfo) -
getOtherAttackInfo
public int getOtherAttackInfo() -
isAirToGround
-
isAirToAir
-
isGroundToAir
-
isOrbitToSurface
-
isDiveBomb
Deprecated, for removal: This API element is subject to removal in a future version.no indicated uses. -
getAltitudeLoss
-
toHit
-
toHit
- Parameters:
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
-
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
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 currentGame
-
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
-
getBombPayloads
-
setBombPayloads
- Parameters:
bombPayloads- 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
Deprecated, for removal: This API element is subject to removal in a future version. -
setHomingShot
public void setHomingShot(boolean isHomingShot) -
setLaunchVelocity
public void setLaunchVelocity(int velocity) Needed by teleoperated missiles- Parameters:
velocity- - an integer representing initial velocity
-
updateTurnsTilHit
-
targetInShortCoverBuilding
Quick routine to determine if the target should be treated as being in a short building. -
toAccessibilityDescription
Description copied from interface:EntityActionReturns a full description of the action that is (only) to be used in theAccessibilityDialogas a textual representation of the action. By default, this method returns the value of toString().- Specified by:
toAccessibilityDescriptionin interfaceEntityAction- Overrides:
toAccessibilityDescriptionin classAbstractAttackAction- Parameters:
client- The local client to obtain any necessary information for the description- Returns:
- A string describing the action
- See Also:
-
toSummaryString
Description copied from interface:EntityActionReturns 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 inTurnDetailsOverlay.- Parameters:
game- The game object to get information from- Returns:
- A short String describing the action
- See Also:
-