Twin Posted February 26, 2015 Author Share Posted February 26, 2015 Had no idea getInteracting was a method, that should fix this actually. Nope, didn't fix it. Still having the issue where it will use the steel bar on the furnace every 10-20 seconds depending on when the sleep ends. Will not work. getInteracting() returns a Character. Welp im an idiot lol could have sworn that said isInteracting, well like acted the same way. Quote Link to comment Share on other sites More sharing options...
Precise Posted February 26, 2015 Share Posted February 26, 2015 Nope, didn't fix it. Still having the issue where it will use the steel bar on the furnace every 10-20 seconds depending on when the sleep ends. if animation = -1, start a timer. If the timer exceeds 20 seconds, interact. Quote Link to comment Share on other sites More sharing options...
Twin Posted February 27, 2015 Author Share Posted February 27, 2015 More than likely you're doing this because the player stops animating in between smelting and the bot goes and attempts to smelt again? Just monitor your last smithing xp gain and if it was over a certain threshold then you know you have to smith. this post did not show up for me for some reason! did not mean to ignore it. This is exactly what I meant, how would I go about doing that? I make an integer of my smithing experience and then what? kind of lost of what to do there. Quote Link to comment Share on other sites More sharing options...
Swizzbeat Posted February 27, 2015 Share Posted February 27, 2015 this post did not show up for me for some reason! did not mean to ignore it. This is exactly what I meant, how would I go about doing that? I make an integer of my smithing experience and then what? kind of lost of what to do there. I have moderated content on here cause I'm an asshole so my posts need to be approved by mods. import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; /** * Created with IntelliJ IDEA * User: Anthony * Date: 6/8/2014 */ public class XPListener extends Thread { private boolean running; private int lastXpGain; private long lastXpGainTime; private Script sI; private Skill skill; public XPListener(Script sI, Skill skill) { this.running = true; this.sI = sI; this.skill = skill; } @Override public void run() { while (running) { int oldXp = sI.skills.getExperience(skill); try { Thread.sleep(600); } catch (InterruptedException e) { } int newXp = sI.skills.getExperience(skill); if (oldXp != newXp) { lastXpGain = newXp - oldXp; lastXpGainTime = System.currentTimeMillis(); } } } public void setRunning(boolean running) { this.running = running; } public Skill getSkill() { return skill; } public int getLastXpGain() { return lastXpGain; } public long getLastXpGainTime() { return lastXpGainTime; } } import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import java.util.HashSet; import java.util.Iterator; import java.util.Set; /** * Created with IntelliJ IDEA * User: Anthony * Date: 6/8/2014 */ public class XPTracker { private Script sI; private Set<XPListener> xpListeners; public XPTracker(Script sI) { this.sI = sI; this.xpListeners = new HashSet<>(); } public void startTrackingSkills(Skill... skills) { for (Skill s : skills) { XPListener listener = new XPListener(sI, s); listener.start(); xpListeners.add(listener); } } public void stopTrackingSkills(Skill... skills) { Iterator<XPListener> iterator = xpListeners.iterator(); for (Skill s : skills) { while (iterator.hasNext()) { XPListener l = iterator.next(); if (l.getSkill() == s) { l.setRunning(false); iterator.remove(); break; } } } } public int getLastXpGainForSkill(Skill skill) { int returnValue = -1; for (XPListener l : xpListeners) { if (l.getSkill() == skill) { returnValue = l.getLastXpGain(); break; } } return returnValue; } public long getLastXpGainTimeForSkill(Skill skill) { long returnValue = -1; for (XPListener l : xpListeners) { if (l.getSkill() == skill) { returnValue = l.getLastXpGainTime(); break; } } return returnValue; } public Set<XPListener> getXpListeners() { return xpListeners; } } Code is shit I wrote it awhile ago (it's not even a listener lol idk why I called it that). Create and register like so: XPTracker tracker = new XPTracker(this); tracker.startTrackingSkills(Skill.FLETCHING); The check using tracker methods: tracker.getLastXpGainTimeForSkill(Skill.FLETCHING) // returns milliseconds since last xp gain 1 Quote Link to comment Share on other sites More sharing options...
Twin Posted February 27, 2015 Author Share Posted February 27, 2015 I have moderated content on here cause I'm an asshole so my posts need to be approved by mods. import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; /** * Created with IntelliJ IDEA * User: Anthony * Date: 6/8/2014 */ public class XPListener extends Thread { private boolean running; private int lastXpGain; private long lastXpGainTime; private Script sI; private Skill skill; public XPListener(Script sI, Skill skill) { this.running = true; this.sI = sI; this.skill = skill; } @Override public void run() { while (running) { int oldXp = sI.skills.getExperience(skill); try { Thread.sleep(600); } catch (InterruptedException e) { } int newXp = sI.skills.getExperience(skill); if (oldXp != newXp) { lastXpGain = newXp - oldXp; lastXpGainTime = System.currentTimeMillis(); } } } public void setRunning(boolean running) { this.running = running; } public Skill getSkill() { return skill; } public int getLastXpGain() { return lastXpGain; } public long getLastXpGainTime() { return lastXpGainTime; } } import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import java.util.HashSet; import java.util.Iterator; import java.util.Set; /** * Created with IntelliJ IDEA * User: Anthony * Date: 6/8/2014 */ public class XPTracker { private Script sI; private Set<XPListener> xpListeners; public XPTracker(Script sI) { this.sI = sI; this.xpListeners = new HashSet<>(); } public void startTrackingSkills(Skill... skills) { for (Skill s : skills) { XPListener listener = new XPListener(sI, s); listener.start(); xpListeners.add(listener); } } public void stopTrackingSkills(Skill... skills) { Iterator<XPListener> iterator = xpListeners.iterator(); for (Skill s : skills) { while (iterator.hasNext()) { XPListener l = iterator.next(); if (l.getSkill() == s) { l.setRunning(false); iterator.remove(); break; } } } } public int getLastXpGainForSkill(Skill skill) { int returnValue = -1; for (XPListener l : xpListeners) { if (l.getSkill() == skill) { returnValue = l.getLastXpGain(); break; } } return returnValue; } public long getLastXpGainTimeForSkill(Skill skill) { long returnValue = -1; for (XPListener l : xpListeners) { if (l.getSkill() == skill) { returnValue = l.getLastXpGainTime(); break; } } return returnValue; } public Set<XPListener> getXpListeners() { return xpListeners; } } Code is shit I wrote it awhile ago (it's not even a listener lol idk why I called it that). Create and register like so: XPTracker tracker = new XPTracker(this); tracker.startTrackingSkills(Skill.FLETCHING); The check using tracker methods: tracker.getLastXpGainTimeForSkill(Skill.FLETCHING) // returns milliseconds since last xp gain I'm getting a weird error where smithXP.startTrackingSkills(Skill.SMITHING); is saying that it wants an @ before start and and @ sign instead of a semi colon, other than that everything looks good, Thanks for this by the way! I would have had no clue on how to write a class/method for something like that. Quote Link to comment Share on other sites More sharing options...