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) {
int boom = 4 + (entity.heat >= 23 ? 2 : 0) + (entity.heat >= 28 ? 2 : 0);
if (mtHeat) {
boom += (entity.heat >= 35 ? 2 : 0) + (entity.heat >= 40 ? 2 : 0) + (entity.heat >= 45 ? 2 : 0);
// Last line is a crutch; 45 heat should be no roll
// but automatic explosion.
}
int boomroll = Compute.d6(2);
r = new Report(5065);
r.subject = entity.getId();
r.addDesc(entity);
r.add(boom);
r.add(boomroll);
if (boomroll >= boom) {
// mech is ok
r.choose(true);
addReport(r);
} else {
// boom!
r.choose(false);
addReport(r);
addReport(explodeAmmoFromHeat(entity));
}
}
// heat effects: pilot damage
if (entity.heat >= 21) {
int ouch = 6 + (entity.heat >= 27 ? 3 : 0);
int ouchroll = Compute.d6(2);
r = new Report(5075);
r.subject = entity.getId();
r.addDesc(entity);
r.add(ouch);
r.add(ouchroll);
if (ouchroll >= ouch) {
// pilot is ok
r.choose(true);
addReport(r);
} else {
// pilot is hurting
r.choose(false);
addReport(r);
addReport(damageCrew(entity, 1));
}
}
// The pilot may have just expired.
if ((entity.crew.isDead() || entity.crew.isDoomed()) && !entity.crew.isEjected()) {
r = new Report(5080);
r.subject = entity.getId();
r.addDesc(entity);
addReport(r);
addReport(destroyEntity(entity, "pilot death", true));
}
continue;
}
// heat doesn't matter for non-mechs
if (!(entity instanceof Mech)) {
entity.heatBuildup = 0;
entity.heatFromExternal = 0;
if (entity.infernos.isStillBurning()) {
doFlamingDamage(entity);
}
if (entity.getTaserShutdownRounds() == 0) {
entity.setShutDown(false);
entity.setBATaserShutdown(false);
} 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);
}
}
}
continue;
}
// Meks gain heat from inferno hits.
if (entity.infernos.isStillBurning()) {
int infernoHeat = entity.infernos.getHeat();
entity.heatFromExternal += infernoHeat;
r = new Report(5010);
r.subject = entity.getId();
r.add(infernoHeat);
addReport(r);
}
// should we even bother?
if (entity.isDestroyed() || entity.isDoomed() || entity.crew.isDoomed() || entity.crew.isDead()) {
continue;
}
// engine hits add a lot of heat, provided the engine is on
entity.heatBuildup += entity.getEngineCritHeat();
// If a Mek had an active Stealth suite, add 10 heat.
if ((entity instanceof Mech) && entity.isStealthOn()) {
entity.heatBuildup += 10;
r = new Report(5015);
r.subject = entity.getId();
addReport(r);
}
//void sig adds 10 heat
if ((entity instanceof Mech) && entity.isVoidSigActive()) {
entity.heatBuildup += 10;
r = new Report(5016);
r.subject = entity.getId();
addReport(r);
}
//null sig adds 10 heat
if ((entity instanceof Mech) && entity.isNullSigActive()) {
entity.heatBuildup += 10;
r = new Report(5017);
r.subject = entity.getId();
addReport(r);
}
//chameleon polarization field adds 6
if ((entity instanceof Mech) && entity.isChameleonShieldActive()) {
entity.heatBuildup += 6;
r = new Report(5014);
r.subject = entity.getId();
addReport(r);
}
// If a Mek is in extreme Temperatures, add or subtract one
// heat per 10 degrees (or fraction of 10 degrees) above or
// below 50 or -30 degrees Celsius
if ((entity instanceof Mech) && (game.getPlanetaryConditions().getTemperatureDifference(50, -30) != 0) && !((Mech) entity).hasLaserHeatSinks()) {
if (game.getPlanetaryConditions().getTemperature() > 50) {
entity.heatFromExternal += game.getPlanetaryConditions().getTemperatureDifference(50, -30);
r = new Report(5020);
r.subject = entity.getId();
r.add(game.getPlanetaryConditions().getTemperatureDifference(50, -30));
addReport(r);
} else {
entity.heatFromExternal -= game.getPlanetaryConditions().getTemperatureDifference(50, -30);
r = new Report(5025);
r.subject = entity.getId();
r.add(game.getPlanetaryConditions().getTemperatureDifference(50, -30));
addReport(r);
}
}
// Add +5 Heat if the hex you're in is on fire
// and was on fire for the full round.
if (entityHex != null) {
if (entityHex.containsTerrain(Terrains.FIRE) && (entityHex.getFireTurn() > 0)
&& (entity.getElevation() <= 1)) {
entity.heatFromExternal += 5;
r = new Report(5030);
r.subject = entity.getId();
addReport(r);
}
int magma = entityHex.terrainLevel(Terrains.MAGMA);
if ((magma > 0) && (entity.getElevation() == 0)) {
entity.heatFromExternal += 5 * magma;
r = new Report(5032);
r.subject = entity.getId();
r.add(5 * magma);
addReport(r);
}
}
// Check the mech for vibroblades if so then check to see if any
// are active and what heat they will produce.
if (entity.hasVibroblades()) {
int vibroHeat = 0;
vibroHeat = entity.getActiveVibrobladeHeat(Mech.LOC_RARM);
vibroHeat += entity.getActiveVibrobladeHeat(Mech.LOC_LARM);
if (vibroHeat > 0) {
r = new Report(5018);
r.subject = entity.getId();
r.add(vibroHeat);
addReport(r);
entity.heatBuildup += vibroHeat;
}
}
int capHeat = 0;
for (Mounted m : entity.getEquipment()) {
if (m.hasChargedCapacitor() && !m.isUsedThisRound()) {
capHeat += 5;
}
}
if (capHeat > 0) {
r = new Report(5019);
r.subject = entity.getId();
r.add(capHeat);
addReport(r);
entity.heatBuildup += capHeat;
}
// Add heat from external sources to the heat buildup
entity.heatBuildup += Math.min(15, entity.heatFromExternal);
entity.heatFromExternal = 0;
// if heatbuildup is negative due to temperature, set it to 0
// for prettier turnreports
if (entity.heatBuildup < 0) {
entity.heatBuildup = 0;
}
// add the heat we've built up so far.
entity.heat += entity.heatBuildup;
// how much heat can we sink?
int tosink = entity.getHeatCapacityWithWater();
if ( entity.getCoolantFailureAmount() > 0 ){
int failureAmount = entity.getCoolantFailureAmount();
r = new Report(5520);
r.subject = entity.getId();
r.add(failureAmount);
tosink -= failureAmount;
}
// should we use a coolant pod?
int safeHeat = entity.hasInfernoAmmo() ? 9 : 13;
int possibleSinkage = ((Mech) entity).getNumberOfSinks() - entity.getCoolantFailureAmount();
for (Mounted m : entity.getEquipment()) {
if (m.getType() instanceof AmmoType) {
AmmoType at = (AmmoType) m.getType();
if ((at.getAmmoType() == AmmoType.T_COOLANT_POD) && m.isAmmoUsable()) {
EquipmentMode mode = m.curMode();
if (mode.equals("dump")) {
r = new Report(5260);
r.subject = entity.getId();
addReport(r);
m.setShotsLeft(0);
tosink += possibleSinkage;
break;
}
if (mode.equals("safe") && (entity.heat - tosink > safeHeat)) {
r = new Report(5265);
r.subject = entity.getId();
addReport(r);
m.setShotsLeft(0);
tosink += possibleSinkage;
break;
}
if (mode.equals("efficient") && (entity.heat - tosink >= possibleSinkage)) {
r = new Report(5270);
r.subject = entity.getId();
addReport(r);
m.setShotsLeft(0);
tosink += possibleSinkage;
break;
}
}
}
}
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;
// Does the unit have inferno ammo?
if (entity.hasInfernoAmmo()) {
// Roll for possible inferno ammo explosion.
if (entity.heat >= 10) {
int boom = 4 + (entity.heat >= 14 ? 2 : 0) + (entity.heat >= 19 ? 2 : 0) + (entity.heat >= 23 ? 2 : 0) + (entity.heat >= 28 ? 2 : 0);
int boomroll = Compute.d6(2);
r = new Report(5040);
r.subject = entity.getId();
r.addDesc(entity);
r.add(boom);
r.add(boomroll);
if (boomroll >= boom) {
// avoided
r.choose(true);
addReport(r);
} else {
r.choose(false);
addReport(r);
addReport(explodeInfernoAmmoFromHeat(entity));
}
}
} // End avoid-inferno-explosion
int autoShutDownHeat;
boolean mtHeat;
if (game.getOptions().booleanOption("tacops_heat")) {
autoShutDownHeat = 50;
mtHeat = true;
} else {
autoShutDownHeat = 30;
mtHeat = false;
}
// heat effects: start up
if ((entity.heat < autoShutDownHeat) && entity.isShutDown() && !entity.isStalled()) {
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;
}
if (entity instanceof QuadMech) {
startup -= 2;
}
}
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 >= 7) {
entity.setTaserShutdownRounds(0);
entity.setShutDown(false);
entity.setBATaserShutdown(false);
}
}
}
}
// heat effects: shutdown!
// Don't shut down if you just restarted.
else if ((entity.heat >= 14) && !entity.isShutDown()) {
if (entity.heat >= autoShutDownHeat) {
r = new Report(5055);
r.subject = entity.getId();
r.addDesc(entity);
addReport(r);
// add a piloting roll and resolve immediately
game.addPSR(new PilotingRollData(entity.getId(), 3, "reactor shutdown"));
addReport(resolvePilotingRolls());
// 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;
}
if (entity instanceof QuadMech) {
shutdown -= 2;
}
}
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);
// add a piloting roll and resolve immediately
game.addPSR(new PilotingRollData(entity.getId(), 3, "reactor shutdown"));
addReport(resolvePilotingRolls());
// okay, now mark shut down
entity.setShutDown(true);
}
}