public static int missilesHit(int missiles,int nMod,boolean hotloaded,boolean streak,boolean advancedAMS){
  int nRoll=Compute.d6(2);
  if (hotloaded) {
    int roll1=Compute.d6();
    int roll2=Compute.d6();
    int roll3=Compute.d6();
    int lowRoll1=0;
    int lowRoll2=0;
    if ((roll1 <= roll2) && (roll1 <= roll3)) {
      lowRoll1=roll1;
      lowRoll2=Math.min(roll2,roll3);
    }
 else     if ((roll2 <= roll1) && (roll2 <= roll3)) {
      lowRoll1=roll2;
      lowRoll2=Math.min(roll1,roll3);
    }
 else     if ((roll3 <= roll1) && (roll3 <= roll2)) {
      lowRoll1=roll3;
      lowRoll2=Math.min(roll2,roll1);
    }
    nRoll=lowRoll1 + lowRoll2;
  }
  if (streak) {
    nRoll=11;
  }
  nRoll+=nMod;
  if (!advancedAMS) {
    nRoll=Math.min(Math.max(nRoll,2),12);
  }
 else {
    nRoll=Math.min(nRoll,12);
  }
  if (nRoll < 2) {
    return 0;
  }
  for (  int[] element : clusterHitsTable) {
    if (element[0] == missiles) {
      return element[nRoll - 1];
    }
  }
  for (int i=clusterHitsTable.length - 1; i >= 0; i--) {
    if (missiles > clusterHitsTable[i][0]) {
      return clusterHitsTable[i][nRoll - 1] + Compute.missilesHit(missiles - clusterHitsTable[i][0],nMod,hotloaded,streak,advancedAMS);
    }
  }
  throw new RuntimeException("Could not find number of missiles in hit table");
}

public static int missilesHit ( int missiles , int nMod , boolean hotloaded , boolean streak , boolean advancedAMS ) { int nRoll = Compute . d6 ( 2 ) ; if ( hotloaded ) { int roll1 = Compute . d6 ( ) ; int roll2 = Compute . d6 ( ) ; int roll3 = Compute . d6 ( ) ; int lowRoll1 = 0 ; int lowRoll2 = 0 ; if ( ( roll1 <= roll2 ) && ( roll1 <= roll3 ) ) { lowRoll1 = roll1 ; lowRoll2 = Math . min ( roll2 , roll3 ) ; } else if ( ( roll2 <= roll1 ) && ( roll2 <= roll3 ) ) { lowRoll1 = roll2 ; lowRoll2 = Math . min ( roll1 , roll3 ) ; } else if ( ( roll3 <= roll1 ) && ( roll3 <= roll2 ) ) { lowRoll1 = roll3 ; lowRoll2 = Math . min ( roll2 , roll1 ) ; } nRoll = lowRoll1 + lowRoll2 ; } if ( streak ) { nRoll = 11 ; } nRoll += nMod ; if ( ! advancedAMS ) { nRoll = Math . min ( Math . max ( nRoll , 2 ) , 12 ) ; } else { nRoll = Math . min ( nRoll , 12 ) ; } if ( nRoll < 2 ) { return 0 ; } for ( int [ ] element : clusterHitsTable ) { if ( element [ 0 ] == missiles ) { return element [ nRoll - 1 ] ; } } for ( int i = clusterHitsTable . length - 1 ; i >= 0 ; i -- ) { if ( missiles > clusterHitsTable [ i ] [ 0 ] ) { return clusterHitsTable [ i ] [ nRoll - 1 ] + Compute . missilesHit ( missiles - clusterHitsTable [ i ] [ 0 ] , nMod , hotloaded , streak , advancedAMS ) ; } } throw new RuntimeException ( "Could not find number of missiles in hit table" ) ; }
roll the number of missiles ( or whatever ) on the missile hit table , with the specified mod to the roll .
