// move path for them.
// the same should be true if the unit is shutdown or the pilot
// is unconscious
if (!client.game.useVectorMove() && (a.isOutControlTotal() || a.isShutDown() || a.getCrew().isUnconscious())) {
MovePath oldmd = md;
dontCheckPSR = true;
md = new MovePath(client.game, ce);
int vel = a.getCurrentVelocity();
// need to check for stall here as well
if ((vel == 0) && !(a.isSpheroid() || client.game.getPlanetaryConditions().isVacuum()) && client.game.getBoard().inAtmosphere() && !a.isVSTOL()) {
// add a stall to the movement path
md.addStep(MovePath.STEP_STALL);
}
while (vel > 0) {
// check to see if the unit is currently on a border
// and facing a direction that would indicate leaving
// the map
Coords position = a.getPosition();
int facing = a.getFacing();
MoveStep step = md.getLastStep();
if (step != null) {
position = step.getPosition();
facing = step.getFacing();
}
boolean evenx = (position.x % 2) == 0;
if ((((position.x == 0) && ((facing == 5) || (facing == 4))) || ((position.x == client.game.getBoard().getWidth() - 1) && ((facing == 1) || (facing == 2))) || ((position.y == 0) && ((facing == 1) || (facing == 5) || (facing == 0)) && evenx) || ((position.y == 0) && (facing == 0)) || ((position.y == client.game.getBoard().getHeight() - 1) && ((facing == 2) || (facing == 3) || (facing == 4)) && !evenx) || ((position.y == client.game.getBoard().getHeight() - 1) && (facing == 3)))) {
// then this birdie go bye-bye
// set the conditions for removal
md.addStep(MovePath.STEP_OFF);
vel = 0;
} else {
if (a.isRandomMove()) {
int roll = Compute.d6(1);
switch (roll) {
case 1:
md.addStep(MovePath.STEP_FORWARDS);
md.addStep(MovePath.STEP_TURN_LEFT);
md.addStep(MovePath.STEP_TURN_LEFT);
case 2:
md.addStep(MovePath.STEP_FORWARDS);
md.addStep(MovePath.STEP_TURN_LEFT);
case 3:
case 4:
md.addStep(MovePath.STEP_FORWARDS);
case 5:
md.addStep(MovePath.STEP_FORWARDS);
md.addStep(MovePath.STEP_TURN_RIGHT);
case 6:
md.addStep(MovePath.STEP_FORWARDS);
md.addStep(MovePath.STEP_TURN_RIGHT);
md.addStep(MovePath.STEP_TURN_RIGHT);
}
} else {
md.addStep(MovePath.STEP_FORWARDS);
}
vel--;
}
}
// check to see if old movement path contained a launch and
// we are still on the board
if (oldmd.contains(MovePath.STEP_LAUNCH) && !md.contains(MovePath.STEP_OFF)) {
// since launches have to be the last step
MoveStep lastStep = oldmd.getLastStep();
if (lastStep.getType() == MovePath.STEP_LAUNCH) {
md.addStep(lastStep.getType(), lastStep.getLaunched());
}
}