Jump to content
mitsuki

Checking what attack style is active?

Recommended Posts

So I want to essentially make a check for whether the player is training attack, strength, or defence, so that my script can activate with widgets to change the attack style. 

I've tried to check whether the style is visible or not, but that always returns true if the combat options screen is showing, and false if not, so it doesn't actually check if "Lunge" is selected or not.

I looked into configs in the api, but can't find anything. Any Ideas? 

Cheers guys

Link to post
Share on other sites
15 minutes ago, mitsuki said:

So I want to essentially make a check for whether the player is training attack, strength, or defence, so that my script can activate with widgets to change the attack style. 

I've tried to check whether the style is visible or not, but that always returns true if the combat options screen is showing, and false if not, so it doesn't actually check if "Lunge" is selected or not.

I looked into configs in the api, but can't find anything. Any Ideas? 

Cheers guys

 

Read section 13 of this tutorial to learn about configs 

 

 

Funnily enough, it actually covers attack style as the example.

Screenshots are a bit out of date and the OSBot UI has changed, but there is still a config debug view in the settings.

TLDR: Config 43.

Link to post
Share on other sites

Just to add on, you should pay attention to weapons with different styles/xp types. Eg. abyssal whip 

You would think an attack style like "slash" would always give you the same xp, bur that's not the case.

Also, configs can help you check what spell you are autocasting. (You would need widgets to select spells though)

Link to post
Share on other sites

@mitsuki~
not sure if you had this solved yet but I only just realised this section was a thing, here's what I've been using for my bots fresh from tutorial island.

 

	public void setAttackStyle(String trainType) {
	      int style = script.getConfigs().get(43);
	      
	      switch (trainType) {
	        case "DEFENCE":
	          if (style != 3) {
	            while (!script.tabs.isOpen(Tab.ATTACK))
	              script.getTabs().open(Tab.ATTACK); 
//	            postStatus("CHANGING ATTACK STANCE TO DEFENCE");
	            script.widgets.get(593, 17, 4).interact(new String[0]);
	          } 
	          break;
	        case "ATTACK":
	          if (style != 0) {
	            while (!script.tabs.isOpen(Tab.ATTACK))
	              script.getTabs().open(Tab.ATTACK); 
//	            postStatus("CHANGING ATTACK STANCE TO ATTACK");
	            script.widgets.get(593, 5, 4).interact(new String[0]);
	          } 
	          break;
	        case "STRENGTH":
	          if (style != 1) {
	            while (!script.tabs.isOpen(Tab.ATTACK))
	            script.getTabs().open(Tab.ATTACK); 
//	            postStatus("CHANGING ATTACK STANCE TO STRENGTH");
	            script.widgets.get(593, 9, 4).interact(new String[0]);
	          }
	          break;
	      }
	}

 

Link to post
Share on other sites
On 3/2/2021 at 7:29 AM, Ricky Dactyl said:

@mitsuki~
not sure if you had this solved yet but I only just realised this section was a thing, here's what I've been using for my bots fresh from tutorial island.

 




	public void setAttackStyle(String trainType) {
	      int style = script.getConfigs().get(43);
	      
	      switch (trainType) {
	        case "DEFENCE":
	          if (style != 3) {
	            while (!script.tabs.isOpen(Tab.ATTACK))
	              script.getTabs().open(Tab.ATTACK); 
//	            postStatus("CHANGING ATTACK STANCE TO DEFENCE");
	            script.widgets.get(593, 17, 4).interact(new String[0]);
	          } 
	          break;
	        case "ATTACK":
	          if (style != 0) {
	            while (!script.tabs.isOpen(Tab.ATTACK))
	              script.getTabs().open(Tab.ATTACK); 
//	            postStatus("CHANGING ATTACK STANCE TO ATTACK");
	            script.widgets.get(593, 5, 4).interact(new String[0]);
	          } 
	          break;
	        case "STRENGTH":
	          if (style != 1) {
	            while (!script.tabs.isOpen(Tab.ATTACK))
	            script.getTabs().open(Tab.ATTACK); 
//	            postStatus("CHANGING ATTACK STANCE TO STRENGTH");
	            script.widgets.get(593, 9, 4).interact(new String[0]);
	          }
	          break;
	      }
	}

 

You could simplify it to something like this (Although didn't test it), another step would be changing the traintype to an enum but yeah.

 

	public void setAttackStyle(String trainType)
	{
		int style = script.getConfigs().get(43);
		switch (trainType)
		{
			case "DEFENCE":
				if (style != 3)
				{
					selectAttackStyle(17, 4);
				}
				break;
			case "ATTACK":
				if (style != 0)
				{
					selectAttackStyle(5, 4);
				}
				break;
			case "STRENGTH":
				if (style != 1)
				{
					selectAttackStyle(9, 4);
				}
				break;
		}
	}

	private void selectAttackStyle(int childId, int subChildId)
	{
		if (!script.getTabs().open(Tab.ATTACK))
		{
			return;
		}
		RS2Widget widget = script.widgets.get(593, childId, subChildId);
		if (widget != null && widget.isVisible())
		{
			widget.interact();
		}
	}

 

Edited by PTY Botting
Fixed bracket formatting
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...