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.

Hopping to random worlds.

Featured Replies

I've been trying to teach myself how to write my own scripts and I've been having trouble with hopToF2PWorld and hopToP2PWorld. It would randomly hang up on trying to select Speed Running worlds and occasionally there would just be a world that didn't want to let me connect for whatever reason and it would stop my scripts. I decided to try to make my own function. It takes note of whether you are in a F2P or P2P world and hops accordingly. I wanted to share incase anyone else is having this issue and more importantly incase someone who know a bit more can tell me why this would be bad to do lol.
 

void HopRandomWorld() {
        int P2PWorlds[] = {303, 304, 305, 306, 307, 309, 310, 311, 312, 313, 314, 315, 317, 318, 319, 320, 321, 322, 323, 324,
                325, 327, 328, 329, 330, 331, 332, 333, 334, 336, 337, 338, 339, 340, 341, 342, 343, 344, 346, 347, 348, 350,
                351, 352, 354, 355, 356, 357, 358, 359, 360, 362, 367, 368, 370, 374, 375, 376, 377, 378, 386, 387, 388, 389,
                390, 395, 421, 422, 424, 443, 444, 445, 446, 463, 464, 465, 466, 477, 478, 480, 481, 482, 484, 485, 486, 487,
                488, 489, 490, 491, 492, 493, 494, 495, 496, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517,
                518, 519, 520, 521, 522, 523, 524, 525, 531, 532, 534, 535};
        int F2PWorlds[] = {308, 316, 335, 371, 382, 383, 384, 394, 397, 398, 399,
                417, 418, 430, 431, 433, 434, 435, 436, 437, 451, 452, 453, 454, 455,
                456, 470, 471, 475, 476, 483, 497, 498, 499, 500, 501, 537, 542, 543,
                544, 545, 546, 547, 552, 553, 554, 556, 557, 562, 563, 571, 575};
        if (getWorlds().isMembersWorld()) {
            int TargetIndex = random(0, P2PWorlds.length);
            if (P2PWorlds[TargetIndex] != getWorlds().getCurrentWorld()) {
                getWorlds().hop(P2PWorlds[TargetIndex]);
            } else {
                HopRandomWorld();
            }
        } else {
            int TargetIndex = random(0, F2PWorlds.length);
            if (F2PWorlds[TargetIndex] != getWorlds().getCurrentWorld()) {
                getWorlds().hop(F2PWorlds[TargetIndex]);
            } else {
                HopRandomWorld();
            }
        }
    }

 

Edited by Alakazizam

I didn't test your method, but immediately I see there's a chance to throw an array out of bounds exception (not providing array.length - 1 on indexing). Here's a more condensed implementation that might help:

static final int[] fWorlds = { 1, 8, 16, ... };
static final int[] mWorlds = { 2, 3, 4, ... };
public static void hopRand() {
    final int[] hWorlds = getWorlds().isMembersWorld() ? mWorlds : fWorlds;
    if (!getWorlds().hop(300 + hWorlds[random(0, hWorlds.length - 1)])) {
        hopRand();
    }
}

 

Edited by TheJacob
Added example

Good work, should be helpful to many people :D Also nice to see more scripters ^^ :D 

A quick heads up though, it's useful to try Filter<Worlds> to filter out worlds, it's possible to exclude speedrunning worlds this way too:


        Filter<World> worldFilter = a -> !a.isFull() && a.isMembers() && !a.isHighRisk() && !a.isPvpWorld()
                && a.getActivity() != null
                && !getHoppedWorlds().contains(a.getId()) && !a.getActivity().contains("kill t") && !a.getActivity().contains("eedrun")
                && !a.getActivity().contains("arget") && a.getId() != getContext().getWorlds().getCurrentWorld();

and then match them with

getWorlds().getAvailableWorlds(true).stream().filter(worldFilter::match)

to find the result

E.g. this is what I use in my prayer bot to hop to safe world when doing chaos altar bones. It avoids skill total worlds, target worlds pvp worlds etc. you could easily modify this to suit your needs :doge: 

 

Edited by Czar

  • Author
57 minutes ago, TheJacob said:

I didn't know this until reading your post, but getWorlds().getAvailableWorlds(...) doesn't dump an OSRS world list, rather a subset of maybe 30 worlds (appears to be an ordered list from W301?).

I didn't test your method, but immediately I see there's a chance to throw an array out of bounds exception (not providing array.length - 1 on indexing). Here's a more condensed implementation that might help:

static final int[] fWorlds = { 1, 8, 16, ... };
static final int[] mWorlds = { 2, 3, 4, ... };
public static void hopRand() {
    final int[] hWorlds = getWorlds().isMembersWorld() ? mWorlds : fWorlds;
    if (!getWorlds().hop(300 + hWorlds[random(0, hWorlds.length - 1)])) {
        hopRand();
    }
}

 

Good catch! 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.