Jump to content

Snippet world hopper fix


Bobbey

Recommended Posts

Here is a quick bad fix to keep your farms running. The world hopper is broken:

 

	private static final int[] F2PWORLDS = new int[] { 335, 379, 380, 382, 383, 384, 393, 394, 397, 398, 399, 418, 430,
			431, 433, 434, 435, 436, 437, 438, 439, 440, 451, 452, 453, 454, 455, 456, 457, 458, 459, 497, 498, 499,
			500, 501, 502, 503, 504 };

	private RS2Widget wor;

	public void hop(int world) {
		safeWhile(() -> !getLogoutTab().isOpen() && !getWorlds().isOpen(), 10, new Runnable() {
			public void run() {
				getLogoutTab().open();
				s(1000, 2000);
			}
		});
		safeWhile(() -> !getWorlds().isOpen(), 10, new Runnable() {
			public void run() {
				getWidgets().get(182, 4).interact("World Switcher");
				s(1000, 2000);
			}
		});
		Random r = new Random();
		s(1000, 2000);
		updateWor(world);
		getWidgets().get(69, 8).hover();
		safeWhile(() -> (wor.getAbsY() > 430 || wor.getAbsY() < 240), 40, new Runnable() {
			@Override
			public void run() {
				updateWor(world);
				getWidgets().get(69, 8).hover();
				if (wor.getAbsY() > 430) {
					getMouse().scrollDown();
					s(80 + r.nextInt(5));
					getMouse().scrollDown();
					s(80 + r.nextInt(5));
					getMouse().scrollDown();
				} else {
					getMouse().scrollUp();
					s(80 + r.nextInt(5));
					getMouse().scrollUp();
					s(80 + r.nextInt(5));
					getMouse().scrollUp();
				}
				s(100 + r.nextInt(20));
			}
		});
		if (wor.hover()) {
			// getMouse().click(false);
			wor.interact("Switch");
		}
		s(5000);
	}

	public void hopF2P() {
		Random r = new Random();
		int world = F2PWORLDS[r.nextInt(F2PWORLDS.length)];
		hop(world);
	}

	private void updateWor(int world) {
		wor = getWidgets().get(69, 16, world);
	}

 

update: you need to click the dialogue to actually hop:

something like this

		waitUntil(() -> getDialogues().isPendingOption(), 500, 10);
		safeWhile(() -> getDialogues().isPendingOption(), 10, new Runnable() {
			@Override
			public void run() {
				try {
					getDialogues().completeDialogue("Yes.");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				s(500);
			}
		});

 

 

And how could I forget: 


	public void safeWhile(Condition c, int attempts, Runnable runnable) {
		while (getBot().getScriptExecutor().isRunning() && !getBot().getScriptExecutor().isPaused()
				&& !getBot().getScriptExecutor().isSuspended() && c.evaluate()) {
			if (attempts-- == 0)
				return;
			runnable.run();
		}
	}

	public boolean waitUntil(Condition c, int interval, int tries) {
		safeWhile(() -> !c.evaluate(), tries, new Runnable() {
			@Override
			public void run() {
				try {
					sleep(interval);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		});
		return true;
	}
public interface Condition {
	
	boolean evaluate();

}

 

Edited by Bobbey
  • Like 1
Link to comment
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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...