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

Client suggestion: make #closest() return the actual closest entity

Featured Replies

In short, this is a suggestion to change the calculation of #closest() from game tiles to a cost function to get the actual closest. It will impact scripts in many contexts, for example Varrock West Bank where 2/3 Bankers are all 2 tiles away, therefore OSBot picks one which could mean that the player moves around between bankers.

 

Let's take this square as an example:

e3040d7048028a6fc04263a4c3f65ec6.png

Its width and height are both 2 arbitrary units.

Now, let's cut it into 2 triangles: (one removed to see easier)

fdbf496488ae625b999eb339bf529d4c.png

With the help of our greek pal Pythagoras, we can conclude that  c != 2.

Why is this relevant?

OSBot will count #closest() in the form of game tiles. Now, if we label our own position as x, and 2 positions both 2 game tiles away (one horizontal, and one diagonal) x and y respectively, OSBot decides that dist(y) = dist(z) where dist(n) = abs(n - x). However, this is wrong:

c1792161cf0857e5d9c7f2a9bac04175.png

We can clearly see in this diagram that dist(z) > dist(y), however OSBot still concludes that they are of equal distance apart.

From this point, OSBot (seems) to choose a random entity from this list of those that are of the same distance apart.

Putting this into context: Varrock West Bank.

If you run getNpcs().closest("Banker") while standing in one of the stall-line things, you will switch between the bankers around you even though the one directly horizontal to you is the closest.

 

Solution: use a calculation like below.

If we set two cost variables, one for diagonal and one for non-diagonal. Their costs are 10 and 14 respectively (you could do 1 and sqrt(2) at the cost of more CPU). We can then perform a calculation like this: (pseudo)

horizontal = abs(n.x - x.x)
vertical = abs(n.y - x.y)

cost = max(horizontal, vertical) + (diagonalcost - nondiagonalcost) * min(horizontal, vertical)

Now, back to our pictures: (added the costs)

5eae153890870af757892fe3c01b7a03.png

From this, we can conclude that dist(y) < dist(z), because our calculations:

dist(y) = max(2, 0) + (14 - 10) * min(2, 0)
dist(z) = max(2, 2) + (14 - 10) * min(2, 2)

This will return the true closest.

Thanks for taking the time to read this :)

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.