View Full Version : Converting all Scripts from RSBot to RSBuddy.
Steve
March 21st, 2011, 01:53
Since a lot of people don't like RSBot since it's unsafe and all, I'll convert all RSBot scripts to RSBuddy for 1m a piece. Or I could just sell you my converter for about 15 - 20m, although it doesn't completely convert it, there will be a few errors since all scripts are different. So anyone want to buy?
Hellslayer96
March 21st, 2011, 01:56
Are you talking about powerbot.org?
Steve
March 21st, 2011, 02:01
Are you talking about powerbot.org?
Yeah, formally known as RSBot.
Hellslayer96
March 21st, 2011, 02:04
I thought that you were talking about Rsbots.net >.<
Steve
March 21st, 2011, 02:05
I thought that you were talking about Rsbots.net >.<
No, no one has access to their scripts lol.
Smudge
March 21st, 2011, 02:06
No, no one has access to their scripts lol.
I thought RsBots were just resellers of OEMBots.
ymx boy
March 21st, 2011, 02:09
Ok first of all i nver had rrsbuddy bot wat eva but can some1 gimme a link to it sounds better lol i wanan check it out becuz i like epic bot alot lol
Ramsin
March 21st, 2011, 02:11
Most of the scripts your going to try and convert wont work.
Steve
March 21st, 2011, 02:15
Most of the scripts your going to try and convert wont work.
Why wouldn't they work? RSBuddy is the exact same as Powerbot, just a couple different method names, and it's not hacked.
Ramsin
March 21st, 2011, 03:01
Why wouldn't they work? RSBuddy is the exact same as Powerbot, just a couple different method names, and it's not hacked.
If you think so. Did you test it already?
Steve
March 21st, 2011, 03:26
If you think so. Did you test it already?
Yeah, i'll upload a test one in a sec.
Steve
March 21st, 2011, 04:10
Here we go.
Only the registered members can see the link.
Code(some of it's weird because it was doing weird stuff, and i had to remove the GUI due to the fact that their theme has a bug in it, not the script):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.GeneralPath;
import java.io.IOException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import com.rsbuddy.event.listeners.PaintListener;
import com.rsbuddy.script.methods.Calculations;
import com.rsbuddy.script.methods.Equipment;
import com.rsbuddy.script.methods.Game;
import com.rsbuddy.script.methods.Mouse;
import com.rsbuddy.script.methods.Players;
import com.rsbuddy.script.methods.Skills;
import com.rsbuddy.script.methods.Walking;
import com.rsbuddy.script.util.Timer;
import com.rsbuddy.script.wrappers.Model;
import com.rsbuddy.script.wrappers.Tile;
@com.rsbuddy.script.Manifest(authors = "Ubuntu4life, Maximonster", name = "PerfectCrafter", version = 1.284, description = "Crafts water runes perfectly.")
public class PerfectCrafter extends com.rsbuddy.script.ActiveScript implements PaintListener, MouseListener {
private enum Action {
OPENBANK, DEPOSIT, WITHDRAW, WALKTORUINS, ENTERRUINS, WALKTOALTAR, CRAFTRUNE, TELEPORT, WALKTOGATE, OPENGATE, WALKTOPORTAL, LEAVEALTAR, WALKTOBANK, SLEEP
}
com.rsbuddy.script.wrappers.Tile gateTile = new com.rsbuddy.script.wrappers.Tile(3053, 3283);
com.rsbuddy.script.wrappers.Tile gateWalkTile = new com.rsbuddy.script.wrappers.Tile(3053, 3285);
com.rsbuddy.script.wrappers.Tile altarTile = new com.rsbuddy.script.wrappers.Tile(3485, 4836);
com.rsbuddy.script.wrappers.Tile altarWalkTile = new com.rsbuddy.script.wrappers.Tile(3486, 4836);
com.rsbuddy.script.wrappers.Tile altarClickTile = new com.rsbuddy.script.wrappers.Tile(3484, 4836);
com.rsbuddy.script.wrappers.Tile boothTile = new com.rsbuddy.script.wrappers.Tile(3091, 3245);
com.rsbuddy.script.wrappers.Tile bankTile = new com.rsbuddy.script.wrappers.Tile(3089, 3244);
com.rsbuddy.script.wrappers.Tile bankWalkTile = new com.rsbuddy.script.wrappers.Tile(3093, 3244);
com.rsbuddy.script.wrappers.Tile portalTile = new com.rsbuddy.script.wrappers.Tile(3495, 4832);
com.rsbuddy.script.wrappers.Tile portalWalkTile = new com.rsbuddy.script.wrappers.Tile(3496, 4832);
com.rsbuddy.script.wrappers.Tile ruinsTile = new com.rsbuddy.script.wrappers.Tile(3184, 3165);
com.rsbuddy.script.wrappers.Tile ruinsWalkTile = new com.rsbuddy.script.wrappers.Tile(3183, 3164);
com.rsbuddy.script.wrappers.Tile ruinsClickTile = new com.rsbuddy.script.wrappers.Tile(3185, 3165);
private PerfectGUI gui;
private boolean checkUpdate;
private boolean useResting;
private boolean useExplorersRing, pressed = true;
public boolean startScript = false, foundWaters = false, firstLoop = true,
outOfEssence = false;
volatile boolean stop = false;
private final int INTERFACE_RUN_ORB = 750, RUN_CHILD_ID = 1;
private int uniqueNumber;
public int startExp, startLvl, mayAntiBan = 0, itemCount = 0,
itemtypeint = 0, invalidCount = 0, runeStart = 0, totalRunes = 0,
essPrice = 0, runePrice = 0, waterRuneStart = 0, totalwaters = 0,
failCount = 0;
private ArrayList<com.rsbuddy.script.wrappers.Tile> pathList;
private Timer timer;
private AntiBan antiBan;
private java.util.Random unique;
private String status = "Starting...";
private Line[] TORUINS = { new Line(3094, 3243, 3093, 3242),
new Line(3103, 3236, 3098, 3235), new Line(3110, 3232, 3099, 3228),
new Line(3114, 3228, 3100, 3227), new Line(3114, 3224, 3110, 3223),
new Line(3116, 3221, 3114, 3220), new Line(3124, 3209, 3118, 3206),
new Line(3129, 3207, 3129, 3206), new Line(3138, 3207, 3131, 3204),
new Line(3143, 3205, 3138, 3201), new Line(3149, 3200, 3138, 3197),
new Line(3157, 3190, 3140, 3189), new Line(3160, 3181, 3150, 3178),
new Line(3167, 3172, 3157, 3169), new Line(3168, 3170, 3164, 3165),
new Line(3176, 3167, 3175, 3162), new Line(3180, 3167, 3180, 3162),
new Line(3184, 3167, 3184, 3162) };
private Line[] TOBANK = { new Line(3183, 3167, 3183, 3162),
new Line(3180, 3167, 3180, 3162), new Line(3176, 3167, 3175, 3162),
new Line(3171, 3169, 3171, 3163), new Line(3168, 3170, 3164, 3165),
new Line(3167, 3172, 3157, 3169), new Line(3160, 3181, 3150, 3178),
new Line(3157, 3190, 3140, 3189), new Line(3149, 3200, 3138, 3197),
new Line(3143, 3205, 3138, 3201), new Line(3138, 3207, 3131, 3204),
new Line(3129, 3207, 3129, 3206), new Line(3124, 3209, 3118, 3206),
new Line(3116, 3221, 3114, 3220), new Line(3114, 3224, 3110, 3223),
new Line(3114, 3228, 3100, 3227), new Line(3110, 3232, 3099, 3228),
new Line(3103, 3236, 3098, 3235), new Line(3093, 3245, 3093, 3242) };
private Line[] TOBANKCABBAGE = { new Line(3054, 3282, 3052, 3282),
new Line(3057, 3281, 3057, 3276), new Line(3071, 3277, 3071, 3274),
new Line(3082, 3268, 3070, 3268), new Line(3082, 3258, 3072, 3258),
new Line(3082, 3254, 3078, 3251), new Line(3086, 3249, 3085, 3247),
new Line(3092, 3246, 3092, 3243) };
public static interface Constants {
int[] openGates = { 7051, 7052 };
int[] closedGates = { 7050, 7049 };
int waterRune = 555;
int waterTalisman = 1444;
int runeEssence = 1436;
int Altar = 2480;
int Portal = 2467;
int Ruins = 2454;
int bankBooth = 2213;
com.rsbuddy.script.wrappers.Area AREA_INALTAR = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3474, 4845), new com.rsbuddy.script.wrappers.Tile(
3500, 4822));
com.rsbuddy.script.wrappers.Area AREA_REST = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3099, 3238), new com.rsbuddy.script.wrappers.Tile(3176,
3154));
com.rsbuddy.script.wrappers.Area AREA_INCABBAGE = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3067, 3283), new com.rsbuddy.script.wrappers.Tile(
3051, 3292));
com.rsbuddy.script.wrappers.Area AREA_INERROR = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3050, 3290), new com.rsbuddy.script.wrappers.Tile(
3057, 3298));
}
@Override
public boolean onStart() {
if (!com.rsbuddy.script.methods.Game.isFixed()) {
log.severe("You must use Fixed Screen Mode to use this script.");
return false;
}
if (com.rsbuddy.script.methods.Game.isLoggedIn()) {
unique = generateSeededRandom(Players.getLocal().getName()) ;
uniqueNumber = unique.nextInt(25);
if (checkUpdate) {
checkForUpdates();
}
startExp = com.rsbuddy.script.methods.Skills.getCurrentExp(Sk ills.RUNECRAFTING);
startLvl = com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING);
mayAntiBan = 0;
log.info(":-:-: Loading PerfectCrafter 1.284 :-:-:");
startTime = System.currentTimeMillis();
timer = new Timer(0);
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(5, 8));
log.info("Loading Prices...");
com.rsbuddy.script.methods.GrandExchange.Item water = com.rsbuddy.script.methods.GrandExchange.lookup(Co nstants.waterRune);
runePrice = water.getMarketPrice();
com.rsbuddy.script.methods.GrandExchange.Item ess = com.rsbuddy.script.methods.GrandExchange.lookup(Co nstants.runeEssence);
essPrice = ess.getMarketPrice();
if (pathList == null) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
pathList = generatePath(TOBANKCABBAGE);
} else {
pathList = generatePath(TOBANK);
}
} else {
pathList = generatePath(TORUINS);
}
}
startScript = true;
log.info("Bot and script are all set to go.");
} else {
log.info("Please log in before starting the script.");
return false;
}
return true;
}
public void onFinish() {
log("Antiban stopped");
log.info(":-:-: Thank you for using PerfectCrafter :-:-:");
com.rsbuddy.script.methods.Mouse.moveOffScreen();
com.rsbuddy.script.methods.Environment.saveScreens hot(true);
log("Remember to comment :p");
stop = true;
stop();
}
public Action getState() {
com.rsbuddy.script.wrappers.GameObject closedGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.closedGates);
try {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(boothTile)) {
if (!com.rsbuddy.script.methods.Bank.isOpen()) {
return Action.OPENBANK;
} else {
if (com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune)) {
return Action.DEPOSIT;
} else {
return Action.WITHDRAW;
}
}
} else {
if (inAltarArea() || Players.getLocal().getAnimation() == 791) {
if (useExplorersRing == true) {
return Action.TELEPORT;
} else if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(portalTile)) {
return Action.LEAVEALTAR;
} else {
return Action.WALKTOPORTAL;
}
} else {
if (useExplorersRing == true) {
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate.getLocation()) < 8
&& closedGate != null && inCabbageArea()) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile)) {
return Action.OPENGATE;
} else {
return Action.WALKTOGATE;
}
}
}
return Action.WALKTOBANK;
}
}
} else {
if (inAltarArea()) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(altarTile)) {
return Action.CRAFTRUNE;
} else {
return Action.WALKTOALTAR;
}
} else {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(ruinsTile)) {
return Action.ENTERRUINS;
} else {
return Action.WALKTORUINS;
}
}
}
} catch (Exception e) {
return Action.SLEEP;
}
}
Random r = new Random();
double val = r.nextGaussian() * 61 + 301;
int millisDelay = (int) Math.round(val);
private Mouse mouse = new Mouse();
private Game game = new Game();
@Override
public int loop() {
if (firstLoop) {
log.info("Starting Seperate AntiBan thread.");
antiBan = new AntiBan(this);
antiBan.start();
firstLoop = false;
return com.rsbuddy.script.util.Random.nextInt(200, 400);
}
if (needToRun() && !com.rsbuddy.script.methods.Walking.isRunEnabled() && !com.rsbuddy.script.methods.Bank.isOpen()) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(8, 9));
com.rsbuddy.script.methods.Widgets.get(INTERFACE_R UN_ORB).getComponent(RUN_CHILD_ID)
.interact("turn run mode on");
nextPercentage = (uniqueNumber + com.rsbuddy.script.util.Random.nextInt(2, 39));
sleep(300, 400);
}
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(5, 7));
try {
com.rsbuddy.script.wrappers.GameObject Altar = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Altar);
com.rsbuddy.script.wrappers.GameObject Portal = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Portal);
com.rsbuddy.script.wrappers.GameObject Ruins = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Ruins);
com.rsbuddy.script.wrappers.GameObject Booth = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.bankBooth);
com.rsbuddy.script.wrappers.GameObject closedGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.closedGates);
com.rsbuddy.script.wrappers.GameObject openGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.openGates);
switch (getState()) {
case OPENBANK:
status = "Opening bank";
mayAntiBan = 0;
if (clickObject(Booth, "Use-quickly", boothTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
int count = 0;
while (!com.rsbuddy.script.methods.Bank.isOpen() && ++count < 9) {
mayAntiBan = 1;
sleep(millisDelay);
if (com.rsbuddy.script.methods.Players.getLocal().isM oving()) {
count = 0;
}
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case DEPOSIT:
status = "Depositing";
mayAntiBan = 0;
try {
if (!foundWaters) {
sleep(com.rsbuddy.script.util.Random.nextInt(500, 600));
waterRuneStart = com.rsbuddy.script.methods.Bank.getCount(Constants .waterRune);
foundWaters = true;
}
totalwaters = com.rsbuddy.script.methods.Bank.getCount(Constants .waterRune);
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Bank.depositAll();
waitForEmpty();
} catch (final Exception e) {
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WITHDRAW:
status = "Withdrawing";
mayAntiBan = 0;
try {
int runeCount = com.rsbuddy.script.methods.Bank.getCount(Constants .runeEssence);
if (runeCount < 1) {
log("You are out of rune essences.");
stop();
} else {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Bank.withdraw(Constants .runeEssence, 0);
waitForFull();
pathList = generatePath(TORUINS);
}
if (!com.rsbuddy.script.methods.Inventory.containsAll (Constants.runeEssence)) {
final int count = com.rsbuddy.script.methods.Inventory.getCount();
com.rsbuddy.script.methods.Bank.depositAllExcept(C onstants.runeEssence);
for (int i = 0; i < 10 && com.rsbuddy.script.methods.Inventory.getCount() == count; i++) {
sleep(com.rsbuddy.script.util.Random.nextInt(100, 200));
}
}
} catch (final Exception e) {
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTORUINS:
status = "Walking to ruins";
step(pathList, ruinsTile);
if (useResting == true) {
if (com.rsbuddy.script.methods.Walking.getEnergy() < ((uniqueNumber + com.rsbuddy.script.util.Random.nextInt(-11, 8)))
&& inRestArea()) {
status = "Resting";
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 8));
com.rsbuddy.script.methods.Walking.rest((uniqueNum ber + com.rsbuddy.script.util.Random.nextInt(43, 88)));
}
}
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(ruinsTile)) {
return com.rsbuddy.script.util.Random.nextInt(200, 390);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(220, 370);
case ENTERRUINS:
status = "Entering Ruins";
mayAntiBan = 0;
if (clickObject(Ruins, "Enter", ruinsTile, false)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(millisDelay);
} while (Players.getLocal().isMoving() && !inAltarArea());
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOALTAR:
status = "Walking to altar";
mayAntiBan = 0;
walkTo(altarWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(altarTile));
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case CRAFTRUNE:
status = "Crafting essences";
mayAntiBan = 0;
if (clickObject(Altar, "Craft-rune", altarTile, false)) {
if (useExplorersRing == true) {
pathList = generatePath(TOBANKCABBAGE);
} else {
pathList = generatePath(TOBANK);
}
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(520, 1025);
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune));
if (useExplorersRing == true && !Players.getLocal().isMoving()) {
for (int i = 140; i > 0; --i) {
if (Players.getLocal().getAnimation() != -1) {
continue;
}
sleep(10);
}
sleep(150, 450);
}
if (useExplorersRing == false) {
for (int i = 140; i > 0; --i) {
if (Players.getLocal().getAnimation() != -1) {
continue;
}
sleep(10);
}
sleep(1300, 1600);
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case TELEPORT:
status = "Teleporting";
mayAntiBan = 0;
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
com.rsbuddy.script.methods.Game.openTab(Game.TAB_E QUIPMENT);
}
if (com.rsbuddy.script.methods.Equipment.getItem(Equi pment.RING) != null) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
if (com.rsbuddy.script.methods.Widgets.get(Equipment. WIDGET)
.getComponent(Equipment.RING).interact(
"Cabbage-port")) {
for (int i = 0; i < 140
&& Players.getLocal().getAnimation() != 9984; i++) {
sleep(10);
}
while (Players.getLocal().getAnimation() == 9984) {
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_INVENTORY) {
sleep(198, 2564);
com.rsbuddy.script.methods.Game.openTab(Game.TAB_I NVENTORY);
}
sleep(47, 52);
}
sleep(998, com.rsbuddy.script.util.Random.nextInt(2891, 2901));
}
} else {
log("Please wear an Explorer's ring 3 of 4 !");
stop();
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOGATE:
status = "Walking to gate";
mayAntiBan = 0;
int angle = com.rsbuddy.script.methods.Camera.getAngleTo(close dGate);
walkTo(gateWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile));
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10
&& Math.abs(angle - com.rsbuddy.script.methods.Camera.getCompassAngle( )) > 20) {
com.rsbuddy.script.methods.Camera.setCompassAngle( angle + com.rsbuddy.script.util.Random.nextInt(-21, 21));
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case OPENGATE:
status = "Opening gate";
mayAntiBan = 0;
if (clickObject(closedGate, "Open Gate", gateTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
if (inErrorArea()) {
int angle2 = com.rsbuddy.script.methods.Camera.getAngleTo(close dGate);
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10
&& Math.abs(angle2 - com.rsbuddy.script.methods.Camera.getCompassAngle( )) > 20) {
com.rsbuddy.script.methods.Camera.setCompassAngle( angle2 + com.rsbuddy.script.util.Random.nextInt(-21, 21));
}
walkTileMM(gateWalkTile, 2, 2);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile));
}
} while (Players.getLocal().isMoving());
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10) {
Timer gateTimer = new Timer(com.rsbuddy.script.util.Random.nextInt(1000, 1400));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (openGate == null && gateTimer.isRunning());
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOPORTAL:
status = "Walking to portal";
mayAntiBan = 0;
walkTo(portalWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(portalTile));
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case LEAVEALTAR:
status = "Leaving altar";
mayAntiBan = 0;
if (clickObject(Portal, "Enter", portalTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(millisDelay);
} while (inAltarArea() && Players.getLocal().isMoving());
sleep(150, 300);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOBANK:
status = "Walking to bank";
com.rsbuddy.script.methods.Camera.setPitch(true);
step(pathList, boothTile);
if (useResting == true) {
if (com.rsbuddy.script.methods.Walking.getEnergy() < ((uniqueNumber + com.rsbuddy.script.util.Random.nextInt(-11, 8)))
&& inRestArea()) {
status = "Resting";
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(8, 9));
com.rsbuddy.script.methods.Walking.rest((uniqueNum ber + com.rsbuddy.script.util.Random.nextInt(43, 88)));
}
}
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(boothTile)) {
return com.rsbuddy.script.util.Random.nextInt(220, 370);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
}
} catch (Exception e) {
sleep(150, 300);
return com.rsbuddy.script.util.Random.nextInt(50, 100);
}
return 0;
}
private void walkTo(Tile destination) {
while (Calculations.distanceTo(destination) > 3) {
Walking.stepTowards(destination);
sleep(2000, 4000);
}
}
public com.rsbuddy.script.methods.Mouse getMouse() {
return mouse;
}
// Credits go to Unknown500 for the AntiBan skeleton code
class AntiBan extends Thread {
private PerfectCrafter parent;
private Random randomGenerator;
AntiBan(PerfectCrafter parent) {
this.parent = parent;
this.randomGenerator = new Random();
}
@Override
public void run() {
try {
while (parent.getGame().isLoggedIn() && !stop) {
if (!parent.isPaused()) {
int random = randomGenerator.nextInt(7);
if (mayAntiBan == 1 && random != 2) {
int rand = randomGenerator.nextInt(5);
switch (rand) {
case 1:
if (mayAntiBan == 1) {
if (com.rsbuddy.script.util.Random.nextInt(1, 5) != com.rsbuddy.script.util.Random.nextInt(1, 4)) {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
} else {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
sleep(com.rsbuddy.script.util.Random.nextInt(0, com.rsbuddy.script.util.Random.nextInt(72, 380)));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
}
} else {
break;
}
case 2:
if (mayAntiBan == 1 && com.rsbuddy.script.util.Random.nextInt(1, 510) == 119) {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveSlightly();
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
} else {
break;
}
case 3:
if (com.rsbuddy.script.util.Random.nextInt(1, 8) == 3) {
int angle = com.rsbuddy.script.methods.Camera.getCompassAngle( )
+ com.rsbuddy.script.util.Random.nextInt(-45, 45);
if (angle < 0) {
angle = com.rsbuddy.script.util.Random.nextInt(0, 10);
}
if (angle > 359) {
angle = com.rsbuddy.script.util.Random.nextInt(0, 10);
}
char whichDir = 37;
if (com.rsbuddy.script.util.Random.nextInt(0, 100) < 50)
whichDir = 39;
com.rsbuddy.script.methods.Keyboard.pressKey(which Dir);
sleep(com.rsbuddy.script.util.Random.nextInt(103, 996));
com.rsbuddy.script.methods.Keyboard.releaseKey(whi chDir);
break;
} else {
break;
}
default:
break;
}
}
sleep(com.rsbuddy.script.util.Random.nextInt(63, 2373));
}
}
} catch (InterruptedException e) {
log(e.getMessage());
}
}
}
// credits to !@!@! for clicking method, it's epic.
private boolean clickObject(com.rsbuddy.script.wrappers.GameObject object, String action, com.rsbuddy.script.wrappers.Tile Tile,
boolean useCentralClicking) {
Point p;
for (int i = 0; i < 4; i++) {
if (isPartiallyOnScreen(object.getModel())) {
p = useCentralClicking ? getCentralPoint(object.getModel())
: getPointOnScreen(object.getModel(), true);
while (isPartiallyOnScreen(object.getModel()) && p.x != -1
&& p.y != -1 && p != null && com.rsbuddy.script.methods.Calculations.isPointOnS creen(p)
&& !com.rsbuddy.script.methods.Bank.isOpen() && com.rsbuddy.script.methods.Calculations.isTileOnSc reen(Tile)) {
p = useCentralClicking ? getCentralPoint(object.getModel())
: getPointOnScreen(object.getModel(), true);
com.rsbuddy.script.methods.Mouse.move(p, 0, 0);
if (com.rsbuddy.script.methods.Menu.contains(action))
break;
if (p.x == -1 || p.y == -1 || p == null
|| !com.rsbuddy.script.methods.Calculations.isPointOn Screen(p)
|| !isPartiallyOnScreen(object.getModel())
|| !com.rsbuddy.script.methods.Calculations.isTileOnS creen(Tile) || com.rsbuddy.script.methods.Bank.isOpen())
continue;
}
String[] items = com.rsbuddy.script.methods.Menu.getItems();
if (items.length > 0 && items[0].contains(action)) {
com.rsbuddy.script.methods.Mouse.click(true);
return true;
} else if (com.rsbuddy.script.methods.Menu.contains(action)) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Mouse.click(false);
sleep(com.rsbuddy.script.util.Random.nextInt(100, 200));
for (int x = 0; x < 4; x++) {
if (com.rsbuddy.script.methods.Menu.click(action)) {
return true;
}
}
}
if (!com.rsbuddy.script.methods.Menu.contains(action) && com.rsbuddy.script.methods.Menu.isOpen()) {
do {
com.rsbuddy.script.methods.Mouse.moveRandomly(com. rsbuddy.script.util.Random.nextInt(180, 275));
} while (com.rsbuddy.script.methods.Menu.isOpen());
sleep(com.rsbuddy.script.util.Random.nextInt(100, 175));
return false;
}
}
}
return false;
}
public Game getGame() {
return game ;
}
private boolean isPartiallyOnScreen(Model m) {
return getPointOnScreen(m, true) != null;
}
private Point getPointOnScreen(Model m, boolean first) {
if (m == null) {
return null;
}
ArrayList<Point> list = new ArrayList<Point>();
try {
Polygon[] tris = m.getTriangles();
for (int i = 0; i < tris.length; i++) {
Polygon p = tris[i];
for (int j = 0; j < p.xpoints.length; j++) {
Point pt = new Point(p.xpoints[j], p.ypoints[j]);
if (Calculations.isPointOnScreen(pt)) {
if (first) {
return pt;
}
list.add(pt);
}
}
}
} catch (Exception e) {
}
return list.size() > 0 ? list.get(com.rsbuddy.script.util.Random.nextInt(0, list.size())) : null;
}
private Point getCentralPoint(Model m) {
if (m == null) {
return null;
}
try {
int x = 0, y = 0, total = 0;
for (Polygon poly : m.getTriangles()) {
for (int i = 0; i < poly.npoints; i++) {
x += poly.xpoints[i];
y += poly.ypoints[i];
total++;
}
}
Point central = new Point(x / total, y / total);
Point curCentral = null;
double dist = 20000;
for (Polygon poly : m.getTriangles()) {
for (int i = 0; i < poly.npoints; i++) {
Point p = new Point(poly.xpoints[i], poly.ypoints[i]);
if (!Calculations.isPointOnScreen(p)) {
continue;
}
double dist2 = distanceBetween(central, p);
if (curCentral == null || dist2 < dist) {
curCentral = p;
dist = dist2;
}
}
}
return curCentral;
} catch (Exception e) {
}
return null;
}
private double distanceBetween(Point p1, Point p2) {
return Math.sqrt(((p1.x - p2.x) * (p1.x - p2.x))
+ ((p1.y - p2.y) * (p1.y - p2.y)));
}
public boolean walkTileMM(com.rsbuddy.script.wrappers.Tile t, int x, int y) {
com.rsbuddy.script.wrappers.Tile dest = new com.rsbuddy.script.wrappers.Tile(t.getX() + com.rsbuddy.script.util.Random.nextInt(0, x), t.getY()
+ com.rsbuddy.script.util.Random.nextInt(0, y));
Point p = com.rsbuddy.script.methods.Calculations.tileToMap( dest);
if (p.x != -1 && p.y != -1) {
com.rsbuddy.script.methods.Mouse.move(p);
Point p2 = com.rsbuddy.script.methods.Calculations.tileToMap( dest);
if (p2.x != -1 && p2.y != -1) {
com.rsbuddy.script.methods.Mouse.move(p2);
com.rsbuddy.script.methods.Mouse.click(p2, true);
return true;
}
}
return false;
}
private int nextPercentage = (uniqueNumber + com.rsbuddy.script.util.Random.nextInt(1, 39));
private boolean needToRun() {
if (com.rsbuddy.script.methods.Walking.getEnergy() > nextPercentage) {
return true;
}
return false;
}
public boolean rest(int stopEnergy) {
int energy = getEnergy();
for (int d = 0; d < 5; d++) {
mayAntiBan = 0;
com.rsbuddy.script.methods.Widgets.getComponent(IN TERFACE_RUN_ORB, 1).interact("Rest");
com.rsbuddy.script.methods.Mouse.moveSlightly();
mayAntiBan = 1;
if (com.rsbuddy.script.util.Random.nextInt(1, 3) == com.rsbuddy.script.util.Random.nextInt(1, 2)) {
if (com.rsbuddy.script.util.Random.nextInt(1, 2) == com.rsbuddy.script.util.Random.nextInt(1, 2)) {
sleep(com.rsbuddy.script.util.Random.nextInt(200, 2000), com.rsbuddy.script.util.Random.nextInt(5000, 15000));
}
mayAntiBan = 0;
com.rsbuddy.script.methods.Mouse.moveOffScreen();
}
int anim = com.rsbuddy.script.methods.Players.getLocal().getA nimation();
if (anim == 12108 || anim == 2033 || anim == 2716 || anim == 11786
|| anim == 5713) {
break;
}
if (d == 4) {
return false;
}
}
while (energy < stopEnergy) {
sleep(millisDelay);
energy = getEnergy();
}
mayAntiBan = 1;
return true;
}
public int getEnergy() {
try {
return Integer.parseInt(com.rsbuddy.script.methods.Widget s.getComponent(750, 5).getText());
} catch (NumberFormatException e) {
return 0;
}
}
private java.util.Random generateSeededRandom(String text) {
MessageDigest coder;
try {
coder = MessageDigest.getInstance("MD5");
coder.update(text.getBytes());
byte[] bytes = coder.digest();
long result1 = 0, result2 = 0;
for (int i = 0; i < 8; i++) {
result1 = (result1 << 8) | bytes[i];
}
for (int i = 8; i < 16; i++) {
result2 = (result2 << 8) | bytes[i];
}
return new java.util.Random(result1 - result2);
} catch (NoSuchAlgorithmException ex) {
}
return new java.util.Random();
}
private boolean inErrorArea() {
return Constants.AREA_INERROR.contains(Players.getLocal() .getLocation());
}
private boolean inAltarArea() {
return Constants.AREA_INALTAR.contains(Players.getLocal() .getLocation());
}
private boolean inRestArea() {
return Constants.AREA_REST.contains(Players.getLocal().ge tLocation());
}
private boolean inCabbageArea() {
return Constants.AREA_INCABBAGE.contains(Players.getLocal ().getLocation());
}
private boolean waitToMove(int timeout) {
long endTime = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < endTime) {
if (Players.getLocal().isMoving()) {
return true;
}
sleep(5, 15);
}
return false;
}
public void waitForEmpty() {
int tries = 0;
while (com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune) && tries < 10) {
tries++;
sleep(180, 200);
}
}
public void waitForFull() {
int tries = 0;
while (!com.rsbuddy.script.methods.Inventory.isFull() && tries < 10
&& !com.rsbuddy.script.methods.Inventory.contains(Con stants.runeEssence)) {
tries++;
sleep(180, 200);
}
}
// Credits go to Enfilade for this epic walking method
private boolean tileInNextRange(com.rsbuddy.script.wrappers.Tile t) {
return com.rsbuddy.script.methods.Calculations.distanceBe tween(t, Players.getLocal().getLocation()) < nextStep;
}
private final Color POLY_FILL = new Color(20, 26, 167, 70);
private int nextStep = com.rsbuddy.script.util.Random.nextInt(15, 16);
private int step(ArrayList<com.rsbuddy.script.wrappers.Tile> path, com.rsbuddy.script.wrappers.Tile tileToWalk) {
if (com.rsbuddy.script.methods.Calculations.distanceB etween(Players.getLocal().getLocation(), path.get(path
.size() - 1)) < 2) {
return path.size();
}
com.rsbuddy.script.wrappers.Tile dest = com.rsbuddy.script.methods.Walking.getDestination( );
int index = -1;
int shortestDist = 0, dist, shortest = -3;
if (dest != null) {
for (int i = 0; i < path.size(); i++) {
dist = (int) com.rsbuddy.script.methods.Calculations.distanceBe tween(path.get(i), dest);
if (shortest < 0 || shortestDist > dist) {
shortest = i;
shortestDist = dist;
}
}
}
for (int i = path.size() - 1; i >= 0; i--) {
if (tileInNextRange(path.get(i))) {
index = i;
break;
}
}
if (index >= 0
&& (dest == null || (index > shortest) || !Players.getLocal()
.isMoving())) {
mayAntiBan = 0;
com.rsbuddy.script.methods.Walking.getTileOnMap(pa th.get(index)).clickOnMap();
sleep(millisDelay);
mayAntiBan = 1;
nextStep = com.rsbuddy.script.util.Random.nextInt(15, 19);
return index;
}
return -1;
}
private ArrayList<com.rsbuddy.script.wrappers.Tile> generatePath(Line[] lines) {
double minStep = 4, maxStep = 13, wander = 3;
if (lines.length < 2) {
return null;
}
ArrayList<com.rsbuddy.script.wrappers.Tile> path = new ArrayList<com.rsbuddy.script.wrappers.Tile>();
Line l1, l2 = lines[0];
double distFromCenter = com.rsbuddy.script.util.Random.nextDouble(0, l2.getDistance() + 1);
com.rsbuddy.script.wrappers.Tile p = l2.translate((int) distFromCenter);
distFromCenter = l2.getDistance() / 2 - distFromCenter;
double centerXdist, centerYdist, line1Xdist, line1Ydist, line2Xdist, line2Ydist;
double line1dist, line2dist, centerDist;
double x, y;
double distOnLine, last, cap1, cap2, move;
double distFromCenterX1, distFromCenterY1, distFromCenterX2, distFromCenterY2;
double force1, force2, slopeX, slopeY, slopeDist;
boolean finished;
int lastX = p.getX(), lastY = p.getY(), curX, curY;
double dist, xdist, ydist;
for (int i = 1; i < lines.length; i++) {
l1 = l2;
l2 = lines[i];
centerXdist = l2.getCenterX() - l1.getCenterX();
centerYdist = l2.getCenterY() - l1.getCenterY();
centerDist = Math.sqrt(centerXdist * centerXdist + centerYdist
* centerYdist);
line1Xdist = l2.getX() - l1.getX();
line1Ydist = l2.getY() - l1.getY();
line2Xdist = l2.getX2() - l1.getX2();
line2Ydist = l2.getY2() - l1.getY2();
centerXdist /= centerDist;
centerYdist /= centerDist;
line1Xdist /= centerDist;
line1Ydist /= centerDist;
line2Xdist /= centerDist;
line2Ydist /= centerDist;
distOnLine = 0;
last = 0;
finished = false;
while (!finished) {
distOnLine += com.rsbuddy.script.util.Random.nextDouble(minStep, maxStep);
if (distOnLine >= centerDist) {
distOnLine = centerDist;
finished = true;
}
x = centerXdist * distOnLine + l1.getCenterX();
y = centerYdist * distOnLine + l1.getCenterY();
distFromCenterX1 = x - (line1Xdist * distOnLine + l1.getX());
distFromCenterY1 = y - (line1Ydist * distOnLine + l1.getY());
distFromCenterX2 = x - (line2Xdist * distOnLine + l1.getX2());
distFromCenterY2 = y - (line2Ydist * distOnLine + l1.getY2());
slopeX = distFromCenterX2 - distFromCenterX1;
slopeY = distFromCenterY2 - distFromCenterY1;
slopeDist = Math.sqrt(slopeX * slopeX + slopeY * slopeY);
slopeX /= slopeDist;
slopeY /= slopeDist;
line1dist = Math.sqrt(distFromCenterX1 * distFromCenterX1
+ distFromCenterY1 * distFromCenterY1);
line2dist = Math.sqrt(distFromCenterX2 * distFromCenterX2
+ distFromCenterY2 * distFromCenterY2);
move = (distOnLine - last) / maxStep * wander;
force1 = line1dist + distFromCenter;
force2 = line2dist - distFromCenter;
cap1 = Math.min(move, force1);
cap2 = Math.min(move, force2);
if (force1 < 0) {
distFromCenter -= force1;
} else if (force2 < 0) {
distFromCenter += force2;
} else {
distFromCenter += com.rsbuddy.script.util.Random.nextDouble(-cap1, cap2);
}
if (finished) {
com.rsbuddy.script.wrappers.Tile t = l2.translateFromCenter(distFromCenter);
curX = t.getX();
curY = t.getY();
} else {
curX = (int) Math.round(distOnLine * centerXdist
+ l1.getCenterX() + distFromCenter * slopeX);
curY = (int) Math.round(distOnLine * centerYdist
+ l1.getCenterY() + distFromCenter * slopeY);
}
xdist = curX - lastX;
ydist = curY - lastY;
dist = Math.sqrt(xdist * xdist + ydist * ydist);
xdist /= dist;
ydist /= dist;
for (int j = 0; j < dist; j++) {
path.add(new com.rsbuddy.script.wrappers.Tile((int) Math.round(xdist * j + lastX),
(int) Math.round(ydist * j + lastY)));
}
last = distOnLine;
lastX = curX;
lastY = curY;
}
}
return cutUp(path);
}
public ArrayList<com.rsbuddy.script.wrappers.Tile> cutUp(ArrayList<com.rsbuddy.script.wrappers.Tile> tiles) {
ArrayList<com.rsbuddy.script.wrappers.Tile> path = new ArrayList<com.rsbuddy.script.wrappers.Tile>();
int index = 0;
while (index < tiles.size()) {
path.add(tiles.get(index));
index += com.rsbuddy.script.util.Random.nextInt(8, 12);
}
if (!path.get(path.size() - 1).equals(tiles.get(tiles.size() - 1))) {
path.add(tiles.get(tiles.size() - 1));
}
return path;
}
private class Line {
private int x, y, xdist, ydist, x2, y2, centerX, centerY;
private com.rsbuddy.script.wrappers.Tile t1, t2;
private double dist;
public Line(int x1, int y1, int x2, int y2) {
t1 = new com.rsbuddy.script.wrappers.Tile(x1, y1);
t2 = new com.rsbuddy.script.wrappers.Tile(x2, y2);
x = x1;
y = y1;
this.x2 = x2;
this.y2 = y2;
xdist = x2 - x1;
ydist = y2 - y1;
centerX = x + (int) (0.5 * xdist);
centerY = y + (int) (0.5 * ydist);
dist = Math.sqrt(xdist * xdist + ydist * ydist);
}
public int getCenterX() {
return centerX;
}
public int getCenterY() {
return centerY;
}
public com.rsbuddy.script.wrappers.Tile getRandomTile() {
double rand = Math.random();
return new com.rsbuddy.script.wrappers.Tile(x + (int) (xdist * rand), y
+ (int) (ydist * rand));
}
public com.rsbuddy.script.wrappers.Tile getTile1() {
return t1;
}
public com.rsbuddy.script.wrappers.Tile getTile2() {
return t2;
}
public void drawTo(Graphics g, Line line) {
if (!com.rsbuddy.script.methods.Calculations.isTileOn Map(t1) || !com.rsbuddy.script.methods.Calculations.isTileOnM ap(t2)) {
return;
}
if (com.rsbuddy.script.methods.Calculations.isTileOnM ap(line.getTile1())
&& com.rsbuddy.script.methods.Calculations.isTileOnMa p(line.getTile2())) {
Point p1 = com.rsbuddy.script.methods.Calculations.tileToMap( t1);
Point p2 = com.rsbuddy.script.methods.Calculations.tileToMap( t2);
Point p3 = com.rsbuddy.script.methods.Calculations.tileToMap( line.getTile2());
Point p4 = com.rsbuddy.script.methods.Calculations.tileToMap( line.getTile1());
GeneralPath path = new GeneralPath();
path.moveTo(p1.x, p1.y);
path.lineTo(p2.x, p2.y);
path.lineTo(p3.x, p3.y);
path.lineTo(p4.x, p4.y);
path.closePath();
g.setColor(POLY_FILL);
((Graphics2D) g).fill(path);
((Graphics2D) g).draw(path);
}
Point last = null, p;
g.setColor(color3);
for (com.rsbuddy.script.wrappers.Tile t : pathList) {
if (com.rsbuddy.script.methods.Calculations.isTileOnM ap(t)) {
p = com.rsbuddy.script.methods.Calculations.tileToMap( t);
g.fillOval(p.x - 2, p.y - 2, 5, 5);
if (last != null) {
g.drawLine(p.x, p.y, last.x, last.y);
}
last = p;
} else {
last = null;
}
}
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getX2() {
return x2;
}
public int getY2() {
return y2;
}
public int getXDistance() {
return xdist;
}
public int getYDistance() {
return ydist;
}
public double getDistance() {
return dist;
}
public com.rsbuddy.script.wrappers.Tile translate(double length) {
return new com.rsbuddy.script.wrappers.Tile((int) Math.round(length * (xdist / dist)) + x,
(int) Math.round(length * (ydist / dist)) + y);
}
public com.rsbuddy.script.wrappers.Tile translateFromCenter(double length) {
return new com.rsbuddy.script.wrappers.Tile((int) Math.round(centerX - (xdist / dist)
* length), (int) Math.round(centerY - (ydist / dist)
* length));
}
}
// START: Code generated using Enfilade's Easel
private Image getImage(String url) {
try {
return ImageIO.read(new URL(url));
} catch (IOException e) {
return null;
}
}
private String format(int number) {
return format(String.valueOf(number));
}
private String format(String number) {
if (number.length() < 4) {
return number;
}
return format(number.substring(0, number.length() - 3)) + ","
+ number.substring(number.length() - 3, number.length());
}
private int getRunesCrafted() {
int watersrcrafted = totalwaters - waterRuneStart;
return watersrcrafted;
}
private int getExpGained() {
if (startExp == -1) {
}
return com.rsbuddy.script.methods.Skills.getCurrentExp(Sk ills.RUNECRAFTING) - startExp;
}
private double getExpHour() {
int xpGained = getExpGained();
long start = System.currentTimeMillis() - timer.getElapsed();
return xpGained * 3600000D / (System.currentTimeMillis() - start);
}
private int getExpToLvl() {
return com.rsbuddy.script.methods.Skills.getExpToNextLeve l(Skills.RUNECRAFTING);
}
private int getLvlGained() {
return com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING) - startLvl;
}
private int getPercentToLvl() {
return com.rsbuddy.script.methods.Skills.getPercentToNext Level(Skills.RUNECRAFTING);
}
private int getRunecraftLvl() {
return com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING);
}
private int getEssenceCrafted() {
return getExpGained() / 6;
}
private double getEssenceHour() {
int EssGained = getEssenceCrafted();
long start = System.currentTimeMillis() - timer.getElapsed();
return EssGained * 3600000D / (System.currentTimeMillis() - start);
}
private int getEssenceLeft() {
return getExpToLvl() / 6;
}
private int getRunesPerHour() {
long start = System.currentTimeMillis() - timer.getElapsed();
int Runescrafted = getRunesCrafted();
return (int) (Runescrafted * 3600000D / (System.currentTimeMillis() - start));
}
private int calcProfitH() {
long start = System.currentTimeMillis() - timer.getElapsed();
int Profit = getProfit();
return (int) (Profit * 3600000D / (System.currentTimeMillis() - start));
}
private int getProfit() {
int runes = (int) (getRunesCrafted());
int ess = (int) (getEssenceCrafted());
return (runes * runePrice) - (ess * essPrice);
}
private String format(long time) {
if (time <= 0) {
return "--:--:--";
}
return Timer.format(time);
}
private String getTimeToLvl() {
return format((long) (getExpToLvl() / getExpHour() * 3600000D));
}
public String formatCommas(double d) {
DecimalFormat df = new DecimalFormat();
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setGroupingSeparator(',');
df.setDecimalFormatSymbols(dfs);
return ((String) df.format((int) d));
}
private static final RenderingHints RENDERING_HINTS = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
public long startTime = System.currentTimeMillis();
private final Color color1 = new Color(0, 0, 0, 206);
private final Color color2 = new Color(255, 255, 255);
private final Color color3 = new Color(0, 255, 255);
private final Color color4 = new Color(0, 0, 255);
private final Color color5 = new Color(0, 0, 0);
private final BasicStroke stroke1 = new BasicStroke(1);
private final Font font1 = new Font("Monotype Corsiva", 2, 17);
private final Image img1 = getImage("Only the registered members can see the link.");
private final Image img2 = getImage("Only the registered members can see the link.");
private final Image img3 = getImage("Only the registered members can see the link.");
private final Image img4 = getImage("Only the registered members can see the link.");
final int percent() {
return (getPercentToLvl() * 5);
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
Point mp = e.getPoint();
final Rectangle toggleRectangle = new Rectangle(493, 347, 16, 15);
if (toggleRectangle.contains(mp)) {
if (pressed) {
pressed = false;
} else {
pressed = true;
}
}
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void onRepaint(Graphics g1) {
final Color MOUSE = new Color(20, 26, 167, 85);
if (com.rsbuddy.script.methods.Game.isLoggedIn()) {
Graphics2D g = (Graphics2D) g1;
g.setRenderingHints(RENDERING_HINTS);
if (pressed) {
long runTime = System.currentTimeMillis() - startTime;
g.setColor(color1);
g.fillRoundRect(9, 344, 504, 127, 16, 16);
g.setColor(color2);
g.drawImage(img4, 65, 305, null);
g.setFont(font1);
g.drawString("Current Level: " + getRunecraftLvl() + " (+"
+ getLvlGained() + ")", 11, 385);
g.drawString("Time running: " + format(runTime), 11, 365);
g.drawString("Essence used: " + getEssenceCrafted() + " ("
+ format((int) getEssenceHour()) + "/hr)", 242, 425);
g.drawString("XP gained: " + getExpGained() + " ("
+ format((int) getExpHour()) + "/hr)", 11, 425);
g.drawString("Runes crafted: " + getRunesCrafted() + " ("
+ format((int) getRunesPerHour()) + "/hr)", 11, 405);
g.drawString("Ess till level: " + getEssenceLeft(), 242, 405);
g.drawString("Time till level: " + getTimeToLvl(), 11, 445);
g.drawString("Status: " + status, 242, 365);
g.drawString("Profit: " + getProfit() + " ("
+ format((int) calcProfitH()) + "/hr)", 242, 385);
g.drawString("XP left till level: " + getExpToLvl(), 242, 445);
g.drawImage(img1, 45, 320, null);
g.drawImage(img1, 445, 320, null);
g.setColor(color3);
g.fillRoundRect(8, 450, 500, 23, 16, 16);
g.setColor(color4);
g.fillRoundRect(8, 450, percent(), 23, 16, 16);
g.drawImage(img3, 396, 5, null);
g.setColor(color3);
g.setStroke(stroke1);
g.drawRoundRect(8, 450, 500, 23, 16, 16);
g.setColor(color3);
g.fillRect(493, 347, 16, 15);
g.setColor(color4);
g.drawRect(493, 347, 16, 15);
g.setFont(new Font("Arial", Font.BOLD, 14));
g.drawString("X", 497, 360);
g.setColor(color5);
g.drawString(getPercentToLvl() + "%", 253, 468);// /At 55%
// exactly over
// the %
g.setColor(color3);
g.setColor(MOUSE);
g.drawImage(img2, ((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tX()) - 31),
((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tY()) - 31), null);
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
for (int i = 1; i < TOBANKCABBAGE.length; i++) {
TOBANKCABBAGE[i].drawTo(g1,
TOBANKCABBAGE[i - 1]);
}
} else {
for (int i = 1; i < TOBANK.length; i++) {
TOBANK[i].drawTo(g1, TOBANK[i - 1]);
}
}
} else {
for (int i = 1; i < TORUINS.length; i++) {
TORUINS[i].drawTo(g1, TORUINS[i - 1]);
}
}
}
} else {
g.setColor(color4);
g.fillRect(493, 347, 16, 15);
g.setColor(color3);
g.drawRect(493, 347, 16, 15);
g.setFont(new Font("Arial", Font.BOLD, 14));
g.drawString("O", 496, 360);
g.fillRoundRect(10, 314, 500, 23, 16, 16);
g.setColor(color4);
g.fillRoundRect(10, 314, percent(), 23, 16, 16);
g.drawImage(img3, 396, 5, null);
g.setColor(color3);
g.setStroke(stroke1);
g.drawRoundRect(10, 314, 500, 23, 16, 16);
g.setColor(color5);
g.drawString(getPercentToLvl() + "%", 255, 334);// /At 55%
// exactly over
// the %
g.setColor(color3);
g.setColor(MOUSE);
g.drawImage(img2, ((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tX()) - 31),
((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tY()) - 31), null);
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
for (int i = 1; i < TOBANKCABBAGE.length; i++) {
TOBANKCABBAGE[i].drawTo(g1,
TOBANKCABBAGE[i - 1]);
}
} else {
for (int i = 1; i < TOBANK.length; i++) {
TOBANK[i].drawTo(g1, TOBANK[i - 1]);
}
}
} else {
for (int i = 1; i < TORUINS.length; i++) {
TORUINS[i].drawTo(g1, TORUINS[i - 1]);
}
}
}
}
}
}
private static final String UPDATER_FILE_NAME = "PerfectCrafter.java";
private static final String UPDATER_URL = "Only the registered members can see the link.";
private static final Pattern UPDATER_VERSION_PATTERN = Pattern
.compile("version\\s*=\\s*([0-9.]+)");
private boolean checkForUpdates() {
try {
double currentVer = PerfectCrafter.class.getAnnotation(
com.rsbuddy.script.Manifest.class).version();
double newVer = -1;
URL url = new URL(UPDATER_URL);
BufferedReader in = new BufferedReader(new InputStreamReader(url
.openStream()));
String line, lines = "";
Matcher m;
while ((line = in.readLine()) != null) {
lines += line + "\n";
if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
newVer = Double.parseDouble(m.group(1));
break;
}
}
if (newVer < 0) {
in.close();
log("Unable to find the new version number. Update failed");
return false;
}
if (currentVer == newVer) {
in.close();
log("You already have the latest version of the script.");
return false;
}
log("Update found! Downloading version " + newVer);
String scriptFilePath = com.rsbuddy.script.methods.Environment.getStorageD irectory()
+ "\\" + UPDATER_FILE_NAME;
PrintWriter out = new PrintWriter(scriptFilePath);
out.print(lines);
while ((line = in.readLine()) != null)
out.println(line);
out.close();
in.close();
log("Successfully saved " + UPDATER_FILE_NAME + " to "
+ com.rsbuddy.script.methods.Environment.getStorageD irectory());
log("Compiling...");
try {
/* Attempt to compile the downloaded version */
Runtime.getRuntime().exec(
new String[] { "javac", "-classpath", "RSBot.jar",
scriptFilePath });
} catch (Exception ex) {
log("Could not compile the script. Please manually compile to finish the update.");
return false;
}
log("Update successful!");
log("The new version will appear near the bottom of the script selector.");
log("Stop and restart the script to run the newer version.");
return true;
} catch (IOException e) {
log(e.toString());
log("Update failed.");
}
return false;
}
// STOP: Code generated using Enfilade's Easel
private final class PerfectGUI extends JFrame {
private static final long serialVersionUID = 1L;
private JTabbedPane tabs;
private JCheckBox Explorer;
private JCheckBox restBox;
private JCheckBox Update;
private JButton submit;
private void init() {
setLocationRelativeTo(getRootPane());
setLayout(new GridLayout(2, 1));
tabs = new JTabbedPane();
tabs.setFocusable(false);
Explorer = new JCheckBox("Use Explorer's ring.");
restBox = new JCheckBox("use resting.");
Update = new JCheckBox("Check for updates.");
submit = new JButton("Start");
JPanel controls = new JPanel();
controls.setLayout(new GridLayout(3, 1));
JPanel Crafting = new JPanel();
Crafting.setLayout(new GridLayout(3, 1));
JPanel extra = new JPanel();
extra.setLayout(new GridLayout(3, 1));
setSize(200, 300);
setTitle("PerfectCrafter");
controls.add(restBox);
controls.add(Update);
controls.add(Explorer);
tabs.add(controls, "General");
add(tabs);
add(submit);
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
submit();
}
});
setVisible(true);
}
private void submit() {
checkUpdate = Update.isSelected();
useResting = restBox.isSelected();
if (Explorer.isSelected()) {
if (Explorer.isSelected()) {
log("Explorer's ring is selected");
useExplorersRing = true;
} else {
log("Explorer's ring is not selected");
useExplorersRing = false;
}
}
dispose();
}
}
}
Ishana
March 21st, 2011, 16:36
If I find something that really needs to be converted and I fail at it I will be sure to PM you ;)
J i m b o
March 21st, 2011, 16:46
Here we go.
Only the registered members can see the link.
Code(some of it's weird because it was doing weird stuff, and i had to remove the GUI due to the fact that their theme has a bug in it, not the script):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.GeneralPath;
import java.io.IOException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import com.rsbuddy.event.listeners.PaintListener;
import com.rsbuddy.script.methods.Calculations;
import com.rsbuddy.script.methods.Equipment;
import com.rsbuddy.script.methods.Game;
import com.rsbuddy.script.methods.Mouse;
import com.rsbuddy.script.methods.Players;
import com.rsbuddy.script.methods.Skills;
import com.rsbuddy.script.methods.Walking;
import com.rsbuddy.script.util.Timer;
import com.rsbuddy.script.wrappers.Model;
import com.rsbuddy.script.wrappers.Tile;
@com.rsbuddy.script.Manifest(authors = "Ubuntu4life, Maximonster", name = "PerfectCrafter", version = 1.284, description = "Crafts water runes perfectly.")
public class PerfectCrafter extends com.rsbuddy.script.ActiveScript implements PaintListener, MouseListener {
private enum Action {
OPENBANK, DEPOSIT, WITHDRAW, WALKTORUINS, ENTERRUINS, WALKTOALTAR, CRAFTRUNE, TELEPORT, WALKTOGATE, OPENGATE, WALKTOPORTAL, LEAVEALTAR, WALKTOBANK, SLEEP
}
com.rsbuddy.script.wrappers.Tile gateTile = new com.rsbuddy.script.wrappers.Tile(3053, 3283);
com.rsbuddy.script.wrappers.Tile gateWalkTile = new com.rsbuddy.script.wrappers.Tile(3053, 3285);
com.rsbuddy.script.wrappers.Tile altarTile = new com.rsbuddy.script.wrappers.Tile(3485, 4836);
com.rsbuddy.script.wrappers.Tile altarWalkTile = new com.rsbuddy.script.wrappers.Tile(3486, 4836);
com.rsbuddy.script.wrappers.Tile altarClickTile = new com.rsbuddy.script.wrappers.Tile(3484, 4836);
com.rsbuddy.script.wrappers.Tile boothTile = new com.rsbuddy.script.wrappers.Tile(3091, 3245);
com.rsbuddy.script.wrappers.Tile bankTile = new com.rsbuddy.script.wrappers.Tile(3089, 3244);
com.rsbuddy.script.wrappers.Tile bankWalkTile = new com.rsbuddy.script.wrappers.Tile(3093, 3244);
com.rsbuddy.script.wrappers.Tile portalTile = new com.rsbuddy.script.wrappers.Tile(3495, 4832);
com.rsbuddy.script.wrappers.Tile portalWalkTile = new com.rsbuddy.script.wrappers.Tile(3496, 4832);
com.rsbuddy.script.wrappers.Tile ruinsTile = new com.rsbuddy.script.wrappers.Tile(3184, 3165);
com.rsbuddy.script.wrappers.Tile ruinsWalkTile = new com.rsbuddy.script.wrappers.Tile(3183, 3164);
com.rsbuddy.script.wrappers.Tile ruinsClickTile = new com.rsbuddy.script.wrappers.Tile(3185, 3165);
private PerfectGUI gui;
private boolean checkUpdate;
private boolean useResting;
private boolean useExplorersRing, pressed = true;
public boolean startScript = false, foundWaters = false, firstLoop = true,
outOfEssence = false;
volatile boolean stop = false;
private final int INTERFACE_RUN_ORB = 750, RUN_CHILD_ID = 1;
private int uniqueNumber;
public int startExp, startLvl, mayAntiBan = 0, itemCount = 0,
itemtypeint = 0, invalidCount = 0, runeStart = 0, totalRunes = 0,
essPrice = 0, runePrice = 0, waterRuneStart = 0, totalwaters = 0,
failCount = 0;
private ArrayList<com.rsbuddy.script.wrappers.Tile> pathList;
private Timer timer;
private AntiBan antiBan;
private java.util.Random unique;
private String status = "Starting...";
private Line[] TORUINS = { new Line(3094, 3243, 3093, 3242),
new Line(3103, 3236, 3098, 3235), new Line(3110, 3232, 3099, 3228),
new Line(3114, 3228, 3100, 3227), new Line(3114, 3224, 3110, 3223),
new Line(3116, 3221, 3114, 3220), new Line(3124, 3209, 3118, 3206),
new Line(3129, 3207, 3129, 3206), new Line(3138, 3207, 3131, 3204),
new Line(3143, 3205, 3138, 3201), new Line(3149, 3200, 3138, 3197),
new Line(3157, 3190, 3140, 3189), new Line(3160, 3181, 3150, 3178),
new Line(3167, 3172, 3157, 3169), new Line(3168, 3170, 3164, 3165),
new Line(3176, 3167, 3175, 3162), new Line(3180, 3167, 3180, 3162),
new Line(3184, 3167, 3184, 3162) };
private Line[] TOBANK = { new Line(3183, 3167, 3183, 3162),
new Line(3180, 3167, 3180, 3162), new Line(3176, 3167, 3175, 3162),
new Line(3171, 3169, 3171, 3163), new Line(3168, 3170, 3164, 3165),
new Line(3167, 3172, 3157, 3169), new Line(3160, 3181, 3150, 3178),
new Line(3157, 3190, 3140, 3189), new Line(3149, 3200, 3138, 3197),
new Line(3143, 3205, 3138, 3201), new Line(3138, 3207, 3131, 3204),
new Line(3129, 3207, 3129, 3206), new Line(3124, 3209, 3118, 3206),
new Line(3116, 3221, 3114, 3220), new Line(3114, 3224, 3110, 3223),
new Line(3114, 3228, 3100, 3227), new Line(3110, 3232, 3099, 3228),
new Line(3103, 3236, 3098, 3235), new Line(3093, 3245, 3093, 3242) };
private Line[] TOBANKCABBAGE = { new Line(3054, 3282, 3052, 3282),
new Line(3057, 3281, 3057, 3276), new Line(3071, 3277, 3071, 3274),
new Line(3082, 3268, 3070, 3268), new Line(3082, 3258, 3072, 3258),
new Line(3082, 3254, 3078, 3251), new Line(3086, 3249, 3085, 3247),
new Line(3092, 3246, 3092, 3243) };
public static interface Constants {
int[] openGates = { 7051, 7052 };
int[] closedGates = { 7050, 7049 };
int waterRune = 555;
int waterTalisman = 1444;
int runeEssence = 1436;
int Altar = 2480;
int Portal = 2467;
int Ruins = 2454;
int bankBooth = 2213;
com.rsbuddy.script.wrappers.Area AREA_INALTAR = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3474, 4845), new com.rsbuddy.script.wrappers.Tile(
3500, 4822));
com.rsbuddy.script.wrappers.Area AREA_REST = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3099, 3238), new com.rsbuddy.script.wrappers.Tile(3176,
3154));
com.rsbuddy.script.wrappers.Area AREA_INCABBAGE = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3067, 3283), new com.rsbuddy.script.wrappers.Tile(
3051, 3292));
com.rsbuddy.script.wrappers.Area AREA_INERROR = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3050, 3290), new com.rsbuddy.script.wrappers.Tile(
3057, 3298));
}
@Override
public boolean onStart() {
if (!com.rsbuddy.script.methods.Game.isFixed()) {
log.severe("You must use Fixed Screen Mode to use this script.");
return false;
}
if (com.rsbuddy.script.methods.Game.isLoggedIn()) {
unique = generateSeededRandom(Players.getLocal().getName()) ;
uniqueNumber = unique.nextInt(25);
if (checkUpdate) {
checkForUpdates();
}
startExp = com.rsbuddy.script.methods.Skills.getCurrentExp(Sk ills.RUNECRAFTING);
startLvl = com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING);
mayAntiBan = 0;
log.info(":-:-: Loading PerfectCrafter 1.284 :-:-:");
startTime = System.currentTimeMillis();
timer = new Timer(0);
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(5, 8));
log.info("Loading Prices...");
com.rsbuddy.script.methods.GrandExchange.Item water = com.rsbuddy.script.methods.GrandExchange.lookup(Co nstants.waterRune);
runePrice = water.getMarketPrice();
com.rsbuddy.script.methods.GrandExchange.Item ess = com.rsbuddy.script.methods.GrandExchange.lookup(Co nstants.runeEssence);
essPrice = ess.getMarketPrice();
if (pathList == null) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
pathList = generatePath(TOBANKCABBAGE);
} else {
pathList = generatePath(TOBANK);
}
} else {
pathList = generatePath(TORUINS);
}
}
startScript = true;
log.info("Bot and script are all set to go.");
} else {
log.info("Please log in before starting the script.");
return false;
}
return true;
}
public void onFinish() {
log("Antiban stopped");
log.info(":-:-: Thank you for using PerfectCrafter :-:-:");
com.rsbuddy.script.methods.Mouse.moveOffScreen();
com.rsbuddy.script.methods.Environment.saveScreens hot(true);
log("Remember to comment :p");
stop = true;
stop();
}
public Action getState() {
com.rsbuddy.script.wrappers.GameObject closedGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.closedGates);
try {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(boothTile)) {
if (!com.rsbuddy.script.methods.Bank.isOpen()) {
return Action.OPENBANK;
} else {
if (com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune)) {
return Action.DEPOSIT;
} else {
return Action.WITHDRAW;
}
}
} else {
if (inAltarArea() || Players.getLocal().getAnimation() == 791) {
if (useExplorersRing == true) {
return Action.TELEPORT;
} else if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(portalTile)) {
return Action.LEAVEALTAR;
} else {
return Action.WALKTOPORTAL;
}
} else {
if (useExplorersRing == true) {
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate.getLocation()) < 8
&& closedGate != null && inCabbageArea()) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile)) {
return Action.OPENGATE;
} else {
return Action.WALKTOGATE;
}
}
}
return Action.WALKTOBANK;
}
}
} else {
if (inAltarArea()) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(altarTile)) {
return Action.CRAFTRUNE;
} else {
return Action.WALKTOALTAR;
}
} else {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(ruinsTile)) {
return Action.ENTERRUINS;
} else {
return Action.WALKTORUINS;
}
}
}
} catch (Exception e) {
return Action.SLEEP;
}
}
Random r = new Random();
double val = r.nextGaussian() * 61 + 301;
int millisDelay = (int) Math.round(val);
private Mouse mouse = new Mouse();
private Game game = new Game();
@Override
public int loop() {
if (firstLoop) {
log.info("Starting Seperate AntiBan thread.");
antiBan = new AntiBan(this);
antiBan.start();
firstLoop = false;
return com.rsbuddy.script.util.Random.nextInt(200, 400);
}
if (needToRun() && !com.rsbuddy.script.methods.Walking.isRunEnabled() && !com.rsbuddy.script.methods.Bank.isOpen()) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(8, 9));
com.rsbuddy.script.methods.Widgets.get(INTERFACE_R UN_ORB).getComponent(RUN_CHILD_ID)
.interact("turn run mode on");
nextPercentage = (uniqueNumber + com.rsbuddy.script.util.Random.nextInt(2, 39));
sleep(300, 400);
}
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(5, 7));
try {
com.rsbuddy.script.wrappers.GameObject Altar = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Altar);
com.rsbuddy.script.wrappers.GameObject Portal = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Portal);
com.rsbuddy.script.wrappers.GameObject Ruins = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Ruins);
com.rsbuddy.script.wrappers.GameObject Booth = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.bankBooth);
com.rsbuddy.script.wrappers.GameObject closedGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.closedGates);
com.rsbuddy.script.wrappers.GameObject openGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.openGates);
switch (getState()) {
case OPENBANK:
status = "Opening bank";
mayAntiBan = 0;
if (clickObject(Booth, "Use-quickly", boothTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
int count = 0;
while (!com.rsbuddy.script.methods.Bank.isOpen() && ++count < 9) {
mayAntiBan = 1;
sleep(millisDelay);
if (com.rsbuddy.script.methods.Players.getLocal().isM oving()) {
count = 0;
}
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case DEPOSIT:
status = "Depositing";
mayAntiBan = 0;
try {
if (!foundWaters) {
sleep(com.rsbuddy.script.util.Random.nextInt(500, 600));
waterRuneStart = com.rsbuddy.script.methods.Bank.getCount(Constants .waterRune);
foundWaters = true;
}
totalwaters = com.rsbuddy.script.methods.Bank.getCount(Constants .waterRune);
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Bank.depositAll();
waitForEmpty();
} catch (final Exception e) {
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WITHDRAW:
status = "Withdrawing";
mayAntiBan = 0;
try {
int runeCount = com.rsbuddy.script.methods.Bank.getCount(Constants .runeEssence);
if (runeCount < 1) {
log("You are out of rune essences.");
stop();
} else {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Bank.withdraw(Constants .runeEssence, 0);
waitForFull();
pathList = generatePath(TORUINS);
}
if (!com.rsbuddy.script.methods.Inventory.containsAll (Constants.runeEssence)) {
final int count = com.rsbuddy.script.methods.Inventory.getCount();
com.rsbuddy.script.methods.Bank.depositAllExcept(C onstants.runeEssence);
for (int i = 0; i < 10 && com.rsbuddy.script.methods.Inventory.getCount() == count; i++) {
sleep(com.rsbuddy.script.util.Random.nextInt(100, 200));
}
}
} catch (final Exception e) {
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTORUINS:
status = "Walking to ruins";
step(pathList, ruinsTile);
if (useResting == true) {
if (com.rsbuddy.script.methods.Walking.getEnergy() < ((uniqueNumber + com.rsbuddy.script.util.Random.nextInt(-11, 8)))
&& inRestArea()) {
status = "Resting";
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 8));
com.rsbuddy.script.methods.Walking.rest((uniqueNum ber + com.rsbuddy.script.util.Random.nextInt(43, 88)));
}
}
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(ruinsTile)) {
return com.rsbuddy.script.util.Random.nextInt(200, 390);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(220, 370);
case ENTERRUINS:
status = "Entering Ruins";
mayAntiBan = 0;
if (clickObject(Ruins, "Enter", ruinsTile, false)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(millisDelay);
} while (Players.getLocal().isMoving() && !inAltarArea());
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOALTAR:
status = "Walking to altar";
mayAntiBan = 0;
walkTo(altarWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(altarTile));
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case CRAFTRUNE:
status = "Crafting essences";
mayAntiBan = 0;
if (clickObject(Altar, "Craft-rune", altarTile, false)) {
if (useExplorersRing == true) {
pathList = generatePath(TOBANKCABBAGE);
} else {
pathList = generatePath(TOBANK);
}
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(520, 1025);
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune));
if (useExplorersRing == true && !Players.getLocal().isMoving()) {
for (int i = 140; i > 0; --i) {
if (Players.getLocal().getAnimation() != -1) {
continue;
}
sleep(10);
}
sleep(150, 450);
}
if (useExplorersRing == false) {
for (int i = 140; i > 0; --i) {
if (Players.getLocal().getAnimation() != -1) {
continue;
}
sleep(10);
}
sleep(1300, 1600);
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case TELEPORT:
status = "Teleporting";
mayAntiBan = 0;
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
com.rsbuddy.script.methods.Game.openTab(Game.TAB_E QUIPMENT);
}
if (com.rsbuddy.script.methods.Equipment.getItem(Equi pment.RING) != null) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
if (com.rsbuddy.script.methods.Widgets.get(Equipment. WIDGET)
.getComponent(Equipment.RING).interact(
"Cabbage-port")) {
for (int i = 0; i < 140
&& Players.getLocal().getAnimation() != 9984; i++) {
sleep(10);
}
while (Players.getLocal().getAnimation() == 9984) {
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_INVENTORY) {
sleep(198, 2564);
com.rsbuddy.script.methods.Game.openTab(Game.TAB_I NVENTORY);
}
sleep(47, 52);
}
sleep(998, com.rsbuddy.script.util.Random.nextInt(2891, 2901));
}
} else {
log("Please wear an Explorer's ring 3 of 4 !");
stop();
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOGATE:
status = "Walking to gate";
mayAntiBan = 0;
int angle = com.rsbuddy.script.methods.Camera.getAngleTo(close dGate);
walkTo(gateWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile));
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10
&& Math.abs(angle - com.rsbuddy.script.methods.Camera.getCompassAngle( )) > 20) {
com.rsbuddy.script.methods.Camera.setCompassAngle( angle + com.rsbuddy.script.util.Random.nextInt(-21, 21));
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case OPENGATE:
status = "Opening gate";
mayAntiBan = 0;
if (clickObject(closedGate, "Open Gate", gateTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
if (inErrorArea()) {
int angle2 = com.rsbuddy.script.methods.Camera.getAngleTo(close dGate);
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10
&& Math.abs(angle2 - com.rsbuddy.script.methods.Camera.getCompassAngle( )) > 20) {
com.rsbuddy.script.methods.Camera.setCompassAngle( angle2 + com.rsbuddy.script.util.Random.nextInt(-21, 21));
}
walkTileMM(gateWalkTile, 2, 2);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile));
}
} while (Players.getLocal().isMoving());
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10) {
Timer gateTimer = new Timer(com.rsbuddy.script.util.Random.nextInt(1000, 1400));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (openGate == null && gateTimer.isRunning());
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOPORTAL:
status = "Walking to portal";
mayAntiBan = 0;
walkTo(portalWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(portalTile));
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case LEAVEALTAR:
status = "Leaving altar";
mayAntiBan = 0;
if (clickObject(Portal, "Enter", portalTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(millisDelay);
} while (inAltarArea() && Players.getLocal().isMoving());
sleep(150, 300);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOBANK:
status = "Walking to bank";
com.rsbuddy.script.methods.Camera.setPitch(true);
step(pathList, boothTile);
if (useResting == true) {
if (com.rsbuddy.script.methods.Walking.getEnergy() < ((uniqueNumber + com.rsbuddy.script.util.Random.nextInt(-11, 8)))
&& inRestArea()) {
status = "Resting";
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(8, 9));
com.rsbuddy.script.methods.Walking.rest((uniqueNum ber + com.rsbuddy.script.util.Random.nextInt(43, 88)));
}
}
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(boothTile)) {
return com.rsbuddy.script.util.Random.nextInt(220, 370);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
}
} catch (Exception e) {
sleep(150, 300);
return com.rsbuddy.script.util.Random.nextInt(50, 100);
}
return 0;
}
private void walkTo(Tile destination) {
while (Calculations.distanceTo(destination) > 3) {
Walking.stepTowards(destination);
sleep(2000, 4000);
}
}
public com.rsbuddy.script.methods.Mouse getMouse() {
return mouse;
}
// Credits go to Unknown500 for the AntiBan skeleton code
class AntiBan extends Thread {
private PerfectCrafter parent;
private Random randomGenerator;
AntiBan(PerfectCrafter parent) {
this.parent = parent;
this.randomGenerator = new Random();
}
@Override
public void run() {
try {
while (parent.getGame().isLoggedIn() && !stop) {
if (!parent.isPaused()) {
int random = randomGenerator.nextInt(7);
if (mayAntiBan == 1 && random != 2) {
int rand = randomGenerator.nextInt(5);
switch (rand) {
case 1:
if (mayAntiBan == 1) {
if (com.rsbuddy.script.util.Random.nextInt(1, 5) != com.rsbuddy.script.util.Random.nextInt(1, 4)) {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
} else {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
sleep(com.rsbuddy.script.util.Random.nextInt(0, com.rsbuddy.script.util.Random.nextInt(72, 380)));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
}
} else {
break;
}
case 2:
if (mayAntiBan == 1 && com.rsbuddy.script.util.Random.nextInt(1, 510) == 119) {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveSlightly();
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
} else {
break;
}
case 3:
if (com.rsbuddy.script.util.Random.nextInt(1, 8) == 3) {
int angle = com.rsbuddy.script.methods.Camera.getCompassAngle( )
+ com.rsbuddy.script.util.Random.nextInt(-45, 45);
if (angle < 0) {
angle = com.rsbuddy.script.util.Random.nextInt(0, 10);
}
if (angle > 359) {
angle = com.rsbuddy.script.util.Random.nextInt(0, 10);
}
char whichDir = 37;
if (com.rsbuddy.script.util.Random.nextInt(0, 100) < 50)
whichDir = 39;
com.rsbuddy.script.methods.Keyboard.pressKey(which Dir);
sleep(com.rsbuddy.script.util.Random.nextInt(103, 996));
com.rsbuddy.script.methods.Keyboard.releaseKey(whi chDir);
break;
} else {
break;
}
default:
break;
}
}
sleep(com.rsbuddy.script.util.Random.nextInt(63, 2373));
}
}
} catch (InterruptedException e) {
log(e.getMessage());
}
}
}
// credits to !@!@! for clicking method, it's epic.
private boolean clickObject(com.rsbuddy.script.wrappers.GameObject object, String action, com.rsbuddy.script.wrappers.Tile Tile,
boolean useCentralClicking) {
Point p;
for (int i = 0; i < 4; i++) {
if (isPartiallyOnScreen(object.getModel())) {
p = useCentralClicking ? getCentralPoint(object.getModel())
: getPointOnScreen(object.getModel(), true);
while (isPartiallyOnScreen(object.getModel()) && p.x != -1
&& p.y != -1 && p != null && com.rsbuddy.script.methods.Calculations.isPointOnS creen(p)
&& !com.rsbuddy.script.methods.Bank.isOpen() && com.rsbuddy.script.methods.Calculations.isTileOnSc reen(Tile)) {
p = useCentralClicking ? getCentralPoint(object.getModel())
: getPointOnScreen(object.getModel(), true);
com.rsbuddy.script.methods.Mouse.move(p, 0, 0);
if (com.rsbuddy.script.methods.Menu.contains(action))
break;
if (p.x == -1 || p.y == -1 || p == null
|| !com.rsbuddy.script.methods.Calculations.isPointOn Screen(p)
|| !isPartiallyOnScreen(object.getModel())
|| !com.rsbuddy.script.methods.Calculations.isTileOnS creen(Tile) || com.rsbuddy.script.methods.Bank.isOpen())
continue;
}
String[] items = com.rsbuddy.script.methods.Menu.getItems();
if (items.length > 0 && items[0].contains(action)) {
com.rsbuddy.script.methods.Mouse.click(true);
return true;
} else if (com.rsbuddy.script.methods.Menu.contains(action)) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Mouse.click(false);
sleep(com.rsbuddy.script.util.Random.nextInt(100, 200));
for (int x = 0; x < 4; x++) {
if (com.rsbuddy.script.methods.Menu.click(action)) {
return true;
}
}
}
if (!com.rsbuddy.script.methods.Menu.contains(action) && com.rsbuddy.script.methods.Menu.isOpen()) {
do {
com.rsbuddy.script.methods.Mouse.moveRandomly(com. rsbuddy.script.util.Random.nextInt(180, 275));
} while (com.rsbuddy.script.methods.Menu.isOpen());
sleep(com.rsbuddy.script.util.Random.nextInt(100, 175));
return false;
}
}
}
return false;
}
public Game getGame() {
return game ;
}
private boolean isPartiallyOnScreen(Model m) {
return getPointOnScreen(m, true) != null;
}
private Point getPointOnScreen(Model m, boolean first) {
if (m == null) {
return null;
}
ArrayList<Point> list = new ArrayList<Point>();
try {
Polygon[] tris = m.getTriangles();
for (int i = 0; i < tris.length; i++) {
Polygon p = tris[i];
for (int j = 0; j < p.xpoints.length; j++) {
Point pt = new Point(p.xpoints[j], p.ypoints[j]);
if (Calculations.isPointOnScreen(pt)) {
if (first) {
return pt;
}
list.add(pt);
}
}
}
} catch (Exception e) {
}
return list.size() > 0 ? list.get(com.rsbuddy.script.util.Random.nextInt(0, list.size())) : null;
}
private Point getCentralPoint(Model m) {
if (m == null) {
return null;
}
try {
int x = 0, y = 0, total = 0;
for (Polygon poly : m.getTriangles()) {
for (int i = 0; i < poly.npoints; i++) {
x += poly.xpoints[i];
y += poly.ypoints[i];
total++;
}
}
Point central = new Point(x / total, y / total);
Point curCentral = null;
double dist = 20000;
for (Polygon poly : m.getTriangles()) {
for (int i = 0; i < poly.npoints; i++) {
Point p = new Point(poly.xpoints[i], poly.ypoints[i]);
if (!Calculations.isPointOnScreen(p)) {
continue;
}
double dist2 = distanceBetween(central, p);
if (curCentral == null || dist2 < dist) {
curCentral = p;
dist = dist2;
}
}
}
return curCentral;
} catch (Exception e) {
}
return null;
}
private double distanceBetween(Point p1, Point p2) {
return Math.sqrt(((p1.x - p2.x) * (p1.x - p2.x))
+ ((p1.y - p2.y) * (p1.y - p2.y)));
}
public boolean walkTileMM(com.rsbuddy.script.wrappers.Tile t, int x, int y) {
com.rsbuddy.script.wrappers.Tile dest = new com.rsbuddy.script.wrappers.Tile(t.getX() + com.rsbuddy.script.util.Random.nextInt(0, x), t.getY()
+ com.rsbuddy.script.util.Random.nextInt(0, y));
Point p = com.rsbuddy.script.methods.Calculations.tileToMap( dest);
if (p.x != -1 && p.y != -1) {
com.rsbuddy.script.methods.Mouse.move(p);
Point p2 = com.rsbuddy.script.methods.Calculations.tileToMap( dest);
if (p2.x != -1 && p2.y != -1) {
com.rsbuddy.script.methods.Mouse.move(p2);
com.rsbuddy.script.methods.Mouse.click(p2, true);
return true;
}
}
return false;
}
private int nextPercentage = (uniqueNumber + com.rsbuddy.script.util.Random.nextInt(1, 39));
private boolean needToRun() {
if (com.rsbuddy.script.methods.Walking.getEnergy() > nextPercentage) {
return true;
}
return false;
}
public boolean rest(int stopEnergy) {
int energy = getEnergy();
for (int d = 0; d < 5; d++) {
mayAntiBan = 0;
com.rsbuddy.script.methods.Widgets.getComponent(IN TERFACE_RUN_ORB, 1).interact("Rest");
com.rsbuddy.script.methods.Mouse.moveSlightly();
mayAntiBan = 1;
if (com.rsbuddy.script.util.Random.nextInt(1, 3) == com.rsbuddy.script.util.Random.nextInt(1, 2)) {
if (com.rsbuddy.script.util.Random.nextInt(1, 2) == com.rsbuddy.script.util.Random.nextInt(1, 2)) {
sleep(com.rsbuddy.script.util.Random.nextInt(200, 2000), com.rsbuddy.script.util.Random.nextInt(5000, 15000));
}
mayAntiBan = 0;
com.rsbuddy.script.methods.Mouse.moveOffScreen();
}
int anim = com.rsbuddy.script.methods.Players.getLocal().getA nimation();
if (anim == 12108 || anim == 2033 || anim == 2716 || anim == 11786
|| anim == 5713) {
break;
}
if (d == 4) {
return false;
}
}
while (energy < stopEnergy) {
sleep(millisDelay);
energy = getEnergy();
}
mayAntiBan = 1;
return true;
}
public int getEnergy() {
try {
return Integer.parseInt(com.rsbuddy.script.methods.Widget s.getComponent(750, 5).getText());
} catch (NumberFormatException e) {
return 0;
}
}
private java.util.Random generateSeededRandom(String text) {
MessageDigest coder;
try {
coder = MessageDigest.getInstance("MD5");
coder.update(text.getBytes());
byte[] bytes = coder.digest();
long result1 = 0, result2 = 0;
for (int i = 0; i < 8; i++) {
result1 = (result1 << 8) | bytes[i];
}
for (int i = 8; i < 16; i++) {
result2 = (result2 << 8) | bytes[i];
}
return new java.util.Random(result1 - result2);
} catch (NoSuchAlgorithmException ex) {
}
return new java.util.Random();
}
private boolean inErrorArea() {
return Constants.AREA_INERROR.contains(Players.getLocal() .getLocation());
}
private boolean inAltarArea() {
return Constants.AREA_INALTAR.contains(Players.getLocal() .getLocation());
}
private boolean inRestArea() {
return Constants.AREA_REST.contains(Players.getLocal().ge tLocation());
}
private boolean inCabbageArea() {
return Constants.AREA_INCABBAGE.contains(Players.getLocal ().getLocation());
}
private boolean waitToMove(int timeout) {
long endTime = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < endTime) {
if (Players.getLocal().isMoving()) {
return true;
}
sleep(5, 15);
}
return false;
}
public void waitForEmpty() {
int tries = 0;
while (com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune) && tries < 10) {
tries++;
sleep(180, 200);
}
}
public void waitForFull() {
int tries = 0;
while (!com.rsbuddy.script.methods.Inventory.isFull() && tries < 10
&& !com.rsbuddy.script.methods.Inventory.contains(Con stants.runeEssence)) {
tries++;
sleep(180, 200);
}
}
// Credits go to Enfilade for this epic walking method
private boolean tileInNextRange(com.rsbuddy.script.wrappers.Tile t) {
return com.rsbuddy.script.methods.Calculations.distanceBe tween(t, Players.getLocal().getLocation()) < nextStep;
}
private final Color POLY_FILL = new Color(20, 26, 167, 70);
private int nextStep = com.rsbuddy.script.util.Random.nextInt(15, 16);
private int step(ArrayList<com.rsbuddy.script.wrappers.Tile> path, com.rsbuddy.script.wrappers.Tile tileToWalk) {
if (com.rsbuddy.script.methods.Calculations.distanceB etween(Players.getLocal().getLocation(), path.get(path
.size() - 1)) < 2) {
return path.size();
}
com.rsbuddy.script.wrappers.Tile dest = com.rsbuddy.script.methods.Walking.getDestination( );
int index = -1;
int shortestDist = 0, dist, shortest = -3;
if (dest != null) {
for (int i = 0; i < path.size(); i++) {
dist = (int) com.rsbuddy.script.methods.Calculations.distanceBe tween(path.get(i), dest);
if (shortest < 0 || shortestDist > dist) {
shortest = i;
shortestDist = dist;
}
}
}
for (int i = path.size() - 1; i >= 0; i--) {
if (tileInNextRange(path.get(i))) {
index = i;
break;
}
}
if (index >= 0
&& (dest == null || (index > shortest) || !Players.getLocal()
.isMoving())) {
mayAntiBan = 0;
com.rsbuddy.script.methods.Walking.getTileOnMap(pa th.get(index)).clickOnMap();
sleep(millisDelay);
mayAntiBan = 1;
nextStep = com.rsbuddy.script.util.Random.nextInt(15, 19);
return index;
}
return -1;
}
private ArrayList<com.rsbuddy.script.wrappers.Tile> generatePath(Line[] lines) {
double minStep = 4, maxStep = 13, wander = 3;
if (lines.length < 2) {
return null;
}
ArrayList<com.rsbuddy.script.wrappers.Tile> path = new ArrayList<com.rsbuddy.script.wrappers.Tile>();
Line l1, l2 = lines[0];
double distFromCenter = com.rsbuddy.script.util.Random.nextDouble(0, l2.getDistance() + 1);
com.rsbuddy.script.wrappers.Tile p = l2.translate((int) distFromCenter);
distFromCenter = l2.getDistance() / 2 - distFromCenter;
double centerXdist, centerYdist, line1Xdist, line1Ydist, line2Xdist, line2Ydist;
double line1dist, line2dist, centerDist;
double x, y;
double distOnLine, last, cap1, cap2, move;
double distFromCenterX1, distFromCenterY1, distFromCenterX2, distFromCenterY2;
double force1, force2, slopeX, slopeY, slopeDist;
boolean finished;
int lastX = p.getX(), lastY = p.getY(), curX, curY;
double dist, xdist, ydist;
for (int i = 1; i < lines.length; i++) {
l1 = l2;
l2 = lines[i];
centerXdist = l2.getCenterX() - l1.getCenterX();
centerYdist = l2.getCenterY() - l1.getCenterY();
centerDist = Math.sqrt(centerXdist * centerXdist + centerYdist
* centerYdist);
line1Xdist = l2.getX() - l1.getX();
line1Ydist = l2.getY() - l1.getY();
line2Xdist = l2.getX2() - l1.getX2();
line2Ydist = l2.getY2() - l1.getY2();
centerXdist /= centerDist;
centerYdist /= centerDist;
line1Xdist /= centerDist;
line1Ydist /= centerDist;
line2Xdist /= centerDist;
line2Ydist /= centerDist;
distOnLine = 0;
last = 0;
finished = false;
while (!finished) {
distOnLine += com.rsbuddy.script.util.Random.nextDouble(minStep, maxStep);
if (distOnLine >= centerDist) {
distOnLine = centerDist;
finished = true;
}
x = centerXdist * distOnLine + l1.getCenterX();
y = centerYdist * distOnLine + l1.getCenterY();
distFromCenterX1 = x - (line1Xdist * distOnLine + l1.getX());
distFromCenterY1 = y - (line1Ydist * distOnLine + l1.getY());
distFromCenterX2 = x - (line2Xdist * distOnLine + l1.getX2());
distFromCenterY2 = y - (line2Ydist * distOnLine + l1.getY2());
slopeX = distFromCenterX2 - distFromCenterX1;
slopeY = distFromCenterY2 - distFromCenterY1;
slopeDist = Math.sqrt(slopeX * slopeX + slopeY * slopeY);
slopeX /= slopeDist;
slopeY /= slopeDist;
line1dist = Math.sqrt(distFromCenterX1 * distFromCenterX1
+ distFromCenterY1 * distFromCenterY1);
line2dist = Math.sqrt(distFromCenterX2 * distFromCenterX2
+ distFromCenterY2 * distFromCenterY2);
move = (distOnLine - last) / maxStep * wander;
force1 = line1dist + distFromCenter;
force2 = line2dist - distFromCenter;
cap1 = Math.min(move, force1);
cap2 = Math.min(move, force2);
if (force1 < 0) {
distFromCenter -= force1;
} else if (force2 < 0) {
distFromCenter += force2;
} else {
distFromCenter += com.rsbuddy.script.util.Random.nextDouble(-cap1, cap2);
}
if (finished) {
com.rsbuddy.script.wrappers.Tile t = l2.translateFromCenter(distFromCenter);
curX = t.getX();
curY = t.getY();
} else {
curX = (int) Math.round(distOnLine * centerXdist
+ l1.getCenterX() + distFromCenter * slopeX);
curY = (int) Math.round(distOnLine * centerYdist
+ l1.getCenterY() + distFromCenter * slopeY);
}
xdist = curX - lastX;
ydist = curY - lastY;
dist = Math.sqrt(xdist * xdist + ydist * ydist);
xdist /= dist;
ydist /= dist;
for (int j = 0; j < dist; j++) {
path.add(new com.rsbuddy.script.wrappers.Tile((int) Math.round(xdist * j + lastX),
(int) Math.round(ydist * j + lastY)));
}
last = distOnLine;
lastX = curX;
lastY = curY;
}
}
return cutUp(path);
}
public ArrayList<com.rsbuddy.script.wrappers.Tile> cutUp(ArrayList<com.rsbuddy.script.wrappers.Tile> tiles) {
ArrayList<com.rsbuddy.script.wrappers.Tile> path = new ArrayList<com.rsbuddy.script.wrappers.Tile>();
int index = 0;
while (index < tiles.size()) {
path.add(tiles.get(index));
index += com.rsbuddy.script.util.Random.nextInt(8, 12);
}
if (!path.get(path.size() - 1).equals(tiles.get(tiles.size() - 1))) {
path.add(tiles.get(tiles.size() - 1));
}
return path;
}
private class Line {
private int x, y, xdist, ydist, x2, y2, centerX, centerY;
private com.rsbuddy.script.wrappers.Tile t1, t2;
private double dist;
public Line(int x1, int y1, int x2, int y2) {
t1 = new com.rsbuddy.script.wrappers.Tile(x1, y1);
t2 = new com.rsbuddy.script.wrappers.Tile(x2, y2);
x = x1;
y = y1;
this.x2 = x2;
this.y2 = y2;
xdist = x2 - x1;
ydist = y2 - y1;
centerX = x + (int) (0.5 * xdist);
centerY = y + (int) (0.5 * ydist);
dist = Math.sqrt(xdist * xdist + ydist * ydist);
}
public int getCenterX() {
return centerX;
}
public int getCenterY() {
return centerY;
}
public com.rsbuddy.script.wrappers.Tile getRandomTile() {
double rand = Math.random();
return new com.rsbuddy.script.wrappers.Tile(x + (int) (xdist * rand), y
+ (int) (ydist * rand));
}
public com.rsbuddy.script.wrappers.Tile getTile1() {
return t1;
}
public com.rsbuddy.script.wrappers.Tile getTile2() {
return t2;
}
public void drawTo(Graphics g, Line line) {
if (!com.rsbuddy.script.methods.Calculations.isTileOn Map(t1) || !com.rsbuddy.script.methods.Calculations.isTileOnM ap(t2)) {
return;
}
if (com.rsbuddy.script.methods.Calculations.isTileOnM ap(line.getTile1())
&& com.rsbuddy.script.methods.Calculations.isTileOnMa p(line.getTile2())) {
Point p1 = com.rsbuddy.script.methods.Calculations.tileToMap( t1);
Point p2 = com.rsbuddy.script.methods.Calculations.tileToMap( t2);
Point p3 = com.rsbuddy.script.methods.Calculations.tileToMap( line.getTile2());
Point p4 = com.rsbuddy.script.methods.Calculations.tileToMap( line.getTile1());
GeneralPath path = new GeneralPath();
path.moveTo(p1.x, p1.y);
path.lineTo(p2.x, p2.y);
path.lineTo(p3.x, p3.y);
path.lineTo(p4.x, p4.y);
path.closePath();
g.setColor(POLY_FILL);
((Graphics2D) g).fill(path);
((Graphics2D) g).draw(path);
}
Point last = null, p;
g.setColor(color3);
for (com.rsbuddy.script.wrappers.Tile t : pathList) {
if (com.rsbuddy.script.methods.Calculations.isTileOnM ap(t)) {
p = com.rsbuddy.script.methods.Calculations.tileToMap( t);
g.fillOval(p.x - 2, p.y - 2, 5, 5);
if (last != null) {
g.drawLine(p.x, p.y, last.x, last.y);
}
last = p;
} else {
last = null;
}
}
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getX2() {
return x2;
}
public int getY2() {
return y2;
}
public int getXDistance() {
return xdist;
}
public int getYDistance() {
return ydist;
}
public double getDistance() {
return dist;
}
public com.rsbuddy.script.wrappers.Tile translate(double length) {
return new com.rsbuddy.script.wrappers.Tile((int) Math.round(length * (xdist / dist)) + x,
(int) Math.round(length * (ydist / dist)) + y);
}
public com.rsbuddy.script.wrappers.Tile translateFromCenter(double length) {
return new com.rsbuddy.script.wrappers.Tile((int) Math.round(centerX - (xdist / dist)
* length), (int) Math.round(centerY - (ydist / dist)
* length));
}
}
// START: Code generated using Enfilade's Easel
private Image getImage(String url) {
try {
return ImageIO.read(new URL(url));
} catch (IOException e) {
return null;
}
}
private String format(int number) {
return format(String.valueOf(number));
}
private String format(String number) {
if (number.length() < 4) {
return number;
}
return format(number.substring(0, number.length() - 3)) + ","
+ number.substring(number.length() - 3, number.length());
}
private int getRunesCrafted() {
int watersrcrafted = totalwaters - waterRuneStart;
return watersrcrafted;
}
private int getExpGained() {
if (startExp == -1) {
}
return com.rsbuddy.script.methods.Skills.getCurrentExp(Sk ills.RUNECRAFTING) - startExp;
}
private double getExpHour() {
int xpGained = getExpGained();
long start = System.currentTimeMillis() - timer.getElapsed();
return xpGained * 3600000D / (System.currentTimeMillis() - start);
}
private int getExpToLvl() {
return com.rsbuddy.script.methods.Skills.getExpToNextLeve l(Skills.RUNECRAFTING);
}
private int getLvlGained() {
return com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING) - startLvl;
}
private int getPercentToLvl() {
return com.rsbuddy.script.methods.Skills.getPercentToNext Level(Skills.RUNECRAFTING);
}
private int getRunecraftLvl() {
return com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING);
}
private int getEssenceCrafted() {
return getExpGained() / 6;
}
private double getEssenceHour() {
int EssGained = getEssenceCrafted();
long start = System.currentTimeMillis() - timer.getElapsed();
return EssGained * 3600000D / (System.currentTimeMillis() - start);
}
private int getEssenceLeft() {
return getExpToLvl() / 6;
}
private int getRunesPerHour() {
long start = System.currentTimeMillis() - timer.getElapsed();
int Runescrafted = getRunesCrafted();
return (int) (Runescrafted * 3600000D / (System.currentTimeMillis() - start));
}
private int calcProfitH() {
long start = System.currentTimeMillis() - timer.getElapsed();
int Profit = getProfit();
return (int) (Profit * 3600000D / (System.currentTimeMillis() - start));
}
private int getProfit() {
int runes = (int) (getRunesCrafted());
int ess = (int) (getEssenceCrafted());
return (runes * runePrice) - (ess * essPrice);
}
private String format(long time) {
if (time <= 0) {
return "--:--:--";
}
return Timer.format(time);
}
private String getTimeToLvl() {
return format((long) (getExpToLvl() / getExpHour() * 3600000D));
}
public String formatCommas(double d) {
DecimalFormat df = new DecimalFormat();
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setGroupingSeparator(',');
df.setDecimalFormatSymbols(dfs);
return ((String) df.format((int) d));
}
private static final RenderingHints RENDERING_HINTS = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
public long startTime = System.currentTimeMillis();
private final Color color1 = new Color(0, 0, 0, 206);
private final Color color2 = new Color(255, 255, 255);
private final Color color3 = new Color(0, 255, 255);
private final Color color4 = new Color(0, 0, 255);
private final Color color5 = new Color(0, 0, 0);
private final BasicStroke stroke1 = new BasicStroke(1);
private final Font font1 = new Font("Monotype Corsiva", 2, 17);
private final Image img1 = getImage("Only the registered members can see the link.");
private final Image img2 = getImage("Only the registered members can see the link.");
private final Image img3 = getImage("Only the registered members can see the link.");
private final Image img4 = getImage("Only the registered members can see the link.");
final int percent() {
return (getPercentToLvl() * 5);
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
Point mp = e.getPoint();
final Rectangle toggleRectangle = new Rectangle(493, 347, 16, 15);
if (toggleRectangle.contains(mp)) {
if (pressed) {
pressed = false;
} else {
pressed = true;
}
}
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void onRepaint(Graphics g1) {
final Color MOUSE = new Color(20, 26, 167, 85);
if (com.rsbuddy.script.methods.Game.isLoggedIn()) {
Graphics2D g = (Graphics2D) g1;
g.setRenderingHints(RENDERING_HINTS);
if (pressed) {
long runTime = System.currentTimeMillis() - startTime;
g.setColor(color1);
g.fillRoundRect(9, 344, 504, 127, 16, 16);
g.setColor(color2);
g.drawImage(img4, 65, 305, null);
g.setFont(font1);
g.drawString("Current Level: " + getRunecraftLvl() + " (+"
+ getLvlGained() + ")", 11, 385);
g.drawString("Time running: " + format(runTime), 11, 365);
g.drawString("Essence used: " + getEssenceCrafted() + " ("
+ format((int) getEssenceHour()) + "/hr)", 242, 425);
g.drawString("XP gained: " + getExpGained() + " ("
+ format((int) getExpHour()) + "/hr)", 11, 425);
g.drawString("Runes crafted: " + getRunesCrafted() + " ("
+ format((int) getRunesPerHour()) + "/hr)", 11, 405);
g.drawString("Ess till level: " + getEssenceLeft(), 242, 405);
g.drawString("Time till level: " + getTimeToLvl(), 11, 445);
g.drawString("Status: " + status, 242, 365);
g.drawString("Profit: " + getProfit() + " ("
+ format((int) calcProfitH()) + "/hr)", 242, 385);
g.drawString("XP left till level: " + getExpToLvl(), 242, 445);
g.drawImage(img1, 45, 320, null);
g.drawImage(img1, 445, 320, null);
g.setColor(color3);
g.fillRoundRect(8, 450, 500, 23, 16, 16);
g.setColor(color4);
g.fillRoundRect(8, 450, percent(), 23, 16, 16);
g.drawImage(img3, 396, 5, null);
g.setColor(color3);
g.setStroke(stroke1);
g.drawRoundRect(8, 450, 500, 23, 16, 16);
g.setColor(color3);
g.fillRect(493, 347, 16, 15);
g.setColor(color4);
g.drawRect(493, 347, 16, 15);
g.setFont(new Font("Arial", Font.BOLD, 14));
g.drawString("X", 497, 360);
g.setColor(color5);
g.drawString(getPercentToLvl() + "%", 253, 468);// /At 55%
// exactly over
// the %
g.setColor(color3);
g.setColor(MOUSE);
g.drawImage(img2, ((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tX()) - 31),
((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tY()) - 31), null);
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
for (int i = 1; i < TOBANKCABBAGE.length; i++) {
TOBANKCABBAGE[i].drawTo(g1,
TOBANKCABBAGE[i - 1]);
}
} else {
for (int i = 1; i < TOBANK.length; i++) {
TOBANK[i].drawTo(g1, TOBANK[i - 1]);
}
}
} else {
for (int i = 1; i < TORUINS.length; i++) {
TORUINS[i].drawTo(g1, TORUINS[i - 1]);
}
}
}
} else {
g.setColor(color4);
g.fillRect(493, 347, 16, 15);
g.setColor(color3);
g.drawRect(493, 347, 16, 15);
g.setFont(new Font("Arial", Font.BOLD, 14));
g.drawString("O", 496, 360);
g.fillRoundRect(10, 314, 500, 23, 16, 16);
g.setColor(color4);
g.fillRoundRect(10, 314, percent(), 23, 16, 16);
g.drawImage(img3, 396, 5, null);
g.setColor(color3);
g.setStroke(stroke1);
g.drawRoundRect(10, 314, 500, 23, 16, 16);
g.setColor(color5);
g.drawString(getPercentToLvl() + "%", 255, 334);// /At 55%
// exactly over
// the %
g.setColor(color3);
g.setColor(MOUSE);
g.drawImage(img2, ((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tX()) - 31),
((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tY()) - 31), null);
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
for (int i = 1; i < TOBANKCABBAGE.length; i++) {
TOBANKCABBAGE[i].drawTo(g1,
TOBANKCABBAGE[i - 1]);
}
} else {
for (int i = 1; i < TOBANK.length; i++) {
TOBANK[i].drawTo(g1, TOBANK[i - 1]);
}
}
} else {
for (int i = 1; i < TORUINS.length; i++) {
TORUINS[i].drawTo(g1, TORUINS[i - 1]);
}
}
}
}
}
}
private static final String UPDATER_FILE_NAME = "PerfectCrafter.java";
private static final String UPDATER_URL = "Only the registered members can see the link.";
private static final Pattern UPDATER_VERSION_PATTERN = Pattern
.compile("version\\s*=\\s*([0-9.]+)");
private boolean checkForUpdates() {
try {
double currentVer = PerfectCrafter.class.getAnnotation(
com.rsbuddy.script.Manifest.class).version();
double newVer = -1;
URL url = new URL(UPDATER_URL);
BufferedReader in = new BufferedReader(new InputStreamReader(url
.openStream()));
String line, lines = "";
Matcher m;
while ((line = in.readLine()) != null) {
lines += line + "\n";
if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
newVer = Double.parseDouble(m.group(1));
break;
}
}
if (newVer < 0) {
in.close();
log("Unable to find the new version number. Update failed");
return false;
}
if (currentVer == newVer) {
in.close();
log("You already have the latest version of the script.");
return false;
}
log("Update found! Downloading version " + newVer);
String scriptFilePath = com.rsbuddy.script.methods.Environment.getStorageD irectory()
+ "\\" + UPDATER_FILE_NAME;
PrintWriter out = new PrintWriter(scriptFilePath);
out.print(lines);
while ((line = in.readLine()) != null)
out.println(line);
out.close();
in.close();
log("Successfully saved " + UPDATER_FILE_NAME + " to "
+ com.rsbuddy.script.methods.Environment.getStorageD irectory());
log("Compiling...");
try {
/* Attempt to compile the downloaded version */
Runtime.getRuntime().exec(
new String[] { "javac", "-classpath", "RSBot.jar",
scriptFilePath });
} catch (Exception ex) {
log("Could not compile the script. Please manually compile to finish the update.");
return false;
}
log("Update successful!");
log("The new version will appear near the bottom of the script selector.");
log("Stop and restart the script to run the newer version.");
return true;
} catch (IOException e) {
log(e.toString());
log("Update failed.");
}
return false;
}
// STOP: Code generated using Enfilade's Easel
private final class PerfectGUI extends JFrame {
private static final long serialVersionUID = 1L;
private JTabbedPane tabs;
private JCheckBox Explorer;
private JCheckBox restBox;
private JCheckBox Update;
private JButton submit;
private void init() {
setLocationRelativeTo(getRootPane());
setLayout(new GridLayout(2, 1));
tabs = new JTabbedPane();
tabs.setFocusable(false);
Explorer = new JCheckBox("Use Explorer's ring.");
restBox = new JCheckBox("use resting.");
Update = new JCheckBox("Check for updates.");
submit = new JButton("Start");
JPanel controls = new JPanel();
controls.setLayout(new GridLayout(3, 1));
JPanel Crafting = new JPanel();
Crafting.setLayout(new GridLayout(3, 1));
JPanel extra = new JPanel();
extra.setLayout(new GridLayout(3, 1));
setSize(200, 300);
setTitle("PerfectCrafter");
controls.add(restBox);
controls.add(Update);
controls.add(Explorer);
tabs.add(controls, "General");
add(tabs);
add(submit);
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
submit();
}
});
setVisible(true);
}
private void submit() {
checkUpdate = Update.isSelected();
useResting = restBox.isSelected();
if (Explorer.isSelected()) {
if (Explorer.isSelected()) {
log("Explorer's ring is selected");
useExplorersRing = true;
} else {
log("Explorer's ring is not selected");
useExplorersRing = false;
}
}
dispose();
}
}
}
This my friend is one of the most beautiful things I've ever seen.
Good job :p
Faab234
March 21st, 2011, 16:53
Here we go.
Only the registered members can see the link.
Code(some of it's weird because it was doing weird stuff, and i had to remove the GUI due to the fact that their theme has a bug in it, not the script):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.GeneralPath;
import java.io.IOException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import com.rsbuddy.event.listeners.PaintListener;
import com.rsbuddy.script.methods.Calculations;
import com.rsbuddy.script.methods.Equipment;
import com.rsbuddy.script.methods.Game;
import com.rsbuddy.script.methods.Mouse;
import com.rsbuddy.script.methods.Players;
import com.rsbuddy.script.methods.Skills;
import com.rsbuddy.script.methods.Walking;
import com.rsbuddy.script.util.Timer;
import com.rsbuddy.script.wrappers.Model;
import com.rsbuddy.script.wrappers.Tile;
@com.rsbuddy.script.Manifest(authors = "Ubuntu4life, Maximonster", name = "PerfectCrafter", version = 1.284, description = "Crafts water runes perfectly.")
public class PerfectCrafter extends com.rsbuddy.script.ActiveScript implements PaintListener, MouseListener {
private enum Action {
OPENBANK, DEPOSIT, WITHDRAW, WALKTORUINS, ENTERRUINS, WALKTOALTAR, CRAFTRUNE, TELEPORT, WALKTOGATE, OPENGATE, WALKTOPORTAL, LEAVEALTAR, WALKTOBANK, SLEEP
}
com.rsbuddy.script.wrappers.Tile gateTile = new com.rsbuddy.script.wrappers.Tile(3053, 3283);
com.rsbuddy.script.wrappers.Tile gateWalkTile = new com.rsbuddy.script.wrappers.Tile(3053, 3285);
com.rsbuddy.script.wrappers.Tile altarTile = new com.rsbuddy.script.wrappers.Tile(3485, 4836);
com.rsbuddy.script.wrappers.Tile altarWalkTile = new com.rsbuddy.script.wrappers.Tile(3486, 4836);
com.rsbuddy.script.wrappers.Tile altarClickTile = new com.rsbuddy.script.wrappers.Tile(3484, 4836);
com.rsbuddy.script.wrappers.Tile boothTile = new com.rsbuddy.script.wrappers.Tile(3091, 3245);
com.rsbuddy.script.wrappers.Tile bankTile = new com.rsbuddy.script.wrappers.Tile(3089, 3244);
com.rsbuddy.script.wrappers.Tile bankWalkTile = new com.rsbuddy.script.wrappers.Tile(3093, 3244);
com.rsbuddy.script.wrappers.Tile portalTile = new com.rsbuddy.script.wrappers.Tile(3495, 4832);
com.rsbuddy.script.wrappers.Tile portalWalkTile = new com.rsbuddy.script.wrappers.Tile(3496, 4832);
com.rsbuddy.script.wrappers.Tile ruinsTile = new com.rsbuddy.script.wrappers.Tile(3184, 3165);
com.rsbuddy.script.wrappers.Tile ruinsWalkTile = new com.rsbuddy.script.wrappers.Tile(3183, 3164);
com.rsbuddy.script.wrappers.Tile ruinsClickTile = new com.rsbuddy.script.wrappers.Tile(3185, 3165);
private PerfectGUI gui;
private boolean checkUpdate;
private boolean useResting;
private boolean useExplorersRing, pressed = true;
public boolean startScript = false, foundWaters = false, firstLoop = true,
outOfEssence = false;
volatile boolean stop = false;
private final int INTERFACE_RUN_ORB = 750, RUN_CHILD_ID = 1;
private int uniqueNumber;
public int startExp, startLvl, mayAntiBan = 0, itemCount = 0,
itemtypeint = 0, invalidCount = 0, runeStart = 0, totalRunes = 0,
essPrice = 0, runePrice = 0, waterRuneStart = 0, totalwaters = 0,
failCount = 0;
private ArrayList<com.rsbuddy.script.wrappers.Tile> pathList;
private Timer timer;
private AntiBan antiBan;
private java.util.Random unique;
private String status = "Starting...";
private Line[] TORUINS = { new Line(3094, 3243, 3093, 3242),
new Line(3103, 3236, 3098, 3235), new Line(3110, 3232, 3099, 3228),
new Line(3114, 3228, 3100, 3227), new Line(3114, 3224, 3110, 3223),
new Line(3116, 3221, 3114, 3220), new Line(3124, 3209, 3118, 3206),
new Line(3129, 3207, 3129, 3206), new Line(3138, 3207, 3131, 3204),
new Line(3143, 3205, 3138, 3201), new Line(3149, 3200, 3138, 3197),
new Line(3157, 3190, 3140, 3189), new Line(3160, 3181, 3150, 3178),
new Line(3167, 3172, 3157, 3169), new Line(3168, 3170, 3164, 3165),
new Line(3176, 3167, 3175, 3162), new Line(3180, 3167, 3180, 3162),
new Line(3184, 3167, 3184, 3162) };
private Line[] TOBANK = { new Line(3183, 3167, 3183, 3162),
new Line(3180, 3167, 3180, 3162), new Line(3176, 3167, 3175, 3162),
new Line(3171, 3169, 3171, 3163), new Line(3168, 3170, 3164, 3165),
new Line(3167, 3172, 3157, 3169), new Line(3160, 3181, 3150, 3178),
new Line(3157, 3190, 3140, 3189), new Line(3149, 3200, 3138, 3197),
new Line(3143, 3205, 3138, 3201), new Line(3138, 3207, 3131, 3204),
new Line(3129, 3207, 3129, 3206), new Line(3124, 3209, 3118, 3206),
new Line(3116, 3221, 3114, 3220), new Line(3114, 3224, 3110, 3223),
new Line(3114, 3228, 3100, 3227), new Line(3110, 3232, 3099, 3228),
new Line(3103, 3236, 3098, 3235), new Line(3093, 3245, 3093, 3242) };
private Line[] TOBANKCABBAGE = { new Line(3054, 3282, 3052, 3282),
new Line(3057, 3281, 3057, 3276), new Line(3071, 3277, 3071, 3274),
new Line(3082, 3268, 3070, 3268), new Line(3082, 3258, 3072, 3258),
new Line(3082, 3254, 3078, 3251), new Line(3086, 3249, 3085, 3247),
new Line(3092, 3246, 3092, 3243) };
public static interface Constants {
int[] openGates = { 7051, 7052 };
int[] closedGates = { 7050, 7049 };
int waterRune = 555;
int waterTalisman = 1444;
int runeEssence = 1436;
int Altar = 2480;
int Portal = 2467;
int Ruins = 2454;
int bankBooth = 2213;
com.rsbuddy.script.wrappers.Area AREA_INALTAR = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3474, 4845), new com.rsbuddy.script.wrappers.Tile(
3500, 4822));
com.rsbuddy.script.wrappers.Area AREA_REST = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3099, 3238), new com.rsbuddy.script.wrappers.Tile(3176,
3154));
com.rsbuddy.script.wrappers.Area AREA_INCABBAGE = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3067, 3283), new com.rsbuddy.script.wrappers.Tile(
3051, 3292));
com.rsbuddy.script.wrappers.Area AREA_INERROR = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3050, 3290), new com.rsbuddy.script.wrappers.Tile(
3057, 3298));
}
@Override
public boolean onStart() {
if (!com.rsbuddy.script.methods.Game.isFixed()) {
log.severe("You must use Fixed Screen Mode to use this script.");
return false;
}
if (com.rsbuddy.script.methods.Game.isLoggedIn()) {
unique = generateSeededRandom(Players.getLocal().getName()) ;
uniqueNumber = unique.nextInt(25);
if (checkUpdate) {
checkForUpdates();
}
startExp = com.rsbuddy.script.methods.Skills.getCurrentExp(Sk ills.RUNECRAFTING);
startLvl = com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING);
mayAntiBan = 0;
log.info(":-:-: Loading PerfectCrafter 1.284 :-:-:");
startTime = System.currentTimeMillis();
timer = new Timer(0);
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(5, 8));
log.info("Loading Prices...");
com.rsbuddy.script.methods.GrandExchange.Item water = com.rsbuddy.script.methods.GrandExchange.lookup(Co nstants.waterRune);
runePrice = water.getMarketPrice();
com.rsbuddy.script.methods.GrandExchange.Item ess = com.rsbuddy.script.methods.GrandExchange.lookup(Co nstants.runeEssence);
essPrice = ess.getMarketPrice();
if (pathList == null) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
pathList = generatePath(TOBANKCABBAGE);
} else {
pathList = generatePath(TOBANK);
}
} else {
pathList = generatePath(TORUINS);
}
}
startScript = true;
log.info("Bot and script are all set to go.");
} else {
log.info("Please log in before starting the script.");
return false;
}
return true;
}
public void onFinish() {
log("Antiban stopped");
log.info(":-:-: Thank you for using PerfectCrafter :-:-:");
com.rsbuddy.script.methods.Mouse.moveOffScreen();
com.rsbuddy.script.methods.Environment.saveScreens hot(true);
log("Remember to comment :p");
stop = true;
stop();
}
public Action getState() {
com.rsbuddy.script.wrappers.GameObject closedGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.closedGates);
try {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(boothTile)) {
if (!com.rsbuddy.script.methods.Bank.isOpen()) {
return Action.OPENBANK;
} else {
if (com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune)) {
return Action.DEPOSIT;
} else {
return Action.WITHDRAW;
}
}
} else {
if (inAltarArea() || Players.getLocal().getAnimation() == 791) {
if (useExplorersRing == true) {
return Action.TELEPORT;
} else if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(portalTile)) {
return Action.LEAVEALTAR;
} else {
return Action.WALKTOPORTAL;
}
} else {
if (useExplorersRing == true) {
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate.getLocation()) < 8
&& closedGate != null && inCabbageArea()) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile)) {
return Action.OPENGATE;
} else {
return Action.WALKTOGATE;
}
}
}
return Action.WALKTOBANK;
}
}
} else {
if (inAltarArea()) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(altarTile)) {
return Action.CRAFTRUNE;
} else {
return Action.WALKTOALTAR;
}
} else {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(ruinsTile)) {
return Action.ENTERRUINS;
} else {
return Action.WALKTORUINS;
}
}
}
} catch (Exception e) {
return Action.SLEEP;
}
}
Random r = new Random();
double val = r.nextGaussian() * 61 + 301;
int millisDelay = (int) Math.round(val);
private Mouse mouse = new Mouse();
private Game game = new Game();
@Override
public int loop() {
if (firstLoop) {
log.info("Starting Seperate AntiBan thread.");
antiBan = new AntiBan(this);
antiBan.start();
firstLoop = false;
return com.rsbuddy.script.util.Random.nextInt(200, 400);
}
if (needToRun() && !com.rsbuddy.script.methods.Walking.isRunEnabled() && !com.rsbuddy.script.methods.Bank.isOpen()) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(8, 9));
com.rsbuddy.script.methods.Widgets.get(INTERFACE_R UN_ORB).getComponent(RUN_CHILD_ID)
.interact("turn run mode on");
nextPercentage = (uniqueNumber + com.rsbuddy.script.util.Random.nextInt(2, 39));
sleep(300, 400);
}
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(5, 7));
try {
com.rsbuddy.script.wrappers.GameObject Altar = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Altar);
com.rsbuddy.script.wrappers.GameObject Portal = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Portal);
com.rsbuddy.script.wrappers.GameObject Ruins = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Ruins);
com.rsbuddy.script.wrappers.GameObject Booth = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.bankBooth);
com.rsbuddy.script.wrappers.GameObject closedGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.closedGates);
com.rsbuddy.script.wrappers.GameObject openGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.openGates);
switch (getState()) {
case OPENBANK:
status = "Opening bank";
mayAntiBan = 0;
if (clickObject(Booth, "Use-quickly", boothTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
int count = 0;
while (!com.rsbuddy.script.methods.Bank.isOpen() && ++count < 9) {
mayAntiBan = 1;
sleep(millisDelay);
if (com.rsbuddy.script.methods.Players.getLocal().isM oving()) {
count = 0;
}
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case DEPOSIT:
status = "Depositing";
mayAntiBan = 0;
try {
if (!foundWaters) {
sleep(com.rsbuddy.script.util.Random.nextInt(500, 600));
waterRuneStart = com.rsbuddy.script.methods.Bank.getCount(Constants .waterRune);
foundWaters = true;
}
totalwaters = com.rsbuddy.script.methods.Bank.getCount(Constants .waterRune);
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Bank.depositAll();
waitForEmpty();
} catch (final Exception e) {
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WITHDRAW:
status = "Withdrawing";
mayAntiBan = 0;
try {
int runeCount = com.rsbuddy.script.methods.Bank.getCount(Constants .runeEssence);
if (runeCount < 1) {
log("You are out of rune essences.");
stop();
} else {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Bank.withdraw(Constants .runeEssence, 0);
waitForFull();
pathList = generatePath(TORUINS);
}
if (!com.rsbuddy.script.methods.Inventory.containsAll (Constants.runeEssence)) {
final int count = com.rsbuddy.script.methods.Inventory.getCount();
com.rsbuddy.script.methods.Bank.depositAllExcept(C onstants.runeEssence);
for (int i = 0; i < 10 && com.rsbuddy.script.methods.Inventory.getCount() == count; i++) {
sleep(com.rsbuddy.script.util.Random.nextInt(100, 200));
}
}
} catch (final Exception e) {
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTORUINS:
status = "Walking to ruins";
step(pathList, ruinsTile);
if (useResting == true) {
if (com.rsbuddy.script.methods.Walking.getEnergy() < ((uniqueNumber + com.rsbuddy.script.util.Random.nextInt(-11, 8)))
&& inRestArea()) {
status = "Resting";
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 8));
com.rsbuddy.script.methods.Walking.rest((uniqueNum ber + com.rsbuddy.script.util.Random.nextInt(43, 88)));
}
}
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(ruinsTile)) {
return com.rsbuddy.script.util.Random.nextInt(200, 390);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(220, 370);
case ENTERRUINS:
status = "Entering Ruins";
mayAntiBan = 0;
if (clickObject(Ruins, "Enter", ruinsTile, false)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(millisDelay);
} while (Players.getLocal().isMoving() && !inAltarArea());
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOALTAR:
status = "Walking to altar";
mayAntiBan = 0;
walkTo(altarWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(altarTile));
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case CRAFTRUNE:
status = "Crafting essences";
mayAntiBan = 0;
if (clickObject(Altar, "Craft-rune", altarTile, false)) {
if (useExplorersRing == true) {
pathList = generatePath(TOBANKCABBAGE);
} else {
pathList = generatePath(TOBANK);
}
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(520, 1025);
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune));
if (useExplorersRing == true && !Players.getLocal().isMoving()) {
for (int i = 140; i > 0; --i) {
if (Players.getLocal().getAnimation() != -1) {
continue;
}
sleep(10);
}
sleep(150, 450);
}
if (useExplorersRing == false) {
for (int i = 140; i > 0; --i) {
if (Players.getLocal().getAnimation() != -1) {
continue;
}
sleep(10);
}
sleep(1300, 1600);
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case TELEPORT:
status = "Teleporting";
mayAntiBan = 0;
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
com.rsbuddy.script.methods.Game.openTab(Game.TAB_E QUIPMENT);
}
if (com.rsbuddy.script.methods.Equipment.getItem(Equi pment.RING) != null) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
if (com.rsbuddy.script.methods.Widgets.get(Equipment. WIDGET)
.getComponent(Equipment.RING).interact(
"Cabbage-port")) {
for (int i = 0; i < 140
&& Players.getLocal().getAnimation() != 9984; i++) {
sleep(10);
}
while (Players.getLocal().getAnimation() == 9984) {
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_INVENTORY) {
sleep(198, 2564);
com.rsbuddy.script.methods.Game.openTab(Game.TAB_I NVENTORY);
}
sleep(47, 52);
}
sleep(998, com.rsbuddy.script.util.Random.nextInt(2891, 2901));
}
} else {
log("Please wear an Explorer's ring 3 of 4 !");
stop();
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOGATE:
status = "Walking to gate";
mayAntiBan = 0;
int angle = com.rsbuddy.script.methods.Camera.getAngleTo(close dGate);
walkTo(gateWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile));
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10
&& Math.abs(angle - com.rsbuddy.script.methods.Camera.getCompassAngle( )) > 20) {
com.rsbuddy.script.methods.Camera.setCompassAngle( angle + com.rsbuddy.script.util.Random.nextInt(-21, 21));
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case OPENGATE:
status = "Opening gate";
mayAntiBan = 0;
if (clickObject(closedGate, "Open Gate", gateTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
if (inErrorArea()) {
int angle2 = com.rsbuddy.script.methods.Camera.getAngleTo(close dGate);
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10
&& Math.abs(angle2 - com.rsbuddy.script.methods.Camera.getCompassAngle( )) > 20) {
com.rsbuddy.script.methods.Camera.setCompassAngle( angle2 + com.rsbuddy.script.util.Random.nextInt(-21, 21));
}
walkTileMM(gateWalkTile, 2, 2);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile));
}
} while (Players.getLocal().isMoving());
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10) {
Timer gateTimer = new Timer(com.rsbuddy.script.util.Random.nextInt(1000, 1400));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (openGate == null && gateTimer.isRunning());
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOPORTAL:
status = "Walking to portal";
mayAntiBan = 0;
walkTo(portalWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(portalTile));
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case LEAVEALTAR:
status = "Leaving altar";
mayAntiBan = 0;
if (clickObject(Portal, "Enter", portalTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(millisDelay);
} while (inAltarArea() && Players.getLocal().isMoving());
sleep(150, 300);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOBANK:
status = "Walking to bank";
com.rsbuddy.script.methods.Camera.setPitch(true);
step(pathList, boothTile);
if (useResting == true) {
if (com.rsbuddy.script.methods.Walking.getEnergy() < ((uniqueNumber + com.rsbuddy.script.util.Random.nextInt(-11, 8)))
&& inRestArea()) {
status = "Resting";
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(8, 9));
com.rsbuddy.script.methods.Walking.rest((uniqueNum ber + com.rsbuddy.script.util.Random.nextInt(43, 88)));
}
}
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(boothTile)) {
return com.rsbuddy.script.util.Random.nextInt(220, 370);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
}
} catch (Exception e) {
sleep(150, 300);
return com.rsbuddy.script.util.Random.nextInt(50, 100);
}
return 0;
}
private void walkTo(Tile destination) {
while (Calculations.distanceTo(destination) > 3) {
Walking.stepTowards(destination);
sleep(2000, 4000);
}
}
public com.rsbuddy.script.methods.Mouse getMouse() {
return mouse;
}
// Credits go to Unknown500 for the AntiBan skeleton code
class AntiBan extends Thread {
private PerfectCrafter parent;
private Random randomGenerator;
AntiBan(PerfectCrafter parent) {
this.parent = parent;
this.randomGenerator = new Random();
}
@Override
public void run() {
try {
while (parent.getGame().isLoggedIn() && !stop) {
if (!parent.isPaused()) {
int random = randomGenerator.nextInt(7);
if (mayAntiBan == 1 && random != 2) {
int rand = randomGenerator.nextInt(5);
switch (rand) {
case 1:
if (mayAntiBan == 1) {
if (com.rsbuddy.script.util.Random.nextInt(1, 5) != com.rsbuddy.script.util.Random.nextInt(1, 4)) {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
} else {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
sleep(com.rsbuddy.script.util.Random.nextInt(0, com.rsbuddy.script.util.Random.nextInt(72, 380)));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
}
} else {
break;
}
case 2:
if (mayAntiBan == 1 && com.rsbuddy.script.util.Random.nextInt(1, 510) == 119) {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveSlightly();
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
} else {
break;
}
case 3:
if (com.rsbuddy.script.util.Random.nextInt(1, 8) == 3) {
int angle = com.rsbuddy.script.methods.Camera.getCompassAngle( )
+ com.rsbuddy.script.util.Random.nextInt(-45, 45);
if (angle < 0) {
angle = com.rsbuddy.script.util.Random.nextInt(0, 10);
}
if (angle > 359) {
angle = com.rsbuddy.script.util.Random.nextInt(0, 10);
}
char whichDir = 37;
if (com.rsbuddy.script.util.Random.nextInt(0, 100) < 50)
whichDir = 39;
com.rsbuddy.script.methods.Keyboard.pressKey(which Dir);
sleep(com.rsbuddy.script.util.Random.nextInt(103, 996));
com.rsbuddy.script.methods.Keyboard.releaseKey(whi chDir);
break;
} else {
break;
}
default:
break;
}
}
sleep(com.rsbuddy.script.util.Random.nextInt(63, 2373));
}
}
} catch (InterruptedException e) {
log(e.getMessage());
}
}
}
// credits to !@!@! for clicking method, it's epic.
private boolean clickObject(com.rsbuddy.script.wrappers.GameObject object, String action, com.rsbuddy.script.wrappers.Tile Tile,
boolean useCentralClicking) {
Point p;
for (int i = 0; i < 4; i++) {
if (isPartiallyOnScreen(object.getModel())) {
p = useCentralClicking ? getCentralPoint(object.getModel())
: getPointOnScreen(object.getModel(), true);
while (isPartiallyOnScreen(object.getModel()) && p.x != -1
&& p.y != -1 && p != null && com.rsbuddy.script.methods.Calculations.isPointOnS creen(p)
&& !com.rsbuddy.script.methods.Bank.isOpen() && com.rsbuddy.script.methods.Calculations.isTileOnSc reen(Tile)) {
p = useCentralClicking ? getCentralPoint(object.getModel())
: getPointOnScreen(object.getModel(), true);
com.rsbuddy.script.methods.Mouse.move(p, 0, 0);
if (com.rsbuddy.script.methods.Menu.contains(action))
break;
if (p.x == -1 || p.y == -1 || p == null
|| !com.rsbuddy.script.methods.Calculations.isPointOn Screen(p)
|| !isPartiallyOnScreen(object.getModel())
|| !com.rsbuddy.script.methods.Calculations.isTileOnS creen(Tile) || com.rsbuddy.script.methods.Bank.isOpen())
continue;
}
String[] items = com.rsbuddy.script.methods.Menu.getItems();
if (items.length > 0 && items[0].contains(action)) {
com.rsbuddy.script.methods.Mouse.click(true);
return true;
} else if (com.rsbuddy.script.methods.Menu.contains(action)) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Mouse.click(false);
sleep(com.rsbuddy.script.util.Random.nextInt(100, 200));
for (int x = 0; x < 4; x++) {
if (com.rsbuddy.script.methods.Menu.click(action)) {
return true;
}
}
}
if (!com.rsbuddy.script.methods.Menu.contains(action) && com.rsbuddy.script.methods.Menu.isOpen()) {
do {
com.rsbuddy.script.methods.Mouse.moveRandomly(com. rsbuddy.script.util.Random.nextInt(180, 275));
} while (com.rsbuddy.script.methods.Menu.isOpen());
sleep(com.rsbuddy.script.util.Random.nextInt(100, 175));
return false;
}
}
}
return false;
}
public Game getGame() {
return game ;
}
private boolean isPartiallyOnScreen(Model m) {
return getPointOnScreen(m, true) != null;
}
private Point getPointOnScreen(Model m, boolean first) {
if (m == null) {
return null;
}
ArrayList<Point> list = new ArrayList<Point>();
try {
Polygon[] tris = m.getTriangles();
for (int i = 0; i < tris.length; i++) {
Polygon p = tris[i];
for (int j = 0; j < p.xpoints.length; j++) {
Point pt = new Point(p.xpoints[j], p.ypoints[j]);
if (Calculations.isPointOnScreen(pt)) {
if (first) {
return pt;
}
list.add(pt);
}
}
}
} catch (Exception e) {
}
return list.size() > 0 ? list.get(com.rsbuddy.script.util.Random.nextInt(0, list.size())) : null;
}
private Point getCentralPoint(Model m) {
if (m == null) {
return null;
}
try {
int x = 0, y = 0, total = 0;
for (Polygon poly : m.getTriangles()) {
for (int i = 0; i < poly.npoints; i++) {
x += poly.xpoints[i];
y += poly.ypoints[i];
total++;
}
}
Point central = new Point(x / total, y / total);
Point curCentral = null;
double dist = 20000;
for (Polygon poly : m.getTriangles()) {
for (int i = 0; i < poly.npoints; i++) {
Point p = new Point(poly.xpoints[i], poly.ypoints[i]);
if (!Calculations.isPointOnScreen(p)) {
continue;
}
double dist2 = distanceBetween(central, p);
if (curCentral == null || dist2 < dist) {
curCentral = p;
dist = dist2;
}
}
}
return curCentral;
} catch (Exception e) {
}
return null;
}
private double distanceBetween(Point p1, Point p2) {
return Math.sqrt(((p1.x - p2.x) * (p1.x - p2.x))
+ ((p1.y - p2.y) * (p1.y - p2.y)));
}
public boolean walkTileMM(com.rsbuddy.script.wrappers.Tile t, int x, int y) {
com.rsbuddy.script.wrappers.Tile dest = new com.rsbuddy.script.wrappers.Tile(t.getX() + com.rsbuddy.script.util.Random.nextInt(0, x), t.getY()
+ com.rsbuddy.script.util.Random.nextInt(0, y));
Point p = com.rsbuddy.script.methods.Calculations.tileToMap( dest);
if (p.x != -1 && p.y != -1) {
com.rsbuddy.script.methods.Mouse.move(p);
Point p2 = com.rsbuddy.script.methods.Calculations.tileToMap( dest);
if (p2.x != -1 && p2.y != -1) {
com.rsbuddy.script.methods.Mouse.move(p2);
com.rsbuddy.script.methods.Mouse.click(p2, true);
return true;
}
}
return false;
}
private int nextPercentage = (uniqueNumber + com.rsbuddy.script.util.Random.nextInt(1, 39));
private boolean needToRun() {
if (com.rsbuddy.script.methods.Walking.getEnergy() > nextPercentage) {
return true;
}
return false;
}
public boolean rest(int stopEnergy) {
int energy = getEnergy();
for (int d = 0; d < 5; d++) {
mayAntiBan = 0;
com.rsbuddy.script.methods.Widgets.getComponent(IN TERFACE_RUN_ORB, 1).interact("Rest");
com.rsbuddy.script.methods.Mouse.moveSlightly();
mayAntiBan = 1;
if (com.rsbuddy.script.util.Random.nextInt(1, 3) == com.rsbuddy.script.util.Random.nextInt(1, 2)) {
if (com.rsbuddy.script.util.Random.nextInt(1, 2) == com.rsbuddy.script.util.Random.nextInt(1, 2)) {
sleep(com.rsbuddy.script.util.Random.nextInt(200, 2000), com.rsbuddy.script.util.Random.nextInt(5000, 15000));
}
mayAntiBan = 0;
com.rsbuddy.script.methods.Mouse.moveOffScreen();
}
int anim = com.rsbuddy.script.methods.Players.getLocal().getA nimation();
if (anim == 12108 || anim == 2033 || anim == 2716 || anim == 11786
|| anim == 5713) {
break;
}
if (d == 4) {
return false;
}
}
while (energy < stopEnergy) {
sleep(millisDelay);
energy = getEnergy();
}
mayAntiBan = 1;
return true;
}
public int getEnergy() {
try {
return Integer.parseInt(com.rsbuddy.script.methods.Widget s.getComponent(750, 5).getText());
} catch (NumberFormatException e) {
return 0;
}
}
private java.util.Random generateSeededRandom(String text) {
MessageDigest coder;
try {
coder = MessageDigest.getInstance("MD5");
coder.update(text.getBytes());
byte[] bytes = coder.digest();
long result1 = 0, result2 = 0;
for (int i = 0; i < 8; i++) {
result1 = (result1 << 8) | bytes[i];
}
for (int i = 8; i < 16; i++) {
result2 = (result2 << 8) | bytes[i];
}
return new java.util.Random(result1 - result2);
} catch (NoSuchAlgorithmException ex) {
}
return new java.util.Random();
}
private boolean inErrorArea() {
return Constants.AREA_INERROR.contains(Players.getLocal() .getLocation());
}
private boolean inAltarArea() {
return Constants.AREA_INALTAR.contains(Players.getLocal() .getLocation());
}
private boolean inRestArea() {
return Constants.AREA_REST.contains(Players.getLocal().ge tLocation());
}
private boolean inCabbageArea() {
return Constants.AREA_INCABBAGE.contains(Players.getLocal ().getLocation());
}
private boolean waitToMove(int timeout) {
long endTime = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < endTime) {
if (Players.getLocal().isMoving()) {
return true;
}
sleep(5, 15);
}
return false;
}
public void waitForEmpty() {
int tries = 0;
while (com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune) && tries < 10) {
tries++;
sleep(180, 200);
}
}
public void waitForFull() {
int tries = 0;
while (!com.rsbuddy.script.methods.Inventory.isFull() && tries < 10
&& !com.rsbuddy.script.methods.Inventory.contains(Con stants.runeEssence)) {
tries++;
sleep(180, 200);
}
}
// Credits go to Enfilade for this epic walking method
private boolean tileInNextRange(com.rsbuddy.script.wrappers.Tile t) {
return com.rsbuddy.script.methods.Calculations.distanceBe tween(t, Players.getLocal().getLocation()) < nextStep;
}
private final Color POLY_FILL = new Color(20, 26, 167, 70);
private int nextStep = com.rsbuddy.script.util.Random.nextInt(15, 16);
private int step(ArrayList<com.rsbuddy.script.wrappers.Tile> path, com.rsbuddy.script.wrappers.Tile tileToWalk) {
if (com.rsbuddy.script.methods.Calculations.distanceB etween(Players.getLocal().getLocation(), path.get(path
.size() - 1)) < 2) {
return path.size();
}
com.rsbuddy.script.wrappers.Tile dest = com.rsbuddy.script.methods.Walking.getDestination( );
int index = -1;
int shortestDist = 0, dist, shortest = -3;
if (dest != null) {
for (int i = 0; i < path.size(); i++) {
dist = (int) com.rsbuddy.script.methods.Calculations.distanceBe tween(path.get(i), dest);
if (shortest < 0 || shortestDist > dist) {
shortest = i;
shortestDist = dist;
}
}
}
for (int i = path.size() - 1; i >= 0; i--) {
if (tileInNextRange(path.get(i))) {
index = i;
break;
}
}
if (index >= 0
&& (dest == null || (index > shortest) || !Players.getLocal()
.isMoving())) {
mayAntiBan = 0;
com.rsbuddy.script.methods.Walking.getTileOnMap(pa th.get(index)).clickOnMap();
sleep(millisDelay);
mayAntiBan = 1;
nextStep = com.rsbuddy.script.util.Random.nextInt(15, 19);
return index;
}
return -1;
}
private ArrayList<com.rsbuddy.script.wrappers.Tile> generatePath(Line[] lines) {
double minStep = 4, maxStep = 13, wander = 3;
if (lines.length < 2) {
return null;
}
ArrayList<com.rsbuddy.script.wrappers.Tile> path = new ArrayList<com.rsbuddy.script.wrappers.Tile>();
Line l1, l2 = lines[0];
double distFromCenter = com.rsbuddy.script.util.Random.nextDouble(0, l2.getDistance() + 1);
com.rsbuddy.script.wrappers.Tile p = l2.translate((int) distFromCenter);
distFromCenter = l2.getDistance() / 2 - distFromCenter;
double centerXdist, centerYdist, line1Xdist, line1Ydist, line2Xdist, line2Ydist;
double line1dist, line2dist, centerDist;
double x, y;
double distOnLine, last, cap1, cap2, move;
double distFromCenterX1, distFromCenterY1, distFromCenterX2, distFromCenterY2;
double force1, force2, slopeX, slopeY, slopeDist;
boolean finished;
int lastX = p.getX(), lastY = p.getY(), curX, curY;
double dist, xdist, ydist;
for (int i = 1; i < lines.length; i++) {
l1 = l2;
l2 = lines[i];
centerXdist = l2.getCenterX() - l1.getCenterX();
centerYdist = l2.getCenterY() - l1.getCenterY();
centerDist = Math.sqrt(centerXdist * centerXdist + centerYdist
* centerYdist);
line1Xdist = l2.getX() - l1.getX();
line1Ydist = l2.getY() - l1.getY();
line2Xdist = l2.getX2() - l1.getX2();
line2Ydist = l2.getY2() - l1.getY2();
centerXdist /= centerDist;
centerYdist /= centerDist;
line1Xdist /= centerDist;
line1Ydist /= centerDist;
line2Xdist /= centerDist;
line2Ydist /= centerDist;
distOnLine = 0;
last = 0;
finished = false;
while (!finished) {
distOnLine += com.rsbuddy.script.util.Random.nextDouble(minStep, maxStep);
if (distOnLine >= centerDist) {
distOnLine = centerDist;
finished = true;
}
x = centerXdist * distOnLine + l1.getCenterX();
y = centerYdist * distOnLine + l1.getCenterY();
distFromCenterX1 = x - (line1Xdist * distOnLine + l1.getX());
distFromCenterY1 = y - (line1Ydist * distOnLine + l1.getY());
distFromCenterX2 = x - (line2Xdist * distOnLine + l1.getX2());
distFromCenterY2 = y - (line2Ydist * distOnLine + l1.getY2());
slopeX = distFromCenterX2 - distFromCenterX1;
slopeY = distFromCenterY2 - distFromCenterY1;
slopeDist = Math.sqrt(slopeX * slopeX + slopeY * slopeY);
slopeX /= slopeDist;
slopeY /= slopeDist;
line1dist = Math.sqrt(distFromCenterX1 * distFromCenterX1
+ distFromCenterY1 * distFromCenterY1);
line2dist = Math.sqrt(distFromCenterX2 * distFromCenterX2
+ distFromCenterY2 * distFromCenterY2);
move = (distOnLine - last) / maxStep * wander;
force1 = line1dist + distFromCenter;
force2 = line2dist - distFromCenter;
cap1 = Math.min(move, force1);
cap2 = Math.min(move, force2);
if (force1 < 0) {
distFromCenter -= force1;
} else if (force2 < 0) {
distFromCenter += force2;
} else {
distFromCenter += com.rsbuddy.script.util.Random.nextDouble(-cap1, cap2);
}
if (finished) {
com.rsbuddy.script.wrappers.Tile t = l2.translateFromCenter(distFromCenter);
curX = t.getX();
curY = t.getY();
} else {
curX = (int) Math.round(distOnLine * centerXdist
+ l1.getCenterX() + distFromCenter * slopeX);
curY = (int) Math.round(distOnLine * centerYdist
+ l1.getCenterY() + distFromCenter * slopeY);
}
xdist = curX - lastX;
ydist = curY - lastY;
dist = Math.sqrt(xdist * xdist + ydist * ydist);
xdist /= dist;
ydist /= dist;
for (int j = 0; j < dist; j++) {
path.add(new com.rsbuddy.script.wrappers.Tile((int) Math.round(xdist * j + lastX),
(int) Math.round(ydist * j + lastY)));
}
last = distOnLine;
lastX = curX;
lastY = curY;
}
}
return cutUp(path);
}
public ArrayList<com.rsbuddy.script.wrappers.Tile> cutUp(ArrayList<com.rsbuddy.script.wrappers.Tile> tiles) {
ArrayList<com.rsbuddy.script.wrappers.Tile> path = new ArrayList<com.rsbuddy.script.wrappers.Tile>();
int index = 0;
while (index < tiles.size()) {
path.add(tiles.get(index));
index += com.rsbuddy.script.util.Random.nextInt(8, 12);
}
if (!path.get(path.size() - 1).equals(tiles.get(tiles.size() - 1))) {
path.add(tiles.get(tiles.size() - 1));
}
return path;
}
private class Line {
private int x, y, xdist, ydist, x2, y2, centerX, centerY;
private com.rsbuddy.script.wrappers.Tile t1, t2;
private double dist;
public Line(int x1, int y1, int x2, int y2) {
t1 = new com.rsbuddy.script.wrappers.Tile(x1, y1);
t2 = new com.rsbuddy.script.wrappers.Tile(x2, y2);
x = x1;
y = y1;
this.x2 = x2;
this.y2 = y2;
xdist = x2 - x1;
ydist = y2 - y1;
centerX = x + (int) (0.5 * xdist);
centerY = y + (int) (0.5 * ydist);
dist = Math.sqrt(xdist * xdist + ydist * ydist);
}
public int getCenterX() {
return centerX;
}
public int getCenterY() {
return centerY;
}
public com.rsbuddy.script.wrappers.Tile getRandomTile() {
double rand = Math.random();
return new com.rsbuddy.script.wrappers.Tile(x + (int) (xdist * rand), y
+ (int) (ydist * rand));
}
public com.rsbuddy.script.wrappers.Tile getTile1() {
return t1;
}
public com.rsbuddy.script.wrappers.Tile getTile2() {
return t2;
}
public void drawTo(Graphics g, Line line) {
if (!com.rsbuddy.script.methods.Calculations.isTileOn Map(t1) || !com.rsbuddy.script.methods.Calculations.isTileOnM ap(t2)) {
return;
}
if (com.rsbuddy.script.methods.Calculations.isTileOnM ap(line.getTile1())
&& com.rsbuddy.script.methods.Calculations.isTileOnMa p(line.getTile2())) {
Point p1 = com.rsbuddy.script.methods.Calculations.tileToMap( t1);
Point p2 = com.rsbuddy.script.methods.Calculations.tileToMap( t2);
Point p3 = com.rsbuddy.script.methods.Calculations.tileToMap( line.getTile2());
Point p4 = com.rsbuddy.script.methods.Calculations.tileToMap( line.getTile1());
GeneralPath path = new GeneralPath();
path.moveTo(p1.x, p1.y);
path.lineTo(p2.x, p2.y);
path.lineTo(p3.x, p3.y);
path.lineTo(p4.x, p4.y);
path.closePath();
g.setColor(POLY_FILL);
((Graphics2D) g).fill(path);
((Graphics2D) g).draw(path);
}
Point last = null, p;
g.setColor(color3);
for (com.rsbuddy.script.wrappers.Tile t : pathList) {
if (com.rsbuddy.script.methods.Calculations.isTileOnM ap(t)) {
p = com.rsbuddy.script.methods.Calculations.tileToMap( t);
g.fillOval(p.x - 2, p.y - 2, 5, 5);
if (last != null) {
g.drawLine(p.x, p.y, last.x, last.y);
}
last = p;
} else {
last = null;
}
}
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getX2() {
return x2;
}
public int getY2() {
return y2;
}
public int getXDistance() {
return xdist;
}
public int getYDistance() {
return ydist;
}
public double getDistance() {
return dist;
}
public com.rsbuddy.script.wrappers.Tile translate(double length) {
return new com.rsbuddy.script.wrappers.Tile((int) Math.round(length * (xdist / dist)) + x,
(int) Math.round(length * (ydist / dist)) + y);
}
public com.rsbuddy.script.wrappers.Tile translateFromCenter(double length) {
return new com.rsbuddy.script.wrappers.Tile((int) Math.round(centerX - (xdist / dist)
* length), (int) Math.round(centerY - (ydist / dist)
* length));
}
}
// START: Code generated using Enfilade's Easel
private Image getImage(String url) {
try {
return ImageIO.read(new URL(url));
} catch (IOException e) {
return null;
}
}
private String format(int number) {
return format(String.valueOf(number));
}
private String format(String number) {
if (number.length() < 4) {
return number;
}
return format(number.substring(0, number.length() - 3)) + ","
+ number.substring(number.length() - 3, number.length());
}
private int getRunesCrafted() {
int watersrcrafted = totalwaters - waterRuneStart;
return watersrcrafted;
}
private int getExpGained() {
if (startExp == -1) {
}
return com.rsbuddy.script.methods.Skills.getCurrentExp(Sk ills.RUNECRAFTING) - startExp;
}
private double getExpHour() {
int xpGained = getExpGained();
long start = System.currentTimeMillis() - timer.getElapsed();
return xpGained * 3600000D / (System.currentTimeMillis() - start);
}
private int getExpToLvl() {
return com.rsbuddy.script.methods.Skills.getExpToNextLeve l(Skills.RUNECRAFTING);
}
private int getLvlGained() {
return com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING) - startLvl;
}
private int getPercentToLvl() {
return com.rsbuddy.script.methods.Skills.getPercentToNext Level(Skills.RUNECRAFTING);
}
private int getRunecraftLvl() {
return com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING);
}
private int getEssenceCrafted() {
return getExpGained() / 6;
}
private double getEssenceHour() {
int EssGained = getEssenceCrafted();
long start = System.currentTimeMillis() - timer.getElapsed();
return EssGained * 3600000D / (System.currentTimeMillis() - start);
}
private int getEssenceLeft() {
return getExpToLvl() / 6;
}
private int getRunesPerHour() {
long start = System.currentTimeMillis() - timer.getElapsed();
int Runescrafted = getRunesCrafted();
return (int) (Runescrafted * 3600000D / (System.currentTimeMillis() - start));
}
private int calcProfitH() {
long start = System.currentTimeMillis() - timer.getElapsed();
int Profit = getProfit();
return (int) (Profit * 3600000D / (System.currentTimeMillis() - start));
}
private int getProfit() {
int runes = (int) (getRunesCrafted());
int ess = (int) (getEssenceCrafted());
return (runes * runePrice) - (ess * essPrice);
}
private String format(long time) {
if (time <= 0) {
return "--:--:--";
}
return Timer.format(time);
}
private String getTimeToLvl() {
return format((long) (getExpToLvl() / getExpHour() * 3600000D));
}
public String formatCommas(double d) {
DecimalFormat df = new DecimalFormat();
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setGroupingSeparator(',');
df.setDecimalFormatSymbols(dfs);
return ((String) df.format((int) d));
}
private static final RenderingHints RENDERING_HINTS = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
public long startTime = System.currentTimeMillis();
private final Color color1 = new Color(0, 0, 0, 206);
private final Color color2 = new Color(255, 255, 255);
private final Color color3 = new Color(0, 255, 255);
private final Color color4 = new Color(0, 0, 255);
private final Color color5 = new Color(0, 0, 0);
private final BasicStroke stroke1 = new BasicStroke(1);
private final Font font1 = new Font("Monotype Corsiva", 2, 17);
private final Image img1 = getImage("Only the registered members can see the link.");
private final Image img2 = getImage("Only the registered members can see the link.");
private final Image img3 = getImage("Only the registered members can see the link.");
private final Image img4 = getImage("Only the registered members can see the link.");
final int percent() {
return (getPercentToLvl() * 5);
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
Point mp = e.getPoint();
final Rectangle toggleRectangle = new Rectangle(493, 347, 16, 15);
if (toggleRectangle.contains(mp)) {
if (pressed) {
pressed = false;
} else {
pressed = true;
}
}
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void onRepaint(Graphics g1) {
final Color MOUSE = new Color(20, 26, 167, 85);
if (com.rsbuddy.script.methods.Game.isLoggedIn()) {
Graphics2D g = (Graphics2D) g1;
g.setRenderingHints(RENDERING_HINTS);
if (pressed) {
long runTime = System.currentTimeMillis() - startTime;
g.setColor(color1);
g.fillRoundRect(9, 344, 504, 127, 16, 16);
g.setColor(color2);
g.drawImage(img4, 65, 305, null);
g.setFont(font1);
g.drawString("Current Level: " + getRunecraftLvl() + " (+"
+ getLvlGained() + ")", 11, 385);
g.drawString("Time running: " + format(runTime), 11, 365);
g.drawString("Essence used: " + getEssenceCrafted() + " ("
+ format((int) getEssenceHour()) + "/hr)", 242, 425);
g.drawString("XP gained: " + getExpGained() + " ("
+ format((int) getExpHour()) + "/hr)", 11, 425);
g.drawString("Runes crafted: " + getRunesCrafted() + " ("
+ format((int) getRunesPerHour()) + "/hr)", 11, 405);
g.drawString("Ess till level: " + getEssenceLeft(), 242, 405);
g.drawString("Time till level: " + getTimeToLvl(), 11, 445);
g.drawString("Status: " + status, 242, 365);
g.drawString("Profit: " + getProfit() + " ("
+ format((int) calcProfitH()) + "/hr)", 242, 385);
g.drawString("XP left till level: " + getExpToLvl(), 242, 445);
g.drawImage(img1, 45, 320, null);
g.drawImage(img1, 445, 320, null);
g.setColor(color3);
g.fillRoundRect(8, 450, 500, 23, 16, 16);
g.setColor(color4);
g.fillRoundRect(8, 450, percent(), 23, 16, 16);
g.drawImage(img3, 396, 5, null);
g.setColor(color3);
g.setStroke(stroke1);
g.drawRoundRect(8, 450, 500, 23, 16, 16);
g.setColor(color3);
g.fillRect(493, 347, 16, 15);
g.setColor(color4);
g.drawRect(493, 347, 16, 15);
g.setFont(new Font("Arial", Font.BOLD, 14));
g.drawString("X", 497, 360);
g.setColor(color5);
g.drawString(getPercentToLvl() + "%", 253, 468);// /At 55%
// exactly over
// the %
g.setColor(color3);
g.setColor(MOUSE);
g.drawImage(img2, ((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tX()) - 31),
((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tY()) - 31), null);
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
for (int i = 1; i < TOBANKCABBAGE.length; i++) {
TOBANKCABBAGE[i].drawTo(g1,
TOBANKCABBAGE[i - 1]);
}
} else {
for (int i = 1; i < TOBANK.length; i++) {
TOBANK[i].drawTo(g1, TOBANK[i - 1]);
}
}
} else {
for (int i = 1; i < TORUINS.length; i++) {
TORUINS[i].drawTo(g1, TORUINS[i - 1]);
}
}
}
} else {
g.setColor(color4);
g.fillRect(493, 347, 16, 15);
g.setColor(color3);
g.drawRect(493, 347, 16, 15);
g.setFont(new Font("Arial", Font.BOLD, 14));
g.drawString("O", 496, 360);
g.fillRoundRect(10, 314, 500, 23, 16, 16);
g.setColor(color4);
g.fillRoundRect(10, 314, percent(), 23, 16, 16);
g.drawImage(img3, 396, 5, null);
g.setColor(color3);
g.setStroke(stroke1);
g.drawRoundRect(10, 314, 500, 23, 16, 16);
g.setColor(color5);
g.drawString(getPercentToLvl() + "%", 255, 334);// /At 55%
// exactly over
// the %
g.setColor(color3);
g.setColor(MOUSE);
g.drawImage(img2, ((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tX()) - 31),
((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tY()) - 31), null);
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
for (int i = 1; i < TOBANKCABBAGE.length; i++) {
TOBANKCABBAGE[i].drawTo(g1,
TOBANKCABBAGE[i - 1]);
}
} else {
for (int i = 1; i < TOBANK.length; i++) {
TOBANK[i].drawTo(g1, TOBANK[i - 1]);
}
}
} else {
for (int i = 1; i < TORUINS.length; i++) {
TORUINS[i].drawTo(g1, TORUINS[i - 1]);
}
}
}
}
}
}
private static final String UPDATER_FILE_NAME = "PerfectCrafter.java";
private static final String UPDATER_URL = "Only the registered members can see the link.";
private static final Pattern UPDATER_VERSION_PATTERN = Pattern
.compile("version\\s*=\\s*([0-9.]+)");
private boolean checkForUpdates() {
try {
double currentVer = PerfectCrafter.class.getAnnotation(
com.rsbuddy.script.Manifest.class).version();
double newVer = -1;
URL url = new URL(UPDATER_URL);
BufferedReader in = new BufferedReader(new InputStreamReader(url
.openStream()));
String line, lines = "";
Matcher m;
while ((line = in.readLine()) != null) {
lines += line + "\n";
if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
newVer = Double.parseDouble(m.group(1));
break;
}
}
if (newVer < 0) {
in.close();
log("Unable to find the new version number. Update failed");
return false;
}
if (currentVer == newVer) {
in.close();
log("You already have the latest version of the script.");
return false;
}
log("Update found! Downloading version " + newVer);
String scriptFilePath = com.rsbuddy.script.methods.Environment.getStorageD irectory()
+ "\\" + UPDATER_FILE_NAME;
PrintWriter out = new PrintWriter(scriptFilePath);
out.print(lines);
while ((line = in.readLine()) != null)
out.println(line);
out.close();
in.close();
log("Successfully saved " + UPDATER_FILE_NAME + " to "
+ com.rsbuddy.script.methods.Environment.getStorageD irectory());
log("Compiling...");
try {
/* Attempt to compile the downloaded version */
Runtime.getRuntime().exec(
new String[] { "javac", "-classpath", "RSBot.jar",
scriptFilePath });
} catch (Exception ex) {
log("Could not compile the script. Please manually compile to finish the update.");
return false;
}
log("Update successful!");
log("The new version will appear near the bottom of the script selector.");
log("Stop and restart the script to run the newer version.");
return true;
} catch (IOException e) {
log(e.toString());
log("Update failed.");
}
return false;
}
// STOP: Code generated using Enfilade's Easel
private final class PerfectGUI extends JFrame {
private static final long serialVersionUID = 1L;
private JTabbedPane tabs;
private JCheckBox Explorer;
private JCheckBox restBox;
private JCheckBox Update;
private JButton submit;
private void init() {
setLocationRelativeTo(getRootPane());
setLayout(new GridLayout(2, 1));
tabs = new JTabbedPane();
tabs.setFocusable(false);
Explorer = new JCheckBox("Use Explorer's ring.");
restBox = new JCheckBox("use resting.");
Update = new JCheckBox("Check for updates.");
submit = new JButton("Start");
JPanel controls = new JPanel();
controls.setLayout(new GridLayout(3, 1));
JPanel Crafting = new JPanel();
Crafting.setLayout(new GridLayout(3, 1));
JPanel extra = new JPanel();
extra.setLayout(new GridLayout(3, 1));
setSize(200, 300);
setTitle("PerfectCrafter");
controls.add(restBox);
controls.add(Update);
controls.add(Explorer);
tabs.add(controls, "General");
add(tabs);
add(submit);
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
submit();
}
});
setVisible(true);
}
private void submit() {
checkUpdate = Update.isSelected();
useResting = restBox.isSelected();
if (Explorer.isSelected()) {
if (Explorer.isSelected()) {
log("Explorer's ring is selected");
useExplorersRing = true;
} else {
log("Explorer's ring is not selected");
useExplorersRing = false;
}
}
dispose();
}
}
}
Isn't the RSBuddy API just the same as the RSBot API?
Steve
March 21st, 2011, 20:09
Isn't the RSBuddy API just the same as the RSBot API?
Not exactly, but mostly the same. Like getMyPlayer() is now Players.getLocal() etc... The converted is really just using buffered reader to read the script line by line and replace old methods/classes with the new ones.
Ramsin
March 21st, 2011, 23:47
Here we go.
Only the registered members can see the link.
Code(some of it's weird because it was doing weird stuff, and i had to remove the GUI due to the fact that their theme has a bug in it, not the script):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.GeneralPath;
import java.io.IOException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import com.rsbuddy.event.listeners.PaintListener;
import com.rsbuddy.script.methods.Calculations;
import com.rsbuddy.script.methods.Equipment;
import com.rsbuddy.script.methods.Game;
import com.rsbuddy.script.methods.Mouse;
import com.rsbuddy.script.methods.Players;
import com.rsbuddy.script.methods.Skills;
import com.rsbuddy.script.methods.Walking;
import com.rsbuddy.script.util.Timer;
import com.rsbuddy.script.wrappers.Model;
import com.rsbuddy.script.wrappers.Tile;
@com.rsbuddy.script.Manifest(authors = "Ubuntu4life, Maximonster", name = "PerfectCrafter", version = 1.284, description = "Crafts water runes perfectly.")
public class PerfectCrafter extends com.rsbuddy.script.ActiveScript implements PaintListener, MouseListener {
private enum Action {
OPENBANK, DEPOSIT, WITHDRAW, WALKTORUINS, ENTERRUINS, WALKTOALTAR, CRAFTRUNE, TELEPORT, WALKTOGATE, OPENGATE, WALKTOPORTAL, LEAVEALTAR, WALKTOBANK, SLEEP
}
com.rsbuddy.script.wrappers.Tile gateTile = new com.rsbuddy.script.wrappers.Tile(3053, 3283);
com.rsbuddy.script.wrappers.Tile gateWalkTile = new com.rsbuddy.script.wrappers.Tile(3053, 3285);
com.rsbuddy.script.wrappers.Tile altarTile = new com.rsbuddy.script.wrappers.Tile(3485, 4836);
com.rsbuddy.script.wrappers.Tile altarWalkTile = new com.rsbuddy.script.wrappers.Tile(3486, 4836);
com.rsbuddy.script.wrappers.Tile altarClickTile = new com.rsbuddy.script.wrappers.Tile(3484, 4836);
com.rsbuddy.script.wrappers.Tile boothTile = new com.rsbuddy.script.wrappers.Tile(3091, 3245);
com.rsbuddy.script.wrappers.Tile bankTile = new com.rsbuddy.script.wrappers.Tile(3089, 3244);
com.rsbuddy.script.wrappers.Tile bankWalkTile = new com.rsbuddy.script.wrappers.Tile(3093, 3244);
com.rsbuddy.script.wrappers.Tile portalTile = new com.rsbuddy.script.wrappers.Tile(3495, 4832);
com.rsbuddy.script.wrappers.Tile portalWalkTile = new com.rsbuddy.script.wrappers.Tile(3496, 4832);
com.rsbuddy.script.wrappers.Tile ruinsTile = new com.rsbuddy.script.wrappers.Tile(3184, 3165);
com.rsbuddy.script.wrappers.Tile ruinsWalkTile = new com.rsbuddy.script.wrappers.Tile(3183, 3164);
com.rsbuddy.script.wrappers.Tile ruinsClickTile = new com.rsbuddy.script.wrappers.Tile(3185, 3165);
private PerfectGUI gui;
private boolean checkUpdate;
private boolean useResting;
private boolean useExplorersRing, pressed = true;
public boolean startScript = false, foundWaters = false, firstLoop = true,
outOfEssence = false;
volatile boolean stop = false;
private final int INTERFACE_RUN_ORB = 750, RUN_CHILD_ID = 1;
private int uniqueNumber;
public int startExp, startLvl, mayAntiBan = 0, itemCount = 0,
itemtypeint = 0, invalidCount = 0, runeStart = 0, totalRunes = 0,
essPrice = 0, runePrice = 0, waterRuneStart = 0, totalwaters = 0,
failCount = 0;
private ArrayList<com.rsbuddy.script.wrappers.Tile> pathList;
private Timer timer;
private AntiBan antiBan;
private java.util.Random unique;
private String status = "Starting...";
private Line[] TORUINS = { new Line(3094, 3243, 3093, 3242),
new Line(3103, 3236, 3098, 3235), new Line(3110, 3232, 3099, 3228),
new Line(3114, 3228, 3100, 3227), new Line(3114, 3224, 3110, 3223),
new Line(3116, 3221, 3114, 3220), new Line(3124, 3209, 3118, 3206),
new Line(3129, 3207, 3129, 3206), new Line(3138, 3207, 3131, 3204),
new Line(3143, 3205, 3138, 3201), new Line(3149, 3200, 3138, 3197),
new Line(3157, 3190, 3140, 3189), new Line(3160, 3181, 3150, 3178),
new Line(3167, 3172, 3157, 3169), new Line(3168, 3170, 3164, 3165),
new Line(3176, 3167, 3175, 3162), new Line(3180, 3167, 3180, 3162),
new Line(3184, 3167, 3184, 3162) };
private Line[] TOBANK = { new Line(3183, 3167, 3183, 3162),
new Line(3180, 3167, 3180, 3162), new Line(3176, 3167, 3175, 3162),
new Line(3171, 3169, 3171, 3163), new Line(3168, 3170, 3164, 3165),
new Line(3167, 3172, 3157, 3169), new Line(3160, 3181, 3150, 3178),
new Line(3157, 3190, 3140, 3189), new Line(3149, 3200, 3138, 3197),
new Line(3143, 3205, 3138, 3201), new Line(3138, 3207, 3131, 3204),
new Line(3129, 3207, 3129, 3206), new Line(3124, 3209, 3118, 3206),
new Line(3116, 3221, 3114, 3220), new Line(3114, 3224, 3110, 3223),
new Line(3114, 3228, 3100, 3227), new Line(3110, 3232, 3099, 3228),
new Line(3103, 3236, 3098, 3235), new Line(3093, 3245, 3093, 3242) };
private Line[] TOBANKCABBAGE = { new Line(3054, 3282, 3052, 3282),
new Line(3057, 3281, 3057, 3276), new Line(3071, 3277, 3071, 3274),
new Line(3082, 3268, 3070, 3268), new Line(3082, 3258, 3072, 3258),
new Line(3082, 3254, 3078, 3251), new Line(3086, 3249, 3085, 3247),
new Line(3092, 3246, 3092, 3243) };
public static interface Constants {
int[] openGates = { 7051, 7052 };
int[] closedGates = { 7050, 7049 };
int waterRune = 555;
int waterTalisman = 1444;
int runeEssence = 1436;
int Altar = 2480;
int Portal = 2467;
int Ruins = 2454;
int bankBooth = 2213;
com.rsbuddy.script.wrappers.Area AREA_INALTAR = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3474, 4845), new com.rsbuddy.script.wrappers.Tile(
3500, 4822));
com.rsbuddy.script.wrappers.Area AREA_REST = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3099, 3238), new com.rsbuddy.script.wrappers.Tile(3176,
3154));
com.rsbuddy.script.wrappers.Area AREA_INCABBAGE = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3067, 3283), new com.rsbuddy.script.wrappers.Tile(
3051, 3292));
com.rsbuddy.script.wrappers.Area AREA_INERROR = new com.rsbuddy.script.wrappers.Area(new com.rsbuddy.script.wrappers.Tile(3050, 3290), new com.rsbuddy.script.wrappers.Tile(
3057, 3298));
}
@Override
public boolean onStart() {
if (!com.rsbuddy.script.methods.Game.isFixed()) {
log.severe("You must use Fixed Screen Mode to use this script.");
return false;
}
if (com.rsbuddy.script.methods.Game.isLoggedIn()) {
unique = generateSeededRandom(Players.getLocal().getName()) ;
uniqueNumber = unique.nextInt(25);
if (checkUpdate) {
checkForUpdates();
}
startExp = com.rsbuddy.script.methods.Skills.getCurrentExp(Sk ills.RUNECRAFTING);
startLvl = com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING);
mayAntiBan = 0;
log.info(":-:-: Loading PerfectCrafter 1.284 :-:-:");
startTime = System.currentTimeMillis();
timer = new Timer(0);
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(5, 8));
log.info("Loading Prices...");
com.rsbuddy.script.methods.GrandExchange.Item water = com.rsbuddy.script.methods.GrandExchange.lookup(Co nstants.waterRune);
runePrice = water.getMarketPrice();
com.rsbuddy.script.methods.GrandExchange.Item ess = com.rsbuddy.script.methods.GrandExchange.lookup(Co nstants.runeEssence);
essPrice = ess.getMarketPrice();
if (pathList == null) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
pathList = generatePath(TOBANKCABBAGE);
} else {
pathList = generatePath(TOBANK);
}
} else {
pathList = generatePath(TORUINS);
}
}
startScript = true;
log.info("Bot and script are all set to go.");
} else {
log.info("Please log in before starting the script.");
return false;
}
return true;
}
public void onFinish() {
log("Antiban stopped");
log.info(":-:-: Thank you for using PerfectCrafter :-:-:");
com.rsbuddy.script.methods.Mouse.moveOffScreen();
com.rsbuddy.script.methods.Environment.saveScreens hot(true);
log("Remember to comment :p");
stop = true;
stop();
}
public Action getState() {
com.rsbuddy.script.wrappers.GameObject closedGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.closedGates);
try {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(boothTile)) {
if (!com.rsbuddy.script.methods.Bank.isOpen()) {
return Action.OPENBANK;
} else {
if (com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune)) {
return Action.DEPOSIT;
} else {
return Action.WITHDRAW;
}
}
} else {
if (inAltarArea() || Players.getLocal().getAnimation() == 791) {
if (useExplorersRing == true) {
return Action.TELEPORT;
} else if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(portalTile)) {
return Action.LEAVEALTAR;
} else {
return Action.WALKTOPORTAL;
}
} else {
if (useExplorersRing == true) {
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate.getLocation()) < 8
&& closedGate != null && inCabbageArea()) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile)) {
return Action.OPENGATE;
} else {
return Action.WALKTOGATE;
}
}
}
return Action.WALKTOBANK;
}
}
} else {
if (inAltarArea()) {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(altarTile)) {
return Action.CRAFTRUNE;
} else {
return Action.WALKTOALTAR;
}
} else {
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(ruinsTile)) {
return Action.ENTERRUINS;
} else {
return Action.WALKTORUINS;
}
}
}
} catch (Exception e) {
return Action.SLEEP;
}
}
Random r = new Random();
double val = r.nextGaussian() * 61 + 301;
int millisDelay = (int) Math.round(val);
private Mouse mouse = new Mouse();
private Game game = new Game();
@Override
public int loop() {
if (firstLoop) {
log.info("Starting Seperate AntiBan thread.");
antiBan = new AntiBan(this);
antiBan.start();
firstLoop = false;
return com.rsbuddy.script.util.Random.nextInt(200, 400);
}
if (needToRun() && !com.rsbuddy.script.methods.Walking.isRunEnabled() && !com.rsbuddy.script.methods.Bank.isOpen()) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(8, 9));
com.rsbuddy.script.methods.Widgets.get(INTERFACE_R UN_ORB).getComponent(RUN_CHILD_ID)
.interact("turn run mode on");
nextPercentage = (uniqueNumber + com.rsbuddy.script.util.Random.nextInt(2, 39));
sleep(300, 400);
}
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(5, 7));
try {
com.rsbuddy.script.wrappers.GameObject Altar = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Altar);
com.rsbuddy.script.wrappers.GameObject Portal = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Portal);
com.rsbuddy.script.wrappers.GameObject Ruins = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.Ruins);
com.rsbuddy.script.wrappers.GameObject Booth = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.bankBooth);
com.rsbuddy.script.wrappers.GameObject closedGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.closedGates);
com.rsbuddy.script.wrappers.GameObject openGate = com.rsbuddy.script.methods.Objects.getNearest(Cons tants.openGates);
switch (getState()) {
case OPENBANK:
status = "Opening bank";
mayAntiBan = 0;
if (clickObject(Booth, "Use-quickly", boothTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
int count = 0;
while (!com.rsbuddy.script.methods.Bank.isOpen() && ++count < 9) {
mayAntiBan = 1;
sleep(millisDelay);
if (com.rsbuddy.script.methods.Players.getLocal().isM oving()) {
count = 0;
}
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case DEPOSIT:
status = "Depositing";
mayAntiBan = 0;
try {
if (!foundWaters) {
sleep(com.rsbuddy.script.util.Random.nextInt(500, 600));
waterRuneStart = com.rsbuddy.script.methods.Bank.getCount(Constants .waterRune);
foundWaters = true;
}
totalwaters = com.rsbuddy.script.methods.Bank.getCount(Constants .waterRune);
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Bank.depositAll();
waitForEmpty();
} catch (final Exception e) {
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WITHDRAW:
status = "Withdrawing";
mayAntiBan = 0;
try {
int runeCount = com.rsbuddy.script.methods.Bank.getCount(Constants .runeEssence);
if (runeCount < 1) {
log("You are out of rune essences.");
stop();
} else {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Bank.withdraw(Constants .runeEssence, 0);
waitForFull();
pathList = generatePath(TORUINS);
}
if (!com.rsbuddy.script.methods.Inventory.containsAll (Constants.runeEssence)) {
final int count = com.rsbuddy.script.methods.Inventory.getCount();
com.rsbuddy.script.methods.Bank.depositAllExcept(C onstants.runeEssence);
for (int i = 0; i < 10 && com.rsbuddy.script.methods.Inventory.getCount() == count; i++) {
sleep(com.rsbuddy.script.util.Random.nextInt(100, 200));
}
}
} catch (final Exception e) {
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTORUINS:
status = "Walking to ruins";
step(pathList, ruinsTile);
if (useResting == true) {
if (com.rsbuddy.script.methods.Walking.getEnergy() < ((uniqueNumber + com.rsbuddy.script.util.Random.nextInt(-11, 8)))
&& inRestArea()) {
status = "Resting";
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 8));
com.rsbuddy.script.methods.Walking.rest((uniqueNum ber + com.rsbuddy.script.util.Random.nextInt(43, 88)));
}
}
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(ruinsTile)) {
return com.rsbuddy.script.util.Random.nextInt(200, 390);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(220, 370);
case ENTERRUINS:
status = "Entering Ruins";
mayAntiBan = 0;
if (clickObject(Ruins, "Enter", ruinsTile, false)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(millisDelay);
} while (Players.getLocal().isMoving() && !inAltarArea());
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOALTAR:
status = "Walking to altar";
mayAntiBan = 0;
walkTo(altarWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(altarTile));
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case CRAFTRUNE:
status = "Crafting essences";
mayAntiBan = 0;
if (clickObject(Altar, "Craft-rune", altarTile, false)) {
if (useExplorersRing == true) {
pathList = generatePath(TOBANKCABBAGE);
} else {
pathList = generatePath(TOBANK);
}
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(520, 1025);
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune));
if (useExplorersRing == true && !Players.getLocal().isMoving()) {
for (int i = 140; i > 0; --i) {
if (Players.getLocal().getAnimation() != -1) {
continue;
}
sleep(10);
}
sleep(150, 450);
}
if (useExplorersRing == false) {
for (int i = 140; i > 0; --i) {
if (Players.getLocal().getAnimation() != -1) {
continue;
}
sleep(10);
}
sleep(1300, 1600);
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case TELEPORT:
status = "Teleporting";
mayAntiBan = 0;
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
com.rsbuddy.script.methods.Game.openTab(Game.TAB_E QUIPMENT);
}
if (com.rsbuddy.script.methods.Equipment.getItem(Equi pment.RING) != null) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
if (com.rsbuddy.script.methods.Widgets.get(Equipment. WIDGET)
.getComponent(Equipment.RING).interact(
"Cabbage-port")) {
for (int i = 0; i < 140
&& Players.getLocal().getAnimation() != 9984; i++) {
sleep(10);
}
while (Players.getLocal().getAnimation() == 9984) {
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_INVENTORY) {
sleep(198, 2564);
com.rsbuddy.script.methods.Game.openTab(Game.TAB_I NVENTORY);
}
sleep(47, 52);
}
sleep(998, com.rsbuddy.script.util.Random.nextInt(2891, 2901));
}
} else {
log("Please wear an Explorer's ring 3 of 4 !");
stop();
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOGATE:
status = "Walking to gate";
mayAntiBan = 0;
int angle = com.rsbuddy.script.methods.Camera.getAngleTo(close dGate);
walkTo(gateWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile));
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10
&& Math.abs(angle - com.rsbuddy.script.methods.Camera.getCompassAngle( )) > 20) {
com.rsbuddy.script.methods.Camera.setCompassAngle( angle + com.rsbuddy.script.util.Random.nextInt(-21, 21));
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case OPENGATE:
status = "Opening gate";
mayAntiBan = 0;
if (clickObject(closedGate, "Open Gate", gateTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
if (inErrorArea()) {
int angle2 = com.rsbuddy.script.methods.Camera.getAngleTo(close dGate);
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10
&& Math.abs(angle2 - com.rsbuddy.script.methods.Camera.getCompassAngle( )) > 20) {
com.rsbuddy.script.methods.Camera.setCompassAngle( angle2 + com.rsbuddy.script.util.Random.nextInt(-21, 21));
}
walkTileMM(gateWalkTile, 2, 2);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(gateTile));
}
} while (Players.getLocal().isMoving());
if (com.rsbuddy.script.methods.Calculations.distanceT o(closedGate) < 10) {
Timer gateTimer = new Timer(com.rsbuddy.script.util.Random.nextInt(1000, 1400));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (openGate == null && gateTimer.isRunning());
}
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOPORTAL:
status = "Walking to portal";
mayAntiBan = 0;
walkTo(portalWalkTile);
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
sleep(millisDelay);
mayAntiBan = 1;
} while (Players.getLocal().isMoving()
&& !com.rsbuddy.script.methods.Calculations.isTileOnS creen(portalTile));
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case LEAVEALTAR:
status = "Leaving altar";
mayAntiBan = 0;
if (clickObject(Portal, "Enter", portalTile, true)) {
waitToMove(com.rsbuddy.script.util.Random.nextInt( 600, 900));
do {
mayAntiBan = 1;
sleep(millisDelay);
} while (inAltarArea() && Players.getLocal().isMoving());
sleep(150, 300);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
case WALKTOBANK:
status = "Walking to bank";
com.rsbuddy.script.methods.Camera.setPitch(true);
step(pathList, boothTile);
if (useResting == true) {
if (com.rsbuddy.script.methods.Walking.getEnergy() < ((uniqueNumber + com.rsbuddy.script.util.Random.nextInt(-11, 8)))
&& inRestArea()) {
status = "Resting";
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(8, 9));
com.rsbuddy.script.methods.Walking.rest((uniqueNum ber + com.rsbuddy.script.util.Random.nextInt(43, 88)));
}
}
if (com.rsbuddy.script.methods.Calculations.isTileOnS creen(boothTile)) {
return com.rsbuddy.script.util.Random.nextInt(220, 370);
}
mayAntiBan = 1;
return com.rsbuddy.script.util.Random.nextInt(3, 8);
}
} catch (Exception e) {
sleep(150, 300);
return com.rsbuddy.script.util.Random.nextInt(50, 100);
}
return 0;
}
private void walkTo(Tile destination) {
while (Calculations.distanceTo(destination) > 3) {
Walking.stepTowards(destination);
sleep(2000, 4000);
}
}
public com.rsbuddy.script.methods.Mouse getMouse() {
return mouse;
}
// Credits go to Unknown500 for the AntiBan skeleton code
class AntiBan extends Thread {
private PerfectCrafter parent;
private Random randomGenerator;
AntiBan(PerfectCrafter parent) {
this.parent = parent;
this.randomGenerator = new Random();
}
@Override
public void run() {
try {
while (parent.getGame().isLoggedIn() && !stop) {
if (!parent.isPaused()) {
int random = randomGenerator.nextInt(7);
if (mayAntiBan == 1 && random != 2) {
int rand = randomGenerator.nextInt(5);
switch (rand) {
case 1:
if (mayAntiBan == 1) {
if (com.rsbuddy.script.util.Random.nextInt(1, 5) != com.rsbuddy.script.util.Random.nextInt(1, 4)) {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
} else {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
sleep(com.rsbuddy.script.util.Random.nextInt(0, com.rsbuddy.script.util.Random.nextInt(72, 380)));
parent.getMouse().moveRandomly(6, com.rsbuddy.script.util.Random.nextInt(46,
72));
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
}
} else {
break;
}
case 2:
if (mayAntiBan == 1 && com.rsbuddy.script.util.Random.nextInt(1, 510) == 119) {
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(9, 12));
parent.getMouse().moveSlightly();
parent.getMouse().setSpeed(com.rsbuddy.script.util .Random.nextInt(5, 7));
break;
} else {
break;
}
case 3:
if (com.rsbuddy.script.util.Random.nextInt(1, 8) == 3) {
int angle = com.rsbuddy.script.methods.Camera.getCompassAngle( )
+ com.rsbuddy.script.util.Random.nextInt(-45, 45);
if (angle < 0) {
angle = com.rsbuddy.script.util.Random.nextInt(0, 10);
}
if (angle > 359) {
angle = com.rsbuddy.script.util.Random.nextInt(0, 10);
}
char whichDir = 37;
if (com.rsbuddy.script.util.Random.nextInt(0, 100) < 50)
whichDir = 39;
com.rsbuddy.script.methods.Keyboard.pressKey(which Dir);
sleep(com.rsbuddy.script.util.Random.nextInt(103, 996));
com.rsbuddy.script.methods.Keyboard.releaseKey(whi chDir);
break;
} else {
break;
}
default:
break;
}
}
sleep(com.rsbuddy.script.util.Random.nextInt(63, 2373));
}
}
} catch (InterruptedException e) {
log(e.getMessage());
}
}
}
// credits to !@!@! for clicking method, it's epic.
private boolean clickObject(com.rsbuddy.script.wrappers.GameObject object, String action, com.rsbuddy.script.wrappers.Tile Tile,
boolean useCentralClicking) {
Point p;
for (int i = 0; i < 4; i++) {
if (isPartiallyOnScreen(object.getModel())) {
p = useCentralClicking ? getCentralPoint(object.getModel())
: getPointOnScreen(object.getModel(), true);
while (isPartiallyOnScreen(object.getModel()) && p.x != -1
&& p.y != -1 && p != null && com.rsbuddy.script.methods.Calculations.isPointOnS creen(p)
&& !com.rsbuddy.script.methods.Bank.isOpen() && com.rsbuddy.script.methods.Calculations.isTileOnSc reen(Tile)) {
p = useCentralClicking ? getCentralPoint(object.getModel())
: getPointOnScreen(object.getModel(), true);
com.rsbuddy.script.methods.Mouse.move(p, 0, 0);
if (com.rsbuddy.script.methods.Menu.contains(action))
break;
if (p.x == -1 || p.y == -1 || p == null
|| !com.rsbuddy.script.methods.Calculations.isPointOn Screen(p)
|| !isPartiallyOnScreen(object.getModel())
|| !com.rsbuddy.script.methods.Calculations.isTileOnS creen(Tile) || com.rsbuddy.script.methods.Bank.isOpen())
continue;
}
String[] items = com.rsbuddy.script.methods.Menu.getItems();
if (items.length > 0 && items[0].contains(action)) {
com.rsbuddy.script.methods.Mouse.click(true);
return true;
} else if (com.rsbuddy.script.methods.Menu.contains(action)) {
com.rsbuddy.script.methods.Mouse.setSpeed(com.rsbu ddy.script.util.Random.nextInt(6, 9));
com.rsbuddy.script.methods.Mouse.click(false);
sleep(com.rsbuddy.script.util.Random.nextInt(100, 200));
for (int x = 0; x < 4; x++) {
if (com.rsbuddy.script.methods.Menu.click(action)) {
return true;
}
}
}
if (!com.rsbuddy.script.methods.Menu.contains(action) && com.rsbuddy.script.methods.Menu.isOpen()) {
do {
com.rsbuddy.script.methods.Mouse.moveRandomly(com. rsbuddy.script.util.Random.nextInt(180, 275));
} while (com.rsbuddy.script.methods.Menu.isOpen());
sleep(com.rsbuddy.script.util.Random.nextInt(100, 175));
return false;
}
}
}
return false;
}
public Game getGame() {
return game ;
}
private boolean isPartiallyOnScreen(Model m) {
return getPointOnScreen(m, true) != null;
}
private Point getPointOnScreen(Model m, boolean first) {
if (m == null) {
return null;
}
ArrayList<Point> list = new ArrayList<Point>();
try {
Polygon[] tris = m.getTriangles();
for (int i = 0; i < tris.length; i++) {
Polygon p = tris[i];
for (int j = 0; j < p.xpoints.length; j++) {
Point pt = new Point(p.xpoints[j], p.ypoints[j]);
if (Calculations.isPointOnScreen(pt)) {
if (first) {
return pt;
}
list.add(pt);
}
}
}
} catch (Exception e) {
}
return list.size() > 0 ? list.get(com.rsbuddy.script.util.Random.nextInt(0, list.size())) : null;
}
private Point getCentralPoint(Model m) {
if (m == null) {
return null;
}
try {
int x = 0, y = 0, total = 0;
for (Polygon poly : m.getTriangles()) {
for (int i = 0; i < poly.npoints; i++) {
x += poly.xpoints[i];
y += poly.ypoints[i];
total++;
}
}
Point central = new Point(x / total, y / total);
Point curCentral = null;
double dist = 20000;
for (Polygon poly : m.getTriangles()) {
for (int i = 0; i < poly.npoints; i++) {
Point p = new Point(poly.xpoints[i], poly.ypoints[i]);
if (!Calculations.isPointOnScreen(p)) {
continue;
}
double dist2 = distanceBetween(central, p);
if (curCentral == null || dist2 < dist) {
curCentral = p;
dist = dist2;
}
}
}
return curCentral;
} catch (Exception e) {
}
return null;
}
private double distanceBetween(Point p1, Point p2) {
return Math.sqrt(((p1.x - p2.x) * (p1.x - p2.x))
+ ((p1.y - p2.y) * (p1.y - p2.y)));
}
public boolean walkTileMM(com.rsbuddy.script.wrappers.Tile t, int x, int y) {
com.rsbuddy.script.wrappers.Tile dest = new com.rsbuddy.script.wrappers.Tile(t.getX() + com.rsbuddy.script.util.Random.nextInt(0, x), t.getY()
+ com.rsbuddy.script.util.Random.nextInt(0, y));
Point p = com.rsbuddy.script.methods.Calculations.tileToMap( dest);
if (p.x != -1 && p.y != -1) {
com.rsbuddy.script.methods.Mouse.move(p);
Point p2 = com.rsbuddy.script.methods.Calculations.tileToMap( dest);
if (p2.x != -1 && p2.y != -1) {
com.rsbuddy.script.methods.Mouse.move(p2);
com.rsbuddy.script.methods.Mouse.click(p2, true);
return true;
}
}
return false;
}
private int nextPercentage = (uniqueNumber + com.rsbuddy.script.util.Random.nextInt(1, 39));
private boolean needToRun() {
if (com.rsbuddy.script.methods.Walking.getEnergy() > nextPercentage) {
return true;
}
return false;
}
public boolean rest(int stopEnergy) {
int energy = getEnergy();
for (int d = 0; d < 5; d++) {
mayAntiBan = 0;
com.rsbuddy.script.methods.Widgets.getComponent(IN TERFACE_RUN_ORB, 1).interact("Rest");
com.rsbuddy.script.methods.Mouse.moveSlightly();
mayAntiBan = 1;
if (com.rsbuddy.script.util.Random.nextInt(1, 3) == com.rsbuddy.script.util.Random.nextInt(1, 2)) {
if (com.rsbuddy.script.util.Random.nextInt(1, 2) == com.rsbuddy.script.util.Random.nextInt(1, 2)) {
sleep(com.rsbuddy.script.util.Random.nextInt(200, 2000), com.rsbuddy.script.util.Random.nextInt(5000, 15000));
}
mayAntiBan = 0;
com.rsbuddy.script.methods.Mouse.moveOffScreen();
}
int anim = com.rsbuddy.script.methods.Players.getLocal().getA nimation();
if (anim == 12108 || anim == 2033 || anim == 2716 || anim == 11786
|| anim == 5713) {
break;
}
if (d == 4) {
return false;
}
}
while (energy < stopEnergy) {
sleep(millisDelay);
energy = getEnergy();
}
mayAntiBan = 1;
return true;
}
public int getEnergy() {
try {
return Integer.parseInt(com.rsbuddy.script.methods.Widget s.getComponent(750, 5).getText());
} catch (NumberFormatException e) {
return 0;
}
}
private java.util.Random generateSeededRandom(String text) {
MessageDigest coder;
try {
coder = MessageDigest.getInstance("MD5");
coder.update(text.getBytes());
byte[] bytes = coder.digest();
long result1 = 0, result2 = 0;
for (int i = 0; i < 8; i++) {
result1 = (result1 << 8) | bytes[i];
}
for (int i = 8; i < 16; i++) {
result2 = (result2 << 8) | bytes[i];
}
return new java.util.Random(result1 - result2);
} catch (NoSuchAlgorithmException ex) {
}
return new java.util.Random();
}
private boolean inErrorArea() {
return Constants.AREA_INERROR.contains(Players.getLocal() .getLocation());
}
private boolean inAltarArea() {
return Constants.AREA_INALTAR.contains(Players.getLocal() .getLocation());
}
private boolean inRestArea() {
return Constants.AREA_REST.contains(Players.getLocal().ge tLocation());
}
private boolean inCabbageArea() {
return Constants.AREA_INCABBAGE.contains(Players.getLocal ().getLocation());
}
private boolean waitToMove(int timeout) {
long endTime = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < endTime) {
if (Players.getLocal().isMoving()) {
return true;
}
sleep(5, 15);
}
return false;
}
public void waitForEmpty() {
int tries = 0;
while (com.rsbuddy.script.methods.Inventory.contains(Con stants.waterRune) && tries < 10) {
tries++;
sleep(180, 200);
}
}
public void waitForFull() {
int tries = 0;
while (!com.rsbuddy.script.methods.Inventory.isFull() && tries < 10
&& !com.rsbuddy.script.methods.Inventory.contains(Con stants.runeEssence)) {
tries++;
sleep(180, 200);
}
}
// Credits go to Enfilade for this epic walking method
private boolean tileInNextRange(com.rsbuddy.script.wrappers.Tile t) {
return com.rsbuddy.script.methods.Calculations.distanceBe tween(t, Players.getLocal().getLocation()) < nextStep;
}
private final Color POLY_FILL = new Color(20, 26, 167, 70);
private int nextStep = com.rsbuddy.script.util.Random.nextInt(15, 16);
private int step(ArrayList<com.rsbuddy.script.wrappers.Tile> path, com.rsbuddy.script.wrappers.Tile tileToWalk) {
if (com.rsbuddy.script.methods.Calculations.distanceB etween(Players.getLocal().getLocation(), path.get(path
.size() - 1)) < 2) {
return path.size();
}
com.rsbuddy.script.wrappers.Tile dest = com.rsbuddy.script.methods.Walking.getDestination( );
int index = -1;
int shortestDist = 0, dist, shortest = -3;
if (dest != null) {
for (int i = 0; i < path.size(); i++) {
dist = (int) com.rsbuddy.script.methods.Calculations.distanceBe tween(path.get(i), dest);
if (shortest < 0 || shortestDist > dist) {
shortest = i;
shortestDist = dist;
}
}
}
for (int i = path.size() - 1; i >= 0; i--) {
if (tileInNextRange(path.get(i))) {
index = i;
break;
}
}
if (index >= 0
&& (dest == null || (index > shortest) || !Players.getLocal()
.isMoving())) {
mayAntiBan = 0;
com.rsbuddy.script.methods.Walking.getTileOnMap(pa th.get(index)).clickOnMap();
sleep(millisDelay);
mayAntiBan = 1;
nextStep = com.rsbuddy.script.util.Random.nextInt(15, 19);
return index;
}
return -1;
}
private ArrayList<com.rsbuddy.script.wrappers.Tile> generatePath(Line[] lines) {
double minStep = 4, maxStep = 13, wander = 3;
if (lines.length < 2) {
return null;
}
ArrayList<com.rsbuddy.script.wrappers.Tile> path = new ArrayList<com.rsbuddy.script.wrappers.Tile>();
Line l1, l2 = lines[0];
double distFromCenter = com.rsbuddy.script.util.Random.nextDouble(0, l2.getDistance() + 1);
com.rsbuddy.script.wrappers.Tile p = l2.translate((int) distFromCenter);
distFromCenter = l2.getDistance() / 2 - distFromCenter;
double centerXdist, centerYdist, line1Xdist, line1Ydist, line2Xdist, line2Ydist;
double line1dist, line2dist, centerDist;
double x, y;
double distOnLine, last, cap1, cap2, move;
double distFromCenterX1, distFromCenterY1, distFromCenterX2, distFromCenterY2;
double force1, force2, slopeX, slopeY, slopeDist;
boolean finished;
int lastX = p.getX(), lastY = p.getY(), curX, curY;
double dist, xdist, ydist;
for (int i = 1; i < lines.length; i++) {
l1 = l2;
l2 = lines[i];
centerXdist = l2.getCenterX() - l1.getCenterX();
centerYdist = l2.getCenterY() - l1.getCenterY();
centerDist = Math.sqrt(centerXdist * centerXdist + centerYdist
* centerYdist);
line1Xdist = l2.getX() - l1.getX();
line1Ydist = l2.getY() - l1.getY();
line2Xdist = l2.getX2() - l1.getX2();
line2Ydist = l2.getY2() - l1.getY2();
centerXdist /= centerDist;
centerYdist /= centerDist;
line1Xdist /= centerDist;
line1Ydist /= centerDist;
line2Xdist /= centerDist;
line2Ydist /= centerDist;
distOnLine = 0;
last = 0;
finished = false;
while (!finished) {
distOnLine += com.rsbuddy.script.util.Random.nextDouble(minStep, maxStep);
if (distOnLine >= centerDist) {
distOnLine = centerDist;
finished = true;
}
x = centerXdist * distOnLine + l1.getCenterX();
y = centerYdist * distOnLine + l1.getCenterY();
distFromCenterX1 = x - (line1Xdist * distOnLine + l1.getX());
distFromCenterY1 = y - (line1Ydist * distOnLine + l1.getY());
distFromCenterX2 = x - (line2Xdist * distOnLine + l1.getX2());
distFromCenterY2 = y - (line2Ydist * distOnLine + l1.getY2());
slopeX = distFromCenterX2 - distFromCenterX1;
slopeY = distFromCenterY2 - distFromCenterY1;
slopeDist = Math.sqrt(slopeX * slopeX + slopeY * slopeY);
slopeX /= slopeDist;
slopeY /= slopeDist;
line1dist = Math.sqrt(distFromCenterX1 * distFromCenterX1
+ distFromCenterY1 * distFromCenterY1);
line2dist = Math.sqrt(distFromCenterX2 * distFromCenterX2
+ distFromCenterY2 * distFromCenterY2);
move = (distOnLine - last) / maxStep * wander;
force1 = line1dist + distFromCenter;
force2 = line2dist - distFromCenter;
cap1 = Math.min(move, force1);
cap2 = Math.min(move, force2);
if (force1 < 0) {
distFromCenter -= force1;
} else if (force2 < 0) {
distFromCenter += force2;
} else {
distFromCenter += com.rsbuddy.script.util.Random.nextDouble(-cap1, cap2);
}
if (finished) {
com.rsbuddy.script.wrappers.Tile t = l2.translateFromCenter(distFromCenter);
curX = t.getX();
curY = t.getY();
} else {
curX = (int) Math.round(distOnLine * centerXdist
+ l1.getCenterX() + distFromCenter * slopeX);
curY = (int) Math.round(distOnLine * centerYdist
+ l1.getCenterY() + distFromCenter * slopeY);
}
xdist = curX - lastX;
ydist = curY - lastY;
dist = Math.sqrt(xdist * xdist + ydist * ydist);
xdist /= dist;
ydist /= dist;
for (int j = 0; j < dist; j++) {
path.add(new com.rsbuddy.script.wrappers.Tile((int) Math.round(xdist * j + lastX),
(int) Math.round(ydist * j + lastY)));
}
last = distOnLine;
lastX = curX;
lastY = curY;
}
}
return cutUp(path);
}
public ArrayList<com.rsbuddy.script.wrappers.Tile> cutUp(ArrayList<com.rsbuddy.script.wrappers.Tile> tiles) {
ArrayList<com.rsbuddy.script.wrappers.Tile> path = new ArrayList<com.rsbuddy.script.wrappers.Tile>();
int index = 0;
while (index < tiles.size()) {
path.add(tiles.get(index));
index += com.rsbuddy.script.util.Random.nextInt(8, 12);
}
if (!path.get(path.size() - 1).equals(tiles.get(tiles.size() - 1))) {
path.add(tiles.get(tiles.size() - 1));
}
return path;
}
private class Line {
private int x, y, xdist, ydist, x2, y2, centerX, centerY;
private com.rsbuddy.script.wrappers.Tile t1, t2;
private double dist;
public Line(int x1, int y1, int x2, int y2) {
t1 = new com.rsbuddy.script.wrappers.Tile(x1, y1);
t2 = new com.rsbuddy.script.wrappers.Tile(x2, y2);
x = x1;
y = y1;
this.x2 = x2;
this.y2 = y2;
xdist = x2 - x1;
ydist = y2 - y1;
centerX = x + (int) (0.5 * xdist);
centerY = y + (int) (0.5 * ydist);
dist = Math.sqrt(xdist * xdist + ydist * ydist);
}
public int getCenterX() {
return centerX;
}
public int getCenterY() {
return centerY;
}
public com.rsbuddy.script.wrappers.Tile getRandomTile() {
double rand = Math.random();
return new com.rsbuddy.script.wrappers.Tile(x + (int) (xdist * rand), y
+ (int) (ydist * rand));
}
public com.rsbuddy.script.wrappers.Tile getTile1() {
return t1;
}
public com.rsbuddy.script.wrappers.Tile getTile2() {
return t2;
}
public void drawTo(Graphics g, Line line) {
if (!com.rsbuddy.script.methods.Calculations.isTileOn Map(t1) || !com.rsbuddy.script.methods.Calculations.isTileOnM ap(t2)) {
return;
}
if (com.rsbuddy.script.methods.Calculations.isTileOnM ap(line.getTile1())
&& com.rsbuddy.script.methods.Calculations.isTileOnMa p(line.getTile2())) {
Point p1 = com.rsbuddy.script.methods.Calculations.tileToMap( t1);
Point p2 = com.rsbuddy.script.methods.Calculations.tileToMap( t2);
Point p3 = com.rsbuddy.script.methods.Calculations.tileToMap( line.getTile2());
Point p4 = com.rsbuddy.script.methods.Calculations.tileToMap( line.getTile1());
GeneralPath path = new GeneralPath();
path.moveTo(p1.x, p1.y);
path.lineTo(p2.x, p2.y);
path.lineTo(p3.x, p3.y);
path.lineTo(p4.x, p4.y);
path.closePath();
g.setColor(POLY_FILL);
((Graphics2D) g).fill(path);
((Graphics2D) g).draw(path);
}
Point last = null, p;
g.setColor(color3);
for (com.rsbuddy.script.wrappers.Tile t : pathList) {
if (com.rsbuddy.script.methods.Calculations.isTileOnM ap(t)) {
p = com.rsbuddy.script.methods.Calculations.tileToMap( t);
g.fillOval(p.x - 2, p.y - 2, 5, 5);
if (last != null) {
g.drawLine(p.x, p.y, last.x, last.y);
}
last = p;
} else {
last = null;
}
}
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getX2() {
return x2;
}
public int getY2() {
return y2;
}
public int getXDistance() {
return xdist;
}
public int getYDistance() {
return ydist;
}
public double getDistance() {
return dist;
}
public com.rsbuddy.script.wrappers.Tile translate(double length) {
return new com.rsbuddy.script.wrappers.Tile((int) Math.round(length * (xdist / dist)) + x,
(int) Math.round(length * (ydist / dist)) + y);
}
public com.rsbuddy.script.wrappers.Tile translateFromCenter(double length) {
return new com.rsbuddy.script.wrappers.Tile((int) Math.round(centerX - (xdist / dist)
* length), (int) Math.round(centerY - (ydist / dist)
* length));
}
}
// START: Code generated using Enfilade's Easel
private Image getImage(String url) {
try {
return ImageIO.read(new URL(url));
} catch (IOException e) {
return null;
}
}
private String format(int number) {
return format(String.valueOf(number));
}
private String format(String number) {
if (number.length() < 4) {
return number;
}
return format(number.substring(0, number.length() - 3)) + ","
+ number.substring(number.length() - 3, number.length());
}
private int getRunesCrafted() {
int watersrcrafted = totalwaters - waterRuneStart;
return watersrcrafted;
}
private int getExpGained() {
if (startExp == -1) {
}
return com.rsbuddy.script.methods.Skills.getCurrentExp(Sk ills.RUNECRAFTING) - startExp;
}
private double getExpHour() {
int xpGained = getExpGained();
long start = System.currentTimeMillis() - timer.getElapsed();
return xpGained * 3600000D / (System.currentTimeMillis() - start);
}
private int getExpToLvl() {
return com.rsbuddy.script.methods.Skills.getExpToNextLeve l(Skills.RUNECRAFTING);
}
private int getLvlGained() {
return com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING) - startLvl;
}
private int getPercentToLvl() {
return com.rsbuddy.script.methods.Skills.getPercentToNext Level(Skills.RUNECRAFTING);
}
private int getRunecraftLvl() {
return com.rsbuddy.script.methods.Skills.getCurrentLevel( Skills.RUNECRAFTING);
}
private int getEssenceCrafted() {
return getExpGained() / 6;
}
private double getEssenceHour() {
int EssGained = getEssenceCrafted();
long start = System.currentTimeMillis() - timer.getElapsed();
return EssGained * 3600000D / (System.currentTimeMillis() - start);
}
private int getEssenceLeft() {
return getExpToLvl() / 6;
}
private int getRunesPerHour() {
long start = System.currentTimeMillis() - timer.getElapsed();
int Runescrafted = getRunesCrafted();
return (int) (Runescrafted * 3600000D / (System.currentTimeMillis() - start));
}
private int calcProfitH() {
long start = System.currentTimeMillis() - timer.getElapsed();
int Profit = getProfit();
return (int) (Profit * 3600000D / (System.currentTimeMillis() - start));
}
private int getProfit() {
int runes = (int) (getRunesCrafted());
int ess = (int) (getEssenceCrafted());
return (runes * runePrice) - (ess * essPrice);
}
private String format(long time) {
if (time <= 0) {
return "--:--:--";
}
return Timer.format(time);
}
private String getTimeToLvl() {
return format((long) (getExpToLvl() / getExpHour() * 3600000D));
}
public String formatCommas(double d) {
DecimalFormat df = new DecimalFormat();
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setGroupingSeparator(',');
df.setDecimalFormatSymbols(dfs);
return ((String) df.format((int) d));
}
private static final RenderingHints RENDERING_HINTS = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
public long startTime = System.currentTimeMillis();
private final Color color1 = new Color(0, 0, 0, 206);
private final Color color2 = new Color(255, 255, 255);
private final Color color3 = new Color(0, 255, 255);
private final Color color4 = new Color(0, 0, 255);
private final Color color5 = new Color(0, 0, 0);
private final BasicStroke stroke1 = new BasicStroke(1);
private final Font font1 = new Font("Monotype Corsiva", 2, 17);
private final Image img1 = getImage("Only the registered members can see the link.");
private final Image img2 = getImage("Only the registered members can see the link.");
private final Image img3 = getImage("Only the registered members can see the link.");
private final Image img4 = getImage("Only the registered members can see the link.");
final int percent() {
return (getPercentToLvl() * 5);
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
Point mp = e.getPoint();
final Rectangle toggleRectangle = new Rectangle(493, 347, 16, 15);
if (toggleRectangle.contains(mp)) {
if (pressed) {
pressed = false;
} else {
pressed = true;
}
}
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void onRepaint(Graphics g1) {
final Color MOUSE = new Color(20, 26, 167, 85);
if (com.rsbuddy.script.methods.Game.isLoggedIn()) {
Graphics2D g = (Graphics2D) g1;
g.setRenderingHints(RENDERING_HINTS);
if (pressed) {
long runTime = System.currentTimeMillis() - startTime;
g.setColor(color1);
g.fillRoundRect(9, 344, 504, 127, 16, 16);
g.setColor(color2);
g.drawImage(img4, 65, 305, null);
g.setFont(font1);
g.drawString("Current Level: " + getRunecraftLvl() + " (+"
+ getLvlGained() + ")", 11, 385);
g.drawString("Time running: " + format(runTime), 11, 365);
g.drawString("Essence used: " + getEssenceCrafted() + " ("
+ format((int) getEssenceHour()) + "/hr)", 242, 425);
g.drawString("XP gained: " + getExpGained() + " ("
+ format((int) getExpHour()) + "/hr)", 11, 425);
g.drawString("Runes crafted: " + getRunesCrafted() + " ("
+ format((int) getRunesPerHour()) + "/hr)", 11, 405);
g.drawString("Ess till level: " + getEssenceLeft(), 242, 405);
g.drawString("Time till level: " + getTimeToLvl(), 11, 445);
g.drawString("Status: " + status, 242, 365);
g.drawString("Profit: " + getProfit() + " ("
+ format((int) calcProfitH()) + "/hr)", 242, 385);
g.drawString("XP left till level: " + getExpToLvl(), 242, 445);
g.drawImage(img1, 45, 320, null);
g.drawImage(img1, 445, 320, null);
g.setColor(color3);
g.fillRoundRect(8, 450, 500, 23, 16, 16);
g.setColor(color4);
g.fillRoundRect(8, 450, percent(), 23, 16, 16);
g.drawImage(img3, 396, 5, null);
g.setColor(color3);
g.setStroke(stroke1);
g.drawRoundRect(8, 450, 500, 23, 16, 16);
g.setColor(color3);
g.fillRect(493, 347, 16, 15);
g.setColor(color4);
g.drawRect(493, 347, 16, 15);
g.setFont(new Font("Arial", Font.BOLD, 14));
g.drawString("X", 497, 360);
g.setColor(color5);
g.drawString(getPercentToLvl() + "%", 253, 468);// /At 55%
// exactly over
// the %
g.setColor(color3);
g.setColor(MOUSE);
g.drawImage(img2, ((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tX()) - 31),
((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tY()) - 31), null);
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
for (int i = 1; i < TOBANKCABBAGE.length; i++) {
TOBANKCABBAGE[i].drawTo(g1,
TOBANKCABBAGE[i - 1]);
}
} else {
for (int i = 1; i < TOBANK.length; i++) {
TOBANK[i].drawTo(g1, TOBANK[i - 1]);
}
}
} else {
for (int i = 1; i < TORUINS.length; i++) {
TORUINS[i].drawTo(g1, TORUINS[i - 1]);
}
}
}
} else {
g.setColor(color4);
g.fillRect(493, 347, 16, 15);
g.setColor(color3);
g.drawRect(493, 347, 16, 15);
g.setFont(new Font("Arial", Font.BOLD, 14));
g.drawString("O", 496, 360);
g.fillRoundRect(10, 314, 500, 23, 16, 16);
g.setColor(color4);
g.fillRoundRect(10, 314, percent(), 23, 16, 16);
g.drawImage(img3, 396, 5, null);
g.setColor(color3);
g.setStroke(stroke1);
g.drawRoundRect(10, 314, 500, 23, 16, 16);
g.setColor(color5);
g.drawString(getPercentToLvl() + "%", 255, 334);// /At 55%
// exactly over
// the %
g.setColor(color3);
g.setColor(MOUSE);
g.drawImage(img2, ((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tX()) - 31),
((int) (com.rsbuddy.script.methods.Mouse.getLocation().ge tY()) - 31), null);
if (com.rsbuddy.script.methods.Game.getCurrentTab() != Game.TAB_EQUIPMENT) {
if (!com.rsbuddy.script.methods.Inventory.containsOne Of(Constants.runeEssence)) {
if (useExplorersRing == true) {
for (int i = 1; i < TOBANKCABBAGE.length; i++) {
TOBANKCABBAGE[i].drawTo(g1,
TOBANKCABBAGE[i - 1]);
}
} else {
for (int i = 1; i < TOBANK.length; i++) {
TOBANK[i].drawTo(g1, TOBANK[i - 1]);
}
}
} else {
for (int i = 1; i < TORUINS.length; i++) {
TORUINS[i].drawTo(g1, TORUINS[i - 1]);
}
}
}
}
}
}
private static final String UPDATER_FILE_NAME = "PerfectCrafter.java";
private static final String UPDATER_URL = "Only the registered members can see the link.";
private static final Pattern UPDATER_VERSION_PATTERN = Pattern
.compile("version\\s*=\\s*([0-9.]+)");
private boolean checkForUpdates() {
try {
double currentVer = PerfectCrafter.class.getAnnotation(
com.rsbuddy.script.Manifest.class).version();
double newVer = -1;
URL url = new URL(UPDATER_URL);
BufferedReader in = new BufferedReader(new InputStreamReader(url
.openStream()));
String line, lines = "";
Matcher m;
while ((line = in.readLine()) != null) {
lines += line + "\n";
if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
newVer = Double.parseDouble(m.group(1));
break;
}
}
if (newVer < 0) {
in.close();
log("Unable to find the new version number. Update failed");
return false;
}
if (currentVer == newVer) {
in.close();
log("You already have the latest version of the script.");
return false;
}
log("Update found! Downloading version " + newVer);
String scriptFilePath = com.rsbuddy.script.methods.Environment.getStorageD irectory()
+ "\\" + UPDATER_FILE_NAME;
PrintWriter out = new PrintWriter(scriptFilePath);
out.print(lines);
while ((line = in.readLine()) != null)
out.println(line);
out.close();
in.close();
log("Successfully saved " + UPDATER_FILE_NAME + " to "
+ com.rsbuddy.script.methods.Environment.getStorageD irectory());
log("Compiling...");
try {
/* Attempt to compile the downloaded version */
Runtime.getRuntime().exec(
new String[] { "javac", "-classpath", "RSBot.jar",
scriptFilePath });
} catch (Exception ex) {
log("Could not compile the script. Please manually compile to finish the update.");
return false;
}
log("Update successful!");
log("The new version will appear near the bottom of the script selector.");
log("Stop and restart the script to run the newer version.");
return true;
} catch (IOException e) {
log(e.toString());
log("Update failed.");
}
return false;
}
// STOP: Code generated using Enfilade's Easel
private final class PerfectGUI extends JFrame {
private static final long serialVersionUID = 1L;
private JTabbedPane tabs;
private JCheckBox Explorer;
private JCheckBox restBox;
private JCheckBox Update;
private JButton submit;
private void init() {
setLocationRelativeTo(getRootPane());
setLayout(new GridLayout(2, 1));
tabs = new JTabbedPane();
tabs.setFocusable(false);
Explorer = new JCheckBox("Use Explorer's ring.");
restBox = new JCheckBox("use resting.");
Update = new JCheckBox("Check for updates.");
submit = new JButton("Start");
JPanel controls = new JPanel();
controls.setLayout(new GridLayout(3, 1));
JPanel Crafting = new JPanel();
Crafting.setLayout(new GridLayout(3, 1));
JPanel extra = new JPanel();
extra.setLayout(new GridLayout(3, 1));
setSize(200, 300);
setTitle("PerfectCrafter");
controls.add(restBox);
controls.add(Update);
controls.add(Explorer);
tabs.add(controls, "General");
add(tabs);
add(submit);
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
submit();
}
});
setVisible(true);
}
private void submit() {
checkUpdate = Update.isSelected();
useResting = restBox.isSelected();
if (Explorer.isSelected()) {
if (Explorer.isSelected()) {
log("Explorer's ring is selected");
useExplorersRing = true;
} else {
log("Explorer's ring is not selected");
useExplorersRing = false;
}
}
dispose();
}
}
}
Oh u changed graphics setting for your rsbuddy, ok nice work.
Steve
March 21st, 2011, 23:52
Oh u changed graphics setting for your rsbuddy, ok nice work.
Lol wow. You serious? That's not at all what I did.
Ramsin
March 21st, 2011, 23:54
Lol wow. You serious? That's not at all what I did.
No thats just something i noticed lol, because some scripts use locations. ex: fletching. I hate low graphics lol
Josh
March 21st, 2011, 23:56
I laughed when I saw "RSbuddy isn't all hacked and shit"
The people who made RSbuddy is Arbiter and his friend.
The people who hacked Powerbot is Arbiter and his friend.
PowerBot is now safe, as long as you don't run his script.
bl00dshooter
March 21st, 2011, 23:58
I laughed when I saw "RSbuddy isn't all hacked and shit"
The people who made RSbuddy is Arbiter and his friend.
The people who hacked Powerbot is Arbiter and his friend.
PowerBot is now safe, as long as you don't run his script.
No bot that doesn't sandbox (Only the registered members can see the link.(computer_security)) it's scripts is safe.
LocusofRune
March 26th, 2011, 18:48
Can you convert Conderoga's Chopper?
Powered by vBulletin® Version 4.1.9 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.