Skip to content

Commit

Permalink
Merge pull request #4916 from MegaMek/vtol_infantry
Browse files Browse the repository at this point in the history
VTOL infantry fixes
  • Loading branch information
neoancient authored Nov 28, 2023
2 parents 173c1eb + bb962fb commit 0aaf73a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion megamek/src/megamek/client/ui/swing/MovementDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,9 @@ private void updateButtons() {

setWalkEnabled(!ce.isImmobile() && ((ce.getWalkMP() > 0) || (ce.getRunMP() > 0))
&& !ce.isStuck());
setJumpEnabled(!isAero && !ce.isImmobile() && !ce.isProne() && (ce.getJumpMP() > 0)
setJumpEnabled(!isAero && !ce.isImmobile() && !ce.isProne()
// Conventional infantry also uses jump MP for VTOL and UMU MP
&& ((ce.getJumpMP() > 0) && (!ce.isConventionalInfantry() || ce.getMovementMode().isJumpInfantry()))
&& !(ce.isStuck() && !ce.canUnstickByJumping()));
setSwimEnabled(!isAero && !ce.isImmobile() && (ce.getActiveUMUCount() > 0)
&& ce.isUnderwater());
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/Infantry.java
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ public void setMotorizedScuba() {

@Override
public String getMovementModeAsString() {
if (!hasETypeFlag(Entity.ETYPE_BATTLEARMOR)) {
if (isConventionalInfantry() && (mount == null)) {
if (getMovementMode().isVTOL()) {
return hasMicrolite() ? "Microlite" : "Microcopter";
}
Expand Down
3 changes: 2 additions & 1 deletion megamek/src/megamek/common/MoveStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -2970,7 +2970,8 @@ protected void calcMovementCostFor(Game game, MoveStep prevStep, CachedEntitySta
// 0 MP infantry units can move 1 hex
if (isInfantry
&& (cachedEntityState.getWalkMP() == 0)
&& (moveMode != EntityMovementMode.SUBMARINE)
&& !moveMode.isSubmarine()
&& !moveMode.isVTOL()
&& getEntity().getPosition().equals(prev)
&& (getEntity().getPosition().distance(getPosition()) == 1)
&& (!isJumping())) {
Expand Down
12 changes: 9 additions & 3 deletions megamek/src/megamek/common/pathfinder/InfantryPathFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,15 @@ private List<MovePath> generateChildren(MovePath startingPath) {
// we've visited this hex already
// we are walking and at or past our movement mp
// we are jumping and at or past our jump mp
if (visitedCoords.contains(startingPath.getFinalCoords()) ||
(!startingPath.isJumping() && (startingPath.getMpUsed() >= startingPath.getEntity().getRunMP()))||
(startingPath.isJumping() && (startingPath.getMpUsed() >= startingPath.getEntity().getJumpMP()))) {
int mp;
if (startingPath.isJumping() || startingPath.getEntity().getMovementMode().isVTOL()) {
mp = startingPath.getEntity().getJumpMP();
} else if (startingPath.getEntity().hasUMU()) {
mp = startingPath.getEntity().getActiveUMUCount();
} else {
mp = startingPath.getEntity().getRunMP();
}
if (visitedCoords.contains(startingPath.getFinalCoords()) || (startingPath.getMpUsed() >= mp)) {
return retval;
}

Expand Down

0 comments on commit 0aaf73a

Please sign in to comment.