luciuspragg Posted February 22, 2019 Share Posted February 22, 2019 (edited) Here's a simple method that will change combat styles using whatever conditions you want, just call the method and pass it an enum of type style corresponding to what you want to switch to: enum style { ATTACK, DEFENSE, STRENGTH; } public void combatSwitch(style changeStyle) { switch (changeStyle) { case ATTACK: if (getTabs().open(Tab.ATTACK)) { if (getWidgets().get(593, 3).interact()) { new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return getConfigs().get(43) == 0; } }.sleep(); } } break; case STRENGTH: if (getTabs().open(Tab.ATTACK)) { if (getWidgets().get(593, 7).interact()) { new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return getConfigs().get(43) == 1; } }.sleep(); } } break; case DEFENSE: if (getTabs().open(Tab.ATTACK)) { if (getWidgets().get(593, 15).interact()) { new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return getConfigs().get(43) == 3; } }.sleep(); } } break; } } Example usage: //checking if strength is a certain level if (skills.getDynamic(Skill.STRENGTH) < 40 && getConfigs().get(43) != 1) { changeStyle = style.STRENGTH; combatSwitch(changeStyle); } Hope this is of help to somebody! Kudos to @ProjectPact and @HeyImJamie for the suggestions. Edited February 22, 2019 by luciuspragg Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted February 22, 2019 Share Posted February 22, 2019 (edited) Try rewriting to not use static ID's Could also check to make sure the tab is actually opened before looking to interact with a widget since getTabs().open should be a boolean Hope this helps! Edited February 22, 2019 by ProjectPact 1 1 Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted February 22, 2019 Share Posted February 22, 2019 Looks good, but may I suggest making it a more 'universal' method? I've edited slightly on here so there may be a few errors etc, but this gives you an idea. This way instead of editing the method everytime to edit it to your combat style, you can just select which style you want. You could even make an AttackStyle enum for readability, rather than using ints. public boolean switchCombatStyle(int combatStyle) { int style = getConfigs().get(43); if (combatStyle == style) { return true; } switch (combatStyle) { case 0: RS2Widget attButton = getWidgets().get(593, 3); if (attButton != null && getTabs().open(Tab.ATTACK)) { if (attButton.interact()) { // sleep until style equals desired. } } break; case 1: RS2Widget strButton = getWidgets().get(593, 7); etc break; case 2: break; case 3: RS2Widget defButton = getWidgets().get(593, 15); etc break; } return combatStyle == getConfgs().get(43); } 1 1 Quote Link to comment Share on other sites More sharing options...
luciuspragg Posted February 22, 2019 Author Share Posted February 22, 2019 (edited) I had originally written it as a standalone one task thing instead of a more universal method so I decided to go ahead and take both of your suggestions into account: public void combatSwitch(style changeStyle) { switch (changeStyle) { case ATTACK: if (getTabs().open(Tab.ATTACK)) { if (getWidgets().get(593, 3).interact()) { new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return getConfigs().get(43) == 0; } }.sleep(); } } break; case STRENGTH: if (getTabs().open(Tab.ATTACK)) { if (getWidgets().get(593, 7).interact()) { new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return getConfigs().get(43) == 1; } }.sleep(); } } break; case DEFENSE: if (getTabs().open(Tab.ATTACK)) { if (getWidgets().get(593, 15).interact()) { new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return getConfigs().get(43) == 3; } }.sleep(); } } break; } } Using: enum style { ATTACK, DEFENSE, STRENGTH; } Thanks again for the suggestions! Edited February 22, 2019 by luciuspragg 1 Quote Link to comment Share on other sites More sharing options...