( CriticalSlot.TYPE_SYSTEM, ch.slot );
( CriticalSlot.TYPE_SYSTEM, ch.slot+1 );
    public void applyDamage(Server s) {        for (int x = 0, n = m_vDamagePlans.size(); x < n; x++) {            DamagePlan dp = (DamagePlan)m_vDamagePlans.elementAt(x);            System.out.println( "Applying damage to " +                                dp.entity.getShortName() );            for (int y = 0; y < dp.nBlocks; y++) {                HitData hit = dp.entity.rollHitLocation(ToHitData.HIT_NORMAL,                         ToHitData.SIDE_FRONT);                System.out.println(s.damageEntity(dp.entity, hit, 5));            }                            //Apply Spec Dammage            for ( int dpspot = 0, dpcount = dp.specificDammage.size();                  dpspot < dpcount; dpspot++ ) {                //Get the SpecDam                SpecDam sd = ((SpecDam)dp.specificDammage.elementAt(dpspot));                            if (dp.entity.locations() <= sd.loc)    //Make sure the the location is valid                     System.out.println("\tInvalid Location Specified " + sd.loc);                else {                    //Infantry only take dammage to "internal"                    if  (sd.internal || ((dp.entity instanceof Infantry ) && !(dp.entity instanceof BattleArmor ))) {                      if (dp.entity.getOInternal(sd.loc) > sd.setArmorTo) {                        dp.entity.setInternal(sd.setArmorTo,sd.loc);                        System.out.println("\tSet Armor Value for (Internal " + dp.entity.getLocationName(sd.loc) + ") To " +  sd.setArmorTo);                        if (sd.setArmorTo == 0) {                            //Mark destroy if internal armor is set to zero                            System.out.println("\tSection Destoyed " + dp.entity.getLocationName(sd.loc));                            s.destroyLocation(dp.entity,sd.loc);                        }                      }                    }                    else {                      if (sd.rear && dp.entity.hasRearArmor(sd.loc)) {                        if (dp.entity.getOArmor(sd.loc,true) > sd.setArmorTo) {                          System.out.println("\tSet Armor Value for (Rear " + dp.entity.getLocationName(sd.loc) + ") To " +  sd.setArmorTo);                          dp.entity.setArmor(sd.setArmorTo,sd.loc,true);                        }                      }                      else {                        if (dp.entity.getOArmor(sd.loc,false) > sd.setArmorTo) {                          System.out.println("\tSet Armor Value for (" + dp.entity.getLocationName(sd.loc) + ") To " +  sd.setArmorTo);                                                    //Battle Armor Handled Differently                          //If armor set to Zero kill the Armor sport which represents                          //one member of the squad                          if (dp.entity instanceof BattleArmor ) {                              if (sd.setArmorTo ==0 ) {                                dp.entity.setArmor(Entity.ARMOR_DOOMED, sd.loc, false);                                dp.entity.setInternal(Entity.ARMOR_DOOMED, sd.loc);                              }                              else {                                  //For some reason setting armor to 1 will result in 2 armor points                                  //left on the GUI Dont know why but adjust here!                                dp.entity.setArmor(sd.setArmorTo-1,sd.loc);                              }                          }                          else {                            dp.entity.setArmor(sd.setArmorTo,sd.loc);                          }                        }                      }                    }                }            }        }                //Loop throught Crit Hits        for (int chSpot = 0, chCount = m_vCritHitPlans.size(); chSpot < chCount; chSpot++) {            CritHitPlan chp = (CritHitPlan)m_vCritHitPlans.elementAt(chSpot);            System.out.print("Applying Critical Hits to " + chp.entity.getShortName());            for (int chpspot = 0, chpcount = chp.critHits.size();chpspot < chpcount; chpspot++) {                 //Get the ScritHit                CritHit ch = ((CritHit)chp.critHits.elementAt(chpspot));                                    // Apply a critical hit to the indicated slot.                if (chp.entity.locations() <= ch.loc)                    System.out.println("\n\tInvalid Location Specified " + ch.loc);                else {                    // Make sure that we have crit spot to hit                    if ( chp.entity instanceof Mech                         || chp.entity instanceof Protomech ) {                         // Is this a torso weapon slot?                        CriticalSlot cs = null;                        if ( chp.entity instanceof Protomech &&                             Protomech.LOC_TORSO == ch.loc &&                             ( Protomech.SYSTEM_TORSO_WEAPON_A == ch.slot ||                               Protomech.SYSTEM_TORSO_WEAPON_B == ch.slot ) ) {                            cs = new CriticalSlot                                ( CriticalSlot.TYPE_SYSTEM, ch.slot );                        }                        // Is this a valid slot number?                        else if ( ch.slot < 0 || ch.slot >                                  chp.entity.getNumberOfCriticals(ch.loc) ) {                            System.out.println                                ( "\n\tInvalid Slot Specified " +                                  ch.loc + ":" + (ch.slot+1) );                        }                        // Get the slot from the entity.                        else {                            cs = chp.entity.getCritical(ch.loc, ch.slot);                        }                        // Ignore invalid, unhittable, and damaged slots.                        if ( null == cs || !cs.isHittable() ) {                            System.out.println                                ( "\n\tSlot not hittable " +                                  ch.loc + ":" + (ch.slot+1) );                        } else {                            System.out.print( s.applyCriticalHit(chp.entity,                                                                   ch.loc,                                                                   cs,                                                                   false) );                        }                    }                    // Handle Tanks differently.                    else if (chp.entity instanceof Tank) {                        if ( ch.slot < 0 || ch.slot >= 6 ) {                            System.out.println                                ( "\n\tInvalid Slot Specified " +                                  ch.loc + ":" + (ch.slot+1) );                        } else {                            CriticalSlot cs = new CriticalSlot                                ( CriticalSlot.TYPE_SYSTEM, ch.slot );                            System.out.print( s.applyCriticalHit(chp.entity,                                                                   Entity.NONE,                                                                   cs,                                                                   false) );                        }                    } // End have-tank                } // End have-valid-location            } // Handle the next critical hit            // Print a line between hit plans.            System.out.println();                    } // Handle the next critical hit plan                        //Loop throught Set Ammo To        for (int saSpot = 0, saCount = m_vSetAmmoTo.size(); saSpot < saCount; saSpot++) {            SetAmmoPlan sap = (SetAmmoPlan)m_vSetAmmoTo.elementAt(saSpot);            System.out.println("Applying Ammo Adjustment to " + sap.entity.getShortName());            for (int sapSpot = 0, sapCount = sap.ammoSetTo.size();sapSpot < sapCount; sapSpot++) {                 //Get the ScritHit                SetAmmoTo sa = ((SetAmmoTo)sap.ammoSetTo.elementAt(sapSpot));                                //Only can be done against Mechs                if (sap.entity instanceof Mech ) {                     if (sa.slot < sap.entity.getNumberOfCriticals(sa.loc)) {                        //Get the piece of Eqipment and Check to make sure it is                        //a ammo item then set its amount!                        CriticalSlot cs = sap.entity.getCritical(sa.loc, sa.slot);                        if (!(cs == null)) {                            Mounted ammo = sap.entity.getEquipment(sap.entity.getCritical(sa.loc, sa.slot).getIndex());                            if (ammo.getType() instanceof AmmoType ) {                              //Also make sure we dont exceed the max aloud                              ammo.setShotsLeft(Math.min(sa.setAmmoTo,ammo.getShotsLeft()));                            }                        }                    }                }            }        }    }