December 15, 201510 yr Hey i'm trying to get all the bank booths near the player so i can pick a random one..Can anyone one point me in the right direction? I don't want to always be banking the same booth. Edited December 15, 201510 yr by ni562
December 15, 201510 yr if (!getBank().isOpen()) { getBank().open(); new ConditionalSleep(5000) { @Override public boolean condition() { return getBank().isOpen(); } }.sleep(); }
December 15, 201510 yr NPC spot = getNpcs().closest((Filter<NPC>) npc -> npc.getName().equals("Banker") && npc.hasAction("Bank")); Use this for the closest NPC. Always do it by their name and actions because if you use the id of the bank etc, on each RS update, the ids do change so the bot will then be unsuccessful. For a bank booth... if (!getBank().isOpen()) getBank().open(); or try Object bank = getBank().open(); Edited December 15, 201510 yr by Kenn
December 15, 201510 yr public ArrayList<RS2Object> obj() { ArrayList<RS2Object> list = new ArrayList<>(); for (RS2Object o : objects.getAll()) { if (o.getName().equalsIgnoreCase("bank booth")) { list.add(o); } } return list; } Returns what you wanted. From this you can choose a random one. Edited December 15, 201510 yr by Nitrousek
December 15, 201510 yr Usually you just want to use bank.open() but to select a booth yourself you could do List<RS2Object> booths = objects.filter(new ContainsNameFilter("bank booth")); RS2Object rndBooth = booths.get(random(0, booths.size()-1));
December 15, 201510 yr Author public ArrayList<RS2Object> obj() { ArrayList<RS2Object> list = new ArrayList<>(); for (RS2Object o : objects.getAll()) { if (o.getName().equalsIgnoreCase("bank booth")) { list.add(o); } } return list; } Returns what you wanted. From this you can choose a random one. Exactly what i needed! thanks for the feedback. I modified it a little and am posting it here if anyone is interested. public RS2Object randomBanker() { ArrayList<RS2Object> list = new ArrayList<>(); RS2Object bank; // Our bank booth for (RS2Object o : objects.getAll()) { if (o.getName().equalsIgnoreCase("Bank booth")) { list.add(o); } } bank = list.get(random(list.size() - 1)); //Chose a random booth return bank; }
December 15, 201510 yr Exactly what i needed! thanks for the feedback. I modified it a little and am posting it here if anyone is interested. public RS2Object randomBanker() { ArrayList<RS2Object> list = new ArrayList<>(); RS2Object bank; // Our bank booth for (RS2Object o : objects.getAll()) { if (o.getName().equalsIgnoreCase("Bank booth")) { list.add(o); } } bank = list.get(random(list.size() - 1)); //Chose a random booth return bank; } This is a bit shorter: public RS2Object getRandomBank() { List<RS2Object> banks = getObjects().filter(obj -> obj.getName().equals("Bank booth")); return (banks == null || banks.size() == 0) ? null : banks.get(random(banks.size()-1)); } Edited December 15, 201510 yr by Explv
December 15, 201510 yr Author This is a bit shorter: public RS2Object getRandomBank() { List<RS2Object> banks = getObjects().filter(obj -> obj.getName().equals("Bank booth")); return (banks == null || banks.size() == 0) ? null : banks.get(random(banks.size()-1)); } Thanks man!! Always swooping in and shortening my code :p I'm not sure i understand all of that...you're knowledge of java/programming is greater than mine.
December 15, 201510 yr Thanks man!! Always swooping in and shortening my code I'm not sure i understand all of that...you're knowledge of java/programming is greater than mine. It just means: -Get all objects and filter them so that the list only contains objects with the name "Bank booth" -If the list is null, or there are no elements in the list, return null Otherwise return a random value from the list. Edited December 15, 201510 yr by Explv
December 15, 201510 yr Author It just means: -Get all objects and filter them so that the list only contains objects with the name "Bank booth" -If the list is null, or there are no elements in the list, return null Otherwise return a random value from the list. Eclipse is throwing up some warnings..What should i do?
December 16, 201510 yr Eclipse is throwing up some warnings..What should i do? Post em here, you need java 8 for the stuff they posted. Ignore them noob ^^
December 16, 201510 yr Author Post em here, you need java 8 for the stuff they posted. noob ^^ "Type Safety: A generic array of Filter<RS2Object> is created for a varargs parameter." anything to worry about?
December 16, 201510 yr Post em here, you need java 8 for the stuff they posted. noob ^^ noob?? Learn to Java 8 m8 It is safe to ignore this warning. It is an unchecked generics array creation warning produced by getObjects().filter(). You can just supress it. @SuppressWarnings("unchecked") List<RS2Object> banks = getObjects().filter(obj -> obj.getName().equals("Bank booth")); If you don't want a warning you can always do: List<RS2Object> banks = getObjects().getAll().stream().filter(obj -> obj.getName().equals("Bank booth")).collect(Collectors.toList()); But the first way is perfectly fine and shorter. "Type Safety: A generic array of Filter<RS2Object> is created for a varargs parameter." anything to worry about? No it is not anything to worry about. Edited December 16, 201510 yr by Explv
Create an account or sign in to comment