/** * Returns this entity's walking/cruising mp, factored for heat and possibly * gravity. * * @param gravity Should the movement be factored for gravity * @param ignoreheat Should heat be ignored? */ public int getWalkMP(boolean gravity, boolean ignoreheat) { return getWalkMP(gravity, ignoreheat, false); }
/** * Returns this entity's walking/cruising mp, factored for heat and gravity. */ public int getWalkMP() { return getWalkMP(true, false); }
public int getRunMP(boolean gravity, boolean ignoreheat, boolean ignoremodulararmor) { return (int) Math.ceil(getWalkMP(gravity, ignoreheat, ignoremodulararmor) * 1.5); }
default int getFuelUsed(int thrust) { int overThrust = Math.max(thrust - ((Entity) this).getWalkMP(), 0); int safeThrust = thrust - overThrust; int used = safeThrust + (2 * overThrust); return used; }
@Override public int getWalkMP(boolean gravity, boolean ignoreheat, boolean ignoremodulararmor) { return fighters.stream().map(fid -> game.getEntity(fid)) .filter(ACTIVE_CHECK) .mapToInt(ent -> ent.getWalkMP(gravity, ignoreheat)).min() .orElse(0); }
/** * Worker function that calculates the AtB-rules walk MP for an entity, for deployment purposes. * @param entity The entity to examine. * @return The walk MP. */ private static int calculateAtBSpeed(Entity entity) { int speed = entity.getWalkMP(); if (entity.getJumpMP() > 0) { if (entity instanceof megamek.common.Infantry) { speed = entity.getJumpMP(); } else { speed++; } } return speed; }
/** * Whether this type of unit can perform charges */ public boolean canCharge() { return !isImmobile() && (getWalkMP() > 0) && !isStuck() && !isProne(); }
@Override public Object getValueAt(int rowIndex, int columnIndex) { final Entity en = entities.get(rowIndex); switch (columnIndex) { case COL_ENTITY: return en.getShortNameRaw(); case COL_BV: return en.calculateBattleValue(); case COL_MOVE: return en.getWalkMP() + "/" + en.getRunMPasString() + "/" + en.getJumpMP(); } return ""; }
model.put("engineDesc", formatSystemFluff(EntityFluff.System.ENGINE, entity.getFluff(), () -> stripNotes(entity.getEngine().getEngineName()))); model.put("cruisingSpeed", entity.getWalkMP() * 10.8); model.put("maxSpeed", entity.getRunMP() * 10.8); model.put("armorDesc",
/** * Helper function that appends an unjam RAC command to the end of a qualifying path. * @param path The path to process. */ private void unjamRAC(MovePath path) { if(path.getEntity().canUnjamRAC() && (path.getMpUsed() <= path.getEntity().getWalkMP()) && !path.isJumping()) { path.addStep(MoveStepType.UNJAM_RAC); } }
/** * Checks if the entity is attempting to sprint with MASC engaged. If so, * returns the target roll for the piloting skill check. */ public PilotingRollData checkSprintingWithMASC( EntityMovementType overallMoveType, int used) { PilotingRollData roll = getBasePilotingRoll(overallMoveType); if ((overallMoveType == EntityMovementType.MOVE_SPRINT || overallMoveType == EntityMovementType.MOVE_VTOL_SPRINT) && (used > ((int) Math.ceil(2.0 * this.getWalkMP())))) { roll.append(new PilotingRollData(getId(), 0, "sprinting with active MASC/Supercharger")); } else { roll.addModifier(TargetRoll.CHECK_FALSE, "Check false: Entity is not attempting to sprint with MASC"); } addPilotingModifierForTerrain(roll); return roll; }
/** * Checks if the entity is attempting to sprint with supercharger engaged. * If so, returns the target roll for the piloting skill check. */ public PilotingRollData checkSprintingWithSupercharger( EntityMovementType overallMoveType, int used) { PilotingRollData roll = getBasePilotingRoll(overallMoveType); if ((overallMoveType == EntityMovementType.MOVE_SPRINT || overallMoveType == EntityMovementType.MOVE_VTOL_SPRINT) && (used > ((int) Math.ceil(2.5 * this.getWalkMP())))) { roll.append(new PilotingRollData(getId(), 0, "sprinting with active MASC/Supercharger")); } else { roll.addModifier(TargetRoll.CHECK_FALSE, "Check false: Entity is not attempting to sprint with Supercharger"); } addPilotingModifierForTerrain(roll); return roll; }
private void updateTurnButton() { final Entity ce = ce(); if (null == ce) { return; } setTurnEnabled(!ce.isImmobile() && !ce.isStuck() && ((ce.getWalkMP() > 0) || (ce.getJumpMP() > 0)) && !(cmd.isJumping() && (ce instanceof Mech) && (ce .getJumpType() == Mech.JUMP_BOOSTER))); }
default PilotingRollData checkVelocityDouble(int velocity, EntityMovementType overallMoveType) { PilotingRollData roll = ((Entity) this).getBasePilotingRoll(overallMoveType); if ((velocity > (2 * ((Entity) this).getWalkMP())) && !((Entity) this).getGame().getBoard().inSpace()) { // append the reason modifier roll.append(new PilotingRollData(((Entity) this).getId(), 0, "Velocity greater than 2x safe thrust")); } else { roll.addModifier(TargetRoll.CHECK_FALSE, "Check false: Entity is not exceeding 2x safe thrust"); } return roll; }
private void updateRACButton() { final Entity ce = ce(); if (null == ce) { return; } GameOptions opts = clientgui.getClient().getGame().getOptions(); setUnjamEnabled(ce.canUnjamRAC() && ((gear == MovementDisplay.GEAR_LAND) || (gear == MovementDisplay.GEAR_TURN) || (gear == MovementDisplay.GEAR_BACKUP)) && ((cmd.getMpUsed() <= ce.getWalkMP()) || (cmd.getLastStep().isOnlyPavement() && (cmd.getMpUsed() <= (ce.getWalkMP() + 1)))) && !(opts.booleanOption("tacops_tank_crews") && (cmd.getMpUsed() > 0) && (ce instanceof Tank) && (ce.getCrew().getSize() < 2))); }
/** * This method returns true if a unit is permanently immobilized either * because its crew is dead/gone or because of damage * * @return true if unit is permanently immobile */ public boolean isPermanentlyImmobilized(boolean checkCrew) { if (checkCrew && ((getCrew() == null) || getCrew().isDead())) { return true; } else if (((getOriginalWalkMP() > 0) || (getOriginalRunMP() > 0) || (getOriginalJumpMP() > 0)) /* * Need to make sure here that we're ignoring heat because * that's not actually "permanent": */ && ((getWalkMP(true, true, false) == 0) && (getRunMP(true, true, false) == 0) && (getJumpMP() == 0))) { return true; } else { return false; } }
/** * A quick determination that checks the given path for the most common causes of a PSR and whether it leads us off board. * The idea being that a safe path off board should not include any PSRs. * @param movePath The path to check * @return True or false */ public static boolean isSafePathOffBoard(MovePath movePath) { // common causes of PSR include, but are not limited to: // stalling your aircraft // crashing your aircraft into the ground // executing maneuvers // thrusting too hard // see your doctor if you experience any of these symptoms as it may lead to your aircraft transforming into a lawn dart return !willStall(movePath) && !willCrash(movePath) && movePath.fliesOffBoard() && !movePath.contains(MoveStepType.MANEUVER) && (movePath.getMpUsed() <= movePath.getEntity().getWalkMP()) && (movePath.getEntity().isAero() && (movePath.getMpUsed() <= ((IAero) movePath.getEntity()).getSI())); }
/** * Returns whether an entity can flee from its current position. Currently * returns true if the entity is on the edge of the board. */ public boolean canFlee() { Coords pos = getPosition(); return (pos != null) && ((getWalkMP() > 0) || (this instanceof Infantry)) && !isProne() && !isStuck() && !isShutDown() && !getCrew().isUnconscious() && ((pos.getX() == 0) || (pos.getX() == (game.getBoard().getWidth() - 1)) || (pos.getY() == 0) || (pos.getY() == (game.getBoard() .getHeight() - 1))); }
public boolean canShift() { return ((getEntity() instanceof QuadMech // QuadVee cannot shift in vee mode && !(getEntity() instanceof QuadVee && (entity.getConversionMode() == QuadVee.CONV_MODE_VEHICLE || getEntity().isConvertingNow()))) // Maneuvering Ace allows Bipeds and VTOLs moving at cruise // speed to perform a lateral shift || (getEntity().isUsingManAce() && ((getEntity() instanceof BipedMech) || ((getEntity() instanceof VTOL) && (getMpUsed() <= getEntity().getWalkMP())))) || (game.getOptions().booleanOption(OptionsConstants.ADVGRNDMOV_VEHICLE_ADVANCED_MANEUVERS) && getEntity() instanceof Tank && (getEntity().getMovementMode() == EntityMovementMode.VTOL || getEntity().getMovementMode() == EntityMovementMode.HOVER)) || ((getEntity() instanceof TripodMech) && (((Mech) getEntity()).countBadLegs() == 0))) && !isJumping(); }
unmovedDistMod = e.getWalkMP(true, false, false);