shaba123 Posted May 20, 2018 Share Posted May 20, 2018 Can someone explain to me what case is, how and when to use case in a script? Quote Link to comment Share on other sites More sharing options...
Night Posted May 20, 2018 Share Posted May 20, 2018 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. 1 Quote Link to comment Share on other sites More sharing options...
shaba123 Posted May 20, 2018 Author Share Posted May 20, 2018 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; } Quote Link to comment Share on other sites More sharing options...
yfoo Posted May 21, 2018 Share Posted May 21, 2018 (edited) 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 May 21, 2018 by PayPalMeRSGP 1 Quote Link to comment Share on other sites More sharing options...
shaba123 Posted May 21, 2018 Author Share Posted May 21, 2018 Thank you so much for your help, both of you. Quote Link to comment Share on other sites More sharing options...