Class Infantry

All Implemented Interfaces:
Serializable, ICarryable, Transporter, InGameObject, CombatRole, ForceAssignable, ITechnology, ITurnOrdered, PhaseUpdated, RoundUpdated, BTObject, Deployable, Targetable
Direct Known Subclasses:
BattleArmor, ConvInfantry

public abstract class Infantry extends Entity
This is a superclass for infantry unit types, Conventional Infantry and BattleArmor. Other personnel on the battlefield (e.g., ejected crew) are subtypes of Conventional Infantry.

Note that formerly, this class represented conventional infantry directly and BattleArmor was a subtype. This has been changed as a substantional number of rules for CI/BA do not overlap.

See Also:
  • Field Details

    • squadCount

      protected int squadCount
    • squadSize

      protected int squadSize
    • originalTrooperCount

      protected int originalTrooperCount
    • troopersShooting

      protected int troopersShooting
      The number of troopers alive in this platoon at the beginning of the phase, before taking damage.
    • activeTroopers

      protected int activeTroopers
      The number of troopers alive in this platoon, including any damage sustained in the current phase.
    • turnsLayingExplosives

      public int turnsLayingExplosives
    • DUG_IN_NONE

      public static final int DUG_IN_NONE
      See Also:
    • DUG_IN_WORKING

      public static final int DUG_IN_WORKING
      See Also:
    • DUG_IN_COMPLETE

      public static final int DUG_IN_COMPLETE
      See Also:
    • DUG_IN_FORTIFYING1

      public static final int DUG_IN_FORTIFYING1
      See Also:
    • DUG_IN_FORTIFYING2

      public static final int DUG_IN_FORTIFYING2
      See Also:
    • DUG_IN_FORTIFYING3

      public static final int DUG_IN_FORTIFYING3
      See Also:
    • HIT_DECK_TURNS_TO_DIG_IN

      public static final int HIT_DECK_TURNS_TO_DIG_IN
      Number of idle turns (no movement, no fire) the unit must spend "hitting the deck" before it may convert to "dug in" status. Per TO:AR p.106.
      See Also:
    • LEG_ATTACK

      public static final String LEG_ATTACK
      See Also:
    • SWARM_MEK

      public static final String SWARM_MEK
      See Also:
    • SWARM_WEAPON_MEK

      public static final String SWARM_WEAPON_MEK
      See Also:
    • STOP_SWARM

      public static final String STOP_SWARM
      See Also:
  • Constructor Details

    • Infantry

      protected Infantry()
      Generate a new, blank, infantry platoon. Hopefully, we'll be loaded from somewhere.
  • Method Details

    • defaultCrewType

      public CrewType defaultCrewType()
      Overrides:
      defaultCrewType in class Entity
    • getMotiveTechAdvancement

      public static TechAdvancement getMotiveTechAdvancement(EntityMovementMode movementMode)
      Generates the TechAdvancement for the unit's motive type. A value of EntityMovementMode.NONE indicates Beast-mounted infantry.
      Parameters:
      movementMode - An infantry movement mode.
      Returns:
      The Tech Advancement data for the movement mode.
    • isValidSecondaryFacing

      public boolean isValidSecondaryFacing(int dir)
      Description copied from class: Entity
      Can this entity torso/turret twist the given direction?
      Specified by:
      isValidSecondaryFacing in class Entity
    • clipSecondaryFacing

      public int clipSecondaryFacing(int dir)
      Description copied from class: Entity
      Returns the closest valid secondary facing to the given direction.
      Specified by:
      clipSecondaryFacing in class Entity
      Returns:
      the closest valid secondary facing.
    • createLocalSupport

      public void createLocalSupport()
      Creates a local platoon (CO 4th p.82, Urban Guerilla)
    • setIsCallingSupport

      public void setIsCallingSupport(boolean b)
    • getIsCallingSupport

      public boolean getIsCallingSupport()
    • hasUMU

      public boolean hasUMU()
      Description copied from class: Entity
      This method checks to see if a unit has Underwater Maneuvering Units
      Overrides:
      hasUMU in class Entity
      Returns:
      boolean if the entity has usable UMU critical slots.
    • getActiveUMUCount

      public int getActiveUMUCount()
      Description copied from class: Entity
      This counts the number of UMU's a Mek has that are still viable
      Overrides:
      getActiveUMUCount in class Entity
      Returns:
      number intof usable UMU's
    • getAllUMUCount

      public int getAllUMUCount()
      Description copied from class: Entity
      This returns all UMU a Mek has.
      Overrides:
      getAllUMUCount in class Entity
      Returns:
      intTotal number of UMUs a Mek has.
    • getMovementAbbr

      public String getMovementAbbr(EntityMovementType movementType)
      Description copied from class: Entity
      Returns the abbreviation of the name of the type of movement used.
      Specified by:
      getMovementAbbr in class Entity
    • getOriginalTrooperCount

      public int getOriginalTrooperCount()
      Returns:
      The full original strength (trooper count) of this infantry unit
    • victoryReport

      public Vector<Report> victoryReport()
      Description copied from class: Entity
      Generates a vector containing reports on all useful information about this entity.
      Specified by:
      victoryReport in class Entity
    • addEntityBonuses

      public PilotingRollData addEntityBonuses(PilotingRollData prd)
      Description copied from class: Entity
      Add in any piloting skill mods
      Specified by:
      addEntityBonuses in class Entity
    • applyDamage

      public void applyDamage()
      Description copied from class: Entity
      Applies any damage that the entity has suffered. When anything gets hit it is simply marked as "hit" but does not stop working until this is called.
      Overrides:
      applyDamage in class Entity
    • getActiveTroopers

      public int getActiveTroopers()
    • getShootingStrength

      public int getShootingStrength()
      Returns:
      The number of troopers in the platoon before damage to the current phase is applied.
    • canCharge

      public boolean canCharge()
      Overrides:
      canCharge in class Entity
      Returns:
      Whether this type of unit can perform charges
    • canDFA

      public boolean canDFA()
      Overrides:
      canDFA in class Entity
      Returns:
      Whether this type of unit can perform DFA attacks
    • checkBogDown

      public PilotingRollData checkBogDown(MoveStep step, EntityMovementType moveType, Hex curHex, Coords lastPos, Coords curPos, int lastElev, boolean isPavementStep)
      Description copied from class: Entity
      Checks if the entity is moving into a hex that might cause it to bog down. If so, returns the target roll for the piloting skill check.
      Overrides:
      checkBogDown in class Entity
    • checkBogDown

      public PilotingRollData checkBogDown(MoveStep step, Hex curHex, Coords lastPos, Coords curPos, boolean isPavementStep)
    • canCallSupport

      public boolean canCallSupport()
      Returns:
      True when this infantry unit can still call upon local support (CO 4th p.82, Urban Guerilla); in other words, if this ability has not been used yet. Note that this method does not check if it has the ability at all.
    • isStealthy

      public abstract boolean isStealthy()
      Returns:
      True if this infantry unit has any type of stealth system.
    • getMaxExtraneousLimbPairs

      public int getMaxExtraneousLimbPairs()
      Returns the maximum number of extraneous limb pairs allowed. Per IO p.85, if glider wings or powered flight wings are installed, only one pair of extraneous limbs is allowed (instead of the normal two pairs).
      Returns:
      1 if any wing type is installed, 2 otherwise
    • isEligibleFor

      public boolean isEligibleFor(GamePhase phase)
      Description copied from class: Entity
      Determines if an entity is eligible for a phase.
      Overrides:
      isEligibleFor in class Entity
    • newRound

      public void newRound(int roundNumber)
      Description copied from class: Entity
      Start a new round
      Specified by:
      newRound in interface RoundUpdated
      Overrides:
      newRound in class Entity
      Parameters:
      roundNumber - the int number of the new round
    • setDugIn

      public void setDugIn(int i)
    • getDugIn

      public int getDugIn()
    • beginDigIn

      public void beginDigIn(boolean convertFromDeck)
      Begins the one-turn self "digging in" process (TO:AR p.106), or completes it immediately for a unit that has stayed on the deck long enough to convert directly. Seeds the damage baseline used to detect an interrupting attack that would extend the effort.
      Parameters:
      convertFromDeck - true if the unit qualifies to convert straight to fully dug-in from the deck (see canDigInFromDeck())
    • beginFortify

      public void beginFortify()
      Begins the three-turn fieldwork that raises a fortified hex (Trench/Fieldworks Engineers, TO:AUE p.153). Seeds the damage baseline used to detect an interrupting attack that extends the effort.
    • isFortifyExtendedThisRound

      public boolean isFortifyExtendedThisRound()
      Returns:
      true if this unit's digging-in / fortification effort was set back by damage this round (so its progress counter was held rather than advanced). TO:AR p.106 / TO:AUE p.153.
    • isFortifying

      public boolean isFortifying()
      Returns:
      true if this unit is partway through building a fortified hex (one of the multi-turn FORTIFYING stages), as opposed to plain one-turn self digging-in. TO:AUE p.153.
    • getFortifyStage

      public int getFortifyStage()
      Returns:
      the current fortification stage (1..getFortifyTotalStages()) while isFortifying(), or 0 when the unit is not building a fortification.
    • getFortifyTotalStages

      public int getFortifyTotalStages()
      Returns:
      the number of turns of work a fortified hex takes to complete.
    • isHitTheDeck

      public boolean isHitTheDeck()
      Returns:
      true if this infantry is currently "hitting the deck", TO:AR p.106.
    • setHitTheDeck

      public void setHitTheDeck(boolean hitTheDeck)
      Sets the "hitting the deck" status. Clearing the status (e.g. when the unit moves or is loaded) also resets the idle-turn counter used for the dig-in conversion.
      Parameters:
      hitTheDeck - true to mark the unit as hitting the deck
    • getTurnsOnDeck

      public int getTurnsOnDeck()
      Returns:
      The number of consecutive idle turns this unit has spent on the deck (no movement, no fire).
    • setFiredWhileOnDeck

      public void setFiredWhileOnDeck(boolean firedWhileOnDeck)
      Marks that this unit fired while on the deck this turn, which breaks the idle streak required for converting to "dug in". TO:AR p.106.
      Parameters:
      firedWhileOnDeck - True if the unit made a weapon attack while on the deck
    • canDigInFromDeck

      public boolean canDigInFromDeck()
      Returns:
      True if this on-deck unit has remained idle long enough that it may convert directly to "dug in" (protected) status, per TO:AR p.106.
    • clearGroundPostures

      public void clearGroundPostures()
      Clears the transient ground defensive postures (dug in and hitting the deck). Called when the unit moves or is loaded into a transport, since either action ends those postures. TO:AR p.106.
    • setTransportId

      public void setTransportId(int transportID)
      This function is called when loading a unit into transport. This is overridden to ensure infantry are no longer considered dug in or hitting the deck when they are being transported.
      Overrides:
      setTransportId in class Entity
      Parameters:
      transportID - The entity ID of the transporter
    • isMechanized

      public boolean isMechanized()
    • setCanCallSupport

      public void setCanCallSupport(boolean b)
    • setSquadSize

      public void setSquadSize(int size)
      Sets the squad size for this infantry unit. For Conventional Infantry, this is the size of a single squad and the CI unit can be composed of more than one squad. For Battle Armor, this is the entire size of the unit (usually 4, 5 or 6).
      Parameters:
      size - The new squad size
    • getSquadSize

      public int getSquadSize()
      Returns:
      The squad size of this infantry unit. For Conventional Infantry, this is the size of a single squad and the CI unit can be composed of more than one squad. For Battle Armor, this is the entire size of the unit (usually 4, 5 or 6).
    • setSquadCount

      public void setSquadCount(int n)
    • getSquadCount

      public int getSquadCount()
    • isSquad

      public boolean isSquad()
    • getBaseMovementMode

      public EntityMovementMode getBaseMovementMode()
      Returns the base (stored) movement mode for this infantry unit, ignoring any virtual VTOL mode from powered flight wings. This should be used for validation and construction rules that need to know the actual infantry type (leg, motorized, etc.) rather than the effective movement mode.
      Returns:
      The actual stored movement mode, not affected by powered flight
    • canMakeAntiMekAttacks

      public abstract boolean canMakeAntiMekAttacks()
      Returns:
      True for all infantry that are allowed AM attacks. Mechanized infantry and infantry units with encumbering armor or field guns are not allowed to make AM attacks, while all other infantry are. Note that a conventional infantry unit without Anti-Mek gear (15 kg per trooper) can still make AM attacks but has a fixed 8 AM skill rating.
    • isUsingManAce

      public boolean isUsingManAce()
      Overrides:
      isUsingManAce in class Entity
    • getEngineHits

      public int getEngineHits()
      Specified by:
      getEngineHits in class Entity
    • isCrippled

      public boolean isCrippled(boolean checkCrew)
      Description copied from class: Entity
      Returns TRUE if the entity meets the requirements for crippling damage as detailed in TW pg 258. Excepting dead or non-existing crew issues
      Specified by:
      isCrippled in class Entity
      Returns:
      boolean
    • hasEngine

      public boolean hasEngine()
      Overrides:
      hasEngine in class Entity
    • checkLandingInHeavyWoods

      public PilotingRollData checkLandingInHeavyWoods(EntityMovementType overallMoveType, Hex curHex)
      Description copied from class: Entity
      Checks if an entity is landing (from a jump) in heavy woods.
      Overrides:
      checkLandingInHeavyWoods in class Entity
    • hasValidCover

      public static boolean hasValidCover(Game game, Coords pos, int elevation)
      Determines if there is valid cover for an infantry unit to utilize the Using Non-Infantry as Cover rules (TO:AR p.106).
      Parameters:
      game - The current Game
      pos - The hex coords
      elevation - The elevation (flying or in building)
      Returns:
      True when this infantry has valid cover
    • isTakingCover

      public boolean isTakingCover()
    • setTakingCover

      public void setTakingCover(boolean isTakingCover)
    • hasViableWeapons

      protected boolean hasViableWeapons()
      Overrides:
      hasViableWeapons in class Entity
    • hasPatchworkArmor

      public boolean hasPatchworkArmor()
      Overrides:
      hasPatchworkArmor in class Entity
      Returns:
      True if this unit has patchwork armor. Note that this is checked by comparing actual armor types (and tech level) across the locations - in other words, it is *not* a simple boolean flag; instead, the result will always correspond to the unit's armoring.
    • checkSkid

      public PilotingRollData checkSkid(EntityMovementType moveType, Hex prevHex, EntityMovementType overallMoveType, MoveStep prevStep, MoveStep currStep, int prevFacing, int curFacing, Coords lastPos, Coords curPos, boolean isInfantry, int distance)
      Description copied from class: Entity
      Checks if the entity might skid. If so, returns the target roll for the piloting skill check.
      Overrides:
      checkSkid in class Entity
    • getRecoveryTime

      public int getRecoveryTime()
      Description copied from class: Entity
      Returns the recovery time for this entity in minutes.

      This method provides the base recovery time required for this entity type. The recovery time represents the duration needed to recover, repair, or prepare the entity after deployment or damage.

      Subclasses should override this method to provide entity-specific recovery times based on their type, weight class, or other relevant characteristics.

      Manual Reference: CamOps pg 214

      Overrides:
      getRecoveryTime in class Entity
      Returns:
      The recovery time in minutes. The default implementation returns 60 minutes.
    • canInitiateInfantryVsInfantryCombat

      public boolean canInitiateInfantryVsInfantryCombat()
      Description copied from class: Entity
      Determines if this entity can initiate infantry vs infantry combat (TO:AR p.169). Default implementation returns false. Infantry units override this.
      Overrides:
      canInitiateInfantryVsInfantryCombat in class Entity
      Returns:
      true if this entity can initiate infantry vs infantry combat
    • canReinforceInfantryVsInfantry

      public boolean canReinforceInfantryVsInfantry()
      Description copied from class: Entity
      Determines if this entity can reinforce ongoing infantry vs infantry combat. Default implementation returns false. Infantry units override this.
      Overrides:
      canReinforceInfantryVsInfantry in class Entity
      Returns:
      true if this entity can reinforce infantry vs infantry combat
    • getNoOfSlots

      protected int[] getNoOfSlots()
      Specified by:
      getNoOfSlots in class Entity
    • canExitVTOLWithGliderWings

      public boolean canExitVTOLWithGliderWings()
      Returns true if this infantry unit can exit a VTOL using glider wings. Per IO:AE p.79, glider wings give a soldier the ability to leave a VTOL during movement as if the soldier were jump infantry.
      Returns:
      true if this infantry can exit a VTOL using glider wings
    • isChassisFamiliarityEligible

      public boolean isChassisFamiliarityEligible()
      Description copied from class: Entity
      Returns whether this unit is a chassis-familiarity-eligible type for MekHQ's Familiarity system
      Overrides:
      isChassisFamiliarityEligible in class Entity
      Returns:
      true if familiarity is tracked for this unit