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

    • 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.
      • 30 replies
    • Come give us feedback on the next version of TRiBot!
      • 74 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
      • 23 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Like
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...