Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • [DB3] Switching Combat styles


    bap

    Recommended Posts

    Hope you guys find this useful :)
     

    public static boolean changeCombatStlye(int config, int childID, String style) {
        WidgetChild accurateWidget = Widgets.getWidget(593).getChild(childID);
        if (PlayerSettings.getConfig(43) != config) {
            log("Switching to: " + style + " | Config: " + config);
            if (Tabs.isOpen(Tab.COMBAT)) {
                Tabs.openWithFKey(Tab.COMBAT);
                sleep(500,800);
                if (accurateWidget.interact() && PlayerSettings.getConfig(43) == config && Tab.COMBAT.isOpen()) {
                    log("Now gaining " + style + " XP");
                    sleep(500,800);
                    Tabs.openWithFKey(Tab.INVENTORY);
                    return true;
                }
            } else {
                Tabs.openWithFKey(Tab.COMBAT);
            }
        }
        return false;
    }
    

    If anything can be improved, let me know! Thanks :)

    Link to comment
    Share on other sites

    public boolean changeCombatStlye(int config, int childID, String style) {
        WidgetChild accurateWidget = Widgets.getWidget(593).getChild(childID);
        if (PlayerSettings.getConfig(43) != config) {
            log("Switching to: " + style + " | Config: " + config);
            if (Tabs.isOpen(Tab.COMBAT)) {
                sleep(500,800);
                return accurateWidget.interact() ? Tabs.openWithFKey(Tab.INVENTORY) : Tabs.openWithFKey(Tab.COMBAT);
            } else {
                Tabs.openWithFKey(Tab.COMBAT);
            }
        }
        return false;
    }
    

    Hopefully this is better :)

    Link to comment
    Share on other sites

    Thank you for the contribution 🙂!

    I'm unsure about how combat style configs & widgets depend on the weapon you're wielding, but it would be optimal to be able to call something like

    setCombatStyle(CombatStyle.ACCURATE);
    setCombatStyle(CombatStyle.RAPID);

    Some things I could point out are:

    1. The following

      if (Tabs.isOpen(Tab.COMBAT)) {
        // interact with widget
      } else {
        Tabs.open(Tab.COMBAT); 
      }

      can be simplified to

      if (Tabs.open(Tab.COMBAT)) {
        // interact with widget 
      }

      Tabs.open will return true if the tab is already open or if it was successfully opened.
       

    2. Your method could be built so that it returns true if the combat style was successfully changed or the style is already activated. (Similarly how in the above example Tabs.open behaves)
      boolean setCombatStyle(...) {
        if style is set {
         	return true; 
        }
        attempt to set combat style;
        return style is set;
      }

       

    3. In my opinion such snippet shouldn't return back to inventory tab. If you wanted to do something else on the combat tab after changing combat style, your script would go from inventory -> combat -> inventory -> combat.

    4. The method name contains a typo 😜

    Link to comment
    Share on other sites

    1 hour ago, Hashtag said:

    Thank you for the contribution 🙂!

    I'm unsure about how combat style configs & widgets depend on the weapon you're wielding, but it would be optimal to be able to call something like

    
    setCombatStyle(CombatStyle.ACCURATE);
    setCombatStyle(CombatStyle.RAPID);

    Some things I could point out are:

    1. The following

      
      if (Tabs.isOpen(Tab.COMBAT)) {
        // interact with widget
      } else {
        Tabs.open(Tab.COMBAT); 
      }

      can be simplified to

      
      if (Tabs.open(Tab.COMBAT)) {
        // interact with widget 
      }

      Tabs.open will return true if the tab is already open or if it was successfully opened.
       

    2. Your method could be built so that it returns true if the combat style was successfully changed or the style is already activated. (Similarly how in the above example Tabs.open behaves)
      
      boolean setCombatStyle(...) {
        if style is set {
         	return true; 
        }
        attempt to set combat style;
        return style is set;
      }

       

    3. In my opinion such snippet shouldn't return back to inventory tab. If you wanted to do something else on the combat tab after changing combat style, your script would go from inventory -> combat -> inventory -> combat.

    4. The method name contains a typo 😜

    1. Ah I didn't know it also returned true if it's already open, I assumed it would still try and do it, thanks!
    2. Okay thanks, I'll update it soon :) 
    3. Yeah, it was for my own use case so I kinda didn't take that into account :P

    4. I've been up for 24 hours man, changed tho, ty!

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.