Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

how to make the cursor move in a circular way

Featured Replies

let's say i have an entity and i want to cursor to move in a circular way like x2+y2=radius around that entity, i know the move command in the API but how do i implement that x2+y2=radius?

 

Edited by kadiem

Why would you want to know how to implement this? Just out of curiosity...

I don't know nearly as much as some of the scripters here, so when I write my own scripts I use many basic methods throughout my scripts. It gets the job done, but just takes more resources, is messier, and can likely be done a much easier or quicker way. 

The only way I can think to make the mouse move like that, is to create the movement of the top/bottom arc, maybe using a "for" statement. Then repeating the same immediately after for the bottom/top arc (because there is not a function that can have multiple values of x and the same time, which is why 2 for statements would be needed for this method). Give me a couple minutes to make an attempt at this lol

 

Well this seems like a stupid thing to do, but whatever.

Presumably you did maths in school, and i'm really unsure as to why you could not Google this yourself......

The equation to calculate the x and y circumference coordinates for a given origin, radius, & angle is:

x = centreX + radius * cos(angle)
y = centerY + radius * sin(angle)

For the sin and cos functions in Java you can use Math.cos(angle) and Math.sin(angle) where the angle is in radians. (360 degrees is 2pi radians)

 

So first to calculate the origin you would get the bounding box (Rectangle) of the Entity using:

Rectangle rect = entity.getModel().getBoundingBox(entity.getGridX(), entity.getGridY(), entity.getZ());

And then get the center point with getCentreX() and getCenterY()

You can choose a radius yourself, or use something like (width / 2)

Once you have the components, you can then calculate the points on the circumference at x angle increments, e.g. 2pi / 360 increments, and move the mouse to each one.

 

Edited by Explv

16 minutes ago, Explv said:

Well this seems like a stupid thing to do, but whatever.

Presumably you did maths in school, and i'm really unsure as to why you could not Google this yourself......

The equation to calculate the x and y circumference coordinates for a given origin, radius, & angle is:


x = centreX + radius * cos(angle)
y = centerY + radius * sin(angle)

For the sin and cos functions in Java you can use Math.cos(angle) and Math.sin(angle) where the angle is in radians. (360 degrees is 2pi radians)

 

So first to calculate the origin you would get the bounding box (Rectangle) of the Entity using:


Rectangle rect = entity.getModel().getBoundingBox(entity.getGridX(), entity.getGridY(), entity.getZ());

And then calculate the center point (minX + (width / 2), minY + (height / 2))

You can choose a radius yourself, or use something like (width / 2)

Once you have the components, you can then calculate the points on the circumference at x angle increments, and move the mouse to each one.

 

This is what I meant when I said somebody more experienced would be able to accomplish this much quicker than myself, lol. I did it as well though, just different...

 

    Entity tree = objects.closest("Tree");
            if(tree != null) {
                tree.hover();
                int mouseCircleX = mouse.getPosition().x;
                int mouseCircleY = mouse.getPosition().y;
                int mouseRadius = 9;
                int radiusSquared = mouseRadius * mouseRadius;
                int timeToCompleteHalfCircle = 800; // .8 seconds for it to complete each half of the circle
                // THIS IS THE BOTTOM HALF OF THE CIRCLE FROM LEFT TO RIGHT              
                for(int k = ((-1)*mouseRadius); k <= mouseRadius; k++)  {
                    mouse.move(mouseCircleX + k, mouseCircleY + ((int) Math.sqrt(radiusSquared - (k * k))));
                    sleep(timeToCompleteHalfCircle/(mouseRadius * 2));
                }
                // THIS IS THE TOP HALF OF THE CIRCLE FROM RIGHT TO LEFT
                for(int k = ((-1)*mouseRadius); k <= mouseRadius; k++)  {
                    mouse.move(mouseCircleX - k, mouseCircleY + ((-1) * (int) Math.sqrt(radiusSquared - (k * k))));
                    sleep(timeToCompleteHalfCircle/(mouseRadius * 2));
                }
                log("Circling Tree, Jagex will never catch me now...");
            }

Oh, and I did test this, it does actually work. Lemme know if this is what you were going for though

Edited by strange_kid

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.