Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Tracking which fighting style is active

Featured Replies

I'm writing my first script which is just a chicken killer. I want to track how much xp is being gained. In order to check what is being trained (ATT, STR, DEF, HP, RANGE, MAGIC) i believe i need to track what fighting style is being used. I haven't found anything in the API to accomplish this. Would anybody be able to share some advice on this issue?

Cheers!

Check out the experience tracker

https://osbot.org/api/org/osbot/rs07/api/util/ExperienceTracker.html

Two methods to find out what attack style is activated:

1. Cache every single attack option for the different types of weapons. They are not the same...

2. Store an old version of getGainedXP and compare it to a new version. If it's increased, then you know the attack style

Edited by Zappster

@Explv just recently gave me a really cool snippet that has methods that will help you.

 

//Credits to Explv
//Main class
  private Skill currentAttStyle;

  private void setAttackStyle(final Skill attackStyle) {
        Event attStyleEvent = new AttackStyle(attackStyle.toString());
        execute(attStyleEvent);
        if (attStyleEvent.hasFinished()) {
            currentAttStyle = attackStyle;
        }
    }
//AttackStyle class
public class AttackStyle extends Event {

    private final int attackStyleParent = 593;
    private final int[] attackStyleChildren = {3, 7, 11, 15};
    private final String xpType;
    private int attackStyleToCheck = 0;

    public AttackStyle(final String xpType) {
        this.xpType = xpType;
    }


    @Override
    public int execute() throws InterruptedException {
        if (getTabs().getOpen() != Tab.ATTACK) {
            getTabs().open(Tab.ATTACK);
            return 0;
        }

        RS2Widget attackStyleWidget = getWidgets().get(attackStyleParent, attackStyleChildren[attackStyleToCheck]);

        if (attackStyleWidget == null) {
            setFailed();
            return 0;
        }

        if (!attackStyleWidget.hover()) {
            return 0;
        }

        sleep(random(500, 600));

        if (getWidgets().singleFilter(attackStyleParent, widget -> widget.getMessage().matches(".*\\(" + xpType + " XP\\)$")) == null) {
            attackStyleToCheck++;
            if (attackStyleToCheck >= attackStyleChildren.length) {
                setFailed();
            }
            return 0;
        }

        Rectangle widgetBounds = attackStyleWidget.getBounds();

        double colorX = widgetBounds.getMinX() + 5;
        double colorY = widgetBounds.getMinY() + 5;

        if (getColorPicker().colorAt((int) colorX, (int) colorY).getRed() > 100) {
            log("Already selected");
            setFinished();
            return 0;
        }

        if (attackStyleWidget.interact()) {
            setFinished();
        }
        return 0;
    }
}

Full credit goes to @Explv

  • Author

@Zappster Cheers man, yeah that was the first place I decided to look. But I need to find out what skill is going to be trained in order to initialise the ExperienceTracker. I could start tracking every skill and then see which one is increasing but ideally i was hoping there was a nicer way to accomplish this. Cheers anyway for the help man. ^^

2 minutes ago, harrypotter said:

@Explv just recently gave me a really cool snippet that has methods that will help you.

 


//Credits to Explv
//Main class
  private Skill currentAttStyle;

  private void setAttackStyle(final Skill attackStyle) {
        Event attStyleEvent = new AttackStyle(attackStyle.toString());
        execute(attStyleEvent);
        if (attStyleEvent.hasFinished()) {
            currentAttStyle = attackStyle;
        }
    }
//AttackStyle class
public class AttackStyle extends Event {

    private final int attackStyleParent = 593;
    private final int[] attackStyleChildren = {3, 7, 11, 15};
    private final String xpType;
    private int attackStyleToCheck = 0;

    public AttackStyle(final String xpType) {
        this.xpType = xpType;
    }


