Jump to content

liverare

Scripter II
  • Posts

    1295
  • Joined

  • Last visited

  • Days Won

    3
  • Feedback

    0%

Everything posted by liverare

  1. Have you checked out bot.getMouseEventHandler().generateBotMouseEvent ? If not, try that before using Robot - I've included you in a PM where somebody else asked how I got around OSBot's slow keyboard/mouse problem. Also, you shouldn't need to use JNativeHook library as you can add listeners to the client itself gl dude, my script blows so I hope you do a ton better
  2. Script works fine. The experimental keyboard feature is broken, but the script isn't dependent on it.
  3. Something like... Position tile = null; RS2Object box = null; Item boxItem = null; if (tile != null) { box = getBox(tile); if (box.hasActions("Check")) { // loot } } else { boxItem = inventory.getItem("Box trap"); if (boxItem != null && boxItem.interact("Lay")) { tile = myPosition(); } } // other stuff..... public RS2Object getBox(Position tile) { return objects.getAll().stream().filter(obj -> obj != null && obj.exists() && obj.getName().equals("Box trap") && obj.getX() == tile.getX() && obj.getY() == tile.getY()) .findFirst().orElse(null); }
  4. Looking good! In your AttackCow code, you're finding a suitable cow on the activate method and on the execute method. Perhaps create a cow variable up top and reuse the same cow? Also, you could filter out any cows that are being attacked by other players: private boolean isCow(NPC npc) { return npc.getName().equals("Cow") && npc.getAnimation() != Cow.DYING.getAnimation() && (ctx.myPlayer().equals(npc.getInteracting()) || npc.getInteracting() == null); // So either we're the dude the cow's focused on OR the cow's not focused on anybody right now } NPC cow = ctx.getNpcs().singleFilter(ctx.getNpcs().getAll(), (Filter<NPC>) this::isCow); Also, you could make your Task a little easier to use by having it extend MethodProvider and then exchanging the context. You can find it under the MethodProvider section here:
  5. Item tuna = inventory.getItem("Tuna"); if (tuna != null) { tuna.interact("Eat"); }
  6. I'm assuming if you have to do this.api.store. then I'm guessing you also need to do this.api.getInventory().isFull() either way, look into this:
  7. Fishing spots are NPCs which means that when you interact with it, you can check for it: Character<?> c = myPlayer().getInteracting(); if (c != null && c.exists() && c.getName().equals("Fishing spot")) { // we're fishing } else { // we're not fishing }
  8. I doubt it. The botting client acts on the game, not the scripts. The scripts are just the instructions the botting clients have to act on.
  9. The 'fast keyboard' feature is broken...again. It's an experimental feature that breaks whenever the devs decide it's time to break it. Please restart the script and turn off the fast keyboard feature before submitting the GUI. The bot will revert to using OSBot's default keyboard mechanics. I tested this and it works. I will look into fixing the fast keyboard feature when I have some time.
  10. I recall one of the changes from OSBot v1 to v2 was that bots could no longer read/write to the same static variables, so that's likely it.
  11. Figure out what you want. When the script starts, take note of what your stats are and create a list of items you can use and prioritise them by usefulness. Figure out what you need. You might not get what you want, but you'll get what you need. A dragon axe is better than an rune one, but if you don't have a dragon axe or if your woodcutting level isn't 61, then that rune axe is your best friend. Once your bot knows what it's got, what it's not got, and where it's at, you can plan for the bot to progress. Depending on the complexity, you may need to look into using a data-structure. It'll be a lot less code than having 20+ IF's for each axe, pick axe, etc.
  12. The rules are a bit ridiculous for scriptwriters, but I believe it's to protect the customers and OSBot's brand. Making it so only the higher ranked scriptwriters get to make & sell the hardest and most complicated scripts not only makes it more likely the customer is getting a higher quality service, but also prevents the market from being over-saturated with potentially worse ones. However, that doesn't mean you can't release your scripts publicly or sell them privately.
  13. A combination of: And a looting API that remembers which items it couldn't pick up so as to avoid them completely.
  14. You don't need to watch for animations: // Some basic mathematics... long barsInInventory = inventory.getAmount("Bronze bar"); long barsPerPlatebody = 5; long platebodiesWeCanMake = (barsInInventory / barsPerPlatebody); // let's figure out how long we need to sleep long timeToMakeEachPlatebody = 1500; // 1.5 seconds (might be more or less don't know) long timeToMakePlatebodies = (platebodiesWeCanMake * timeToMakeEachPlatebody); long timeToMakePlatebodiesWithRandomOffset = (timeToMakePlatebodies + random(500, 1500)); // + 0.5 to 1.5 seconds if (anvil.interact("Smith")) { new ConditionalSleep(timeToMakePlatebodiesWithRandomOffset) { @Override public boolean condition() { // if any of the following happen, then we need to wake up! return getDialogues().isPendingContinuation() // level up message || inventory.getAmount("Bronze bar") == 0 // we're out of bronze bars || (inventory.getAmount("Bronze bar") / barsPerPlatebody) == 0; // we don't have enough bars to make another platebody } }.sleep(); }
  15. Try avoid re-checking the same logic cases and instead structure your code to run the fewest number of checks as possible: private void smithPlateBodys() throws InterruptedException { if(smithArea.contains(myPosition())) { RS2Object anvil = getObjects().closest("Anvil"); RS2Widget smithMenu = getWidgets().getWidgetContainingText("What would you like to make?"); RS2Widget plateBody = getWidgets().get(312,15,2); if (getDialogues().isPendingContinuation()) { log("Handling dialogue..."); if (getDialogues().clickContinue()) { sleep(random(500,700)); } } else if (smithMenu != null && plateBody != null) { log("Smithing Platebody's..."); new ConditionalSleep(10000) { @Override public boolean condition() { return !readyToSmith() || getInventory().getAmount("Iron platebody") == 5; } }.sleep(); } else if (anvil != null && !myPlayer().isAnimating()) { log("Interacting with Anvil..."); if (anvil.interact("Smith")) { new ConditionalSleep(5000) { @Override public boolean condition() { return getWidgets().getWidgetContainingText("What would you like to make?") != null; } }.sleep(); } } } else { log("Walking to Anvil..."); if (getWalking().webWalk(smithArea)) { sleep(random(500,700)); } } }
  16. When it comes to performing actions, you should probably leave that to the onLoop. Just have it set a flag and then have your onLoop react to it.
  17. There's an array of frames in the JFrame class: JFrame.getFrames()[0].setFocus(false)
  18. It's not enough just to copy/paste code, you actually need to read it and try to understand what it's doing. Here: // ... textField.addActionListener(e -> { String text = ((JTextField) e.getSource()).getText() int number = -1; try { number = Integer.parseInt(text); someStaticNumber = number; // let's pretend someStaticNumber is a static int } catch (NumberFormatException e) { // err you typed something in, but it wasn't a number! } }); // ... When you hit [enter] after typing in a number, that'll kick-start an "action event" which will go on to kick-start a bunch of routines that deal with that event.
  19. Slow progress man. I hit writer's block trying to reconstruct the fundamentals of this script to improve its efficiency and make it easier to maintain. Also am lazy af. I have done some work to it, but I've got like 5 other projects on the go.
  20. I had trouble recovering an old account of mine that I had forgotten the password for, and it was so old it didn't have an email associated with it. In my recovery notes, I talked about when I created the account, when I first brought membership, some of the achievements I'd accomplished, and what items I had on the account. If you've ever paid for membership via mobile/telephone, then dig up your old numbers and mention those too. I'm sure Jagex has records on that. I don't quite remember what else I talked about, but I did eventually end up gaining access again after the 2nd or 3rd try.
  21. You feel like shit. I know, I've been there before.
×
×
  • Create New...