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]; } }
  public void characterize() {    this.entity = game.getEntity(this.entity.getId());    this.old = new EntityState(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(Compute.getBasePilotingRoll(game,entity.getId()).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.MinRanges = 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 = Compute.getExpectedDamage(weapon);      double odds = 0;      for (int range = 1; range <= lr && range <= MAX_RANGE; range++) {        if (range <= min) {          if (range < 7) this.MinRanges[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.MinRanges.length; r++) {      if (num_weapons > 0) this.MinRanges[r] = (int)Math.round(((double)this.MinRanges[r])/(double)num_weapons);      //System.out.println(this.MinRanges[r]);    }    /*for (int a = this.FIRST_ARC; a <= this.LAST_ARC; a++) {      for (int r = 1; r <= this.MAX_RANGE; r++) {        System.out.print(this.damages[a][r]+" ");      }      System.out.println();    }*/    //what type of overheater am I    int heat = heat_total - capacity ;    if (heat < 8 && heat > 3) {      this.overheat = this.OVERHEAT_LOW;    } else if (heat > 12) {      this.overheat = this.OVERHEAT_HIGH;    }    //only worries about external armor    double max = 1;    for(int arc = this.FIRST_ARC; arc <= this.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 {           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[this.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[this.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;           }      }      this.armor_health[arc] = ((double)total*points)/242;      if (this.armor_health[arc] > max) {        max = this.armor_health[arc];      }      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 = this.FIRST_ARC; arc <= this.LAST_PRIMARY_ARC; arc++) {      this.armor_percent[arc] = this.armor_health[arc]/max;    }        this.computeRange();  }