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.

What is the best way to find the center of a tile ? or area ?

Featured Replies

I have no idea on how to do it; everything I have tried is always just slightly off, its driving me insane ):

will post what I got if needed but obviously mines wrong lol

  • Author
13 minutes ago, raijin said:

isnt area like

position x = area.getcentertile(); or getcenter?

i dunno ill try and report back xD

 

15 minutes ago, raijin said:

isnt area like

position x = area.getcentertile(); or getcenter?

Nope that doesnt work there is no getCenter

  • Author
5 minutes ago, Stimpack said:

Try averaging out the x and y points of the tile's polygon and use the result as your new point. If the polygon isn't too complex i think it should be close to what you need.

 

https://en.m.wikipedia.org/wiki/Centroid#Of_a_finite_set_of_points

I figured it out using this 

int mouseSpotX = Math.toIntExact((long) hoverTile.getPolygon(getBot()).getBounds().getCenterX());
		int mouseSpotY = Math.toIntExact((long) hoverTile.getPolygon(getBot()).getBounds().getCenterY());

mouse.move really needs to have both x and y but also sometimes z ): 

 

  • Author
49 minutes ago, LoudPacks said:

You can do some math and then do:

int x = x + width / 2

int y = y + height / 2 (or subtract depending on if up is -y or +y)

Ill give that a shot as well, I have found that different camera angles play a part, thats why I want mouse.move to contain z axis as this will help with the height why do I divide by 2 ? just asking 

 

Edited by whipz

  • Author
4 hours ago, Explv said:

Edit: Nevermind

@whipz What exactly are you trying to achieve here?

i want to get the mouse to move on the z axis on a tile ):

Here is finding the center using Centroid finite set of points. I passed in Area#getPolygon(), not sure how it'd react to Position#getPolygon()

The function output

 Point2D.Double[6703.75, 3367.75]

 

In my use I will always be rounding up, but you may choose to do either way.

 

public Point2D.Double calcPolygonCenter(Polygon polygon) {
		double x = 0;
		double y = 0;
		int points = polygon.npoints;
		for (int i = 0; i < polygon.xpoints.length; i++) {
			x += polygon.xpoints[i];
		}
		for (int i = 0; i < polygon.ypoints.length; i++) {
			y += polygon.ypoints[i];
		}

		x = x / points;
		y = y / points;

		return new Point2D.Double(x, y);
	}

 

Create an account or sign in to comment

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.