May 12, 20178 yr 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!
May 12, 20178 yr 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 May 12, 20178 yr by Zappster
May 12, 20178 yr @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
May 12, 20178 yr 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 May 12, 20178 yr by Tasemu
May 12, 20178 yr 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.
May 12, 20178 yr 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
May 12, 20178 yr 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
May 12, 20178 yr 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 May 12, 20178 yr by progamerz
May 12, 20178 yr 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 May 12, 20178 yr by Explv
May 12, 20178 yr 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
May 12, 20178 yr 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