heat += entity.getEngineCritHeat(); }  if (entity.getPosition() != null){ if (tb.game.getBoard().getHex(entity.getPosition()) != null) { if (tb.game.getBoard().getHex(entity.getPosition()). terrainLevel(Terrains.FIRE) == 2) { heat += 5; } } }  heat += tb.game.getTemperatureDifference(); if (heat < 8 && heat > 3) {
heat = heat_total - capacity;  if (entity instanceof Mech && entity.isStealthActive()){ heat += 10; }  if (entity.infernos.isStillBurning()){ heat += 6; }  if (entity instanceof Mech){ heat += entity.getEngineCritHeat(); }  if (entity.getPosition() != null){ if (tb.game.getBoard().getHex(entity.getPosition()) != null) { if (tb.game.getBoard().getHex(entity.getPosition()). terrainLevel(Terrains.FIRE) == 2) { heat += 5; } } }  heat += tb.game.getTemperatureDifference(); }  if (heat <= 4){ this.overheat = OVERHEAT_NONE; } if (heat > 3){
    public void characterize() {        this.entity = tb.game.getEntity(this.entity.getId());        this.current = new MoveOption(tb.game, this);        this.bv = entity.calculateBattleValue();        this.runMP = entity.getRunMP();        this.jumpMP = entity.getJumpMP();        this.overall_armor_percent = entity.getArmorRemainingPercent();        this.base_psr_odds = Compute.oddsAbove(entity.getBasePilotingRoll().getValue()) / 100;        // If this is a Mech equipped with TSM, push for the sweet spot at 9 heat        if (this.entity instanceof Mech){            if (((Mech)tb.game.getEntity(this.entity.getId())).hasTSM()){                this.tsm_offset = true;            }        }        //begin weapons characterization        double heat_mod = .9; //these estimates are consistently too high        if (entity.heat > 7)            heat_mod = .8; //reduce effectiveness        if (entity.heat > 12)            heat_mod = .5;        if (this.tsm_offset){            if (entity.heat == 9){                heat_mod = 1.0;            }            if (entity.heat < 12 && entity.heat > 9){                heat_mod = 0.8;            }        }        if (entity.heat > 16)            heat_mod = .35;        int capacity = entity.getHeatCapacity();        int heat_total = 0;        int num_weapons = 0;        this.minRangeMods = new int[7];        for(Mounted m : entity.getWeaponList()) {            num_weapons++;            int arc = entity.getWeaponArc(entity.getEquipmentNum(m));            WeaponType weapon = (WeaponType) m.getType();            final boolean usesAmmo = weapon.getAmmoType() != AmmoType.T_NA;            final Mounted ammo = usesAmmo ? m.getLinked() : null;            if (m.isDestroyed())                continue;            if (usesAmmo && (ammo == null || ammo.getShotsLeft() == 0))                continue;            heat_total += weapon.getHeat();            int min = weapon.getMinimumRange();            int sr = weapon.getShortRange();            int mr = weapon.getMediumRange();            int lr = weapon.getLongRange();            double ed = CEntity.getExpectedDamage(weapon);            double odds = 0;            int gunnery = entity.getCrew().getGunnery();            for (int curRange = 1; curRange <= lr && curRange <= MAX_RANGE;                 curRange++) {                if (curRange <= min) {                    if (curRange < 7)                        this.minRangeMods[curRange] += 1 + min - curRange;                    odds = Compute.oddsAbove(gunnery + 1 + min - curRange)                        / 100.0;                } else if (curRange <= sr) {                    odds = Compute.oddsAbove(gunnery) / 100.0;                } else if (curRange <= mr) {                    odds = Compute.oddsAbove(gunnery + 2) / 100.0;                } else if (curRange <= lr) {                    odds = Compute.oddsAbove(gunnery + 4) / 100.0;                }                //weapons unaffected by heat don't get penalized                this.addDamage(                    arc,                    entity.isSecondaryArcWeapon(entity.getEquipmentNum(m)),                    curRange,                    ed * odds * ((weapon.getHeat() > 0) ? heat_mod : 1));                this.long_range = Math.max(this.long_range, curRange);            }        }        for (int r = 1; r < this.minRangeMods.length; r++) {            if (num_weapons > 0)                this.minRangeMods[r] = (int) Math.round(((double) this.minRangeMods[r]) / (double) num_weapons);        }        //what type of overheater am I        int heat = heat_total - capacity;        // Include heat from active stealth armor        if (entity instanceof Mech && entity.isStealthActive()){            heat += 10;        }        // Include heat from infernos        if (entity.infernos.isStillBurning()){            heat += 6;        }        // Include heat from engine hits        if (entity instanceof Mech){            heat += entity.getEngineCritHeat();        }        // Include heat for standing in a fire        if (entity.getPosition() != null){            if (tb.game.getBoard().getHex(entity.getPosition()) != null) {                if (tb.game.getBoard().getHex(entity.getPosition()).                        terrainLevel(Terrains.FIRE) == 2) {                    heat += 5;                }            }        }        // Include heat from ambient temperature        heat += tb.game.getTemperatureDifference();        if (heat < 8 && heat > 3) {            this.overheat = OVERHEAT_LOW;        } else if (heat > 12) {            this.overheat = OVERHEAT_HIGH;        }        //only worries about external armor        double max = 1;        double armor[][] = MECH_ARMOR;        if (this.entity instanceof Tank) {            if (((Tank) entity).hasNoTurret()) {                armor = TANK_ARMOR;            } else {                armor = TANK_WT_ARMOR;            }        } else if (this.entity instanceof Infantry) {            armor = INFANTRY_ARMOR;        } else if (this.entity instanceof Protomech) {            if (((Protomech) entity).hasMainGun()) {                armor = PROTOMECH_MG_ARMOR;            } else {                armor = PROTOMECH_ARMOR;            }        } else if (this.entity instanceof GunEmplacement) {            armor = ((GunEmplacement) entity).hasTurret()                ? GUN_EMPLACEMENT_TURRET_ARMOR : GUN_EMPLACEMENT_ARMOR;        }        for (int arc = FIRST_ARC; arc <= LAST_PRIMARY_ARC; arc++) {            double total = 0;            for (int i = 0; i < armor[arc].length; i++) {                total += armor[arc][i] * getArmorValue(i, arc == ToHitData.SIDE_REAR);            }            this.armor_health[arc] = total;            max = Math.max(armor_health[arc], max);        }        this.avg_armor = (armor_health[0] + armor_health[1] + armor_health[2] + armor_health[3]) / 4;        this.avg_iarmor = this.entity.getTotalInternal() / 5;        for (int arc = FIRST_ARC; arc <= LAST_PRIMARY_ARC; arc++) {            this.armor_percent[arc] = this.armor_health[arc] / max;        }        this.computeRange();    }