if (en.isDestroyed()) {
return false;
}
int explosionBTH = 10;
int hitsPerRound = 4;
Engine engine = null;
if (en instanceof Mech) {
engine = ((Mech) en).getEngine();
} else if (en instanceof Tank) {
explosionBTH = 12;
hitsPerRound = 1;
engine = ((Tank) en).getEngine();
} else {
engine = ((Aero) en).getEngine();
explosionBTH = 12;
hitsPerRound = 1;
}
// Non mechs and mechs that already rolled are safe
if (en.rolledForEngineExplosion || !(en instanceof Mech)) {
return false;
}
// ICE can always explode and roll every time hit
if (engine.isFusion()
&& (!game.getOptions().booleanOption("tacops_engine_explosions")
|| (en.engineHitsThisRound < hitsPerRound))) {
return false;
}
if (!engine.isFusion()) {
switch (hits) {
case 0:
return false;
case 1:
explosionBTH = 10;
break;
case 2:
explosionBTH = 7;
break;
case 3:
default:
explosionBTH = 4;
break;
}
}
int explosionRoll = Compute.d6(2);
boolean didExplode = explosionRoll >= explosionBTH;
Report r;
r = new Report(6150);
r.subject = en.getId();
r.indent(2);
r.addDesc(en);
r.add(en.engineHitsThisRound);
vDesc.addElement(r);
r = new Report(6155);
r.subject = en.getId();
r.indent(2);
r.add(explosionBTH);
r.add(explosionRoll);
vDesc.addElement(r);
if (!didExplode) {
// whew!
if (engine.isFusion()) {
en.rolledForEngineExplosion = true;
}
// fusion engines only roll 1/phase but ICE roll every time damaged
r = new Report(6160);
r.subject = en.getId();
r.indent(2);
vDesc.addElement(r);
} else {
en.rolledForEngineExplosion = true;
r = new Report(6165, Report.PUBLIC);
r.subject = en.getId();
r.indent(2);
vDesc.addElement(r);
vDesc.addAll(destroyEntity(en, "engine explosion", false, false));
// kill the crew
en.getCrew().setDoomed(true);
// This is a hack so MM.NET marks the mech as not salvageable
if (en instanceof Mech) {
en.destroyLocation(Mech.LOC_CT);
}
// ICE explosions don't hurt anyone else, but fusion do
if (engine.isFusion()) {
int engineRating = en.getEngine().getRating();
Report.addNewline(vDesc);
r = new Report(5400, Report.PUBLIC);
r.subject = en.getId();
r.indent(2);