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 int
protected boolean
Boolean flag that determines if this shot was fired using homing ammunition.protected boolean
Boolean flag that determines if this shot was fired as part of a pointblank shot from a hidden unit.protected boolean
Boolean flag that determines if this shot was the first one by a particular weapon in a strafing run.protected int
static final int
static int
-
Constructor Summary
ConstructorsConstructorDescriptionWeaponAttackAction
(int entityId, int targetId, int weaponId) WeaponAttackAction
(int entityId, int targetType, int targetId, int weaponId) -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
int
getAltitudeLoss
(Game game) int
Returns the entity id of the unit carrying the ammo used by this attackint
int[]
int
int
int
int
int
int
int
boolean
isAirToAir
(Game game) boolean
isAirToGround
(Game game) boolean
isDiveBomb
(Game game) boolean
isGroundToAir
(Game game) boolean
boolean
boolean
boolean
boolean
boolean
static ToHitData
processAttackerQuirks
(ToHitData toHit, Entity ae, Targetable target, Mounted<?> weapon) static ToHitData
processAttackerSPAs
(ToHitData toHit, Entity ae, Targetable target, WeaponMounted weapon, Game game) static ToHitData
void
setAimedLocation
(int aimedLocation) void
setAimingMode
(AimingMode aimMode) void
setAmmoCarrier
(int entityId) Sets the entity id of the ammo carrier for this shot, if different than the firing entityvoid
setAmmoId
(int ammoId) void
setAmmoMunitionType
(EnumSet<AmmoType.Munitions> ammoMunitionType) void
setBombPayloads
(HashMap<String, int[]> bpls) void
setHomingShot
(boolean isHomingShot) void
setLaunchVelocity
(int velocity) Needed by teleoperated missilesvoid
setNemesisConfused
(boolean nemesisConfused) void
setOldTargetId
(int id) void
setOldTargetType
(int t) void
setOriginalTargetId
(int id) void
setOriginalTargetType
(int t) void
setOtherAttackInfo
(int newInfo) void
setPointblankShot
(boolean isPointblankShot) void
setStrafing
(boolean isStrafing) void
setStrafingFirstShot
(boolean isStrafingFirstShot) void
setSwarmingMissiles
(boolean swarmingMissiles) void
setSwarmMissiles
(int swarmMissiles) void
setWeaponId
(int weaponId) static boolean
targetInShortCoverBuilding
(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 theAccessibilityWindow
as a textual representation of the action.static ToHitData
toHit
(Game game, int attackerId, Targetable target) To-hit number for attacker firing a generic weapon at the target.static ToHitData
toHit
(Game game, int attackerId, Targetable target, int weaponId, boolean isStrafing) static ToHitData
toHit
(Game game, int attackerId, Targetable target, int weaponId, int aimingAt, AimingMode aimingMode, boolean isStrafing) 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) 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) toSummaryString
(Game game) Returns a short one-line description of the action that is used in the UI, e.g.void
updateTurnsTilHit
(Game game) Methods inherited from class megamek.common.actions.AbstractAttackAction
getEntity, getEntity, getTarget, getTargetId, getTargetType, nightModifiers, setTargetId, setTargetType, toString
Methods inherited from class megamek.common.actions.AbstractEntityAction
getEntityId
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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- Returns:
-
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 than the firing entity- Parameters:
entityId
-
-
setAimedLocation
public void setAimedLocation(int aimedLocation) -
getAimingMode
-
setAimingMode
-
addCounterEquipment
-
setOtherAttackInfo
public void setOtherAttackInfo(int newInfo) -
getOtherAttackInfo
public int getOtherAttackInfo() -
isAirToGround
-
isAirToAir
-
isGroundToAir
-
isDiveBomb
-
getAltitudeLoss
-
toHit
-
toHit
- 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
-
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
public int[] getBombPayload() -
getBombPayloads
-
setBombPayloads
- 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
-
targetInShortCoverBuilding
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
-
toAccessibilityDescription
Description copied from interface:EntityAction
Returns a full description of the action that is (only) to be used in theAccessibilityWindow
as a textual representation of the action. By default, this method returns the value of toString().- Specified by:
toAccessibilityDescription
in interfaceEntityAction
- Overrides:
toAccessibilityDescription
in 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: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 inTurnDetailsOverlay
.- Parameters:
game
- The game object to get information from- Returns:
- A short String describing the action
- See Also:
-