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.

Awesome Java Code Snippets

Featured Replies

Here are some awesome, useful snippets:

 

DistanceToPoint (Distance from character to point, can be used for finding the closest thing to the character at any distance):

	private int distanceToPoint(int pointX,int pointY) {
		return (int) Math.sqrt(Math.pow(this.client.getMyPlayer().getX() - pointX, 2) + Math.pow(this.client.getMyPlayer().getY() - pointY, 2));
	} 

 Get XP for Level:

	public int getXPForLevel(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;
	}

Get Level for XP:

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

Edited by Divine

Instead of distance to point you can just use position.distance(otherPosition) and I don't see why you would use Level for XP when you can just get the level from client.getSkills().getLevel(Skill). Getting XP for level is useful though :)

 

Here are some awesome, useful snippets:

 

DistanceToPoint (Distance from character to point, can be used for finding the closest thing to the character at any distance):

	private int distanceToPoint(int pointX,int pointY) {
		return (int) Math.sqrt(Math.pow(this.client.getMyPlayer().getX() - pointX, 2) + Math.pow(this.client.getMyPlayer().getY() - pointY, 2));
	} 

 Get XP for Level:

	public int getXPForLevel(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;
	}

Get Level for XP:

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

ALL OF THIS IS USELESS

 

Plus all of these snippets are from rsps servers

  • Author

I used all but getXPForLevel in my Firemaking code. The distance for finding the closest bank, and the LevelforXP for XP till next level.

If it's useless to YOU, don't use it :-).

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.