Divine Posted May 23, 2013 Share Posted May 23, 2013 (edited) 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 May 23, 2013 by Divine Link to comment Share on other sites More sharing options...
Diclonius Posted May 23, 2013 Share Posted May 23, 2013 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 Link to comment Share on other sites More sharing options...
Exx Posted May 23, 2013 Share Posted May 23, 2013 ty Link to comment Share on other sites More sharing options...
zachtucker Posted May 23, 2013 Share Posted May 23, 2013 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 1 Link to comment Share on other sites More sharing options...
Divine Posted May 23, 2013 Author Share Posted May 23, 2013 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 :-). Link to comment Share on other sites More sharing options...
zachtucker Posted May 23, 2013 Share Posted May 23, 2013 (client.getSkills().getExperience(Skill.FIREMAKING) = your firemaking code Link to comment Share on other sites More sharing options...