Jump to content

JS3

Members
  • Posts

    27
  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by JS3

  1. Nice job on the first script! Keep it up!!
  2. This is easily the best advice. ?
  3. Ain't that the truth! OP stay at it! Good luck with completion, looking forward to it.
  4. Last comment was only a couple weeks old, I'm sure if you try to run it will work..
  5. Hi Guys, I have been expanding on using Enum for storing multiple points of data, but I am unsure how to call upon certain aspects of them to use. Also @Explv, I see you commonly recommend this when others post, so thank you for explaining in other peoples threads. public enum BoatOptions { NOVICE("Novice", 40, new Area(1, 2, 3, 4), 3), INTERMEDIATE("Intermediate", 70, new Area(2, 3, 4, 5), 4), VETERAN("Veteran", 100, new Area(3,4,5,6), 5); String name; int levelRequired; Area area; int pointBonus; BoatOptions(final String name, final int levelRequired, final Area area, final int pointBonus){ this.name = name; this.levelRequired = levelRequired; this.area = area; this.pointBonus = pointBonus; } @Override public boolean toString(){ return name; } public int getLevelRequired() { return levelRequired; } public int getPointBonus() { return pointBonus; } } I want to set up a few methods based on the BoatOptions. Obvious examples are, area for walking to, pointBonus to display the number of PC points and I was planning to make the bot choose the best boat based on combat level. I'm sure it's simple but I am confused. Any help is appreciated!
  6. JS3

    Simple Alcher

    import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; @ScriptManifest(name = "HiAlch", version = 1, author = "J$", logo = "", info = "") public class Main extends Script { @Override public void onStart() throws InterruptedException { getExperienceTracker().start(Skill.MAGIC); } @Override public int onLoop() throws InterruptedException { if (canAlch()) { clickAlch(); } else { stop(); log("Out of supplies or dead"); } return 700; } public boolean canAlch() { return getEquipment().isWieldingWeaponThatContains("staff") && getInventory().contains("Nature rune", "Yew longbow (u)"); } public void clickAlch() { RS2Widget[] alchPic = getWidgets().getWidgets(218, 35); int rX = random(705, 717); int rY = random(331, 338); if (getTabs().magic.open()) { getMouse().click(rX, rY, false); getMouse().click(rX, rY, false); new ConditionalSleep(2000, 500) { @Override public boolean condition() throws InterruptedException { return alchPic != null; } }.sleep(); } } @Override public void onPaint(Graphics2D paint) { int mXp = getExperienceTracker().getGainedXP(Skill.MAGIC); super.onPaint(paint); paint.drawString("Magic XP: " + mXp, 387, 328); } } I was working on an Agility Alcher and decided to make this while bank standing. If you can use it, sweet, if it's bad, sorry.
  7. Feedback on scripts he is developing seems to be what's in it for him. Nonetheless, this is great and something I've also considered as I have been learning recently. Great Idea OP!
  8. No Worries! Thanks for response, the null check fixed the error. Thank you
  9. Updated OP and made changes to script based on previous recommendations and also attempting to improve overall!
  10. Is that something I can add to the conditional sleep? Can I do if and else statements within there? One thing I was also considering was breaking up the Smithing case into 2 parts. First being interaction with the furnace and opening the widget. Then once that completes, have it complete the action and sleep until cannonball amount was met or pendingcontinuation or player is not animating. I've noticed with any changes I apply, I have a problem on the initial widget interaction, it will click furnace, see the widget, loop then click furnace again and finally interact. Other problem is, if I have cannonballs and steel bars in my inv, and it hits the Idle state, it will not come out of Idle to re-engage with the furnace/widget. Also, @progamerz I hit you up on discord if you can help. Thank you!
  11. I've run into some interesting problems. See below: case SMITH_CBALLS: log("BEGIN BALLS"); RS2Object furnace = objects.closest("Furnace"); RS2Widget smithFace = getWidgets().get(270, 14, 38); if (furnace != null) { if (!myPlayer().isAnimating()) { if (smithFace != null && smithFace.isVisible()) { if (smithFace.interact("Make sets:")) { getMouse().moveOutsideScreen(); new ConditionalSleep(30000, 5000) { @Override public boolean condition() throws InterruptedException { return getDialogues().isPendingContinuation() || !getInventory().contains("Steel bar"); } }.sleep(); } else { sleep(800); if (!myPlayer().isAnimating()) { furnace.interact(); } } } } } break; When adding if(smithFace.interact("Make sets:"), it cannot locate the action to select unless I remove the if statement. On the contrary, when looking for the widget dynamically, it cannot locate the widget when doing RS2Widget smithFace = getWidgets().getWidgetContainingText(240, "How many bars would you like to smith?"); when I run it, I keep getting stuck on BEGIN BALLS and Starting to Make Cannonballs in the logger for either option. For the script to keep running, I default back to original setup. Update: I have updated OP but since then have improved the smithing state. See Below case SMITH_CBALLS: log("BEGIN BALLS"); boolean cBallTotal = getInventory().getAmount("Cannonball") == 108; RS2Object furnace = objects.closest("Furnace"); RS2Widget smithFace = getWidgets().getWidgetContainingText(270, "How many"); if (furnace != null && furnace.interact("Smelt")) { sleep(3000); if (smithFace != null) { getKeyboard().pressKey(32); } new ConditionalSleep(25000, 5000){ @Override public boolean condition(){ getMouse().moveOutsideScreen(); return cBallTotal || getDialogues().isPendingContinuation(); } }.sleep(); } break; I have not had any issues with clicking timing or getting stuck.
  12. Great feedback and thank you for the suggestions! My goal is to create bigger and more complex scripts but to also put forth my efforts back to the community. I have tried to go back to not using States and enums as I am fairly new to Java and don't understand fully why to use enums over not using them. I think I need to go back and do some basic Java to better understand everything. I used the tutorials @Chris made and scanned through a lot of snippets and other forum posts. As for the widget, I was thinking about that this morning, I am gonna do some separate tests off script to practice.
  13. I've run into some interesting problems. See below: case SMITH_CBALLS: log("BEGIN BALLS"); RS2Object furnace = objects.closest("Furnace"); RS2Widget smithFace = getWidgets().get(270, 14, 38); if (furnace != null) { if (!myPlayer().isAnimating()) { if (smithFace != null && smithFace.isVisible()) { if (smithFace.interact("Make sets:")) { getMouse().moveOutsideScreen(); new ConditionalSleep(30000, 5000) { @Override public boolean condition() throws InterruptedException { return getDialogues().isPendingContinuation() || !getInventory().contains("Steel bar"); } }.sleep(); } else { sleep(800); if (!myPlayer().isAnimating()) { furnace.interact(); } } } } } break; When adding if(smithFace.interact("Make sets:"), it cannot locate the action to select unless I remove the if statement. On the contrary, when looking for the widget dynamically, it cannot locate the widget when doing RS2Widget smithFace = getWidgets().getWidgetContainingText(240, "How many bars would you like to smith?"); when I run it, I keep getting stuck on BEGIN BALLS and Starting to Make Cannonballs in the logger for either option. For the script to keep running, I default back to original setup.
  14. Awesome! I will work on that. Thanks again for your feedback!
  15. Thanks! When you say dynamic, do you mean straying away from using the IDs like 270,14, etc? For example, use the root ID 270 and then something like containsText("example")?
  16. As the title says, not my first script. BUT I am looking for feedback. Some of the issues I am running into now is when I level up, it will not continue and restart smithing, and sometimes it doesn't click the widget box on the first try, will wait few seconds, then start over again. Please let me know how this looks so far. Thanks EDIT: I've updated the script a bit to avoid static IDs on the widget and tried cleaning up the SMITH_CBALLS case to interact better. I keep running into issues with animation delay. For example, when I click the furnace, it will sleep, press space, but not go into IDLE everytime. Instead, it seems like the delay is throwing off myPlayer().isAnimating, as it will try to run through and click furnace -> Interact with widget, loops until hitting IDLE. EDIT AGAIN: I have separated the smithing action into 2 cases. I wanted to see if this would fix the re-click on the furnace when the widget is present and if I could get the smithing state to re-engage if cannonballs and steels bars were still in inv. Trying to figure out the issue with the widget and interaction. Now getting this error on the log. [INFO][Bot #1][07/09 10:38:34 PM]: STATE: START_WIDGET [INFO][Bot #1][07/09 10:38:34 PM]: Interacting with Furnace and widget [ERROR][Bot #1][07/09 10:38:34 PM]: Error in script executor! java.lang.NullPointerException [INFO][Bot #1][07/09 10:38:34 PM]: STATE: START_WIDGET [INFO][Bot #1][07/09 10:38:34 PM]: Interacting with Furnace and widget [ERROR][Bot #1][07/09 10:38:34 PM]: Error in script executor! java.lang.NullPointerException [INFO][Bot #1][07/09 10:38:34 PM]: STATE: START_WIDGET [INFO][Bot #1][07/09 10:38:34 PM]: Interacting with Furnace and widget [ERROR][Bot #1][07/09 10:38:34 PM]: Error in script executor! java.lang.NullPointerException Last Edit: Finally have worked out all the bugs I was experiencing. Posting the final code here. Thanks to everyone for the help!
  17. I know that, I was referencing the if statement, your saying if the bank contains my player, then walk to bank. if (bankingArea.contains(myPlayer())) { //here is where the error shows in the logger when i start the script bankking area = null, ive tried doing  // if(bankingArea == null) { (log"Bank is null")} but everything still crashes getWalking().webWalk(bankingArea); } What I suggested was saying if bank does NOT contain my player.
  18. Hi Guys, I have a basic understanding of Arrays in a sense that I know it's a list of stuff. I'm writing an agility script and I'm doing checks to see if Area contains my play in order to move on, but I wanted to try and create it as a list, in which it would need to verify based on like a queue or priority system to move forward to next area. Any help would be appreciated!
  19. I may be wrong but, Shouldn't that first line be if (!bankingAre.contains(myPlayer()))) { getWalking.webWalk(bankingArea); ?
  20. I do that here. Do I need to have it check before? - if (!getInventory().isFull() && barbarian.Fish.contains(myPlayer))) { } else if (getInventory().contains("Raw trout", "Raw salmon") && getInventory().isFull()) { log("COOK_FISH"); Edit: private State getState() { if (!getInventory().isFull() && barbarianFish.contains(myPlayer())) { log("FISH_FISH"); return State.FISH_FISH; } else if (!barbarianFish.contains(myPlayer()) && getInventory().isEmptyExcept("Fly fishing rod", "Feather")) { log("WALK_TO_FISH"); return State.WALK_TO_FISH; } else if (getInventory().contains("Raw trout", "Raw salmon") && getInventory().isFull()) { log("COOK_FISH"); return State.COOK_FISH; } else if (getInventory().contains("Salmon", "Trout") && bankArea.contains(myPlayer())) { log("DEPOSIT"); return State.DEPOSIT; } else if (!bankArea.contains(myPlayer())) { log("WALK_TO_BANK"); return State.WALK_TO_BANK; } log("IDLE"); return State.IDLE; } and is now working. Thank you @GPSwap
  21. Hi Guys, I am new to scripting and have been learning through videos, threads and the OSbot scripting discord. Below is a script I have made for Barbarian Fishing, cooking and banking. import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(logo ="" , name ="Barbarian Fishing! xD" , version =1.0 , info ="Fish and Cook, Trout and Salmon. + Banking!" , author ="J$" ) public class Main extends Script { public final Area barbarianFish = new Area(3109, 3434, 3102, 3423); public final Area bankArea = new Area(3094, 3489, 3093, 3491); private final org.osbot.rs07.api.map.Position bankTeller = new org.osbot.rs07.api.map.Position(3094, 3491, 0); enum State { WALK_TO_FISH, WALK_TO_BANK, COOK_FISH, DEPOSIT, IDLE, FISH_FISH } @Override public void onStart() throws InterruptedException { } @Override public int onLoop() throws InterruptedException { switch (getState()){ case FISH_FISH: log("FISHING THE FISH"); NPC salmon = getNpcs().closest("Rod Fishing spot"); if (barbarianFish.contains(myPlayer())) { if (!myPlayer().isAnimating()) { if (salmon != null) { if (getMap().canReach(salmon)) { if (salmon.interact("Lure")) { log("Starting to fish."); getCamera().movePitch(67); getCamera().moveYaw(3); getMouse().moveOutsideScreen(); } } else { Sleep.sleepUntil(() -> myPlayer().isAnimating(), 3000); } } } } break; case COOK_FISH: log("COOKING FISH"); if (getInventory().contains("Raw trout", "Raw salmon") && getInventory().isFull()) { RS2Widget cookOpt = getWidgets().get(270, 14, 38); RS2Object fire = getObjects().closest("Fire"); if (fire != null) { if (!myPlayer().isAnimating()) { if (cookOpt != null) { cookOpt.interact("Cook"); getMouse().moveOutsideScreen(); } else { sleep(1000); if (!myPlayer().isAnimating()) { getInventory().interactWithNameThatContains("Use", "Raw salmon", "Raw trout"); fire.interact("Use"); } } } } } break; case WALK_TO_FISH: log("WALKING TO FISH"); getWalking().webWalk(barbarianFish); break; case WALK_TO_BANK: log("WALKING TO BANK"); getWalking().webWalk(bankArea); break; case DEPOSIT: log("DEPOSITING IN BANK"); if (bank.isOpen()){ bank.depositAllExcept("Fly fishing rod", "Feather"); } else { NPC bankBooth = getNpcs().closest("Banker"); if (bankBooth != null && bankBooth.interact("Bank")){ new ConditionalSleep(1000){ @Override public boolean condition(){ return bank.isOpen(); } }.sleep(); } } break; case IDLE: log("IDLING"); } return 700; } private State getState() { if (getInventory().isEmptyExcept("Fly fishing rod", "Feather", "Raw salmon", "Raw trout") && barbarianFish.contains(myPlayer())) { log("FISH_FISH"); return State.FISH_FISH; } else if (!barbarianFish.contains(myPlayer()) && getInventory().isEmptyExcept("Fly fishing rod", "Feather")) { log("WALK_TO_FISH"); return State.WALK_TO_FISH; } else if (getInventory().contains("Raw trout", "Raw salmon") && getInventory().isFull()) { log("COOK_FISH"); return State.COOK_FISH; } else if (getInventory().contains("Salmon", "Trout") && bankArea.contains(myPlayer())) { log("DEPOSIT"); return State.DEPOSIT; } else if (!bankArea.contains(myPlayer())) { log("WALK_TO_BANK"); return State.WALK_TO_BANK; } log("IDLE"); return State.IDLE; } @Override public void onExit() throws InterruptedException { } } The problem I am running into is, I can get the bot to perform 4/5 functions, but not all 5. For example, as the scripts sits now, It will bank if full of Cooked Fish, Deposit, Walk to Fish, Fish the fish, but now gets stuck when fishing because it wont recognize the inv.isFull(). I feel like I am in the right direction, but missing something small or misunderstanding something small rather. Any help and or feedback on the script would be appreciated as well. Thanks!
×
×
  • Create New...