    @Override
    public int execute() throws InterruptedException {
        if (getTabs().getOpen() != Tab.ATTACK) {
            getTabs().open(Tab.ATTACK);
            return 0;
        }

        RS2Widget attackStyleWidget = getWidgets().get(attackStyleParent, attackStyleChildren[attackStyleToCheck]);

        if (attackStyleWidget == null) {
            setFailed();
            return 0;
        }

        if (!attackStyleWidget.hover()) {
            return 0;
        }

        sleep(random(500, 600));

        if (getWidgets().singleFilter(attackStyleParent, widget -> widget.getMessage().matches(".*\\(" + xpType + " XP\\)$")) == null) {
            attackStyleToCheck++;
            if (attackStyleToCheck >= attackStyleChildren.length) {
                setFailed();
            }
            return 0;
        }

        Rectangle widgetBounds = attackStyleWidget.getBounds();

        double colorX = widgetBounds.getMinX() + 5;
        double colorY = widgetBounds.getMinY() + 5;

        if (getColorPicker().colorAt((int) colorX, (int) colorY).getRed() > 100) {
            log("Already selected");
            setFinished();
            return 0;
        }

        if (attackStyleWidget.interact()) {
            setFinished();
        }
        return 0;
    }
}

Full credit goes to @Explv

Oh sweet, cheers brother!

Edited by Tasemu

2 hours ago, progamerz said:

Configs is the way to know which is active.

 

I don't think there is a config for what skill you are / will gain xp in, only for which of the attack styles is selected.

1 hour ago, Explv said:

I don't think there is a config for what skill you are / will gain xp in, only for which of the attack styles is selected.

Isn't that what he wanted anyways sorry if i was wrong what i meant is to know if Strength/Attack/Defence is selected ignore it if its not what u wanted

29 minutes ago, progamerz said:

Isn't that what he wanted anyways sorry if i was wrong what i meant is to know if Strength/Attack/Defence is selected ignore it if its not what u wanted

It can vary for different weapons though I think

6 minutes ago, Explv said:

It can vary for different weapons though I think

Umm not sure but i used to use this before in my old Seagull Script and used to work with Melee(Scimitar/Swords) not sure about others but i'll share it:
 

Credits @Khaleesi

import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.MethodProvider;

public enum FightStyle {
	ATT("Attack", 0, 3), STR("Strength", 1, 7), DEF("Defence", 3, 15);

	public static FightStyle[] STYLES = FightStyle.values();

	String name;
	int child, id, parent = 593;

	private FightStyle(String name, int id, int child) {
		this.name = name;
		this.child = child;
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public int getChild() {
		return child;
	}

	public int getId() {
		return id;
	}

	public static FightStyle getFightStyle(MethodProvider p) {

		for (FightStyle f : FightStyle.STYLES)
			if (f.getId() == p.configs.get(43))
				return f;

		return null;
	}

	public void changeTo(MethodProvider p) {

		if (p.configs.get(43) == id)
			return;

		RS2Widget w = p.getWidgets().get(593, child);
		if (w != null && w.isVisible()) {
			w.interact();
		} else {
			p.getTabs().open(Tab.ATTACK);
		}
	}

}

 

Edited by progamerz

21 minutes ago, progamerz said:

Umm not sure but i used to use this before in my old Seagull Script and used to work with Melee(Scimitar/Swords) not sure about others but i'll share it:
 

Still won't necessarily work for all melee weapons.

Check this combat options page http://2007.runescape.wikia.com/wiki/Combat_Options

"Melee weapons vary in their attack styles. Some have four options, with either a controlled option or an alternative aggressive attack with a different action, while others have only three options. Players intending to remain a pure with no Defence need to take care when using the third option (alternative aggressive), as switching weapons may result in controlled or defensive becoming selected, often only spotted when an unwanted Defence level is gained."

So the 4th option might be Strength XP or it might be Attack, Strength and Defence

Edited by Explv

3 minutes ago, Explv said:

Still won't necessarily work for all melee weapons.

Check this combat options page http://2007.runescape.wikia.com/wiki/Combat_Options

"Melee weapons vary in their attack styles. Some have four options, with either a controlled option or an alternative aggressive attack with a different action, while others have only three options. Players intending to remain a pure with no Defence need to take care when using the third option (alternative aggressive), as switching weapons may result in controlled or defensive becoming selected, often only spotted when an unwanted Defence level is gained."

So the 4th option might be Strength XP or it might be Attack, Strength and Defence

Oh then idk i feel like post farming anyways thanks for letting me know :)

2 minutes ago, progamerz said:

Oh then idk i feel like post farming anyways thanks for letting me know :)

I think your way would still work, as long as you figure out what type of weapon they are using (ranged, mage or melee) and disregard the 4th combat option

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.