Jump to content

The Full Paint Tutorial - All aspects covered - Pug Tutorials


Pug

Recommended Posts

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.

Link to comment
Share on other sites

Do NOT add a sleep in the onPaint method facep.gif

 

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 by Botrepreneur
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

  • Like 1
Link to comment
Share on other sites

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.

  • Like 3
Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

  • 2 months later...

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 by tmanowen
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 2 months later...

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...?

Link to comment
Share on other sites

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 :)

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...