Joseph Posted July 14, 2015 Share Posted July 14, 2015 (edited) so im releasing my skill tracker on account of a request. Plus i personally dont like osbot experience tracker. IM pretty sure they have most of these methods in there, probably hidden. @Alek feel free to use if you decide to update the experience class. updated: to support EnumMap Add this into the on start of the script. (The class that extends Script) Skilltracker skillTracker = new SkillTracker(this); SkillTracker.java package com.divine.tracker; import java.util.ArrayList; import java.util.EnumMap; import java.util.Iterator; import java.util.List; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; public class SkillTracker { private final EnumMap<Skill, Tracker> mapTracker; private Script ctx; public SkillTracker(Script ctx) { this.ctx = ctx; this.mapTracker = new EnumMap<Skill, Tracker>(Skill.class); } public EnumMap<Skill, Tracker> getTrackerMap() { return this.mapTracker; } public long getTotalXpGained() { long amount = 0; for (Skill skill: getGainedSkills()) { amount += getGainedXP(skill); } return amount; } public List<Skill> getGainedSkills() { Iterator<Skill> skill = mapTracker.keySet().iterator(); List<Skill> list = new ArrayList<>(); while (skill.hasNext()) { if (hasGainedXP(skill.next())) { list.add(skill.next()); } } return list; } private boolean hasGainedXP(Skill skill) { return getGainedXP(skill) > 0; } public void track(Skill...skills) { for (Skill skill: (skills.length == 0) ? Skill.values(): skills) { mapTracker.put(skill, new Tracker(skill)); } } public Tracker get(Skill skill) { Tracker tracker = mapTracker.get(skill); if (tracker == null) throw new UnsupportedOperationException("You're not tracking this skill!"); return tracker; } public long getElapsed(Skill skill) { return System.currentTimeMillis() - get(skill).startedTrackingAt; } public int getGainedLevels(Skill skill) { return ctx.skills.getStatic(skill) - get(skill).getStartLevel(); } public int getGainedXP(Skill skill) { return ctx.skills.getExperience(skill) - get(skill).getStartExp(); } public int getGainedXPPerHour(Skill skill) { return (int) actionsPerHour(getGainedXP(skill), get(skill).getStartedTrackingAt()); } public int percentToLevel(Skill skill) { int currentLevel = ctx.skills.getStatic(skill); int expBetween = expBetween(currentLevel, currentLevel+1); int expIntoLevel = ctx.skills.getExperience(skill) - getExpForLevel(currentLevel); return (int) (((double) expIntoLevel / (double) expBetween) * 100D); } public long getTimeToLevel(Skill skill) { if (getGainedXP(skill) <= 0) return 0; return (long) ((expToLevel(skill) * 3600000.0D) / (double) getGainedXPPerHour(skill)); } public long getTimeToLevel(Skill skill, int target) { if (getGainedXP(skill) <= 0) return 0; return (long) ((expToLevel(skill, target) * 3600000.0D) / (double) getGainedXPPerHour(skill)); } /* * Private methods */ private int expToLevel(Skill skill) { return ctx.skills.experienceToLevel(skill); } private int expToLevel(Skill skill, int target) { return getExpForLevel(target) - ctx.skills.getExperience(skill); } private int expBetween(int value1, int value2) { return getExpForLevel(Math.max(value1, value2)) - getExpForLevel(Math.min(value1, value2)); } private double actionsPerHour(long actions, long startTime) { return (3600000D / (System.currentTimeMillis() - startTime) * actions); } private int getExpForLevel(int level) { return ctx.skills.getExperienceForLevel(level); } private class Tracker { private final int startExp, startLevel; private final long startedTrackingAt; private Tracker(final Skill track) { this.startExp = ctx.skills.getExperience(track); this.startLevel = ctx.skills.getStatic(track); this.startedTrackingAt = System.currentTimeMillis(); } public int getStartExp() { return startExp; } public int getStartLevel() { return startLevel; } public long getStartedTrackingAt() { return startedTrackingAt; } } } Edited July 14, 2015 by josedpay 1 Quote Link to comment Share on other sites More sharing options...
K00wal Posted July 14, 2015 Share Posted July 14, 2015 Goog job Quote Link to comment Share on other sites More sharing options...
Botre Posted July 14, 2015 Share Posted July 14, 2015 EnumMap pls 1 Quote Link to comment Share on other sites More sharing options...
Joseph Posted July 14, 2015 Author Share Posted July 14, 2015 EnumMap pls SkillTracker.java private final EnumMap<Skill, Tracker> mapTracker; private Script ctx; public SkillTracker(Script ctx) { this.ctx = ctx; this.mapTracker = new EnumMap<Skill, Tracker>(Skill.class); } public EnumMap<Skill, Tracker> getTrackerMap() { return this.mapTracker; } public List<Skill> getGainedSkills() { Iterator<Skill> skill = mapTracker.keySet().iterator(); List<Skill> list = new ArrayList<>(); while (skill.hasNext()) { if (hasGainedXP(skill.next())) { list.add(skill.next()); } } return list; } it always did my friend. Quote Link to comment Share on other sites More sharing options...
Booleans YAY Posted December 28, 2016 Share Posted December 28, 2016 I tried the usages and no errors, but the strings doesn't print out for some reason. Any help on how to fix this? Quote Link to comment Share on other sites More sharing options...
Deceiver Posted December 28, 2016 Share Posted December 28, 2016 I tried the usages and no errors, but the strings doesn't print out for some reason. Any help on how to fix this? use this, its in teh api http://osbot.org/api/org/osbot/rs07/api/util/ExperienceTracker.html 1 Quote Link to comment Share on other sites More sharing options...
Booleans YAY Posted December 29, 2016 Share Posted December 29, 2016 (edited) use this, its in teh api http://osbot.org/api/org/osbot/rs07/api/util/ExperienceTracker.html i'm calling it correctly but still not showing up. g.drawString("Experience p/HR: " + skillTracker.getGainedXPPerHour(Skill.PRAYER), 5, 160); g.drawString("Next Level up in: " + skillTracker.getTimeToLevel(Skill.PRAYER), 5, 175); Fixed* by reverting back to the api code i did before using this released version; thanks for posting anyways. Edited December 29, 2016 by booleans yay Quote Link to comment Share on other sites More sharing options...
Pegasus Posted July 14, 2018 Share Posted July 14, 2018 (edited) Great code! there is a minor mistake in getGainedSkills() public List<Skill> getGainedSkills() { Iterator<Skill> skill = mapTracker.keySet().iterator(); List<Skill> list = new ArrayList<>(); while (skill.hasNext()) { Skill s = skill.next(); if (hasGainedXP(s)) { list.add(s); } } return list; } Edited July 14, 2018 by Pegasus 1 Quote Link to comment Share on other sites More sharing options...
Hel Posted July 14, 2018 Share Posted July 14, 2018 (edited) 20 hours ago, Pegasus said: Great code! there is a minor mistake in getGainedSkills() public List<Skill> getGainedSkills() { Iterator<Skill> skill = mapTracker.keySet().iterator(); List<Skill> list = new ArrayList<>(); while (skill.hasNext()) { Skill s = skill.next(); if (hasGainedXP(s)) { list.add(s); } } return list; } bruh the thread was made in 2015, OP is banned AND the last post was well over 1.5 years ago. Edited July 14, 2018 by Slut fuq 1 Quote Link to comment Share on other sites More sharing options...
Pegasus Posted July 14, 2018 Share Posted July 14, 2018 (edited) 2 minutes ago, Slut said: bruh the thread was made in 2015, OP is banned AND the last post was well over 1.5 years ago. It took me more than 10 minutes to debug this bro. I think it is a useful debug for new scripters. Edited July 14, 2018 by Pegasus Quote Link to comment Share on other sites More sharing options...
Mordred Posted July 14, 2018 Share Posted July 14, 2018 1 minute ago, Pegasus said: It took me more than 10 minutes to debug this bro. I think it is a useful debug for new scripters. Such a helpful fucking post man! Quote Link to comment Share on other sites More sharing options...
Hel Posted July 14, 2018 Share Posted July 14, 2018 17 hours ago, Pegasus said: It took me more than 10 minutes to debug this bro. I think it is a useful debug for new scripters. I don't considering there's an Experience Tracker in the API. Quote Link to comment Share on other sites More sharing options...
Explv Posted July 14, 2018 Share Posted July 14, 2018 (edited) 2 hours ago, Slut said: I don't considering there's an Experience Tracker in the API. This. OP's class doesn't really offer anything that the existing OSBot ExperienceTracker and Skills class doesn't. getGainedSkills() is redundant because you should know which skills you are gaining XP in, because you started the experience tracker for them Edited July 14, 2018 by Explv Quote Link to comment Share on other sites More sharing options...
Pegasus Posted July 15, 2018 Share Posted July 15, 2018 Ah.. there is startAll() method in the API already Quote Link to comment Share on other sites More sharing options...