for ( int dpspot = 0, dpcount = dp.specificDammage.size(); dpspot < dpcount; dpspot++ ) {  SpecDam sd = ((SpecDam)dp.specificDammage.elementAt(dpspot));  if (dp.entity.locations() <= sd.loc) System.out.println("\tInvalid Location Specified " + sd.loc); else {  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) {  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);     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 {   dp.entity.setArmor(sd.setArmorTo-1,sd.loc); } } else { dp.entity.setArmor(sd.setArmorTo,sd.loc); } } } } } } }   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++) {  CritHit ch = ((CritHit)chp.critHits.elementAt(chpspot));   if (chp.entity.locations() <= ch.loc) System.out.println("\n\tInvalid Location Specified " + ch.loc); else {  if ( chp.entity instanceof Mech || chp.entity instanceof Protomech ) {   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 ); }  else if ( ch.slot < 0 || ch.slot > chp.entity.getNumberOfCriticals(ch.loc) ) { System.out.println ( "\n\tInvalid Slot Specified " + ch.loc + ":" + (ch.slot+1) ); }  else { cs = chp.entity.getCritical(ch.loc, ch.slot); }   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) ); } }  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) ); }  }  }  }   System.out.println();  }     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++) {  SetAmmoTo sa = ((SetAmmoTo)sap.ammoSetTo.elementAt(sapSpot));   if (sap.entity instanceof Mech ) { if (sa.slot < sap.entity.getNumberOfCriticals(sa.loc)) {   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 ) {  ammo.setShotsLeft(Math.min(sa.setAmmoTo,ammo.getShotsLeft())); } } } } }
    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));            }        }    }