computor Posted October 15, 2014 Share Posted October 15, 2014 (edited) Hey guys, I created a simple fishing bot that clicks on the Net fishing spot for shrimp and anchovies. It's really simple, but I'd like to try and make it more complex. Right now, when I run it, the bot gets to the antiban section under "while (myPlayer().isAnimating())" section under the FISH enum state. Every time it hits the antiban, the chacter is animating, but sometimes the character stops animating mid-antiban. The bot runs through the entire antiban loop, and then clicks on the fishing spot. How can I keep it constantly updating, and override the antiban? I want it to immediately click the fishing spot if it stops fishing, not wait for the antiban to end. PLEASE HELP! Thanks. Code below: import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.MethodProvider; import java.awt.*; @ScriptManifest(author = "Computor", info = "My first script", name = "Simple Power-Shrimper", version = 1.0, logo = "") public class main extends Script { private static final int[] FISHING_ID = {1528}; @Override public void onStart() { log("Simple power-fisher for anchovies and shrimps. Run anywhere."); } private enum State { FISH, DROP, WAIT }; private State getState() { if (inventory.isFull()) return State.DROP; return State.FISH; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case FISH: if (!myPlayer().isAnimating()) { NPC Fishing_spot = npcs.closest(FISHING_ID); if (!inventory.isFull()){ Fishing_spot.interact("Net"); sleep(random(800,1200)); } while (myPlayer().isAnimating()){ sleep(MethodProvider.gRandom(6000, 13000)); getTabs().open(Tab.SKILLS); sleep(MethodProvider.gRandom(300, 1200)); getSkills().hoverSkill(Skill.FISHING); sleep(MethodProvider.gRandom(3000, 4000)); getTabs().open(Tab.INVENTORY); sleep(MethodProvider.gRandom(7000, 12000)); getMouse().moveRandomly(); } } break; case DROP: inventory.dropAllExcept(303); break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("End of fishing script."); } @Override public void onPaint(Graphics2D g) { } } Edited October 15, 2014 by computor Link to comment Share on other sites More sharing options...
Pug Posted October 15, 2014 Share Posted October 15, 2014 (edited) to make it a tiny bit more complex you could do this. Make a whole new method for your anti ban, then each time you run through your onLoop() method got to the antiban method, should also change the antiban up so do different things, like look at different skills, open different tabs, move camera pitch, move camera Yaw, etc etc. Code wise, something like this: private void antiban() throws InterruptedException { if(myPlayer().isAnimating()) { getTabs().open(Tab.SKILLS); sleep(100 + random(300, 700)); getSkills().hoverSkill(Skill.FISHING); sleep(100 + random(3000, 4000)); getTabs().open(Tab.INVENTORY); sleep(100 + random(500, 700)); getMouse().moveRandomly(); } } ^^^ this is your new antiban method. I cleaned it up a little and formatted it correctly. then you simply put into your on Loop method: antiban(); where ever you want it, i would suggest somewhere like this: case FISH: if (!myPlayer().isAnimating()) { NPC Fishing_spot = npcs.closest(FISHING_ID); if(Fishing_spot != null) { if (!inventory.isFull()) { Fishing_spot.interact("Net"); antiban(); } } } break; Edited October 15, 2014 by Pug Link to comment Share on other sites More sharing options...
Apaec Posted October 15, 2014 Share Posted October 15, 2014 you could also use the client's antiban instead! (this activates while you call a sleep. Link to comment Share on other sites More sharing options...
computor Posted October 15, 2014 Author Share Posted October 15, 2014 (edited) Thank you both very much! Apaec, the client antiban isn't that good in my opinion, and I wanted to make a few more options. Edited October 15, 2014 by computor Link to comment Share on other sites More sharing options...
Extreme Scripts Posted October 15, 2014 Share Posted October 15, 2014 Thank you both very much! Apaec, the client antiban isn't that good in my opinion, and I wanted to make a few more options. As @Pug said, you should really have a separate method for it and if you want to get even more technical + add a lot more features to the antiban then a separate class altogether would be better. Link to comment Share on other sites More sharing options...
computor Posted October 15, 2014 Author Share Posted October 15, 2014 I still am running in to the same problem however. Every time the bot runs the antiban, it finishes the entire antiban before fishing again. How do I interrupt the antiban process AS SOON AS the character stops animating? Link to comment Share on other sites More sharing options...
Extreme Scripts Posted October 16, 2014 Share Posted October 16, 2014 I still am running in to the same problem however. Every time the bot runs the antiban, it finishes the entire antiban before fishing again. How do I interrupt the antiban process AS SOON AS the character stops animating? It sounds like from the way you have it set up you will need to check if the character is animating before while your antiban task. You can do this using conditions ^_^ Link to comment Share on other sites More sharing options...
computor Posted October 16, 2014 Author Share Posted October 16, 2014 I know it would be a burden, but mind giving me an example? Link to comment Share on other sites More sharing options...
boyyo11 Posted October 25, 2014 Share Posted October 25, 2014 I still am running in to the same problem however. Every time the bot runs the antiban, it finishes the entire antiban before fishing again. How do I interrupt the antiban process AS SOON AS the character stops animating? The easiest way to would be is create a seperate class that extends Thread. Make it run and check if the while the player is animating you can sleep otherwise it will not run, so make the condition for the the stuff in the thread to sleep if your not animating. Link to comment Share on other sites More sharing options...