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 walk a random predefined path?

Featured Replies

So I understand how to declare a path, and walk the path. What I'm trying to do is declare 3 paths that all go to the same location, but using different tile combinations, and then make my script randomly select a path to take, making it more random, and less boy like.

Has Java got a built in random function that I can tell it to return a random between 0 and 2, and then make it walk the path correlating to that number? Sorry if I'm being confusing

Like chris mentioned, you can use Random.nextInt(3) or osbot's random(0,2).


If your 3 paths are similar, you probably don't need to do this kind of thing because osbot doesn't always click on the exact same tiles.

  • Author
8 hours ago, Chris said:

 

8 hours ago, Khaleesi said:

public static int randInt(int min, int max) {
    Random rand = new Random();
   return rand.nextInt((max - min) + 1) + min;
}

Thank you for the help guys!

 

 

8 hours ago, Jarl said:

Like chris mentioned, you can use Random.nextInt(3) or osbot's random(0,2).


If your 3 paths are similar, you probably don't need to do this kind of thing because osbot doesn't always click on the exact same tiles.

Yeah, I appreciate that, just thought that it couldn't hurt to make my script seem more random, right?

  • Author
List<Position> pathToSewer = new ArrayList<>();
@Override
public void onStart() {
    log("Let's get started!");
    pathToSewer.add(new Position(3246, 3433, 0));
    pathToSewer.add(new Position(3246, 3450, 0));
    pathToSewer.add(new Position(3238, 3457, 0));
}
public int onLoop() throws InterruptedException {
    if (varrockBank.contains(myPlayer()) && !getInventory().isFull())
    {
        log("Walking to sewer");
        getWalking().walkPath(pathToSewer);
    }
    return random(2000, 5000);
}

 

So i'm using the walkPath function, but basically, it walks my player to the first position on the path, and even once I reach the tile, the script clicks on the exact tile to ensure I have moved to it. It doesn't do this for any other position of the path? Anyone know what could be causing this?

  • Author

Do I need to spread the positions out even more? They are already only just visible by zooming all the way out

On 1/9/2021 at 7:04 AM, mitsuki said:

Do I need to spread the positions out even more? They are already only just visible by zooming all the way out

No. Your positions were too spread out. You need to make the positions closer for the part where the script keeps clicking on the same tile.

  • Author

Is there any other way to declare the path before the onstart or onloop? I currently just add all of the positions of the path in onStart with: 

@Override
public void onStart() {
    log("Let's get started!");
    pathToSewer.add(new Position(3246, 3433, 0));
    pathToSewer.add(new Position(3246, 3450, 0));
    pathToSewer.add(new Position(3238, 3457, 0));
}

But is there any other way to declare it outside of the loops? Or is adding each position on startup the best method?

1 hour ago, mitsuki said:

?

I thinks this will work 

static{
    pathToSewer.add(new Position(3246, 3433, 0));
    pathToSewer.add(new Position(3246, 3450, 0));
    pathToSewer.add(new Position(3238, 3457, 0));
}

or

    List<Position> pathToSewer = new ArrayList<Position>(Arrays.asList(new Position[]{new Position(3246, 3433, 0), new Position(3246, 3450, 0), new Position(3238, 3457, 0)}));

or use 

https://explv.github.io/?centreX=3108&centreY=3315&centreZ=0&zoom=7

Edited by Nbacon

private static final List<Position> PATH_TO_SEWER = Arrays.asList(
            new Position(3246, 3433, 0),
            new Position(3246, 3450, 0),
            new Position(3238, 3457, 0)
    );

You can put this at the top, inside the class but outside the methods. It is not a must but it is a good idea to follow java naming conventions. Constants should be declared in capitals.

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.