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.

How and when to use CASE?

Featured Replies

If you're referring to the Java syntax of case, it's used inside switch statements to give code to execute based on the value of the statement/variable being switched.

  • Author

I have this snippet iv just taken from snippet section, could your or someone break it down for me and tell me what it does? id really appreciate it, and thanks for the reply btw :)

	private void hoverskill() throws InterruptedException {
		if (tabs.getOpen() != Tab.SKILLS) {
			tabs.open(Tab.SKILLS);
		}
		switch (attmethod) {
		case ATTACK:
			getWidgets().get(320, 1).hover();
			break;

		case STRENGTH:
			getWidgets().get(320, 2).hover();
			break;

		case DEFENCE:
			getWidgets().get(320, 3).hover();
			break;
		}
		sleep(random(4000, 7000));
	}

	private Skill getAttMethod() {
		switch (getConfigs().get(43)) {
		case 0:
			attmethod = Skill.ATTACK;
			break;
		case 1:
			attmethod = Skill.STRENGTH;
			break;
		case 3:
			attmethod = Skill.DEFENCE;
			break;
		}
		return attmethod;
	}

 

private void hoverskill() throws InterruptedException {
		if (tabs.getOpen() != Tab.SKILLS) {
			tabs.open(Tab.SKILLS);
		}
		switch (attmethod) { //1
		case ATTACK: //2
			getWidgets().get(320, 1).hover();
			break;

		case STRENGTH://2
			getWidgets().get(320, 2).hover(); 
			break;

		case DEFENCE://2
			getWidgets().get(320, 3).hover(); 
			break;
		}
		sleep(random(4000, 7000));
	}

	private Skill getAttMethod() {
		switch (getConfigs().get(43)) { //3
		case 0:
			attmethod = Skill.ATTACK; //4
			break;
		case 1:
			attmethod = Skill.STRENGTH; //4
			break;
		case 3:
			attmethod = Skill.DEFENCE; //4
			break;
		}
		return attmethod;
	}

I marked some numbers in the code snippit you posted so I can individually address what they mean.

1. the attmethod variable is an enum. An enum is a variable that can only be equal a few specific values, in this example the enum can only be the specific values of any osrs skill such as ATTACK, STRENGTH, DEFENCE....., FARMING (this snippit uses an enum present in the osbot API you can see them listed under Enum Constants section here: https://osbot.org/api/org/osbot/rs07/api/ui/Skill.html). 

2. The attmethod variable is used in a switch statement. You will notice that following this line are multiple occurances of the CASE keyword. Whatever value after the case keyword matches with attmethod is the case statement that gets executed. This is similar to:

if(attmethid == Skill.Attack){
	gitWidgets.get.....;
	break;
}

There is a caveat to switch statements, as soon as one case matches, every subsequent case block regardless of whether the case matches or not is also executed. 

To prevent this from happening add the break keyword into every case block.

In your snippit, getWidgets().get(320, 1).hover(); means to hover over attack simulating a check of current experience. this is "antiban" that is not effective whatsoever. You are not fooling Jagex's anticheat with "human-like behavior" because this action is done client-side, no data of this interaction is sent to Jagex's servers. 

 

3. getConfigs(43) means to check bit strings (varbits) associated with the current attack player attack style. Obtaining varbits for congif 43 will return  either 0,1,2,or 3.

0 correlates with the upper left option selected in the combat (usually associated with attack),

1 with upper right (usually strength),

2 with lower left (usually controlled),

and 3 with lower right (usually defensive)

 

4. This second set of switch and case labels refers to setting up attmethod stay current with the attack method selected by the player. So that the hoverSkill method can correctly (and uselessly) hover over the correct skill being trained. This may also be used to paint the correct statistics of the skill being trained onto the game window. 

 

More detail on switch statments can be found here: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html

Edited by PayPalMeRSGP

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.