Package megamek.common.moves
Class ClimbingHelper
java.lang.Object
megamek.common.moves.ClimbingHelper
Utility class for Mek climbing rules (TO:AR p.20).
Climbing allows a Mek to enter a hex that is 3 or more levels higher or lower than the hex it occupies, provided it has at least one arm with all four actuators functional and the hand free. Only walking MP can be used when climbing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPSR modifier applied to all piloting rolls while climbing.static final intNumber of levels lowered per Dangle-and-Drop turn.static final intMP cost for dropping from a dangle position.static final intMinimum level difference that requires climbing or dangle-and-drop.static final intMP cost per level when climbing with one functional hand.static final intMP cost per level when climbing with two functional hands.static final intAdditional PSR modifier when climbing with only one functional arm.static final intTo-hit modifier applied against a climbing target (easier to hit). -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns true if the given entity is a Mek capable of climbing (TO:AR p.20).static booleanPath-aware variant ofcanClimb(Entity)that evaluates against the supplied prone state rather than the entity's live prone state.static booleanReturns true if the given entity can perform a Dangle-and-Drop maneuver (TO:AR p.20).static intcountClimbableArms(Mek mek) Returns the number of arms (0, 1, or 2) eligible for climbing on the given Mek.static intSame asgetClimbDestinationLevel(Hex)but expressed as elevation relative to the hex's own level — so a building roof returnsBLDG_ELEV, a bridge surface returnsBRIDGE_ELEV, and a bare hex (cliff top, dry ground) returns 0.static intReturns the absolute level of the top climbable surface in the given hex — the building roof, the bridge surface, or the bare hex level if neither is present.static StringgetClimbingImpossibleReason(Entity entity) Returns a human-readable reason why the entity cannot climb, or null if climbing is possible.static intReturns the MP cost per level climbed for the given Mek (TO:AR p.20).static StringgetDangleImpossibleReason(Entity entity) Returns a human-readable reason why the entity cannot dangle, or null if dangling is possible.static intgetEdgeDropHeight(Entity entity, Coords targetCoords, Game game) Checks if an entity is at the edge of a cliff or building roof, with an adjacent hex that is 3+ levels lower.static booleanisArmClimbCapable(Mek mek, int location) Checks whether a specific arm on a Mek has all four actuators functional and the hand is free (not holding a physical weapon or carried object).static booleanReturns true if the entity is at the edge of a cliff or building roof, with the target hex being 3+ levels lower.static booleanisOnBuildingRoof(Entity entity, Game game) Returns true if the entity is standing on a building roof.
-
Field Details
-
MP_COST_TWO_HANDS
public static final int MP_COST_TWO_HANDSMP cost per level when climbing with two functional hands.- See Also:
-
MP_COST_ONE_HAND
public static final int MP_COST_ONE_HANDMP cost per level when climbing with one functional hand.- See Also:
-
CLIMBING_PSR_MODIFIER
public static final int CLIMBING_PSR_MODIFIERPSR modifier applied to all piloting rolls while climbing.- See Also:
-
ONE_ARM_PSR_MODIFIER
public static final int ONE_ARM_PSR_MODIFIERAdditional PSR modifier when climbing with only one functional arm.- See Also:
-
TARGET_CLIMBING_MODIFIER
public static final int TARGET_CLIMBING_MODIFIERTo-hit modifier applied against a climbing target (easier to hit).- See Also:
-
DANGLE_LEVELS_PER_TURN
public static final int DANGLE_LEVELS_PER_TURNNumber of levels lowered per Dangle-and-Drop turn.- See Also:
-
DROP_MP_COST
public static final int DROP_MP_COSTMP cost for dropping from a dangle position.- See Also:
-
MIN_CLIMBING_LEVELS
public static final int MIN_CLIMBING_LEVELSMinimum level difference that requires climbing or dangle-and-drop.- See Also:
-
-
Method Details
-
getEdgeDropHeight
Checks if an entity is at the edge of a cliff or building roof, with an adjacent hex that is 3+ levels lower. Returns the level difference to the lowest adjacent hex in the given direction, or 0 if not at an edge.- Parameters:
entity- the entity to checktargetCoords- the adjacent hex to check (the potential lower hex)game- the current game- Returns:
- the level difference (positive = entity is higher), or 0 if not an edge
-
isAtEdge
Returns true if the entity is at the edge of a cliff or building roof, with the target hex being 3+ levels lower.- Parameters:
entity- the entity to checktargetCoords- the adjacent hex to checkgame- the current game- Returns:
- true if the entity is at a climbable/dangleable edge
-
isOnBuildingRoof
Returns true if the entity is standing on a building roof.- Parameters:
entity- the entity to checkgame- the current game- Returns:
- true if the entity is on a building roof
-
isArmClimbCapable
Checks whether a specific arm on a Mek has all four actuators functional and the hand is free (not holding a physical weapon or carried object).- Parameters:
mek- the Mek to checklocation- the arm location (Mek.LOC_LEFT_ARMorMek.LOC_RIGHT_ARM)- Returns:
- true if the arm is fully functional and hand is free
-
countClimbableArms
Returns the number of arms (0, 1, or 2) eligible for climbing on the given Mek.- Parameters:
mek- the Mek to check- Returns:
- the number of climbable arms
-
canClimb
Returns true if the given entity is a Mek capable of climbing (TO:AR p.20). Requires at least one arm with all four actuators functional and hand free, and the unit must not be prone or shut down.- Parameters:
entity- the entity to check- Returns:
- true if this entity can climb
-
canClimb
Path-aware variant ofcanClimb(Entity)that evaluates against the supplied prone state rather than the entity's live prone state. Used during MovePath compilation so a GET_UP step earlier in the path lets the subsequent climbing branch engage — even though the entity itself is still prone on the board until the turn commits.- Parameters:
entity- the entity to checkisProne- the per-step prone state to evaluate against- Returns:
- true if this entity can climb given the supplied prone state
-
getClimbingImpossibleReason
Returns a human-readable reason why the entity cannot climb, or null if climbing is possible.- Parameters:
entity- the entity to check- Returns:
- the reason climbing is impossible, or null if climbing is allowed
-
canDangle
Returns true if the given entity can perform a Dangle-and-Drop maneuver (TO:AR p.20). Requires two arms with all four actuators functional and hands free.- Parameters:
entity- the entity to check- Returns:
- true if this entity can dangle
-
getDangleImpossibleReason
Returns a human-readable reason why the entity cannot dangle, or null if dangling is possible.- Parameters:
entity- the entity to check- Returns:
- the reason dangling is impossible, or null if dangling is allowed
-
getClimbingMPCostPerLevel
Returns the MP cost per level climbed for the given Mek (TO:AR p.20). 2 MP per level with two functional hands, 3 MP per level with one.- Parameters:
mek- the Mek to check- Returns:
- the MP cost per level of climbing
-
getClimbDestinationLevel
Returns the absolute level of the top climbable surface in the given hex — the building roof, the bridge surface, or the bare hex level if neither is present. Used by the climbing dialog to compute remaining levels of an in-progress climb; without the bridge branch a continuation climb toward a bridge hex measures only to the bare hex level (the water/ground beneath the bridge), reports 0 levels remaining, and skips the dialog entirely.- Parameters:
hex- the hex whose climbable top to measure- Returns:
- the absolute level of the building roof, bridge surface, or bare hex level
-
getClimbDestinationElevation
Same asgetClimbDestinationLevel(Hex)but expressed as elevation relative to the hex's own level — so a building roof returnsBLDG_ELEV, a bridge surface returnsBRIDGE_ELEV, and a bare hex (cliff top, dry ground) returns 0. Used byMoveStep.compile(megamek.common.game.Game, megamek.common.units.Entity, megamek.common.moves.MoveStep, megamek.common.pathfinder.CachedEntityState)to place a continuation-climbing Mek on the destination hex's top surface, bypassing the water-emergence math inEntity.calcElevation(megamek.common.Hex, megamek.common.Hex, int, boolean)that doesn't apply when the Mek is on a cliff face above the waterline.- Parameters:
hex- the destination hex- Returns:
- the elevation of the climbable top surface, relative to the hex's own level
-