Пример #1
0
  /**
   * Return the number of players in a defined radius.<br>
   * Dead players aren't counted, invisible ones is the boolean parameter.
   *
   * @param range : the radius.
   * @param npc : the object to make the test on.
   * @param invisible : true counts invisible characters.
   * @return the number of targets found.
   */
  public static int getPlayersCountInRadius(int range, L2Character npc, boolean invisible) {
    int count = 0;
    for (L2PcInstance player : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (player.isDead()) continue;

      if (!invisible && player.getAppearance().getInvisible()) continue;

      if (Util.checkIfInRange(range, npc, player, true)) count++;
    }
    return count;
  }
Пример #2
0
  /**
   * Under that barbarian name, return the number of players in front, back and sides of the npc.
   * <br>
   * Dead players aren't counted, invisible ones is the boolean parameter.
   *
   * @param range : the radius.
   * @param npc : the object to make the test on.
   * @param invisible : true counts invisible characters.
   * @return an array composed of front, back and side targets number.
   */
  public static int[] getPlayersCountInPositions(int range, L2Character npc, boolean invisible) {
    int frontCount = 0;
    int backCount = 0;
    int sideCount = 0;

    for (L2PcInstance player : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (player.isDead()) continue;

      if (!invisible && player.getAppearance().getInvisible()) continue;

      if (!Util.checkIfInRange(range, npc, player, true)) continue;

      if (player.isInFrontOf(npc)) frontCount++;
      else if (player.isBehind(npc)) backCount++;
      else sideCount++;
    }

    int[] array = {frontCount, backCount, sideCount};
    return array;
  }