Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold
Sign in to follow this  
Sidesteppin12

Random WorldHopper [Hop to random worlds]

Recommended Posts

Posted (edited)

This Worldhopper is solely for hopping to random worlds. It will ignore skill total worlds if isTotal is set to false. Setting it to true will NOT make you hop only to skill total worlds. It means it has to the chance to choose one of them to hop to.

It will also remember the last 10 worlds you hopped to, and will not hop to those worlds.

Spoiler
package scripts.jTasker.jay_api;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import org.tribot.api.General;
import org.tribot.api.Timing;
import org.tribot.api.input.Mouse;
import org.tribot.api.util.abc.ABCUtil;
import org.tribot.api2007.ChooseOption;
import org.tribot.api2007.Magic;
import org.tribot.api2007.WorldHopper;

public class WorldHopping {
	private static ABCUtil util = new ABCUtil();
	private static HashMap<Integer, Integer> CACHE = new HashMap<Integer, Integer>();

	// Ignores deadman worlds & skill total worlds by default.
	public static boolean changeRandom(boolean isMembers) {
		return changeRandom(isMembers, false, false);
	}

	// Ignores deadman worlds by default.
	public static boolean changeRandom(boolean isMembers, boolean isTotal) {
		return changeRandom(isMembers, isTotal, false);
	}
	
	public static boolean changeRandom(boolean isMembers, boolean isTotal, boolean isDeadman) {
		if (deselectMagic()) // Can fail to click the world select screen if a spell is selected.
			return false;
		
		if (CACHE.size() > 10) {
			CACHE.remove(0); // Remove the least recent world we hopped to.
			Set<Integer> set = new HashSet<Integer>(CACHE.values()); // Get all the world numbers.
			CACHE.clear(); // Clear the map.
			for (int value : set)
				CACHE.put(CACHE.size(), value);
		}

		WorldHopper.openWorldSelect();
		int randWorld = WorldHopper.getRandomWorld(isMembers, isDeadman);
		long startTime = System.currentTimeMillis();
		while((randWorld == WorldHopper.getWorld() || CACHE.containsValue(randWorld) ||
			  (!isTotal && getTotalWorldLvl(randWorld) != 0)) &&
			 ((System.currentTimeMillis() - startTime) / 1000.0f) % 60 < 2) {
			General.sleep(50);
			randWorld = WorldHopper.getRandomWorld(isMembers, isDeadman);
		}

		CACHE.put(CACHE.size(), randWorld);
		return WorldHopper.changeWorld(randWorld);
	}
	
	private static int getTotalWorldLvl(int w) {
		switch(w) {
			case 381: case 413: case 419: case 427: case 468: // 500 total worlds. F2P
				return 500;
			case 372: case 385: case 414: case 432: case 530: // 750 total worlds. F2P
				return 750;
			case 353: case 364: case 429: case 447: case 529: // 1250 total worlds.
				return 1250;
			case 366: case 416: case 420: case 448: case 528: // 1,5k total worlds.
				return 1500;
			case 373: case 391: case 449: case 467: // 1750 total worlds.
				return 1750;
			case 349: case 361: case 396: case 428: case 527: // 2k total worlds.
				return 2000;
			case 363: case 415: case 450: case 526: // 2,2k total worlds.
				return 2200;
			default:
				return 0;
		}
	}
	
	public static boolean deselectMagic() {
		if (Magic.isSpellSelected()) {
		    if (Timing.waitCondition(() -> {
				util.moveMouse();
				General.sleep(200, 400);
				Mouse.click(3);
				General.sleep(200, 700);
				ChooseOption.select("Cancel");
				General.sleep(200, 700);
		        return !Magic.isSpellSelected();
		    }, General.random(7000, 10000)) == false) {
		    	General.println("AutoGeneral_Error - Could not deselect mouse.");
		    	return false;
		    }
		}

		return true;
	}
}

 

 

There are some things to be worked on though. Such as not hard coding the total worlds as they are constantly changing numbers or adding/removing worlds and instead find a better way to filter total worlds. 

Or checking if the player has a high enough skill total before attempting to hop onto the selected skill total world. These are things I might return to in the future unless someone beats me to it and releases an update of my class.

Edited by Sidesteppin12
  • Like 1

Share this post


Link to post
Share on other sites

Nice mate. A few improvements I'd recommend:

1. is using a Guava Cache (you can set a max size, and a timeout on the data inside it). Cache I use in my personal world hopper code:

private static Cache<String, String> worldBlacklistCache;

worldBlacklistCache = CacheBuilder.newBuilder()
  .maximumSize(15)
  .expireAfterWrite(20, TimeUnit.MINUTES)
  .build();

2. You can also use the WorldHopper.getServers()  to get the servers, and do things like sort them by population so you can hop to the lowest populated worlds (and you can create a method to filter them by activity, so you don't have to hardcode the required skill worlds). 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Our picks

    • To better support the upcoming changes (TRiBot X, new repository), we're switching our login handler to Auth0. Instead of logging in with the standard form, you'll now be required to login through our Auth0 application.

      All existing accounts which have been used within approximately the past year have been imported into Auth0 using the same email and password combination which has been stored on the forums.

      What does this mean for users?

      Your account credentials are now even more securely stored


      You'll be able to login via Facebook, Google, and others in the future


      Is there anything users have to do differently now?

      Existing users: You'll have to login with the standard login, open your Account Settings, then link your Auth0 account


      New users: You'll be redirected to our Auth0 app (auth.tribot.org) where you'll be able to create an account


      Why was this change made?

      The new apps we are creating (such as the new repository) aren't able to use the forums to handle user logins


      To centralize all user accounts in one area


      To ensure that the client login doesn't go down when the forums are having problems


      To speed up our development


      Other considerations

      There's no documentation or official support for using Invision Community combined with Auth0, so there are still a few kinks we're working out


      We're in the works of creating an account management panel specifically for Auth0 accounts (ETA August)


      It's not possible to change email addresses for the time being (this will be resolved this August)


      Changing passwords is a weird process for the time being. To change your password, you'll have to use the "Don't remember your password" tool on the Auth0 login page
        • Like
      • 10 replies
    • Over the past month, we've been working hard on TRiBot's new repository - a much needed update. This change has been deemed necessary for TRiBot X, and will allow us to really speed up development of all aspects of TRiBot.

      Today we are going to share what we've been working on!


      Now you must be wondering what kind of features the new repository will have.... well, you'll have to be patient for a little while longer. We're still figuring out various technical aspects so we can't provide answers to all possible questions. We're also focusing on development rather than writing about it so that everyone can get access to our latest developments at lightning speed. I will however answer a few users' questions.

      We're planning on a release of this early to mid August, giving users some goodies before TRiBot X's release.

      Thank you all for being patient. I hope everyone is excited as much as I am!
        • Like
      • 17 replies
    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
        • Like
      • 50 replies
    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 86 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
        • Like
      • 26 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...