Laz Posted April 11, 2014 Share Posted April 11, 2014 Hello fellow scripters, you know that "int onLoop()" method you guys like to use a lot? Well depending on how much logic you handle within this method call, you could be making your bot use more CPU. The best way to reduce this CPU usage is to raise the value given to it. In essence, you shouldn't be looping at less than 150 ms because it's a complete waste of CPU power and makes your script more detectable! Do you really think your brain makes concious decesions about the game your playing at 20 times a second (assuming your using return values of 50 ms)? No... in fact heres some data: http://www.humanbenchmark.com/tests/reactiontime/ They're median response time for humans on their study is 215 ms. I'm not exactly sure to what extent some scripters do this, but the more instructions you run per second, the more power your CPU needs to allocate to the script. Additionally, if your script for some reason needs to spam click or something, then make sure that your script doesn't execute many instructions when its looping at higher speeds. In essence, if you made it only do this... public int onLoop() { return 50; } ... than your not going to be using much CPU. But if you have an onLoop() method FILLED with hundreds of if-statements and conditionals everywhere, you're going to be using MUCH MUCH more! So tl;dr; Use a sleep time like gRandom(215, 80). That method uses a mean of 215 with a standard deviation of 80ms. Additionally, RuneScape's servers loop exactly every 600ms. What does this mean? It means that for every step you take in RS while walking, it takes roughly 600ms. If you're running, the steps get sent twice every 600ms. When you click on an object, it takes approximately 600ms for it to open. Etc. Etc. Thanks, Hopefully you guys learned something. 3 Link to comment Share on other sites More sharing options...
Kittens Posted April 11, 2014 Share Posted April 11, 2014 1st, and thank you Laz this is really helpful man Link to comment Share on other sites More sharing options...
Botre Posted April 11, 2014 Share Posted April 11, 2014 coolio Link to comment Share on other sites More sharing options...
Extreme Scripts Posted April 11, 2014 Share Posted April 11, 2014 Thanks @Laz, i remember doing this mistake back in the day Link to comment Share on other sites More sharing options...
Realist Posted April 11, 2014 Share Posted April 11, 2014 No clue what this means but yeah! Link to comment Share on other sites More sharing options...
Swizzbeat Posted April 11, 2014 Share Posted April 11, 2014 I thought this was common sense O_o 2 Link to comment Share on other sites More sharing options...
Sex Posted April 11, 2014 Share Posted April 11, 2014 Thanks. Link to comment Share on other sites More sharing options...
Ziy Posted April 11, 2014 Share Posted April 11, 2014 Hey Laz, please add this to the javadocs so it comes up in the API It would make it more helpful (I didn't realise the returned value did this), I assumed it was an exit status (d'oh) Link to comment Share on other sites More sharing options...
Mikey Posted April 11, 2014 Share Posted April 11, 2014 (edited) Common sense if you've ever worked with deadlocks. Edited April 11, 2014 by Mikey1 Link to comment Share on other sites More sharing options...
fre024 Posted May 7, 2014 Share Posted May 7, 2014 i run my scripts with 500 ms wait in the onLoop Link to comment Share on other sites More sharing options...
Ericthecmh Posted May 19, 2014 Share Posted May 19, 2014 I thought this was common sense O_o Lol you'd be surprised at how often people ask me to look over their code and it says "return 0" at the end... Link to comment Share on other sites More sharing options...