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.

getRandomizedPath(Position[], int), getLocalPath(Position, Position[])

Featured Replies

    /**
     * Returns an array of {@link org.osbot.rs07.api.map.Position} nodes that
     * are randomized within {@code radius}. The {@code path} will not be
     * modified, nor will it hold any references to the returned array.
     *
     * @param path
     *            the path that will be randomized.
     * @param radius
     *            the radius in which the path will be randomized.
     * @return the new randomized path.
     */
    public static Position[] getRandomizedPath(Position[] path, int radius) {
        Position[] newPath = new Position[path.length];
        int idx = 0;
        for (Position node : path)
            newPath[idx++] = node.translate(MethodProvider.random(radius), MethodProvider.random(radius));
        return newPath;
    }

    /**
     * Returns an array of {@link org.osbot.rs07.api.map.Position} nodes that
     * are localized for the {@code node} point. This method is very useful for
     * when the script needs to cut out certain positions that aren't relevant;
     * for example, if the player starts a script when they are in the middle of
     * a path instead of the beginning or ending. Take for instance, this
     * pseudo-code.
     * 
     * <pre>
     * Position[] path = { position1, position2, position3, position4, position5, position6, position7 };
     * </pre>
     * 
     * If {@code node} is closest to "position3" in distance, the returned array
     * will look like...
     * 
     * <pre>
     * ... = { position3, position4, position5, position6, position7 };
     * </pre>
     * 
     * @param node
     *            the node in which the path should be localized for.
     * @param path
     *            the path that will be localized.
     * @return the new localized path.
     */
    public static Position[] getLocalPath(Position node, Position[] path) {
        List<Position> newPath = new LinkedList<>();
        int dist = -1;
        int index = -1;
        for (int i = 0; i < path.length; i++) {
            int newDist = node.distance(path[i]);
            if (dist == -1 || newDist < dist) {
                dist = newDist;
                index = i;
            }
        }
        IntStream.range(index, path.length).forEach(x -> newPath.add(path[x]));
        return newPath.toArray(new Position[newPath.size()]);
    }

Could come in handy for scripts that utilize walking, everything is explained in the documentation.

  • Author

and this is how I want the osbot docs to be made.

A decent explanation of what the function actually does smile.png

 

Thx for your contribution! 

 

Thanks man, I appreciate it.

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.