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.

Move away from other player

Featured Replies

Im trying to move away my player of another player is standing next to it, but it does not seem to do anything.

I have tried alot of different methods, but none seem to work.

Here is what I have now:

 

    private void moveAway(Player player) throws InterruptedException
    {
        try {
            if (isRanger) {

                if (!(abs(myPlayer().getPosition().getX() - player.getPosition().getX()) > 1) && !(abs(myPlayer().getPosition().getY() - player.getPosition().getY()) > 1)) {
                    log("Trying to move");

                    WalkingEvent event = new WalkingEvent(player).setMinDistanceThreshold(3);
                    execute(event);
                }
            }
        }catch (RuntimeException ex)
        {
            log(ex);
        }
    }

Best would be if it clicked on the screen and not he minimap.

 

Thanks in advance.

Couple of things. Firstly, it might be worth taking a look at the WalkingEvent API https://osbot.org/api/org/osbot/rs07/event/WalkingEvent.html (specifically setMinDistanceThreshold, which presumably doesn't do what you think it does)

Secondly, it is worth noting that a Position (https://osbot.org/api/org/osbot/rs07/api/map/Position.html) represents an in-game tile. You might find your 'same tile' check can be simplified:

if (myPlayer().getPosition().equals(player.getPosition())) {
  // ..
}

Best of luck

Apa

Instead of calculating the distance like that what you can do is

if (myPosition().equals(player.getPosition())

And the reason why you're not moving is because your walking event is trying to walk to the player itself.

WalkingEvent event = new WalkingEvent(player).setMinDistanceThreshold(3);
should be
WalkingEvent event = new WalkingEvent(the position you want to walk to);

 

  • Author
7 minutes ago, d0zza said:

Instead of calculating the distance like that what you can do is


if (myPosition().equals(player.getPosition())

And the reason why you're not moving is because your walking event is trying to walk to the player itself.


WalkingEvent event = new WalkingEvent(player).setMinDistanceThreshold(3);
should be
WalkingEvent event = new WalkingEvent(the position you want to walk to);

 

I got it working now thanks. 

And yes I know I can use 

if (myPosition().equals(player.getPosition())

But that only checks if iets the exact same position. And I also need to know if it is next to him. So I need to absolute difference between player and use X and Y.

6 minutes ago, digitaltoaster said:

I got it working now thanks. 

And yes I know I can use 


if (myPosition().equals(player.getPosition())

But that only checks if iets the exact same position. And I also need to know if it is next to him. So I need to absolute difference between player and use X and Y.

Have you considered:

if (getMap().distance(player) <= 1) {
  // ..
}

?

  • Author
1 minute ago, Apaec said:

Have you considered:


if (getMap().distance(player) <= 1) {
  // ..
}

?

Oh I did not, thanks! Will use that instead of what I used.
Thank you!

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.