int total = 0; int points = 0; int temp[] = null; boolean rear = false; if (this.entity instanceof Tank) { switch (arc) { case ToHitData.SIDE_FRONT : temp = this.getArmorValues(Tank.LOC_FRONT, false); total += 2 * temp[0]; points += 2 * temp[1]; break; case ToHitData.SIDE_REAR : temp = this.getArmorValues(Tank.LOC_REAR, false); total += 2 * temp[0]; points += 2 * temp[1]; break; case ToHitData.SIDE_RIGHT : temp = this.getArmorValues(Tank.LOC_RIGHT, false); total += 2 * temp[0]; points += 2 * temp[1]; break; case ToHitData.SIDE_LEFT : temp = this.getArmorValues(Tank.LOC_LEFT, false); total += 2 * temp[0]; points += 2 * temp[1]; break; } } else if (this.entity instanceof Infantry) { for (int i = 0; i < this.entity.locations(); i++) { temp = this.getArmorValues(i, false); total += 2 * temp[0]; points += 2 * temp[1]; } } else { switch (arc) { case ToHitData.SIDE_REAR : rear = true; case ToHitData.SIDE_FRONT : temp = this.getArmorValues(Mech.LOC_CT, rear); total += 2 * temp[0]; points += 2 * temp[1]; temp = this.getArmorValues(Mech.LOC_RARM, rear); total += 2 * temp[0]; points += 2 * temp[1]; temp = this.getArmorValues(Mech.LOC_RLEG, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_RT, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_LT, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_LLEG, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_LARM, rear); total += 2 * temp[0]; points += 2 * temp[1]; temp = this.getArmorValues(Mech.LOC_HEAD, rear); total += temp[0]; points += temp[1]; break; case ToHitData.SIDE_LEFT : temp = this.getArmorValues(Mech.LOC_CT, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_RARM, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_RLEG, rear); this.leg_health[RIGHT_LEG] = temp[0] / entity.getOArmor(Mech.LOC_RLEG); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_RT, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_LT, rear); total += 2 * temp[0]; points += 2 * temp[1]; temp = this.getArmorValues(Mech.LOC_LLEG, rear); this.leg_health[LEFT_LEG] = temp[0] / entity.getOArmor(Mech.LOC_LLEG); total += 2 * temp[0]; points += 2 * temp[1]; temp = this.getArmorValues(Mech.LOC_LARM, rear); total += 2 * temp[0]; points += 2 * temp[1]; temp = this.getArmorValues(Mech.LOC_HEAD, rear); total += temp[0]; points += temp[1]; break; case ToHitData.SIDE_RIGHT : temp = this.getArmorValues(Mech.LOC_CT, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_RARM, rear); total += 2 * temp[0]; points += 2 * temp[1]; temp = this.getArmorValues(Mech.LOC_RLEG, rear); total += 2 * temp[0]; points += 2 * temp[1]; temp = this.getArmorValues(Mech.LOC_RT, rear); total += 2 * temp[0]; points += 2 * temp[1]; temp = this.getArmorValues(Mech.LOC_LT, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_LLEG, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_LARM, rear); total += temp[0]; points += temp[1]; temp = this.getArmorValues(Mech.LOC_HEAD, rear); total += temp[0]; points += temp[1]; break; }
double total = 0; for (int i = 0; i < armor[arc].length; i++) { total += armor[arc][i] * getArmorValue(i, arc == SIDE_REAR);
    public void characterize() {        this.entity = tb.game.getEntity(this.entity.getId());        this.current = new MoveOption(tb.game, this);        this.bv = entity.calculateBattleValue();        this.gunnery = entity.getCrew().getGunnery();        this.piloting = entity.getCrew().getGunnery();        this.runMP = entity.getRunMP();        this.jumpMP = entity.getJumpMP();        this.overall_armor_percent = entity.getArmorRemainingPercent();        this.base_psr_odds = Compute.oddsAbove(entity.getBasePilotingRoll().getValue()) / 100;        //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 (entity.heat > 16)            heat_mod = .35;        int capacity = entity.getHeatCapacity();        int heat_total = 0;        Enumeration weapons = entity.getWeapons();        int num_weapons = 0;        this.minRangeMods = new int[7];        while (weapons.hasMoreElements()) {            num_weapons++;            Mounted m = (Mounted) weapons.nextElement();            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;            for (int range = 1; range <= lr && range <= MAX_RANGE; range++) {                if (range <= min) {                    if (range < 7)                        this.minRangeMods[range] += 1 + min - range;                    odds = Compute.oddsAbove(this.gunnery + 1 + min - range) / 100.0;                } else if (range <= sr) {                    odds = Compute.oddsAbove(this.gunnery) / 100.0;                } else if (range <= mr) {                    odds = Compute.oddsAbove(this.gunnery + 2) / 100.0;                } else if (range <= lr) {                    odds = Compute.oddsAbove(this.gunnery + 4) / 100.0;                }                //weapons unaffected by heat don't get penalized                this.addDamage(                    arc,                    entity.isSecondaryArcWeapon(entity.getEquipmentNum(m)),                    range,                    ed * odds * ((weapon.getHeat() > 0) ? heat_mod : 1));                this.long_range = Math.max(this.long_range, range);            }        }        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;        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;        for (int arc = FIRST_ARC; arc <= LAST_PRIMARY_ARC; arc++) {            int total = 0;            int points = 0;            int temp[] = null;            boolean rear = false;            if (this.entity instanceof Tank) {                switch (arc) {                    case ToHitData.SIDE_FRONT :                        temp = this.getArmorValues(Tank.LOC_FRONT, false);                        total += 2 * temp[0];                        points += 2 * temp[1];                        break;                    case ToHitData.SIDE_REAR :                        temp = this.getArmorValues(Tank.LOC_REAR, false);                        total += 2 * temp[0];                        points += 2 * temp[1];                        break;                    case ToHitData.SIDE_RIGHT :                        temp = this.getArmorValues(Tank.LOC_RIGHT, false);                        total += 2 * temp[0];                        points += 2 * temp[1];                        break;                    case ToHitData.SIDE_LEFT :                        temp = this.getArmorValues(Tank.LOC_LEFT, false);                        total += 2 * temp[0];                        points += 2 * temp[1];                        break;                }            } else if (this.entity instanceof Infantry) {                for (int i = 0; i < this.entity.locations(); i++) {                    temp = this.getArmorValues(i, false);                    total += 2 * temp[0];                    points += 2 * temp[1];                }            } else {                switch (arc) {                    case ToHitData.SIDE_REAR :                        rear = true;                    case ToHitData.SIDE_FRONT :                        temp = this.getArmorValues(Mech.LOC_CT, rear);                        total += 2 * temp[0];                        points += 2 * temp[1];                        temp = this.getArmorValues(Mech.LOC_RARM, rear);                        total += 2 * temp[0];                        points += 2 * temp[1];                        temp = this.getArmorValues(Mech.LOC_RLEG, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_RT, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_LT, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_LLEG, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_LARM, rear);                        total += 2 * temp[0];                        points += 2 * temp[1];                        temp = this.getArmorValues(Mech.LOC_HEAD, rear);                        total += temp[0];                        points += temp[1];                        break;                    case ToHitData.SIDE_LEFT :                        temp = this.getArmorValues(Mech.LOC_CT, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_RARM, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_RLEG, rear);                        this.leg_health[RIGHT_LEG] = temp[0] / entity.getOArmor(Mech.LOC_RLEG);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_RT, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_LT, rear);                        total += 2 * temp[0];                        points += 2 * temp[1];                        temp = this.getArmorValues(Mech.LOC_LLEG, rear);                        this.leg_health[LEFT_LEG] = temp[0] / entity.getOArmor(Mech.LOC_LLEG);                        total += 2 * temp[0];                        points += 2 * temp[1];                        temp = this.getArmorValues(Mech.LOC_LARM, rear);                        total += 2 * temp[0];                        points += 2 * temp[1];                        temp = this.getArmorValues(Mech.LOC_HEAD, rear);                        total += temp[0];                        points += temp[1];                        break;                    case ToHitData.SIDE_RIGHT :                        temp = this.getArmorValues(Mech.LOC_CT, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_RARM, rear);                        total += 2 * temp[0];                        points += 2 * temp[1];                        temp = this.getArmorValues(Mech.LOC_RLEG, rear);                        total += 2 * temp[0];                        points += 2 * temp[1];                        temp = this.getArmorValues(Mech.LOC_RT, rear);                        total += 2 * temp[0];                        points += 2 * temp[1];                        temp = this.getArmorValues(Mech.LOC_LT, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_LLEG, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_LARM, rear);                        total += temp[0];                        points += temp[1];                        temp = this.getArmorValues(Mech.LOC_HEAD, rear);                        total += temp[0];                        points += temp[1];                        break;                }            }            int max_points = 22*11;            if (entity instanceof Infantry) {                max_points = 4;            } else if (entity instanceof Tank) {                max_points = 4;            }            this.armor_health[arc] = ((double) total * points) / max_points;            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();    }