Joseph Posted March 23, 2014 Share Posted March 23, 2014 Ps. Depending on the weapon they are wearing why they start the script. That will be the their initial weapon, and the class will always switch between their initial weapon and there special weapon. How to initiate it. SpecialAttack specialWeapon; @Override public void onStart() { specialWeapon = new SpecialAttack(this); } How to use it: specialWeapon.useSpecial(SpecialWeapon.DRAGON_DAGGER_S); package elder.choas.druid; import org.osbot.script.MethodProvider; import org.osbot.script.Script; import org.osbot.script.rs2.model.Item; import org.osbot.script.rs2.ui.EquipmentSlot; import org.osbot.script.rs2.ui.Tab; public class SpecialAttack { private Script script; private Item initialWeapon; public SpecialAttack(Script script) { this.script = script; initialWeapon = script.equipmentTab.getItemInSlot(EquipmentSlot.WEAPON); } public int getCurrentWeapon() { return script.equipmentTab.getItemInSlot(EquipmentSlot.WEAPON).getId(); } public boolean isWeildingWeapon(SpecialWeapon sw) { return script.equipmentTab.isWieldingWeapon(sw.getId()); } public boolean isSpecialReady(SpecialWeapon sw) { return script.combat.getSpecialPercentage() >= sw.specialPercent; } public boolean activateSpecial() throws InterruptedException { if (script.client.getConfig(301) != 1) { if (!script.currentTab().equals(Tab.ATTACK)) { script.openTab(Tab.ATTACK); script.sleep(MethodProvider.random(500, 700)); }else{ if (script.client.getInterface(593) !=null && script.client.getInterface(593).getChild(30) !=null) { script.client.getInterface(593).getChild(30).interact(); } } } return script.client.getConfig(301) == 1; } public boolean switchToInitialWeapon() throws InterruptedException { if (getCurrentWeapon() != initialWeapon.getId()) if (!script.currentTab().equals(Tab.INVENTORY)) script.openTab(Tab.INVENTORY); else if (script.client.getInventory().contains(initialWeapon.getId())) script.client.getInventory().interactWithId(initialWeapon.getId(), initialWeapon.getDefinition().getActions()[0]); else return false; return true; } public boolean switchToSpecialWeapon(SpecialWeapon sw) throws InterruptedException { if (getCurrentWeapon() == -1 || getCurrentWeapon() != sw.getId()) { if (!script.currentTab().equals(Tab.INVENTORY)) script.openTab(Tab.INVENTORY); else if (script.client.getInventory().contains(sw.getId())){ Item sWeapon = script.client.getInventory().getItemForId(sw.getId()); script.client.getInventory().interactWithId(sw.getId(), sWeapon.getDefinition().getActions()[0]); }else return false; } return true; } public int useSpecial(SpecialWeapon sw) throws InterruptedException { if (script.combat.getSpecialPercentage() >= sw.specialPercent) { if (getCurrentWeapon() != sw.getId()) this.switchToSpecialWeapon(sw); else this.activateSpecial(); }else{ if (getCurrentWeapon() != this.initialWeapon.getId()) this.switchToInitialWeapon(); } return MethodProvider.random(700, 1000); } public enum SpecialWeapon { DRAGON_DAGGER_S(25, 5698), DRAGON_SCIMITAR(55, 4587), ABYSSAL_WHIP(50, 4151), MAGIC_SHORTBOW(55, 861), DRAGON_BATTLEAXE(100, 1377), DRAGON_LONGSWORD(25, 1305), EXCALIBUR(100, 35), SARADOMIN_SWORD(100, 11730), ARMADYL_GODSWORD(50, 11694), SARADOMIN_GODSWORD(50, 11806); private int specialPercent; private int id; SpecialWeapon(int specialPercent, int id) { this.specialPercent = specialPercent; this.id = id; } public int getId() { return id; } public int getSpecialPercent() { return specialPercent; } } } 1 Link to comment Share on other sites More sharing options...
Declarative Posted March 23, 2014 Share Posted March 23, 2014 great job! Now I can scrap my shit lines of code! Thanks buddy 1 Link to comment Share on other sites More sharing options...
Joseph Posted March 23, 2014 Author Share Posted March 23, 2014 great job! Now I can scrap my shit lines of code! Thanks buddy your welcome Link to comment Share on other sites More sharing options...