Esempio n. 1
0
 /**
  * Finds store customers by name and sorts them by distance
  *
  * @return RSNPC[] containing customers
  */
 private RSNPC[] getCustomers() {
   return NPCs.findNearest(
       NPCs.generateFilterGroup(
           new Filter<RSNPC>() {
             @Override
             public boolean accept(RSNPC npc) {
               if (npc != null) {
                 String name = npc.getName();
                 return name != null && name.equals("Shop keeper") || name.equals("Shop assitant");
               }
               return false;
             }
           }));
 }
Esempio n. 2
0
  /**
   * Checks what npc in the array should be attacked.
   *
   * <p>Does canReach and isInCombat checks as well.
   *
   * @param npcs
   * @return the npc to attack, or null if input array was null.
   */
  public static RSNPC[] orderOfAttack(RSNPC[] npcs) {

    if (npcs.length > 0) {

      npcs = NPCs.sortByDistance(Player.getPosition(), npcs);

      List<RSNPC> orderedNPCs = new ArrayList<RSNPC>();

      for (RSNPC npc : npcs) {

        if (npc.isInCombat() || !npc.isValid() || !MovementMgr.canReach(npc)) continue;

        orderedNPCs.add(npc);
      }

      if (orderedNPCs.size() > 1) {

        if (getUtil().BOOL_TRACKER.USE_CLOSEST.next()) {

          // if the 2nd closest npc is within 3 tiles of the closest npc, attack the 2nd one first.
          if (orderedNPCs.get(0).getPosition().distanceTo(orderedNPCs.get(1)) <= 3)
            Collections.swap(orderedNPCs, 0, 1);
        }

        getUtil().BOOL_TRACKER.USE_CLOSEST.reset();
      }

      return orderedNPCs.toArray(new RSNPC[orderedNPCs.size()]);
    }

    return null;
  }
Esempio n. 3
0
  @Override
  public void execute() {
    console.log("42");

    RSNPC[] warriors = NPCs.getAll(Filters.NPCs.nameContains(WARRIOR));

    if (warriors.length <= 0) return;

    RSNPC warrior = Arrays.stream(warriors).findFirst().get();

    api.interact(warrior, "Pickpocket");

    General.sleep(300, 400);
  }