Swizzbeat Posted September 29, 2014 Share Posted September 29, 2014 Multiple threads for different paint data is the best way to go imo, for example: you might want to have real-time display of the run time which would be relatively cheap in terms of processing but only a once every 5 seconds update of your experience tracker(s) which would be more costly. But if you don't mind applying the same performance cost restrictions to all calculations, then pausing your onPaint could do just that indeed ^^ You'll use more processing power running all those threads than just by calculating the statistic every loop. Besides, considering this is the 21st century, doing simple mathematical calculations a few times per second is nothing for our current processors. The difference between calculating it 50 times versus even 3 times is barely (if at all) noticeable. Quote Link to comment Share on other sites More sharing options...
Botre Posted September 29, 2014 Share Posted September 29, 2014 (edited) Do NOT add a sleep in the onPaint method OSBot subclasses the Canvas (specifically to override the getGraphics method) which allows us to paint directly over the game image buffer. Adding a sleep will not only make your paint update slower but also the game frame rate. Since when does botting require game frame rate? This is a genuine question, does the slow buffering of graphics have any impact on interacting with the game at all? You'll use more processing power running all those threads than just by calculating the statistic every loop. Besides, considering this is the 21st century, doing simple mathematical calculations a few times per second is nothing for our current processors. The difference between calculating it 50 times versus even 3 times is barely (if at all) noticeable. Depends on how simple (or not) your calculations actually are. But yeah making 50 different threads for XP calculations probably isn't a smart thing to do. Edited September 29, 2014 by Botrepreneur Quote Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 29, 2014 Share Posted September 29, 2014 Since when does botting require game frame rate? This is a genuine question, does the slow buffering of graphics have any impact on interacting with the game at all? Depends on how simple (or not) your calculations actually are. But yeah making 50 different threads for XP calculations probably isn't a smart thing to do. How do you think we can actually "see" the game? RuneScape is just a Java Applet and inside of that applet a Canvas component which is obviously where the game is drawn to. The only way to actually draw to it though is to get the Canvas's Graphics context (using getGraphics) and using that instance to draw whatever it is they need. The bot takes advantage of this by injecting it's own "Canvas" as a superclass of the RuneScape canvas (aka subclassing the canvas since we're replacing the java.awt.Canvas class they're extending with our own). You could also xboot to replace the default one found in rt.jar for the same effect. Any call the game makes to the getGraphics method would then run our custom method where we can draw the current context to a back buffer and layer out paint over top of it, returning the back buffer for the game to draw on.If you're confused let me know, I have some great links stored back from my days of investigating into making my own injection bot. 1 Quote Link to comment Share on other sites More sharing options...
Botre Posted September 29, 2014 Share Posted September 29, 2014 How do you think we can actually "see" the game? RuneScape is just a Java Applet and inside of that applet a Canvas component which is obviously where the game is drawn to. The only way to actually draw to it though is to get the Canvas's Graphics context (using getGraphics) and using that instance to draw whatever it is they need. The bot takes advantage of this by injecting it's own "Canvas" as a superclass of the RuneScape canvas (aka subclassing the canvas since we're replacing the java.awt.Canvas class they're extending with our own). You could also xboot to replace the default one found in rt.jar for the same effect. Any call the game makes to the getGraphics method would then run our custom method where we can draw the current context to a back buffer and layer out paint over top of it, returning the back buffer for the game to draw on. If you're confused let me know, I have some great links stored back from my days of investigating into making my own injection bot. Does the client actually has to render the game's latest buffered image for let's say interactions to work? If not (which I think is the case) then it doesn't really matter, if anything lowering the FPS would be beneficial in terms of processing, or am I missing something here? I'm asking this because the client has (or used to have) a "no render" option. Quote Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 29, 2014 Share Posted September 29, 2014 Does the client actually has to render the game's latest buffered image for let's say interactions to work? If not (which I think is the case) then it doesn't really matter, if anything lowering the FPS would be beneficial in terms of processing, or am I missing something here? I'm asking this because the client has (or used to have) a "no render" option. No, this isn't a color based bot. The bot interacts with the game based off what it finds in the jar file using the injected accessor methods. We're using nothing more than a RuneScape virus. Yes lowered FPS would be better in terms of processing, however adding a sleep to the onPaint would cause an overall "lag" for not only the paint but the game as well (something I doubt a botter would want). 1 Quote Link to comment Share on other sites More sharing options...
FrostBug Posted September 29, 2014 Share Posted September 29, 2014 I'm fairly certain that they were talking about asynchronous updaters for the values, and not sleeping in onPaint. Doing so could be mildly beneficial, using something like a Scheduler or ScheduledExecutorService, altho as Swizz mentioned, it's not really necessary. If you did infact talk about adding sleeps in onPaint, tho, then... well.. don't. Threads that hande graphics/rendering should never be obstructed from returning, as it can make the entire user interface unresponsive. Especially if it's the EDT being sent to the paint methods. 3 Quote Link to comment Share on other sites More sharing options...
Botre Posted September 29, 2014 Share Posted September 29, 2014 I'm fairly certain that they were talking about asynchronous updaters for the values, and not sleeping in onPaint. Doing so could be mildly beneficial, using something like a Scheduler or ScheduledExecutorService, altho as Swizz mentioned, it's not really necessary. If you did infact talk about adding sleeps in onPaint, tho, then... well.. don't. Threads that hande graphics/rendering should never be obstructed from returning, as it can make the entire user interface unresponsive. Especially if it's the EDT being sent to the paint methods. No, this isn't a color based bot. The bot interacts with the game based off what it finds in the jar file using the injected accessor methods. We're using nothing more than a RuneScape virus. Yes lowered FPS would be better in terms of processing, however adding a sleep to the onPaint would cause an overall "lag" for not only the paint but the game as well (something I doubt a botter would want). I wasn't the one who suggested it. Coolio thanks for the info Quote Link to comment Share on other sites More sharing options...
Augury13 Posted December 10, 2014 Share Posted December 10, 2014 (edited) So i was just looking through and I was wondering why Pug uses public void onPaint(Graphics2D g) { Graphics2D gr = g; currentXp = skills.getExperience(Skill.WOODCUTTING); xpGained = currentXp - beginningXp; g.drawString("" + xpGained, 1, 1); } when i'm getting the error that gr is never used... so i try to switch 'g.drawString("" ' with 'gr.drawString("" ' and neither of them actually show anything on the client. A paint would be nice and helpful but i feel like i should try to figure this out step by step (:. Thanks for the help whoever can help me!! edit: the pastebin i'm referring to: http://pastebin.com/MtmTxL2w Edited December 10, 2014 by tmanowen Quote Link to comment Share on other sites More sharing options...
Synapse Posted January 14, 2015 Share Posted January 14, 2015 Hey, My background image is fucked up. It gets cut off by the chat. Link to screenshot: http://puu.sh/ew35h/737b70af66.jpg Quote Link to comment Share on other sites More sharing options...
Augury13 Posted February 27, 2015 Share Posted February 27, 2015 So i know pug resigned(sadly), but can anyone help me with paints, as in the paints here, or at least the time began ones dont work for me anymore? Quote Link to comment Share on other sites More sharing options...
Pug Posted May 5, 2015 Author Share Posted May 5, 2015 (edited) nice to see my thread being used. Popped in for a look around. Might update the thread this week if i have time. Can add a few things to a paint ive learnt since this. edit: also nice to see swizzbeat banned Edited May 5, 2015 by Pug 1 Quote Link to comment Share on other sites More sharing options...
lare96 Posted May 5, 2015 Share Posted May 5, 2015 Nice tutorial, but a few things. This private String ft(long duration) { String res = ""; long days = TimeUnit.MILLISECONDS.toDays(duration); long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration)); long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS .toHours(duration)); long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS .toMinutes(duration)); if (days == 0) { res = (hours + ":" + minutes + ":" + seconds); } else { res = (days + ":" + hours + ":" + minutes + ":" + seconds); } return res; } Can just be this LocalTime.ofSecondOfDay(TimeUnit.MILLISECONDS.toSeconds(duration)).toString(); And for the experience gained part, can you not just use the experience tracker...? Quote Link to comment Share on other sites More sharing options...
Pug Posted May 5, 2015 Author Share Posted May 5, 2015 Nice tutorial, but a few things. This private String ft(long duration) { String res = ""; long days = TimeUnit.MILLISECONDS.toDays(duration); long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration)); long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS .toHours(duration)); long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS .toMinutes(duration)); if (days == 0) { res = (hours + ":" + minutes + ":" + seconds); } else { res = (days + ":" + hours + ":" + minutes + ":" + seconds); } return res; } Can just be this LocalTime.ofSecondOfDay(TimeUnit.MILLISECONDS.toSeconds(duration)).toString(); And for the experience gained part, can you not just use the experience tracker...? at the time of thread creation, we didnt have any API for experince tracking. Everything was made by ourselves lol. Nice addition though 1 Quote Link to comment Share on other sites More sharing options...
Poopsiedaisy Posted May 16, 2015 Share Posted May 16, 2015 Great tut helped me heaps thank you very much pug!. 1 Quote Link to comment Share on other sites More sharing options...
Ask4Help Posted May 31, 2015 Share Posted May 31, 2015 Very nice guide! Thanks for putting the time and effort into making this Quote Link to comment Share on other sites More sharing options...