* ejection system
* @return a <code>Vector</code> of report objects for the gamelog.
*/
public Vector<Report> ejectEntity(Entity entity, boolean autoEject) {
Vector<Report> vDesc = new Vector<Report>();
Report r;
// An entity can only eject it's crew once.
if (entity.getCrew().isEjected()) {
return vDesc;
}
// If the crew are already dead, don't bother
if (entity.isCarcass()) {
return vDesc;
}
// Mek pilots may get hurt during ejection,
// and run around the board afterwards.
if (entity instanceof Mech) {
PilotingRollData rollTarget = new PilotingRollData(entity.getId(), entity.getCrew().getPiloting(), "ejecting");
if (entity.isProne()) {
rollTarget.addModifier(5, "Mech is prone");
}
if (entity.getCrew().isUnconscious()) {
rollTarget.addModifier(3, "pilot unconscious");
}
if (autoEject) {
rollTarget.addModifier(1, "automatic ejection");
}
if (entity.getInternal(Mech.LOC_HEAD) < 3) {
rollTarget.addModifier(Math.min(3 - entity.getInternal(Mech.LOC_HEAD), 2), "Head Internal Structure Damage");
}
int facing = entity.getFacing();
Coords targetCoords = entity.getPosition().translated((facing + 3) % 6);
IHex targetHex = game.getBoard().getHex(targetCoords);
if (targetHex != null) {
if ((targetHex.terrainLevel(Terrains.WATER) > 0) && !targetHex.containsTerrain(Terrains.ICE)) {
rollTarget.addModifier(-1, "landing in water");
} else if (targetHex.containsTerrain(Terrains.ROUGH)) {
rollTarget.addModifier(0, "landing in rough");
} else if (targetHex.containsTerrain(Terrains.RUBBLE)) {
rollTarget.addModifier(0, "landing in rubble");
} else if (targetHex.terrainLevel(Terrains.WOODS) == 1) {
rollTarget.addModifier(2, "landing in light woods");
} else if (targetHex.terrainLevel(Terrains.WOODS) == 2) {
rollTarget.addModifier(3, "landing in heavy woods");
} else if (targetHex.terrainLevel(Terrains.WOODS) == 3) {
rollTarget.addModifier(4, "landing in ultra heavy woods");
} else if (targetHex.terrainLevel(Terrains.JUNGLE) == 1) {
rollTarget.addModifier(3, "landing in light jungle");
} else if (targetHex.terrainLevel(Terrains.JUNGLE) == 2) {
rollTarget.addModifier(5, "landing in heavy jungle");
} else if (targetHex.terrainLevel(Terrains.JUNGLE) == 3) {
rollTarget.addModifier(7, "landing in ultra heavy jungle");
} else if (targetHex.terrainLevel(Terrains.BLDG_ELEV) > 0) {
rollTarget.addModifier(targetHex.terrainLevel(Terrains.BLDG_ELEV), "landing in a building");
} else {
rollTarget.addModifier(-2, "landing in clear terrain");
}
} else {
rollTarget.addModifier(-2, "landing off the board");
}
if ( game.getPlanetaryConditions().getGravity() == 0 ){
rollTarget.addModifier(3,"Zero-G");
}else if ( game.getPlanetaryConditions().getGravity() < .8){
rollTarget.addModifier(2,"Low-G");
}else if ( game.getPlanetaryConditions().getGravity() > 1.2 ){
rollTarget.addModifier(2,"High-G");
}
if ( game.getPlanetaryConditions().getAtmosphere() == PlanetaryConditions.ATMO_VACUUM ){
rollTarget.addModifier(3,"Vacuum");
}else if ( game.getPlanetaryConditions().getAtmosphere() == PlanetaryConditions.ATMO_VHIGH){
rollTarget.addModifier(2,"Very High Atmosphere Pressure");
}else if ( game.getPlanetaryConditions().getAtmosphere() == PlanetaryConditions.ATMO_TRACE){
rollTarget.addModifier(2,"Trace atmosphere");
}
if ( (game.getPlanetaryConditions().getWeather() == PlanetaryConditions.WE_HEAVY_SNOW)
|| (game.getPlanetaryConditions().getWeather() == PlanetaryConditions.WE_ICE_STORM)
|| (game.getPlanetaryConditions().getWeather() == PlanetaryConditions.WE_DOWNPOUR)
|| (game.getPlanetaryConditions().getWindStrength() == PlanetaryConditions.WI_STRONG_GALE)){
rollTarget.addModifier(2,"Bad Weather");
}
if ( (game.getPlanetaryConditions().getWindStrength() >= PlanetaryConditions.WI_STORM)
|| ( (game.getPlanetaryConditions().getWeather() == PlanetaryConditions.WE_HEAVY_SNOW)
&& (game.getPlanetaryConditions().getWindStrength() == PlanetaryConditions.WI_STRONG_GALE))){
rollTarget.addModifier(3,"Really Bad Weather");
}
if (autoEject) {
r = new Report(6395);
r.subject = entity.getId();
r.addDesc(entity);
r.indent(2);
r.newlines = 0;
vDesc.addElement(r);
}
// okay, print the info
r = new Report(2180);
r.subject = entity.getId();
r.addDesc(entity);
r.add(rollTarget.getLastPlainDesc(), true);
r.indent(3);
vDesc.addElement(r);
// roll
final int diceRoll = Compute.d6(2);
r = new Report(2190);
r.subject = entity.getId();
r.add(rollTarget.getValueAsString());
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);