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.

Skill Monitor

Featured Replies

onStart;

SkillMonitor.resetSkills();

onLoop or onPaint;

SkillMonitor.updateSkills(client.getSkills());

use as;

SkillMonitor.xpGained(Skill.MINING)

Class;


import org.osbot.script.rs2.skill.Skill;
import org.osbot.script.rs2.skill.Skills;

import java.util.Collection;
import java.util.HashMap;

/**
 * User: Cory
 * Date: 26/06/13
 * Time: 06:41
 */
public class SkillMonitor {

	private static HashMap<Skill, Monitor> monitors = new HashMap<Skill, Monitor>();

	public static Monitor get(Skill skill) {
		Monitor mon = monitors.get(skill);
		if(mon == null) {
			mon = new Monitor();
			mon.skill = skill;
			monitors.put(skill, mon);
		}
		return mon;
	}

	public static void updateSkills(Skills skills){
		for(Monitor mon : values()) {
			int currentXp = skills.getExperience(mon.skill);
			if(mon.currentXp > 0)
				mon.lastGainedXp = currentXp-mon.currentXp;
			if(mon.currentXp != currentXp && mon.startXp <= 0 && mon.currentXp >= 0) {
				mon.startXp = mon.currentXp;
				mon.startLevel = mon.currentLevel;
				mon.startedTraining = System.currentTimeMillis();
			}
			mon.currentXp = currentXp;
			mon.currentLevel = skills.getCurrentLevel(mon.skill);
			mon.actualLevel = skills.getLevel(mon.skill);
			mon.xpToLvl = xPForLevel(mon.currentLevel+1)-mon.currentXp;
		}
	}

	public static int xpGained(Skill skill) {
		if(startXp(skill) <= 0)
			return 0;
		return currentXp(skill)-startXp(skill);
	}

	public static int lvlGained(Skill skill) {
		if(startXp(skill) <= 0)
			return 0;
		return currentLvl(skill)-startLvl(skill);
	}

	public static int xpToLvl(Skill skill) {
		return get(skill).xpToLvl;
	}

	public static int startXp(Skill skill) {
		return get(skill).startXp;
	}

	public static int startLvl(Skill skill) {
		return get(skill).startLevel;
	}

	public static int currentXp(Skill skill) {
		return get(skill).currentXp;
	}

	public static int currentLvl(Skill skill) {
		return get(skill).currentLevel;
	}

	public static int xPForLevel(int level) {
		int points = 0;
		int output = 0;
		for (int lvl = 1; lvl <= level; lvl++) {
			points += Math.floor((double)lvl + 300.0 * Math.pow(2.0, (double)lvl / 7.0));
			if (lvl >= level)
				return output;
			output = (int)Math.floor(points / 4);
		}
		return 0;
	}

	public static void resetSkills() {
		monitors.clear();
	}

	public static Collection<Monitor> values() {
		return monitors.values();
	}

	public static class Monitor {
		public int startXp = -1, startLevel = 0, lastGainedXp;
		public int currentXp = -1, currentLevel = -1, actualLevel = -1;
		public long startedTraining = -1;
		public Skill skill = null;
		public int xpToLvl = 0;
	}
}

Edited by Cory

Thanks. :) 

Thank you very much, I was sitting late up yesterday and thought of something like this, I'm just not the biggest/best in java coding so far, I'll definitely make use of this! smile.png

Guest
This topic is now closed to further replies.

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.