/** * Clones this path, will contain a new clone of the steps so that the clone * is independent from the original. * * @return the cloned MovePath */ @Override public MovePath clone() { final MovePath copy = new MovePath(getGame(), getEntity()); copy.steps = new Vector<MoveStep>(steps); copy.careful = careful; copy.containedStepTypes = new HashSet<>(containedStepTypes); copy.fliesOverEnemy = fliesOverEnemy; return copy; }
MovePath altitudePath = startingPath.clone(); while(altitudePath.getFinalAltitude() != desiredAltitude) { if(altitudePath.getFinalAltitude() < desiredAltitude && altitudePath.getMpUsed() < maxThrust - 1) { altitudePath.addStep(MoveStepType.UP); else if(altitudePath.getFinalAltitude() > desiredAltitude && altitudePath.getFinalAltitude() >= startingPath.getFinalAltitude() - 1) { altitudePath.addStep(MoveStepType.DOWN);
/** * Initialize an entity state from a movement path */ EntityState(MovePath path) { position = path.getFinalCoords(); facing = path.getFinalFacing(); hexesMoved = path.getHexesMoved(); heat = path.getEntity().heat; if (path.getLastStepMovementType() == EntityMovementType.MOVE_WALK) { heat = getHeat() + 1; } else if (path.getLastStepMovementType() == EntityMovementType.MOVE_RUN) { heat = getHeat() + 2; } else if ((path.getLastStepMovementType() == EntityMovementType.MOVE_JUMP) && (getHexesMoved() <= 3)) { heat = getHeat() + 3; } else if ((path.getLastStepMovementType() == EntityMovementType.MOVE_JUMP) && (getHexesMoved() > 3)) { heat = getHeat() + getHexesMoved(); } prone = path.getFinalProne() || path.getFinalHullDown(); immobile = path.getEntity().isImmobile(); jumping = path.isJumping(); movementType = path.getLastStepMovementType(); naturalAptGun = path.getEntity().hasAbility(OptionsConstants.PILOT_APTITUDE_GUNNERY); naturalAptPilot = path.getEntity().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING); setSecondaryFacing(getFacing()); }
public PathState(MovePath p) { location = p.getFinalCoords(); facing = p.getFinalFacing(); hulldown = p.getFinalHullDown() || p.getFinalProne(); isjumping = p.isJumping(); }
/** * Rotate from the current facing to the destination facing. */ public void rotatePathfinder(final int destFacing, final boolean isManeuver) { while (getFinalFacing() != destFacing) { final MoveStepType stepType = getDirection(getFinalFacing(), destFacing); addStep(stepType, isManeuver, isManeuver); } }
public CoordsWithFacing(MovePath mp) { this(mp.getFinalCoords(), mp.getFinalFacing()); }
cmd.clipToPossible(); if ((cmd.length() == 0) && !ce().isAirborne() && GUIPreferences.getInstance().getNagForNoAction()) { if (cmd.hasActiveMASC() && GUIPreferences.getInstance().getNagForMASC()) { if ((cmd.getLastStepMovementType() == EntityMovementType.MOVE_SPRINT || cmd.getLastStepMovementType() == EntityMovementType.MOVE_VTOL_SPRINT) && GUIPreferences.getInstance().getNagForSprint() && !((cmd.getEntity() instanceof Tank || (cmd.getEntity() instanceof QuadVee && cmd.getEntity().getConversionMode() == QuadVee.CONV_MODE_VEHICLE) && GUIPreferences.getInstance().getNagForPSR()))) { ConfirmDialog nag = new ConfirmDialog(clientgui.frame, if (cmd.shouldMechanicalJumpCauseFallDamage() && GUIPreferences.getInstance() .getNagForMechanicalJumpFallDamage()) { "MovementDisplay.ConfirmMechanicalJumpFallDamage", new Object[] { cmd.getJumpMaxElevationChange(), ce().getJumpMP(), cmd.getJumpMaxElevationChange() - ce().getJumpMP() }), true); nag.setVisible(true); if (cmd.contains(MoveStepType.VTAKEOFF)
final Entity entity = md.getEntity(); final IGame game = entity.getGame(); md.clipToPossible(); overallMoveType = md.getLastStepMovementType(); for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements();) { final MoveStep step = i.nextElement(); boolean isPavementStep = step.isPavementStep(); if (step.getMovementType(md.isEndStep(step)) == EntityMovementType.MOVE_ILLEGAL) { break; moveType = step.getMovementType(md.isEndStep(step)); distance = step.getDistance(); boolean isLastStep = md.getLastStep().equals(step); rollTarget = entity.checkRubbleMove(step, overallMoveType, curHex, lastPos, curPos, isLastStep, isPavementStep); } else if ((game.getPlanetaryConditions().getGravity() > 1) && ((origWalkMP - gravWalkMP) > 0)) { rollTarget = entity.getBasePilotingRoll(md.getLastStepMovementType()); entity.addPilotingModifierForTerrain(rollTarget, step); int gravMod = game.getPlanetaryConditions() || (step.getType() == MoveStepType.LATERAL_LEFT_BACKWARDS) || (step.getType() == MoveStepType.LATERAL_RIGHT_BACKWARDS))
.append(path.toString()).append(") for hazards."); if (EntityMovementType.MOVE_FLYING.equals(path.getLastStepMovementType()) || EntityMovementType.MOVE_OVER_THRUST.equals(path.getLastStepMovementType()) || EntityMovementType.MOVE_SAFE_THRUST.equals(path.getLastStepMovementType()) || EntityMovementType.MOVE_VTOL_WALK.equals(path.getLastStepMovementType()) || EntityMovementType.MOVE_VTOL_RUN.equals(path.getLastStepMovementType()) || EntityMovementType.MOVE_VTOL_SPRINT.equals(path.getLastStepMovementType()) || EntityMovementType.MOVE_SUBMARINE_WALK.equals(path.getLastStepMovementType()) || EntityMovementType.MOVE_SUBMARINE_RUN.equals(path.getLastStepMovementType())) { logMsg.append("\n\tMove Type (").append(path.getLastStepMovementType().toString()) .append(") ignores ground hazards."); return 0; if (path.isJumping()) { logMsg.append("\n\tJumping"); Coords endCoords = path.getFinalCoords(); IHex endHex = game.getBoard().getHex(endCoords); return checkHexForHazards(endHex, movingUnit, true, path.getLastStep(), true, path, game.getBoard(), logMsg); MoveStep lastStep = path.getLastStep(); for (MoveStep step : path.getStepVector()) { Coords coords = step.getPosition(); if ((coords == null) || coords.equals(previousCoords)) {
cmd = new MovePath(getClient().getGame(), ce()); if (!cmd.isJumping()) { cmd.addStep(MoveStepType.START_JUMP); gear = GEAR_TURN; } else if (args[1].equalsIgnoreCase("CLIP")) { cmd.clipToPossible(); return "Path cliped to whats actually possible. " + ce().toString() + " is now in gear " + gearName(gear) + " heading towards " + cmd.getFinalCoords().toFriendlyString() + " with a final facing of " + getDirection(cmd.getFinalFacing()) + ". Total mp used: " + cmd.getMpUsed() + " for a movement of: " + cmd.getHexesMoved(); } else if (args[1].equalsIgnoreCase("GETUP")) { if (cmd.getFinalProne() || cmd.getFinalHullDown()) { cmd.addStep(MoveStepType.GET_UP); return "Mech will try to stand up. this requieres a piloting roll."; if (cmd.getFinalProne() || cmd.getFinalHullDown() && getClient().getGame().getOptions() .booleanOption(OptionsConstants.ADVGRNDMOV_TACOPS_CAREFUL_STAND)) { cmd.addStep(MoveStepType.CAREFUL_STAND); return "Mech will try to stand up. this requieres a piloting roll."; + " is now in gear " + gearName(gear) + " heading towards " + cmd.getFinalCoords().toFriendlyString()
Entity mover = startingPathList.get(0).getEntity(); if((path == null) || !path.isMoveLegal()) { continue; StringBuilder msg = new StringBuilder("Validating Path: ").append(path.toString()); if((path.getEntity().getBombs(BombType.F_GROUND_BOMB).size() == 0) && (path.getFinalAltitude() < 2)) { msg.append("\n\tNo bombs but at altitude 1. No way."); continue; Coords finalCoords = path.getFinalCoords(); if(needToUnjamRAC && ((path.getMpUsed() > walkMP) || path.isJumping())) { logLevel = LogLevel.INFO; msg.append("\n\tINADVISABLE: Want to unjam autocannon but path involves running or jumping");
protected List<MovePath> generateSidePaths(MovePath mp, MoveStepType stepType) { List<MovePath> retval = new ArrayList<MovePath>(); MovePath straightLine = mp.clone(); while(straightLine.getFinalVelocityLeft() > 0 && game.getBoard().contains(straightLine.getFinalCoords())) { MoveStep currentStep = straightLine.getLastStep(); if(currentStep == null) { currentStep = new MoveStep(straightLine, MoveStepType.NONE); int turnCost = currentStep.asfTurnCost(mp.getGame(), stepType, mp.getEntity()); currentStep.getMpUsed() <= mp.getEntity().getRunMP() - turnCost) { MovePath tiltedPath = straightLine.clone(); tiltedPath.addStep(stepType); straightLine.addStep(MoveStepType.FORWARDS);
final Entity entity = md.getEntity(); final IGame game = entity.getGame(); md.clipToPossible(); overallMoveType = md.getLastStepMovementType(); for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements();) { final MoveStep step = i.nextElement(); if (step.getMovementType(md.isEndStep(step)) == EntityMovementType.MOVE_ILLEGAL) { break; moveType = step.getMovementType(md.isEndStep(step)); int thrust = md.getMpUsed(); rollTarget = a.checkThrustSITotal(thrust, overallMoveType); checkNag(rollTarget, nagReport, psrList); if (!game.getBoard().inSpace() && !md.contains(MoveStepType.LAND) && !md.contains(MoveStepType.VLAND)) { rollTarget = a.checkVelocityDouble(md.getFinalVelocity(), overallMoveType); checkNag(rollTarget, nagReport, psrList); rollTarget = a.checkDown(md.getFinalNDown(), overallMoveType); checkNag(rollTarget, nagReport, psrList);
/** * Returns whether or not a unit would end up prone after all of the steps */ public boolean getFinalProne() { if (getLastStep() != null) { return getLastStep().isProne(); } if (getEntity() == null) { return false; } return getEntity().isProne(); }
private void adjustPathForBridge(MovePath path) { boolean needsAdjust = false; for (Coords c : path.getCoordsSet()) { IHex hex = getGame().getBoard().getHex(c); if ((hex != null) && hex.containsTerrain(Terrains.BRIDGE)) { if (getGame().getBoard().getBuildingAt(c).getCurrentCF(c) >= path.getEntity().getWeight()) { needsAdjust = true; break; } else { needsAdjust = false; break; } } } if (!needsAdjust) { return; } MovePath adjusted = new MovePath(getGame(), path.getEntity()); adjusted.addStep(MoveStepType.CLIMB_MODE_ON); adjusted.addSteps(path.getStepVector(), true); adjusted.addStep(MoveStepType.CLIMB_MODE_OFF); path.replaceSteps(adjusted.getStepVector()); }
/** * @param boardView1 * @param mp */ public MovementModifierEnvelopeSprite(BoardView1 boardView1, MovePath mp) { super(boardView1, mp.getFinalCoords()); facing = Facing.valueOfInt(mp.getFinalFacing()); int modi = Compute.getTargetMovementModifier(mp.getHexesMoved(), mp.isJumping(), mp.getEntity() instanceof VTOL, boardView1.game).getValue(); //Add evasion bonus for 'Mech with dual cockpit if (mp.getEntity().getCrew().getCrewType().equals(CrewType.DUAL) && mp.getEntity().getCrew().hasDedicatedPilot() && !mp.isJumping() && mp.getHexesMoved() > 0) { modi++; } float hue = 0.7f - 0.15f * modi; color = new Color(Color.HSBtoRGB(hue, 1, 1)); modifier = String.format("%+d", modi); }
public static MovePath moveAero(MovePath md, Client client) { final Entity entity = md.getEntity(); final IGame game = entity.getGame(); if (!entity.isAero()) { if ((md.getLastStep() != null) && (md.getLastStep().getType() == MoveStepType.RAM)) { isRamming = true; md = new MovePath(game, entity); int vel = a.getCurrentVelocity(); md.addStep(MoveStepType.FORWARDS); steps--; if (!game.getBoard().contains(md.getLastStep().getPosition())) { md.removeLastStep(); if(game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_RETURN_FLYOVER)) { md.addStep(MoveStepType.OFF); } else { md.addStep(MoveStepType.RETURN); md.addStep(MoveStepType.OFF); switch (roll) { case 1: md.addStep(MoveStepType.TURN_LEFT); md.addStep(MoveStepType.TURN_LEFT); break;
private void removeLastStep() { cmd.removeLastStep(); if (cmd.length() == 0) { clear(); if ((gear == MovementDisplay.GEAR_JUMP) && (!cmd.isJumping())) { cmd.addStep(MoveStepType.START_JUMP); } else if (ce().isConvertingNow()) { cmd.addStep(MoveStepType.CONVERT_MODE); } } else { clientgui.bv.drawMovementData(ce(), cmd); clientgui.bv.setWeaponFieldofFire(ce(), cmd); // Set the button's label to "Done" // if the entire move is impossible. MovePath possible = cmd.clone(); possible.clipToPossible(); if (possible.length() == 0) { butDone.setText("<html><b>" + Messages.getString("MovementDisplay.Done") + "</b></html>"); //$NON-NLS-1$ } } updateButtons(); }
if(path.getEntity().isAero() || path.getEntity().hasETypeFlag(Entity.ETYPE_VTOL)) { return false; if (path.isJumping()) { final Coords finalCoords = path.getFinalCoords(); final Building building = game.getBoard().getBuildingAt(finalCoords); if (building == null) { double mass = path.getEntity().getWeight() + 10; final double mass = path.getEntity().getWeight() + 10; final Enumeration<MoveStep> steps = path.getSteps(); while (steps.hasMoreElements()) { final MoveStep step = steps.nextElement();
private int getFacingDiff(final MovePath first) { if (first.isJumping()) { return 0; } if (first.getFinalCoords().equals(destination)) { return 0; } int firstFacing = Math.abs(((first.getFinalCoords().direction(destination) + (backward ? 3 : 0)) % 6) - first.getFinalFacing()); if (firstFacing > 3) { firstFacing = 6 - firstFacing; } if (first.canShift()) { firstFacing = Math.max(0, firstFacing - 1); } if ((first.getFinalCoords().degree(destination) % 60) != 0) { firstFacing++; } return firstFacing; } }