r.add(rollTarget.getDesc());
r.add(diceRoll);
r.indent(4);
r.newlines = 0;
// create the MechWarrior in any case, for campaign tracking
MechWarrior pilot = new MechWarrior(entity);
pilot.setDeployed(true);
pilot.setId(getFreeEntityId());
pilot.setLanded(false);
game.addEntity(pilot.getId(), pilot);
send(createAddEntityPacket(pilot.getId()));
// make him not get a move this turn
pilot.setDone(true);
if (diceRoll < rollTarget.getValue()) {
r.choose(false);
vDesc.addElement(r);
Report.addNewline(vDesc);
if ( (rollTarget.getValue()-diceRoll) > 1){
vDesc.addAll(damageCrew(pilot, (rollTarget.getValue()-diceRoll)/2));
}
} else {
r.choose(true);
vDesc.addElement(r);
}
if (entity.getCrew().isDoomed()) {
vDesc.addAll(destroyEntity(pilot, "deadly ejection", false, false));
} else {
// Add the pilot as an infantry unit on the battlefield.
if (game.getBoard().contains(targetCoords)) {
pilot.setPosition(targetCoords);
/*
* Can pilots eject into water??? ASSUMPTION : They can
* (because they get a -1 mod to the PSR. // Did the pilot
* land in water? if ( game.getBoard().getHex(
* targetCoords).levelOf ( Terrain.WATER ) > 0 ) { //report
* missing desc.append("and the pilot ejects, but lands in
* water!!!\n"); //report missing desc.append(destroyEntity(
* pilot, "a watery grave", false )); } else { //report
* missing desc.append("and the pilot ejects safely!\n"); }
*/
// report safe ejection
r = new Report(6400);
r.subject = entity.getId();
r.indent(5);
vDesc.addElement(r);
//infantry have auto XTC gear so do pilots
/*if (game.getPlanetaryConditions().isVacuum()) {
// ended up in a vacuum
r = new Report(6405);
r.subject = entity.getId();
r.indent(3);
vDesc.addElement(r);
vDesc.addAll(destroyEntity(pilot, "explosive decompression", false, false));
}*/
// Update the entity
entityUpdate(pilot.getId());
// check if the pilot lands in a minefield
vDesc.addAll(doEntityDisplacementMinefieldCheck(pilot, entity.getPosition(), targetCoords, entity.getElevation()));
} else {
// ejects safely
r = new Report(6410);
r.subject = entity.getId();
r.indent(3);
vDesc.addElement(r);
/*
if (game.getPlanetaryConditions().isVacuum()) {
// landed in vacuum
r = new Report(6405);
r.subject = entity.getId();
r.indent(3);
vDesc.addElement(r);
vDesc.addAll(destroyEntity(pilot, "explosive decompression", false, false));
} else {*/
game.removeEntity(pilot.getId(), IEntityRemovalConditions.REMOVE_IN_RETREAT);
send(createRemoveEntityPacket(pilot.getId(), IEntityRemovalConditions.REMOVE_IN_RETREAT));
//}
}
if (game.getOptions().booleanOption("ejected_pilots_flee")) {
game.removeEntity(pilot.getId(), IEntityRemovalConditions.REMOVE_IN_RETREAT);
send(createRemoveEntityPacket(pilot.getId(), IEntityRemovalConditions.REMOVE_IN_RETREAT));
}
} // Pilot safely ejects.
} // End entity-is-Mek
else if (game.getBoard().contains(entity.getPosition()) && !game.getOptions().booleanOption("ejected_pilots_flee") && (entity instanceof Tank)) {
int crewSize = Math.max(1, (int) (14 + entity.getWeight()) / 15);
MechWarrior pilot = new MechWarrior(entity);
pilot.setChassis("Vehicle Crew");
pilot.setDeployed(true);
pilot.setId(getFreeEntityId());
pilot.initializeInternal(crewSize, Infantry.LOC_INFANTRY);
game.addEntity(pilot.getId(), pilot);
send(createAddEntityPacket(pilot.getId()));
// make him not get a move this turn
pilot.setDone(true);
// place on board
pilot.setPosition(entity.getPosition());
// Update the entity
entityUpdate(pilot.getId());
// check if the pilot lands in a minefield
vDesc.addAll(doEntityDisplacementMinefieldCheck(pilot, entity.getPosition(), entity.getPosition(), entity.getElevation()));
}
// Mark the entity's crew as "ejected".