Jump to content

BravoTaco

Scripter II
  • Posts

    237
  • Joined

  • Last visited

  • Feedback

    100%

Everything posted by BravoTaco

  1. Hello all, I've been out of the scripting scene for a little bit now and was wanting to get back into it, so if anyone wants a particular script created then you can reply here or message me with the details and I'll make it for you. I will most likely attach a link to the source code and compiled .jar file on my GitHub after completion for others to look at and or use. Script complexities will vary based off of how much time I have available to work on it and I may have to turn down some scripts as I don't want to create a free version of something that another scripter has a paid version for.
  2. I am willing to help you out with anything you need, scripting related, all though I won't be able to talk through things on Discord as my current employment requires me to travel around a fair bit. I can however respond to messages, so feel free to reach out whenever you have questions.
  3. If you are not needing an entire GUI, you could use the JOptionPane class, it allows you to bring up a modal input dialog box with just one line of code. String monsterID = JOptionPane.showInputDialog("Please enter the monster ID.");
  4. Sure! No problem! // Basic code to chop a regular tree, with a conditional sleep, when the player is not animating. if (!myPlayer().isAnimating()) { RS2Object tree = getObjects().closest("Tree"); if (tree != null && tree.interact("Chop down")) { // The conditional sleep returns true or false. // True being returned if the condition is met. IE. The player is animating. // False being returned if the condition is not met, and the max sleep time is met. // The sleep time is in milliseconds so 15000 == 15 seconds. if (ConditionalSleep2.sleep(15000, () -> myPlayer().isAnimating())) { log("Player is chopping the tree."); } } }
  5. @mrdukesilver Without having knowledge of the code inside of the other methods, this will be rather hard to debug. Try executing only the worldHop1 method without executing any other code to see if it functions as expected. I also recommend to look into the ConditionalSleep classes. Standard ConditionalSleep class new ConditionalSleep(maxSleepTime, checkInterval) { @Override public boolean condition() throws InterruptedException { return condition; } }.sleep(); Non-Standard ConditionalSleep class - I personally recommend using this one, as it is more straightforward. ConditionalSleep2.sleep(maxSleepTime, () -> condition)
  6. @CheckingItOut You are missing the import for the Message class. I would recommend giving this a look, https://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-or-cannot-resolve-symbol-error-mean It will help explain the error in detail. Adding this to your imports, should fix this though; import org.osbot.rs07.api.ui.Message;
  7. Not at the moment. Don't have the requirements on any account (That I'm willing to bot on) to use.
  8. I believe the difference is that completeDialogueU is surrounded in a try-catch, while the other is not. So you can use completeDialogueU without having to catch the exception yourself.
  9. I wrote up a quick example script. Not everything is implemented I left the buyItem() method blank so that you can implement that. It uses an Array of strings for the different items to alch, and a HashMap<String, Integer> that holds the alched count for each item. If you have any questions let me know. Also this code is untested. So it may be broken public class UCAlcher extends Script { private BotState botState; // This is used to keep track of how many of each item that can be alched, has been alched. private final HashMap<String, Integer> alchsMap = new HashMap<>(); // The different items you want to alch. private final String[] itemNames = new String[]{"Rune 2h Sword", "Rune platebody", "Rune platelegs"}; // This value represents how many items will be alched/bought for each item. private int alchLimitForEachItem = 2; private String currentAlchItemName; @Override public void onStart() throws InterruptedException { // Initialize the HashMap with the values from the itemNames array. for (String s : itemNames) { alchsMap.put(s, 0); } } @Override public int onLoop() throws InterruptedException { botState = setBotState(); if (botState != null) { switch (botState) { case ALCH_ITEM: { alchItem(); } case BUY_ITEM: { buyItem(); } } } else { warn("The botState is null."); stop(false); } return random(800, 3600); } private BotState setBotState() { currentAlchItemName = null; // for (Item item : getInventory().getItems()) { if (item != null && alchsMap.containsKey(item.getName()) && alchsMap.get(item.getName()) < alchLimitForEachItem) { currentAlchItemName = item.getName(); return BotState.ALCH_ITEM; } } // If the currentAlchItemName is null here than that means we need to possibly buy a new item to alch // or we need to reset the alch count on each item. if (currentAlchItemName == null) { for (String s : alchsMap.keySet()) { if (alchsMap.get(s) < alchLimitForEachItem) { currentAlchItemName = s; return BotState.BUY_ITEM; } } } // If the currentAlchItemName is still null than that means we have bought and alched all items. // So now we have to reset the alch count on each item and set the currentAlchItemName to the first index in the itemNames array. if (currentAlchItemName == null) { for (String s : alchsMap.keySet()) { alchsMap.replace(s, 0); } currentAlchItemName = itemNames[0]; return BotState.BUY_ITEM; } return null; } private void buyItem() { // Implement the buying of the item here. } private void alchItem() throws InterruptedException { Item alchItem = getInventory().getItem(currentAlchItemName); if (alchItem != null) { if (getMagic().canCast(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY)) { if (getMagic().castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY)) { if (sleepUntil(() -> alchItem.interact("cast"), 5000, 20)) { alchsMap.replace(currentAlchItemName, alchsMap.get(currentAlchItemName) + 1); } else { warn("Unable to alch item."); } } } else { warn("Unable to cast high level alchemy. Stopping script."); stop(false); } } else { warn("The inventory does not contain the required item to alch. Something must have gone wrong when calculating the botState."); } } private boolean sleepUntil(BooleanSupplier condition, int maxTime, int checkInterval) throws InterruptedException { long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < maxTime) { if (condition.getAsBoolean()) { return true; } Thread.sleep(checkInterval); } return false; } private enum BotState { BUY_ITEM, ALCH_ITEM } }
  10. Yeah you are correct, you are essentially setting the pathToBank as a pointer to the pathToAltar so when accessing the pathToBank variable you are actually just accessing the value stored in the pathToAltar. Subsequently if you were to change the pathToAltar value than you would also essentially be changing the value of pathToBank since it is a pointer to that value.
  11. When you added your positions, you may have added them in a reversed order. Try recreating the array/list with the current positions reversed. Or you could do it through code at runtime with a quick Java call. Collections.reverse(pathToAltar); Edit: Just tested the current list you have and it seems to walk correctly from the bank to the air altar, if that is what you are intending. If so than you may have an issue with another part of your script somewhere. Is their more to this script or is it just executing the walking from above?
  12. Generally, you should always use getters/setters for variables contained in other classes, if one is provided as they may be doing more than just returning the variable. In example, calling getInventory() instead of just calling the variable could actually be verifying that it is returning the most up-to-date Inventory state, instead of the one that is currently cached.
  13. You are calling the Player class. To use methods that are within that class you must first set a Player variable. Also getSkullIcon() does not return a boolean value, it returns an integer. Player player = getPlayers().closest("Bob"); Then once you have set the Player variable you can than call those methods. Player player = getPlayers().closest("Bob"); if (player != null) { int enemyPlayerSkullIcon = player.getSkullIcon(); int enemyCombatLevel = player.getCombatLevel(); }
  14. Didn't mean to repost this lol. Meant to edit the old one.
  15. Also just tested your code, It is the sleep you are using causing the script to not interact with your inventory item. This is what I tested. getMagic().castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY); new ConditionalSleep(random(30000, 100000)) { @Override public boolean condition() throws InterruptedException { return !getTabs().magic.isSpellSelected(); } }.sleep(); // sleep untill magic tab isnt open getInventory().interact("Cast", "Feather"); Than I removed the sleep. getMagic().castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY); // sleep untill magic tab isnt open getInventory().interact("Cast", "Feather"); This allowed it to work. Also, It will work even with the sleep, but again it will take 30-100 seconds before it will interact with the item in the inventory. Also you should use if statements on those calls so you can do other things based on if they were performed or not. if (getMagic().castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY)) { if (getInventory().interact("Cast", "Feather")) { // Do sleeps here } }
  16. You are sleeping for 30 to 100 seconds after you have selected the alch spell. Do a sleep until the inventory is visible, than interact with the item.
  17. Sorry to hear it's not working properly, will look into this. I will change it so it buys as many wines as possible.
  18. Are you building the script into a .jar file? Or just exporting the script file directly into the OSBots script folder? If you are building it into a .jar file make sure you are building it with the correct java version, which is java 8 I believe. Also make sure you do have the script manifest as Gunman has said.
  19. There are a lot of different ways you can go about this. You could extend the class from the MethodProvider class as Medusa stated, you would also need to exchangeContext() in the onStart() method of your script if you go that route. That would look something like this. First create a class that extends from the MethodProvider. Than create and store that object in your script. You could also, just take in variables you need in that method as a parameter like such. public static void actionSleep(Player myPlayer, int maxSleepTime, int checkInterval) throws InterruptedException { Random random = new Random(System.nanoTime()); new ConditionalSleep(maxSleepTime, checkInterval) { @Override public boolean condition() throws InterruptedException { int x = (int) (random.nextFloat() * 7f); if (x == 4) antiBans.shortTermAntiban(); return myPlayer.getInteracting() == null; } }.sleep(); } Also here is a simple StopWatch class.
  20. To do this you can declare a Filter and than use that Filter to get the closest log. To declare a Filter to be used you would set it as a variable wherever you need it like so. Heres a link to the Filter api doc. private final Filter<RS2Object> logFilter = new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object.getName().equalsIgnoreCase("logName") && getMap().canReach(rs2Object) && getObjects().get(rs2Object.getPosition().getX(), rs2Object.getPosition().getY()) .stream().noneMatch((object) -> object.getName().equalsIgnoreCase("Fire")); } }; You would need to replace the logName string with the name of the log you are looking for. This Filter will check a few conditions first, if the RS2Object's name matches the supplied string, second it checks to see if you can reach the object lastly, it checks to see if there are no fires at that position. To use the filter in the onLoop() method you would call getObjects().closest(logFilter) and set that equal to a variable than null check it before acting up on it. Like so. RS2Object log = getObjects().closest(logFilter); if (log != null) { doLogic(); }
  21. @C7amg Scripts seems too break on the second level, run past the sack of grain and stands between two of the doors. I have the logger for it, repeating 'Error in script executor!' I am having trouble reproducing this, I ran 12 accounts through the stronghold using mirror mode, and none of them experienced this issue. If you are still having trouble with it could you send me the log file?
  22. Sorry to hear that its not working for ya I will look into this.
  23. Thanks for the positive feedback. You should be able to start it from almost anywhere and it will walk to where it needs to.
  24. This is usually caused when using while loops wrong. Or if you are using more threads. Will need code to diagnose though.
×
×
  • Create New...