Exemplo n.º 1
0
 /**
  * Returns the average damage of the given weapon at the given range using the ammunition
  * specified. This routine is provided to support LB-X ACs, ATMs, and MMLs. We say "average" here
  * as some weapons use a clustered system and may only do partial damage, otherwise we return the
  * maximum damage. If the range specified is less than 0 or greater than the maximum range of the
  * weapon we return -1.
  *
  * @param w The weapon in question.
  * @param a The ammunition that the weapon will use.
  * @param range The range that the weapon will be hitting a target at.
  * @return The average damage of the weapon at that range.
  */
 public static int GetAverageDamageAtRange(ifWeapon w, Ammunition a, int range) {
   if (a.IsCluster()) {
     boolean Streak = w.IsStreak();
     boolean Ultra = w.IsUltra();
     boolean Rotary = w.IsRotary();
     boolean Ballistic = false;
     if (w.GetWeaponClass() == ifWeapon.W_BALLISTIC && a.IsCluster()) {
       Ballistic = true;
     }
     if (range > a.GetLongRange()) {
       return 0;
     } else if (range > a.GetMediumRange()) {
       if (Streak) {
         return a.GetDamageLong() * a.ClusterSize();
       } else if (Ultra) {
         // don't even bother with the cluster table, it'll always
         // return 1 in this case.
         return a.GetDamageLong();
       } else if (Ballistic & !Rotary) {
         // this covers LB-X cannons in general
         return GetAverageClusterHits(w, w.ClusterModLong());
       } else {
         return a.GetDamageLong() * GetAverageClusterHits(w, w.ClusterModLong());
       }
     } else if (range > a.GetShortRange()) {
       if (Streak) {
         return a.GetDamageMedium() * a.ClusterSize();
       } else if (Ultra) {
         return a.GetDamageMedium();
       } else if (Ballistic & !Rotary) {
         return GetAverageClusterHits(w, w.ClusterModMedium());
       } else {
         return a.GetDamageMedium() * GetAverageClusterHits(w, w.ClusterModMedium());
       }
     } else {
       if (Streak) {
         return a.GetDamageShort() * a.ClusterSize();
       } else if (Ultra) {
         return a.GetDamageShort();
       } else if (Ballistic & !Rotary) {
         return GetAverageClusterHits(w, w.ClusterModShort());
       } else {
         return a.GetDamageShort() * GetAverageClusterHits(w, w.ClusterModShort());
       }
     }
   } else {
     if (range > a.GetLongRange()) {
       return 0;
     } else if (range > a.GetMediumRange()) {
       return a.GetDamageLong();
     } else if (range > a.GetShortRange()) {
       return a.GetDamageMedium();
     } else {
       return a.GetDamageShort();
     }
   }
 }