public static int applyDistanceAttackModifiers(final int damage,final double squareDistance,final double maxrange){
  final double maxRangeSquared=maxrange * maxrange;
  if (maxRangeSquared < squareDistance) {
    return 0;
  }
 else   if (squareDistance == 0) {
    return (int)(0.8 * damage);
  }
  final double outOfRange=maxrange + 1;
  final double distance=Math.sqrt(squareDistance);
  return (int)(damage * ((distance * 4) / outOfRange - 4 * squareDistance / (outOfRange * outOfRange)));
}

public static int applyDistanceAttackModifiers ( final int damage , final double squareDistance , final double maxrange ) { final double maxRangeSquared = maxrange * maxrange ; if ( maxRangeSquared < squareDistance ) { return 0 ; } else if ( squareDistance == 0 ) { return ( int ) ( 0.8 * damage ) ; } final double outOfRange = maxrange + 1 ; final double distance = Math . sqrt ( squareDistance ) ; return ( int ) ( damage * ( ( distance * 4 ) / outOfRange - 4 * squareDistance / ( outOfRange * outOfRange ) ) ) ; }
calculates the damage that will be done in a distance attack ( bow and arrows , spear , etc . ) .
