

liverare
Scripter II-
Posts
1300 -
Joined
-
Last visited
-
Days Won
3 -
Feedback
0%
Everything posted by liverare
-
You can use Explv's "min" statement. It's easy to make the adaptation: private void withdrawGlory() { Item glory = Stream .of(bank.getItems()) // all bank items .filter(ScriptName::isAmuletOfGlory) // glories only (which includes eternal glory) .min(ScriptName::sortByItemName) // get first glory, but not before sorting them by item name .orElse(null); // return result glory, or else return null if (glory != null) { // do something } } public static int sortByItemName(Item a, Item b) { String aa = a.getName(); String bb = b.getName(); return aa.compareTo(bb); } public static boolean isAmuletOfGlory(Item item) { return item.getName().contains("glory"); }
-
My favourite thing about programming is that there's literally a million different ways of doing things: public void withdrawGlory() { Item glory = Stream .of(bank.getItems()) // stream of all bank items .filter(ScriptName::isAmuletOfGlory) // filter for glories .findFirst() // get first glory .orElse(null); // null if (glory != null) { // do something } } public static boolean isAmuletOfGlory(Item item) { return item.getName().contains("glory("); }
-
Example of how to use: Image img; SystemAlert sa; try { img = ImageIO.read(YourScript.class.getResourceAsStream("/unnamed.png")); sa = new SystemAlert(400, 100, img, "Task Completed!", "You've successfully chopped 5000 yew logs.", new Date()); sa.setVisible(true); } catch (Exception e) { logger.error(e); } Note: Load images locally, not externally. You can chose between passing either a java.awt.Image or javax.swing.ImageIcon for the 3rd parameter. If you chose the first, the image will be resized proportionally to the alert box, whereas the other one will allow you to have complete control over the image size. The alert can be dismissed by clicking on it. The default fonts and colours can be found in the configureComponents function (lines 126-129). Source code:
-
I made my own a very long time ago, back before they patched the farming exploit (being able to see plant growth and disease from anywhere in-game): http://imgur.com/cFwNBZ4 I salvaged my old code to produce this: http://imgur.com/sFYmx5f Is this something you're after? Because it works with OSBot. You can always change the colours and fonts to suit your design. If you wanted to add audio as well, that's also in my old code, but audio will need a little more tinkering to get working.
-
What kind of dollarydoos we talking about?
-
I wrote an API for this. There's 5 functions of interest: //AppearanceAPI.isDefined(Player, Predicare<ItemDefinition>) //appearance.findPlayersWielding(Predicare<ItemDefinition>) //appearance.findPlayersWielding(List<Player>, Predicare<ItemDefinition>) //appearance.findPlayerWielding(Predicare<ItemDefinition>) //appearance.findPlayerWielding(List<Player>, Predicare<ItemDefinition>) Example: Player randomPlayer123 = null; // TODO fix if (AppearanceAPI.isDefined(randomPlayer123, id -> id.getName().equals("Dragon claws"))) { // TODO stuff... } List<Player> richPeople = appearance.findPlayersWielding(id -> id.getName().endsWith("spirit shield")); for (Player richPerson : richPeople) { // TODO stuff.... } Source: package com.liverare.api; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; import org.osbot.rs07.api.def.ItemDefinition; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.script.API; /** * Appearance API * * @author LiveRare * */ public class AppearanceAPI extends API { @Override public void initializeModule() { } /** * Find players wielding specific items * * Note: rings are not retrieved * * @param players * - Players to filter * @param itemDefinitionFilter * - Filter * @return List of filtered players * @see {@link AppearanceAPI#isDefined(Player, Predicate)} */ public List<Player> findPlayersWielding(List<Player> players, Predicate<ItemDefinition> itemDefinitionFilter) { List<Player> results = null; if (players != null && !players.isEmpty() && itemDefinitionFilter != null) { results = new ArrayList<>(); for (Player player : players) { if (isDefined(player, itemDefinitionFilter)) { results.add(player); } } } return results; } /** * Find players wielding specific items * * Note: rings are not retrieved * * @param itemDefinitionFilter * - Filter * @return List of filtered players * @see {@link AppearanceAPI#findPlayersWielding(List, Predicate)} */ public List<Player> findPlayersWielding(Predicate<ItemDefinition> itemDefinitionFilter) { return findPlayersWielding(players.getAll(), itemDefinitionFilter); } /** * Find first player wielding specific items * * Note: rings are not retrieved * * @param players * - Players to filter * @param itemDefinitionFilter * - Filter * @return List of filtered players * @see {@link AppearanceAPI#findPlayersWielding(List, Predicate)} */ public Player findPlayerWielding(List<Player> players, Predicate<ItemDefinition> itemDefinitionFilter) { Player result = null; List<Player> filtered = findPlayersWielding(players, itemDefinitionFilter); if (filtered != null && !filtered.isEmpty()) { result = filtered.get(0); } return result; } /** * Find first player wielding specific items * * Note: rings are not retrieved * * @param itemDefinitionFilter * - Filter * @return List of filtered players * @see {@link AppearanceAPI#findPlayerWielding(List, Predicate)} */ public Player findPlayerWielding(Predicate<ItemDefinition> itemDefinitionFilter) { return findPlayerWielding(players.getAll(), itemDefinitionFilter); } /** * Test whether player is wielding a particular item * * @param player * - Player * @param itemDefinitionFilter * - Item filter * @return <tt>Item found on player</tt> * @see {@link AppearanceAPI#isDefined(int[], Predicate)} */ public static boolean isDefined(Player player, Predicate<ItemDefinition> itemDefinitionFilter) { return isDefined(player.getDefinition().getAppearance(), itemDefinitionFilter); } /** * Gets item definitions for the items IDs in 'appearance' and tests them * against the ItemDefinition filter * * @param appearance * - Item IDs * @param itemDefinitionFilter * - Filter * @return <tt>Item found</tt> */ private static boolean isDefined(int[] appearance, Predicate<ItemDefinition> itemDefinitionFilter) { boolean result = false; ItemDefinition itemDefinition = null; if (appearance != null && appearance.length > 0) { for (int itemId : appearance) { if (itemId > 0) { itemId -= 512; itemDefinition = ItemDefinition.forId(itemId); if (itemDefinition != null && itemDefinitionFilter.test(itemDefinition)) { result = true; break; } } } } return result; } } Note: this is a custom API, so the gain access to all the methods that start with "appearance", you will have to instantiate a new AppearanceAPI object and exchange the bot's context with it (like so): AppearanceAPI appearance; @Override public void onStart() throws InterruptedException { appearance = new AppearanceAPI(); appearance.exchangeContext(bot); } Enjoy.
-
Filtering by IDs is bad unless you dynamically retrieve those IDs and store them on each run. Because otherwise, a RuneScape update will change those IDs breaking your script. Running #canReach each is bad practice. If there's only one position you need to filter for, store that position as a constant and check against it. Running path-finding algorithm to exclude one fishing spot would be unnecessarily process intensive. Alternatively, you could write up a small tile-flag checker around the north, east, south, and west tiles of the fishing spot to determine whether it's a tile that can your player can stand on. That wouldn't be as bad and would be more applicable. However, be sure to store the results so you, so you don't keep asking the same questions you already know the answer to.
-
Is it that fishing spot which sits on an awkward corner in the Fisher Realm?
-
java.lang.NumberFormatException: For input string: "-----"
liverare replied to Viston's topic in Scripting Help
I wrote a Wilderness API a very long time ago. I'll re-write it at some point, but until then, here: /** * Calculate Y coordinate by wilderness level. * * Note: This is based of Edgeville Wilderness and there are some zones * where the Wilderness level increments are inconsistent with the rest of * the Wilderness (which is 8 tiles per Wilderness level). * * @param wildernessLevel * - Wilderness level * @param upperBound * - Upper-most tile for that Wilderness level * @return Y coordinate * @see {@link WildernessAPI#calculateYCoordinate(int, boolean)} */ public static int calculateYCoordinate(Vector3D vector3d, boolean upperBound) { return calculateYCoordinate(vector3d.getY(), upperBound); } /** * Calculate Y coordinate by wilderness level. * * Note: This is based of Edgeville Wilderness and there are some zones * where the Wilderness level increments are inconsistent with the rest of * the Wilderness (which is 8 tiles per Wilderness level). * * @param vector3d * - 3D vector * @param upperBound * - Upper-most tile for that Wilderness level * @return Y coordinate */ public static int calculateYCoordinate(int wildernessLevel, boolean upperBound) { int yCoordinate; if (wildernessLevel <= 0) { yCoordinate = 3524; } else if (wildernessLevel <= 1) { yCoordinate = 3527; } else if (wildernessLevel <= 2) { yCoordinate = 3535; } else { wildernessLevel -= 3; yCoordinate = 3535; yCoordinate += (wildernessLevel * 8); if (upperBound) { yCoordinate += 8; } else { yCoordinate++; } } return yCoordinate; } /** * Calculates Wilderness level by Y coordinate * * Note: This is based of Edgeville Wilderness and there are some zones * where the Wilderness level increments are inconsistent with the rest of * the Wilderness (which is 8 tiles per Wilderness level). * * @param vector3d * - 3D vector * @return Wilderness level * @see {@link WildernessAPI#calculateWildernessLevel(int)} */ public static int calculateWildernessLevel(Vector3D vector3d) { return calculateWildernessLevel(vector3d.getY()); } /** * Calculates Wilderness level by Y coordinate * * Note: This is based of Edgeville Wilderness and there are some zones * where the Wilderness level increments are inconsistent with the rest of * the Wilderness (which is 8 tiles per Wilderness level). * * @param yCoordinate * - Y coordinate * @return Wilderness level */ public static int calculateWildernessLevel(int yCoordinate) { int wildernessLevel; if (yCoordinate <= 3524) { // not in wilderness wildernessLevel = 0; } else if (yCoordinate <= 3527) { // Level 1 wilderness wildernessLevel = 1; } else if (yCoordinate <= 3535) { // Level 2 wilderness wildernessLevel = 2; } else { wildernessLevel = (yCoordinate - 3535); wildernessLevel = (int) Math.ceil(wildernessLevel / 8D); wildernessLevel += 2; // can't remember why... } return wildernessLevel; } With this, you can begin to assess stuff like: What level must I be in before player X can attack me? Who can I attack? Where's the nearest/furthest safe Y coordinate? etc. I sprung up quite a beefy API around this, it could do all kinds of checks. -
Again, please, can you help me with the problem?
liverare replied to kaitelin's topic in Scripting Help
Green dragon; dragon cave Dragon Slayer quest? ??? door (spikes to hop over)? -
Bot busting ban is when a bot identifies your bot and you get banned for it. It's justified: if a computer can tell you're botting, you're doing it wrong. A macroing major is when you get caught botting by either reports or player moderators. In this instance, there's room for human error, but also there's room for forgiveness. For instance, if you get caught and you don't bot afterwards, your ban can be forgiven (as has happened with my account).
-
You'd have to use JFrame.getFrames() and filter through the frames, the frame's components, and the component's components to find the menu item for disabling input, then you'd have to send an event to it manually. Why? Because the Security Manager intentionally blocks any attempt at using reflection to solve your problem. If you could use reflection, then you would be able to do something like: // 1. log out all the declared fields (boolean type) for (Field next : bot.getClass().getDeclaredFields()) { if (next.getType().equals(boolean.class) || next.getType().equals(Boolean.class)) { logger.debug(next); } } // 2. get the field itself try { Field inputEnabled = bot.getClass().getDeclaredField("IIiiIiiiiiiI"); if (inputEnabled != null) { inputEnabled.setAccessible(true); boolean value = inputEnabled.getBoolean(null); // 3. Toggle value inputEnabled.set(bot, value); } } catch (Exception e) { logger.error(e); } But again, the Security Manger would prevent this AND a script which has any use of reflection won't be submitted to the SVN (I had to rework my fletching script because of this).
-
Alias Sometime ago, I discovered Hotmail/Outlook provided a free 'alias' service. An alias is where you can make a new 'ghost email' address which actually works, and anything sent to that ghost email will actually be sent to your inbox. This means you can create one email address to work with multiple new RuneScape accounts. Read more here. What are the benefits? Validate multiple RS accounts quickly from one inbox. No additional sign-up. Validating new accounts with a Microsoft email is undoubtedly less suspicious than some throwaway email service. If you've somehow lost an old, old email, you could perhaps traffic any new mail to that old account to your current one. What are the drawbacks? You can only add 10 aliases per account each year. But you can create as many new email accounts as you desire. Using a throwaway email service will be quicker and less of a hassle to deal with. How do I set one up? Login to your Microsoft email account and go to your inbox. Click into settings and then options. Navigate to Mail > Accounts > Connected accounts. Under "Email aliases" click on manage. Follow Microsoft's user guide. Due to my religious hacking escapade with Warrock back in the day (thanks leaked premium trainer :D), I have a lot of Hotmail emails. If I were to list them all up, I could possibly set up over 100 aliases. However, It'd be easier to make new Microsoft email accounts than trying to remember the passwords for my stupidly old emails from well over 10 years ago.
-
Everyday we stray further from God's light.
-
Here // for item list public void interactWithItemsRandomly(List<Item> itemList, Consumer<Item> consumer) { Collections.shuffle(itemList); itemList.forEach(consumer); } // for item array public void interactWithItemsRandomly(Item[] items, Consumer<Item> consumer) { interactWithItemsRandomly(Arrays.asList(items), consumer); } Use like Item[] items = depositBox.getItems(); interactWithItemsRandomly(items, item -> item.interact("Deposit")); Or to filter items Item[] items = depositBox.getItems(); List<Item> itemsWeWantToDeposit = Stream.of(items) .filter(item -> item.getName().equals("Lobster") || item.getName().equals("Shark")) .collect(Collectors.toList()); interactWithItemsRandomly(itemsWeWantToDeposit, item -> item.interact("Deposit")); Have fun!
-
Simple and native: int twistedBowId = 20997; String webAddress = null; String webContents = null; Map<String, String> jsonData = null; try { webAddress = "https://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + twistedBowId; webContents = downloadWebpage(webAddress); jsonData = parseJsonKeyValuePairs(webContents); logger.debug(jsonData); } catch (IOException e) { logger.error("Failed to load price for: " + twistedBowId, e); } Which outputs: All that's missing is the parsing and possibly even a wrapper class. But the content's there. The other functions (downloadWebpage & parseJsonKey: /** * Download all contents from a URL * * @param address * - Web site address * @return Contents * @throws IOException * Error input/output */ public static String downloadWebpage(String address) throws IOException { String result = ""; String nextLine = null; try ( InputStream inputStream = new URL(address).openStream(); InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); ) { while ((nextLine = bufferedReader.readLine()) != null) { result += nextLine; } } return result; } /** * Simple JSON parser to extract key & value pairs. * * Note: values must be numbers. * * @param input * - JSON input * @return Mapped contents */ public static Map<String, String> parseJsonKeyValuePairs(String input) { final Map<String, String> result = new HashMap<>(); final Pattern pattern = Pattern.compile(".*?\"(.*?)\":(\\d+)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); final Matcher matcher = pattern.matcher(input); while (matcher.find()) { result.put(matcher.group(1), matcher.group(2)); } return result; } I wrote my own JSON parser, but it's very simple and will only work where the values are numeric. I'm staying away from any libraries that aren't packaged with Java. Also, don't suppress errors. If the errors are thrown at a point in the code where it can't be logged out, just keep throwing it on up the stack until it reaches a point where it can. Errors are useful; if you suppress them, then you're going to have a bad time.
-
This is something scruffy, but the logic's structured and easy to read: if (isAtBank()) { if (isInventoryFull()) { if (isBankOpen()) { depositLoot(); } else { openBank(); } } else if (isLowOnSupplies()) { if (isBankOpen()) { withdrawSupplies(); } else { openBank(); } } else { if (isBankOpen()) { closeBank(); } else { walkToMonsters(); } } } else if (isAtMonsters()) { // etc. }
-
Both have their pros and cons. You should look into trying all of them to understand them for yourself, where best they are applied and which you prefer to use. Throughout my RS scripting life, I've gone through all the funky and wacky methods of doing stuff, but none of them have worked for me. What I've found works best for me is to just cut out all the bullshit: Don't program; just script. Don't create dependencies; just duplicate them.
-
Inventory returning something as true when it should be false.
liverare replied to HeyImJamie's topic in Scripting Help
You should re-run all checks each time you hop worlds. -
I'd like to apply there one day. My biggest fear is that I'll mention that I've played the game for over a decade and when they ask for my username, I'll freeze up, because if I give it them, they'd be able to see that I've gotten banned for botting in the past. They'd probably do a little more searching to find any associated accounts and find out that it's not my first account I've lost to bot ban. Then they'd probably go further and somehow realise I'm a member here and have been a member of other botting communities. My only retort would be: "w-well you hired Jacmob!"
-
Holy shit you must suck. The one point, the only point, to CS:GO is to get kills with your gun. If you're going to let the computer do that for you, you may as well just uninstall the game. What game are you playing? None. Your computer's playing it for you. How is that fun? Are you deriving your enjoyment from making your opponents unfairly lose to your computer? Stop hacking and git gud.
-
We're the insane ones; he sees through the matrix.
-
We'll exact our revenge come nightfall, when they start to glow in the dark.
-
Just doing my part to spread God's message.