IHex entityHex = game.getBoard().getHex(entity.getPosition());
// put in ASF heat build-up first because there are few differences
if (entity instanceof Aero) {
Aero a = (Aero) entity;
// should we even bother?
if (entity.isDestroyed() || entity.isDoomed() || entity.crew.isDoomed() || entity.crew.isDead()) {
continue;
}
// Engine hits cause excess heat for fighters
if (!((entity instanceof SmallCraft) || (entity instanceof Jumpship))) {
entity.heatBuildup += 2 * a.getEngineHits();
}
// add the heat we've built up so far.
entity.heat += entity.heatBuildup;
// how much heat can we sink?
int tosink = entity.getHeatCapacityWithWater();
tosink = Math.min(tosink, entity.heat);
entity.heat -= tosink;
r = new Report(5035);
r.subject = entity.getId();
r.addDesc(entity);
r.add(entity.heatBuildup);
r.add(tosink);
r.add(entity.heat);
addReport(r);
entity.heatBuildup = 0;
// add in the effects of heat
if ((entity instanceof Dropship) || (entity instanceof Jumpship)) {
// only check for a possible control roll
if (entity.heat > 0) {
int bonus = (int) Math.ceil(entity.heat / 100.0);
game.addControlRoll(new PilotingRollData(entity.getId(), bonus, "used too much heat"));
entity.heat = 0;
}
continue;
}
int autoShutDownHeat = 30;
boolean mtHeat = game.getOptions().booleanOption("tacops_heat");
if (mtHeat) {
autoShutDownHeat = 50;
}
// heat effects: start up
if ((entity.heat < autoShutDownHeat) && entity.isShutDown()) {
// only start up if not shut down by taser
if (entity.getTaserShutdownRounds() == 0) {
if (entity.heat < 14) {
// automatically starts up again
entity.setShutDown(false);
r = new Report(5045);
r.subject = entity.getId();
r.addDesc(entity);
addReport(r);
} else {
// roll for startup
int startup = 4 + (entity.heat - 14) / 4 * 2;
if (mtHeat) {
startup -= 5;
switch (entity.crew.getPiloting()) {
case 0:
case 1:
startup -= 2;
break;
case 2:
case 3:
startup -= 1;
break;
case 6:
case 7:
startup += 1;
break;
}
}
int suroll = Compute.d6(2);
r = new Report(5050);
r.subject = entity.getId();
r.addDesc(entity);
r.add(startup);
r.add(suroll);
if (suroll >= startup) {
// start 'er back up
entity.setShutDown(false);
r.choose(true);
} else {
r.choose(false);
}
addReport(r);
}
} else {
// if we're shutdown by a BA taser, we might activate
// again
if (entity.isBATaserShutdown()) {
int roll = Compute.d6(2);
if (roll >= 8) {
entity.setTaserShutdownRounds(0);
entity.setShutDown(false);
entity.setBATaserShutdown(false);
}
}
}
}
// heat effects: shutdown!
else if ((entity.heat >= 14) && !entity.isShutDown()) {
if (entity.heat >= autoShutDownHeat) {
r = new Report(5055);
r.subject = entity.getId();
r.addDesc(entity);
addReport(r);
// okay, now mark shut down
entity.setShutDown(true);
} else if (entity.heat >= 14) {
int shutdown = 4 + (entity.heat - 14) / 4 * 2;
if (mtHeat) {
shutdown -= 5;
switch (entity.crew.getPiloting()) {
case 0:
case 1:
shutdown -= 2;
break;
case 2:
case 3:
shutdown -= 1;
break;
case 6:
case 7:
shutdown += 1;
break;
}
}
int sdroll = Compute.d6(2);
r = new Report(5060);
r.subject = entity.getId();
r.addDesc(entity);
r.add(shutdown);
r.add(sdroll);
if (sdroll >= shutdown) {
// avoided
r.choose(true);
addReport(r);
} else {
// shutting down...
r.choose(false);
addReport(r);
// okay, now mark shut down
entity.setShutDown(true);
}
}
}
// heat effects: control effects (must make it unless already
// random moving)
if ((entity.heat >= 5) && !a.isRandomMove()) {
int controlavoid = 5 + (entity.heat >= 10 ? 1 : 0) + (entity.heat >= 15 ? 1 : 0) + (entity.heat >= 20 ? 1 : 0) + (entity.heat >= 25 ? 2 : 0);
int controlroll = Compute.d6(2);
r = new Report(9210);
r.subject = entity.getId();
r.addDesc(entity);
r.add(controlavoid);
r.add(controlroll);
if (controlroll >= controlavoid) {
// in control
r.choose(true);
addReport(r);
} else {
// out of control
r.choose(false);
addReport(r);
// if not already out of control, this may lead to
// elevation decline
if (!a.isOutControl() && game.getBoard().inAtmosphere()) {
int loss = Compute.d6(1);
r = new Report(9366);
r.newlines = 0;
r.subject = entity.getId();
r.addDesc(entity);
r.add(loss);
addReport(r);
// check for crash
if ((a.getElevation() - loss) <= game.getBoard().getHex(a.getPosition()).ceiling()) {
a.setElevation(0);
addReport(processCrash(entity, a.getCurrentVelocity()));
} else {
a.setElevation(a.getElevation() - loss);
}
}
// force unit out of control through heat
a.setOutCtrlHeat(true);
a.setRandomMove(true);
}
} //End of Entity Instance of Aero
// heat effects: ammo explosion!
if (entity.heat >= 19) {