Jump to content

How do I make a bot world hop?


Recommended Posts

  • 4 months later...

There are a couple of ways you can do this.

Firstly you can make a list of valid worlds and then hop to either of those.

import com.epicbot.api.shared.util.Random;
import com.epicbot.api.shared.script.ScriptManifest;
import com.epicbot.api.shared.GameType;

@ScriptManifest(name = "World Hopper", gameType = GameType.OS)
public class WorldHopper extends LoopScript {
	private int[] AVAILABLE_WORLDS = {501, 562, 544, 499, 502};
  
  	@Override
   	protected int loop() {
      	// Get the current world
        int previousWorld = getAPIContext().world().getCurrent();
      	
      	// Select random world from AVAILABLE WORLDS
        int randomWorld = AVAILABLE_WORLDS[Random.nextInt(0, AVAILABLE_WORLDS.length - 1)];
      	
      	// Hop to random world
      	getAPIContext().world().hop(randomWorld);
      	
      	// Sleep till world changes
      	Time.sleep(5000, 15000, () -> getAPIContext().world().getCurrent() != previousWorld);
       	
       	return 0;
    }
}

Another method would be to use the world().hopToF2P() or world().hopToP2P()

import com.epicbot.api.shared.script.ScriptManifest;
import com.epicbot.api.shared.GameType;

@ScriptManifest(name = "World Hopper", gameType = GameType.OS)
public class WorldHopper extends LoopScript {  
  	@Override
   	protected int loop() {
        // Get the current world
        int previousWorld = getAPIContext().world().getCurrent();
      	
      	// Hop to F2P world (switch F2P for P2P for members)
      	getAPIContext().world().hopToF2P();
      	
      	// Sleep till the world changes
      	Time.sleep(5000, 15000, () -> getAPIContext().world().getCurrent() != previousWorld);
       	
       	return 0;
    }
}

 

Edited by crashbashash
Added comments and formatting was a bit wrong.
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×
  • Create New...