Skip to content

Instantly share code, notes, and snippets.

@JeroenMerks
Created May 3, 2011 11:49
Show Gist options
  • Save JeroenMerks/953202 to your computer and use it in GitHub Desktop.
Save JeroenMerks/953202 to your computer and use it in GitHub Desktop.
AIORuneCrafter 0.2
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
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.KeyEvent;
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.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import org.rsbot.event.events.MessageEvent;
import org.rsbot.event.listeners.MessageListener;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.methods.Bank;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.methods.GrandExchange.GEItem;
import org.rsbot.script.util.Timer;
import org.rsbot.script.wrappers.RSArea;
import org.rsbot.script.wrappers.RSModel;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSTile;
@ScriptManifest(authors = "Ubuntu4life", name = "AIORuneCrafter", version = 0.2, description = "Crafts all F2P runes.", website = "")
public class AIORuneCrafter extends Script implements PaintListener,
MessageListener, MouseListener {
// TODO place correct powerbot link
/**
* All possible states in the process of runecrafting
*/
private enum Action {
OPENBANK, DEPOSIT, WITHDRAW, WALKTORUINS, ENTERRUINS, WALKTOALTAR, CRAFTRUNE, TELEPORT, WALKTOGATE, OPENGATE, WALKTOPORTAL, LEAVEALTAR, WALKTOBANK, SLEEP, UNKNOWN
}
/**
* Determines what action needs to be taken
*
* @return Action
*/
public Action getAction() {
try {
if (game.getClientState() != 10)
return Action.SLEEP;
else {
if (!inventory.containsOneOf(runeEssence)
&& !inventory.isFull()) {
RSObject Booth = objects.getNearest(bankBoothID);
RSObject Chest = objects.getNearest(chestID);
if (Rune == 554 ? Chest != null // Fire chest
&& isPartiallyOnScreen(Chest.getModel())
: Booth != null
&& isPartiallyOnScreen(Booth.getModel())) {
if (!bank.isOpen())
return Action.OPENBANK;
if (inventory.contains(Rune))
return Action.DEPOSIT;
return Action.WITHDRAW;
} else {
if (inAltarArea()) {
RSObject Portal = objects.getNearest(portalID);
if (Portal != null
&& isPartiallyOnScreen(Portal.getModel()))
return Action.LEAVEALTAR;
return Action.WALKTOPORTAL;
} else
return Action.WALKTOBANK;
}
} else {
if (inAltarArea()) {
RSObject Altar = objects.getNearest(altarID);
if (Altar != null
&& isPartiallyOnScreen(Altar.getModel()))
return Action.CRAFTRUNE;
return Action.WALKTOALTAR;
} else {
RSObject Ruins = objects.getNearest(ruinsID);
if (Ruins != null
&& isPartiallyOnScreen(Ruins.getModel()))
return Action.ENTERRUINS;
return Action.WALKTORUINS;
}
}
}
} catch (Exception e) {
return Action.UNKNOWN;
}
}
/*
* All variables the script needs to start. Air runecrafting variables are
* set by default.
*/
private boolean Pressed = true, stoppingScript = false;
private final int INTERFACE_RUN_ORB = 750, RUN_CHILD_ID = 1;
private int[] bankerID = Bank.BANKERS; // TODO
// streamline
private int bankBoothID = 782, chestID = 27663, runesCrafted = 0,
essUsed = 0, craftMode = 0, runeEssence = 1436, Rune = 556,
Tiara = 5527, ruinsID = 2452, altarID = 2478, portalID = 2465,
musicianID = 8699, stairsID = 24353, uniqueNumber, screenLevel,
essPrice, runePrice, nextPercentageRun, nextPercentageRest;
private long startTime, startExp, startLevel;
public long expGained;
public String Status = "Starting...";
private final Color lineColor = new Color(90, 15, 15);
private final Color fillColor = new Color(0, 0, 0, 80);
// private final Color color3 = new Color(0, 255, 255);
private final Color Succes = new Color(0, 0, 255);
private final Color Fail = new Color(255, 0, 0);
private final Color Mouse = new Color(20, 26, 167, 85);
private java.util.Random Unique, f = new java.util.Random();
private PerfectGUI GUI;
private Timer hourTimer;
Thread screenShotter = new Thread(new screenShotter());
Thread freeMemory = new Thread(new freeMemory());
Thread antiBan = new Thread(new antiBan());
Image img1, img2, closed, tabOne, tabTwo;
RSArea ALTAR_AREA = new RSArea(new RSTile(2835, 4823), new RSTile(2851,
4843));
RSTile altarWalkTile = new RSTile(2843, 4832), portalWalkTile = new RSTile(
2841, 4829), errorTile1 = new RSTile(3250, 3419),
errorTile2 = new RSTile(3257, 3419);// Two tiles where banking is
// not possible in Varrock east
// bank.
private ArrayList<RSTile> pathList;
private Line[] TOBANK = { // Fire is special
new Line(3323, 3247, 3323, 3248), new Line(3325, 3247, 3325, 3264),
new Line(3328, 3264, 3328, 3269),
new Line(3335, 3265, 3335, 3270),
new Line(3348, 3265, 3348, 3271),
new Line(3353, 3262, 3353, 3267),
new Line(3367, 3262, 3367, 3269),
new Line(3372, 3264, 3372, 3267),
new Line(3380, 3265, 3380, 3266),
new Line(3382, 3267, 3382, 3272),
new Line(3383, 3267, 3383, 3272) },
TORUINS = { // Air
new Line(3182, 3435, 3182, 3440), new Line(3173, 3425, 3173, 3433),
new Line(3164, 3418, 3163, 3425),
new Line(3153, 3415, 3153, 3425),
new Line(3145, 3413, 3145, 3418),
new Line(3136, 3403, 3136, 3417),
new Line(3127, 3403, 3127, 3407) };
@Override
public boolean onStart() {
if (!game.isFixed()) {
log
.severe("It is highly recommended to bot with fixed screen mode.");
return false;
}
GUI = new PerfectGUI();
GUI.setAlwaysOnTop(true);
while (!GUI.startScript) {
if (GUI.close)
return false;
else {
try {
camera.setPitch(true);
Unique = generateSeededRandom(getMyPlayer().getName());
uniqueNumber = Unique.nextInt(16);
sleep(100);
} catch (Exception e) {
log(e.getMessage());
}
}
}
log.info("Loading AIORuneCrafter "
+ getClass().getAnnotation(ScriptManifest.class).version());
if (inventory.contains(Tiara))
inventory.getItem(Tiara).doAction("Wear");
if (equipment.containsOneOf(Tiara))
log(Succes, "Tiara detected");
else {
log(Fail, "Cannot detect your tiara. Script stopping");
return false;
}
startExp = (long) skills.getCurrentExp(skills.RUNECRAFTING);
startLevel = (long) skills.getRealLevel(skills.RUNECRAFTING);
startTime = (long) System.currentTimeMillis();
log("Loading prices...");
new Thread(new Runnable() {
public void run() {
closed = getImage("http://img546.imageshack.us/img546/368/closedc1.png");
tabOne = getImage("http://img189.imageshack.us/img189/3391/gentab1.png");
tabTwo = getImage("http://img36.imageshack.us/img36/1476/exptab2.png");
img1 = getImage("http://www.rw-designer.com/cursor-view/13449.png");
img2 = getImage("http://www.ubuntu.com/sites/default/themes/ubuntu10/images/footer_logo.png");
GEItem rune = grandExchange.lookup(Rune);
GEItem ess = grandExchange.lookup(runeEssence);
runePrice = rune.getGuidePrice();
essPrice = ess.getGuidePrice();
}
}).start();
if (inventory.containsOneOf(runeEssence))
pathList = generatePath(TORUINS);
else
pathList = generatePath(reverse(TORUINS));
nextPercentageRun = randomGauss(3, 43, (uniqueNumber + 14), 12);
nextPercentageRest = randomGauss(0, 38, (uniqueNumber + 9), 11);
freeMemory.start();
return true;
}
@Override
public void onFinish() {
stoppingScript = true;
if (GUI.screenOnFinish)
env.saveScreenshot(false);
if (GUI.screenOnHour || GUI.screenOnLevel) {
while (screenShotter.isAlive()) {
if (screenShotter.isAlive()) {
screenShotter.interrupt();
if (screenShotter.isInterrupted()) {
}
}
}
}
while (antiBan.isAlive()) {
if (antiBan.isAlive()) {
antiBan.interrupt();
if (antiBan.isInterrupted()) {
}
}
}
while (freeMemory.isAlive()) {
if (freeMemory.isAlive()) {
freeMemory.interrupt();
if (freeMemory.isInterrupted()) {
}
}
}
long runTime = System.currentTimeMillis() - startTime;
long gainedXP = skills.getCurrentExp(Skills.RUNECRAFTING) - startExp;
long gainedLevels = skills.getRealLevel(Skills.RUNECRAFTING)
- startLevel;
int profit = (runePrice * runesCrafted) - (essPrice * essUsed);
log("Total XP gained: " + getFormattedMoney(gainedXP) + ".");
log("Total Levels gained: " + gainedLevels + ".");
log("Total Runes crafted: " + getFormattedMoney(runesCrafted) + ".");
log("Total Essence used: " + getFormattedMoney(essUsed) + ".");
log("Total Profit made: " + getFormattedMoney(profit) + ".");
log("Total Run time: " + getFormattedTime(runTime) + ".");
stopScript(true);
}
private int tab = 1;
@Override
public void mouseClicked(MouseEvent e) {
if (hideRect.contains(e.getPoint())) {
tab = 3;
} else if (tabOneRect.contains(e.getPoint())) {
tab = 1;
} else if (tabTwoRect.contains(e.getPoint())) {
tab = 2;
}
}
@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) {
}
private boolean inAltarArea() {
return ALTAR_AREA.contains(getMyPlayer().getLocation());
}
@Override
public int loop() {
try {
if (!antiBan.isAlive() && GUI.antiban) {
log.info("Antiban Engaging");
antiBan.start();
}
mouse.setSpeed(random(GUI.minMouse, GUI.maxMouse));
if (GUI.antiban)
antiBan();
if (craftMode == 1) {
runesCrafted = runesCrafted + inventory.getCount(true, Rune);
essUsed = essUsed + 28;
craftMode = 0;
}
if (!walking.isRunEnabled()
&& walking.getEnergy() >= nextPercentageRun
&& !bank.isOpen()) {
interfaces.get(INTERFACE_RUN_ORB).getComponent(RUN_CHILD_ID)
.doAction("turn run mode on");
nextPercentageRun = randomGauss(4, 43, (uniqueNumber + 14), 12);
}
if (GUI.restMode && !bank.isOpen()) {
if (Rune == 556 || Rune == 557 || Rune == 558) { // Resting at a
// musician
if (walking.getEnergy() < random(29, 38)) {
RSNPC Musician = npcs.getNearest(musicianID);
if (Musician != null
&& isPartiallyOnScreen(Musician.getModel())) {
if (clickNPC(Musician, "Listen-to")) {
sleepToMove(random(1500, 2000));
if (!players.getMyPlayer().isMoving())
return 1;
for (int i = 0; i < 75
&& players.getMyPlayer().getAnimation() == -1; i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(20, 30));
}
if (players.getMyPlayer().getAnimation() == -1)
return 1;
Status = "Resting";
int energy = walking.getEnergy();
int maxsleep = 0;
int targetEnergy = randomGauss(64, 100,
(uniqueNumber + 47), 10);
while (energy <= targetEnergy
&& maxsleep++ <= 1401) {
sleep(random(20, 30));
energy = walking.getEnergy();
}
}
}
}
} else { // Normal resting
if (walking.getEnergy() <= nextPercentageRest) {
int energy = walking.getEnergy();
mouse.setSpeed(random(5, 8));
interfaces.getComponent(750, 6).doAction("Rest");
for (int i = 0; i < 90
&& getMyPlayer().getAnimation() == -1; i++)
sleep(random(20, 30));
if (getMyPlayer().getAnimation() == -1)
return 1;
Status = "Resting";
energy = walking.getEnergy();
int maxsleep = 0;
int targetEnergy = randomGauss(74, 99,
(uniqueNumber + 57), 11);
while (energy <= targetEnergy && maxsleep++ <= 1401) {
sleep(random(20, 30));
energy = walking.getEnergy();
}
nextPercentageRest = randomGauss(0, 38,
(uniqueNumber + 9), 11);
}
}
}
if (Rune == 557) { // Earth runecrafting failsafes
if (game.getPlane() == 1) {
RSObject Stairs = objects.getNearest(stairsID);
for (int i = 0; i < 150; i++) {
if (Stairs != null) {
if (Stairs.isOnScreen()) {
Status = "Getting of stairs";
Stairs.doAction("Climb");
sleepToMove(random(1000, 1300));
if (!players.getMyPlayer().isMoving())
return 1;
for (int o = 0; o < 100 && game.getPlane() == 1; o++) {
if (players.getMyPlayer().isMoving()
|| getMyPlayer().getAnimation() != -1
|| game.getClientState() != 10)
o = 0;
sleep(random(5, 15));
}
if (game.getPlane() == 1)
return 1;
} else
walking.walkTo(Stairs.getLocation());
}
if (i == 149 && Stairs == null) {
log("Stuck somewhere.");
stoppingScript = true;
stopScript(true);
}
sleep(random(20, 30));
}
}
if (players.getMyPlayer().getLocation().equals(errorTile1)
&& getAction() == Action.OPENBANK
|| players.getMyPlayer().getLocation().equals(
errorTile2) && getAction() == Action.OPENBANK) {
RSNPC Banker = npcs.getNearest(bankerID);
if (clickNPC(Banker, "Bank Banker")) {
Status = "Opening bank";
for (int i = 0; i < 100 && !bank.isOpen(); i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(5, 15));
}
if (!bank.isOpen())
return 1;
}
}
}
switch (getAction()) {
case OPENBANK:
Status = "Opening bank";
if (Rune == 554) { // Fire runecrafting banks in a chest
RSObject Chest = objects.getNearest(chestID);
if (calc.distanceTo(Chest.getLocation()) >= 2) {
if (clickObject(Chest, "Bank Bank Chest", false)) {
sleepToMove(random(1500, 2000));
if (!players.getMyPlayer().isMoving())
return 1;
for (int i = 0; i < 100 && !bank.isOpen(); i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(5, 15));
}
}
} else {
if (clickObject(Chest, "Bank Bank Chest", true)) {
for (int i = 0; i < 100 && !bank.isOpen(); i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(5, 15));
}
}
}
} else { // Other runes use the normal bankBooth
RSObject Booth = objects.getNearest(bankBoothID);
if (calc.distanceTo(Booth.getLocation()) >= 2) {
if (clickObject(Booth, "Use-quickly", false)) {
sleepToMove(random(1500, 2000));
if (!players.getMyPlayer().isMoving())
return 1;
for (int i = 0; i < 100 && !bank.isOpen(); i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(5, 15));
}
}
} else {
if (clickObject(Booth, "Use-quickly", true)) {
for (int i = 0; i < 100 && !bank.isOpen(); i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(5, 15));
}
}
}
}
break;
case DEPOSIT:
Status = "Depositing";
mouse.setSpeed(random(5, 8));
bank.depositAll();
for (int i = 0; i < 75 && inventory.getCount() != 0; i++)
sleep(random(20, 30));
break;
case WITHDRAW:
Status = "Withdrawing";
mouse.setSpeed(random(5, 8));
for (int i = 0; i < 150; i++) {
if (bank.getCount(runeEssence) >= 1)
break;
if (i == 149 && bank.getCount(runeEssence) == 0) {
log("Ran out of rune essence.");
stoppingScript = true;
stopScript(true);
}
sleep(random(20, 30));
}
int invCount = inventory.getCount();
bank.withdraw(runeEssence, 0);
for (int i = 0; i < 75 && invCount == inventory.getCount(); i++)
sleep(random(20, 30));
if (invCount == inventory.getCount())
return 1;
for (int i = 0; i < 75; i++) {
if (inventory.getCount(true, runeEssence) >= 1) {
pathList = generatePath(TORUINS);
break;
}
sleep(random(20, 30));
}
break;
case WALKTORUINS:
Status = "Walking to ruins";
step(pathList);
break;
case ENTERRUINS:
Status = "Entering ruins";
RSObject Ruins = objects.getNearest(ruinsID);
if (calc.distanceTo(Ruins.getLocation()) >= 3) {
if (clickObject(Ruins, "Enter", false)) {
sleepToMove(random(1500, 2000));
if (!players.getMyPlayer().isMoving())
return 1;
for (int i = 0; i < 100 && !inAltarArea(); i++) {
if (players.getMyPlayer().isMoving()
|| game.getClientState() != 10)
i = 0;
sleep(random(5, 15));
}
}
} else {
if (clickObject(Ruins, "Enter", true)) {
for (int i = 0; i < 100 && !inAltarArea(); i++) {
if (players.getMyPlayer().isMoving()
|| game.getClientState() != 10)
i = 0;
sleep(random(5, 15));
}
}
}
break;
case WALKTOALTAR:
Status = "Walking to altar";
RSObject Altar = objects.getNearest(altarID);
if (walking.walkTo(altarWalkTile.randomize(3, 3))) {
if (calc.distanceTo(Altar.getLocation()) >= 2) {
sleepToMove(random(1500, 2000));
if (!players.getMyPlayer().isMoving())
return 1;
}
for (int i = 0; i < 100 && Altar == null
|| !isPartiallyOnScreen(Altar.getModel()); i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(5, 15));
}
}
break;
case CRAFTRUNE:
Status = "Crafting pure essence";
RSObject Altar2 = objects.getNearest(altarID);
if (inventory.containsOneOf(runeEssence)) {
if (calc.distanceTo(Altar2.getLocation()) >= 3) {
if (clickObject(Altar2, "Craft-rune", false)) {
if (Rune == 554) // Fire rune
pathList = generatePath(TOBANK);
else
pathList = generatePath(reverse(TORUINS));
int count = inventory.getCount(true, Rune);
sleepToMove(random(1500, 2000));
if (!players.getMyPlayer().isMoving())
return 1;
for (int i = 0; i < 100
&& count == inventory.getCount(true, Rune); i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(5, 15));
}
if (count == inventory.getCount(true, Rune))
return 1;
sleep(random(1463, 2163));
}
} else {
if (clickObject(Altar2, "Craft-rune", true)) {
if (Rune == 554)
pathList = generatePath(TOBANK);
else
pathList = generatePath(reverse(TORUINS));
int count = inventory.getCount(true, Rune);
for (int i = 0; i < 100
&& count == inventory.getCount(true, Rune); i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(5, 15));
}
if (count == inventory.getCount(true, Rune))
return 1;
sleep(random(763, 2163));
}
}
}
break;
case WALKTOPORTAL:
Status = "Walking to portal";
RSObject Portal = objects.getNearest(portalID);
if (walking.walkTo(portalWalkTile.randomize(3, 3))) {
if (calc.distanceTo(Portal.getLocation()) >= 2) {
sleepToMove(random(1500, 2000));
if (!players.getMyPlayer().isMoving())
return 1;
}
for (int i = 0; i < 100 && Portal != null
&& !isPartiallyOnScreen(Portal.getModel()); i++) {
if (players.getMyPlayer().isMoving())
i = 0;
sleep(random(5, 15));
}
}
break;
case LEAVEALTAR:
RSObject Portal2 = objects.getNearest(portalID);
Status = "Leaving altar";
if (calc.distanceTo(Portal2.getLocation()) >= 2) {
if (clickObject(Portal2, "Enter", false)) {
sleepToMove(random(1500, 2000));
if (!players.getMyPlayer().isMoving())
return 1;
for (int i = 0; i < 100 && inAltarArea(); i++) {
if (players.getMyPlayer().isMoving()
|| game.getClientState() != 10)
i = 0;
sleep(random(5, 15));
}
}
} else {
if (clickObject(Portal2, "Enter", true)) {
for (int i = 0; i < 100 && inAltarArea(); i++) {
if (players.getMyPlayer().isMoving()
|| game.getClientState() != 10)
i = 0;
sleep(random(5, 15));
}
}
}
break;
case WALKTOBANK:
Status = "Walking to bank";
step(pathList);
break;
case SLEEP:
sleep(random(180, 420));
break;
}
} catch (Exception e) {
log(e.getMessage());
}
return (randomGauss(random(189, 191), random(428, 431), 251, 40));
}
/*
* Looped AntiBan
*/
private void antiBan() {
int random = random(1, 9);
while (game.getClientState() == 10) {
switch (random) {
case 1:
if (random(1, 17) != 1)
return;
mouse.move(random(10, 750), random(10, 495));
if (random(1, 7) == 1)
mouse.move(random(10, 750), random(10, 495));
return;
case 2:
if (random(1, 12) != 1)
return;
mouse.moveSlightly();
return;
case 3:
if (random(1, 18) != 1)
return;
if (random(1, 11) == 1)
camera.setPitch(true);
int angle = camera.getAngle() + random(-45, 45);
if (angle < 0)
angle = random(0, 10);
if (angle > 359)
angle = random(0, 10);
char whichDir = 37;
if (random(0, 100) < 50)
whichDir = 39;
keyboard.pressKey(whichDir);
sleep(random(100, 700));
keyboard.releaseKey(whichDir);
return;
default:
return;
}
}
}
/*
* Multithreaded AntiBan Credits go to Unknown500 for the AntiBan skeleton
* code
*/
private class antiBan implements Runnable {
private Random randomGenerator;
@Override
public void run() {
randomGenerator = new Random();
try {
while (game.isLoggedIn() && !game.isLoginScreen()
&& !isPaused() && !stoppingScript) {
int rand = randomGenerator.nextInt(23);
if (rand == 4) {
final char[] LR = new char[] { KeyEvent.VK_LEFT,
KeyEvent.VK_RIGHT };
final char[] UD = new char[] { KeyEvent.VK_DOWN,
KeyEvent.VK_UP };
final char[] LRUD = new char[] { KeyEvent.VK_LEFT,
KeyEvent.VK_RIGHT, KeyEvent.VK_UP,
KeyEvent.VK_UP };
final int random1 = random(0, 2);
final int random2 = random(0, 2);
final int random4 = random(0, 4);
if (random(0, 3) == 0) {
keyboard.pressKey(LR[random1]);
Thread.sleep(random(104, 403));
keyboard.pressKey(UD[random2]);
Thread.sleep(random(308, 601));
keyboard.releaseKey(UD[random2]);
Thread.sleep(random(106, 405));
keyboard.releaseKey(LR[random1]);
} else {
keyboard.pressKey(LRUD[random4]);
if (random4 > 1)
Thread.sleep(random(301, 604));
else {
Thread.sleep(random(502, 906));
keyboard.releaseKey(LRUD[random4]);
}
}
} else
Thread.sleep(random(189, 2163));
}
} catch (InterruptedException e) {
log(e.getMessage());
}
}
}
/*
* Multithreaded Java garbage collector.
*/
class freeMemory implements Runnable {
@Override
public void run() {
while (game.isLoggedIn() && !game.isLoginScreen()
&& !stoppingScript) {
try {
if (random(0, 450) == 3) {
Runtime r = Runtime.getRuntime();
r.gc();
}
Thread.sleep(random(1000, 1500));
} catch (InterruptedException e) {
log(e.getMessage());
}
}
}
}
/*
* Multithreaded screenshot manager.
*/
private class screenShotter implements Runnable {
@Override
public void run() {
while (game.isLoggedIn() && !game.isLoginScreen() && !isPaused()
&& !stoppingScript) {
try {
if (GUI.screenOnLevel) {
if (skills.getRealLevel(Skills.RUNECRAFTING)
- screenLevel > 0) {
screenLevel = skills
.getRealLevel(Skills.RUNECRAFTING);
env.saveScreenshot(false);
}
}
if (GUI.screenOnHour) {
if (!hourTimer.isRunning()) {
hourTimer.reset();
env.saveScreenshot(false);
}
}
Thread.sleep(random(1000, 3000));
} catch (InterruptedException e) {
log(e.getMessage());
}
}
}
}
/*
* Server message listener.
*/
@Override
public void messageReceived(MessageEvent e) {
String msg = e.getMessage();
if (msg.contains("runes"))
craftMode = 1;
if (msg.contains("advanced a Runecrafting level")) {
log("Congratulations on level up !");
log("Your level is now "
+ skills.getCurrentLevel(Skills.RUNECRAFTING) + ".");
}
if (msg.toLowerCase().contains("The next Runescape")) {
log("There will be a system update soon, logged out.");
stoppingScript = true;
stopScript(true);
}
if (msg.contains("Oh dear")) {
stoppingScript = true;
stopScript(true);
log("Dead :/");
}
}
private final Rectangle hideRect = new Rectangle(477, 336, 34, 37);
private final Rectangle tabOneRect = new Rectangle(177, 335, 147, 37);
private final Rectangle tabTwoRect = new Rectangle(327, 336, 148, 37);
/*
* Java render paint.
*/
@Override
public void onRepaint(Graphics g) {
if (game.isLoggedIn() && !game.isLoginScreen() && !stoppingScript) {
Graphics2D g2 = (Graphics2D) g;
((Graphics2D) g2).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
((Graphics2D) g2).setRenderingHint(
RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
((Graphics2D) g2).setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
((Graphics2D) g2).setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
long millis = System.currentTimeMillis() - startTime;
if (millis <= 0)
millis = 1;
if ((skills.getCurrentExp(skills.RUNECRAFTING) - startExp) > 0
&& startExp > 0)
expGained = skills.getCurrentExp(skills.RUNECRAFTING)
- startExp;
if (Rune == 554) { // Fire rune
if (getAction() == Action.WALKTORUINS)
for (int i = 1; i < TORUINS.length; i++)
TORUINS[i].drawTo(g2, TORUINS[i - 1]);
else
for (int i = 1; i < TOBANK.length; i++)
TOBANK[i].drawTo(g2, TOBANK[i - 1]);
} else
for (int i = 1; i < TORUINS.length; i++)
TORUINS[i].drawTo(g2, TORUINS[i - 1]);
g2.setColor(Mouse);
g2.drawImage(img1, ((int) (mouse.getLocation().getX()) - 31),
((int) (mouse.getLocation().getY()) - 31), null);
g2.drawImage(img2, 396, 5, null);
long expPerHour = (expGained * 3600000l) / millis;
int profit = (runePrice * runesCrafted) - (essPrice * essUsed);
long craftedPerHour = (runesCrafted * 3600000l) / millis;
long essUsedPerHour = (essUsed * 3600000l) / millis;
long profitPerHour = (profit * 3600000l) / millis;
g.setColor(new Color(90, 15, 15));
g.setFont(new Font("Serif", 0, 12));
if (tab == 1) { // General
g.drawImage(tabOne, -1, 293, null);
g2.drawString("Time running: " + getFormattedTime(millis), 19,
365);
if (runesCrafted > 0) {
g2.drawString("Runes crafted: "
+ getFormattedMoney(runesCrafted) + " ("
+ getFormattedMoney(craftedPerHour) + "/hr)", 19,
417);
g2.drawString(
"Essence used: " + getFormattedMoney(essUsed)
+ " (" + getFormattedMoney(essUsedPerHour)
+ "/hr)", 19, 433);
} else {
}
} else if (tab == 2) { // exp and cash
g.drawImage(tabTwo, -1, 293, null);
g.setColor(new Color(153, 153, 153));
g.drawRect(19, 390, 150, 15);
g.setColor(new Color(0, 0, 0, 80));
g.fillRect(19, 390, (int) (skills
.getPercentToNextLevel(Skills.RUNECRAFTING) * 1.5), 15);
g.drawString(skills.getPercentToNextLevel(skills.RUNECRAFTING)
+ " %", 83, 390 + 12);
g.setColor(new Color(90, 15, 15));
g.setFont(new Font("Serif", 0, 12));
long timeToLevel = 0;
String timeToLevel2 = "Calculating";
if (expPerHour > 0) {
timeToLevel = (long) (skills
.getExpToNextLevel(Skills.RUNECRAFTING) * 60 / expPerHour);
if (timeToLevel >= 60) {
long thours = (int) timeToLevel / 60;
long tmin = (timeToLevel - (thours * 60));
timeToLevel2 = thours + " Hours, " + tmin + " Minutes";
} else
timeToLevel2 = timeToLevel + " Minutes";
}
g2.drawString("Time till level: " + timeToLevel2, 19, 433);
g2.drawString("XP gained: " + getFormattedMoney(expGained)
+ " (" + getFormattedMoney(expPerHour) + "/hr)", 19,
449);
g2.drawString("Profit made: " + getFormattedMoney(profit)
+ " gp" + " (" + getFormattedMoney(profitPerHour)
+ "/hr)", 19, 465);
} else { // closed
g.drawImage(closed, 162, 293, null);
}
}
}
/**
* Formats time to DD:HH:MM:SS:MSMS with days and millis optional.
*
* @author Equinox_
* @param timeMillis
* Milliseconds of time
* @param sep
* Seperation character
* @param millisInc
* True when include milliseconds
* @return
*/
public static String getFormattedTime(final long timeMillis, String sep,
boolean millisInc) {
long millis = timeMillis;
final long days = millis / (24 * 1000 * 60 * 60);
millis -= days * (24 * 1000 * 60 * 60);
final long hours = millis / (1000 * 60 * 60);
millis -= hours * 1000 * 60 * 60;
final long minutes = millis / (1000 * 60);
millis -= minutes * 1000 * 60;
final long _seconds = millis / 1000;
millis -= _seconds * 1000;
String dayString = String.valueOf(days);
String hoursString = String.valueOf(hours);
String minutesString = String.valueOf(minutes);
String secondsString = String.valueOf(_seconds);
if (hours < 10) {
hoursString = 0 + hoursString;
}
if (minutes < 10) {
minutesString = 0 + minutesString;
}
if (_seconds < 10) {
secondsString = 0 + secondsString;
}
String s = "";
if (days > 0)
s = dayString + sep;
s += hoursString + sep + minutesString + sep + secondsString;
if (millisInc)
s += sep + String.valueOf(millis);
return s;
}
public static String getFormattedTime(final long timeMillis) {
return getFormattedTime(timeMillis, ":", false);
}
/**
* Formats a specified amount into thousands, millions or billions, then
* adds the proper suffix.
*
* @author Equinox_
* @param Money
* the amount of money
* @return The formatted string
*/
public static String getFormattedMoney(long money) {
/*
* String suffix = ""; int t = 1; if (money >= 10000) { t *= 1000;
* suffix = "K"; } if (money / t > 10000) { t *= 1000; suffix = "M"; }
* if (money / t > 10000) { t *= 1000; suffix = "B"; } return
* String.valueOf((money / t)) + suffix;
*/
return new DecimalFormat("###,###,###,###,###,###").format(money);
}
/**
* Extracts images from an external server.
*
* @param url
* To extract image from
* @return Image
*/
private Image getImage(String url) {
try {
return ImageIO.read(new URL(url));
} catch (IOException e) {
return null;
}
}
/**
* Returns a pseudorandom, Gaussian ("normally") distributed value with
* provided mean and standard deviation.
*
* @param lo
* @param hi
* @param d
* @param sd
* @return Random integer min <= n < max from the normal distribution
* described by the parameters.
*/
private int randomGauss(int lo, int hi, double d, double sd) {
int rand;
do {
rand = (int) (f.nextGaussian() * sd + d);
} while (rand < lo || rand >= hi);
return rand;
}
/**
* Checks if the mouse is within the bounds of the model.
*
* @param Java
* point p
* @param RSObject
* object
* @return true if the point is within the bounds of the model
*/
private boolean mouseOnObjectModel(Point p, RSObject object) {
if (object == null)
return false;
Polygon[] triangles = object.getModel().getTriangles();
for (Polygon poly : triangles) {
if (poly.contains(p))
return true;
}
return false;
}
private boolean mouseOnNPCModel(Point p, RSNPC npc) {
if (npc == null)
return false;
Polygon[] triangles = npc.getModel().getTriangles();
for (Polygon poly : triangles) {
if (poly.contains(p))
return true;
}
return false;
}
/**
* Clicks the RSModel and clicks the menu action.
*
* @param object
* that needs to be clicked
* @param action
* the action to be clicked in the menu
* @param random
* when a point on the object needs to be randomly clicked
* @return True when clicked successfully
*/
private boolean clickObject(RSObject object, String action, boolean random) {
try {
for (int x = 0; x < 45; x++) {
Point p;
for (p = getCentralPoint(object.getModel()); !menu
.contains(action); p = random ? object.getModel()
.getPoint() : getCentralPoint(object.getModel())) {
if (!isPartiallyOnScreen(object.getModel()) || p.x == -1
|| p.y == -1 || bank.isOpen())
return false;
moveMouse(random(20, 30), p);
}
String[] items = menu.getItems();
if (items.length > 0
&& items[0].toLowerCase().startsWith(
action.toLowerCase())) {
if (mouseOnObjectModel(mouse.getLocation(), object)) {
mouse.click(true);
return true;
}
} else if (menu.contains(action)) {
mouse.setSpeed(random(5, 8));
mouse.click(false);
for (int i = 0; i < 4; i++) {
if (menu.doAction(action))
return true;
}
}
}
if (!menu.contains(action) && menu.isOpen()) {
do {
mouse.moveRandomly(random(180, 422));
} while (menu.isOpen());
return false;
}
} catch (Exception e) {
}
return false;
}
private boolean clickNPC(RSNPC npc, String action) {
try {
for (int x = 0; x < 45; x++) {
Point p;
for (p = getCentralPoint(npc.getModel()); !menu
.contains(action); p = getCentralPoint(npc.getModel())) {
if (!isPartiallyOnScreen(npc.getModel()) || p.x == -1
|| p.y == -1 || bank.isOpen())
return false;
moveMouse(random(20, 30), p);
}
String[] items = menu.getItems();
if (items.length > 0
&& items[0].toLowerCase().startsWith(
action.toLowerCase())) {
if (mouseOnNPCModel(mouse.getLocation(), npc)) {
mouse.click(true);
return true;
}
} else if (menu.contains(action)) {
mouse.setSpeed(random(5, 8));
mouse.click(false);
for (int i = 0; i < 4; i++) {
if (menu.doAction(action))
return true;
}
}
}
if (!menu.contains(action) && menu.isOpen()) {
do {
mouse.moveRandomly(random(180, 422));
} while (menu.isOpen());
return false;
}
} catch (Exception e) {
}
return false;
}
/**
* Checks if a model is partially on screen.
*
* @author !@!@
* @param m
* The RSModel to check.
* @return True if any point on the model is on screen.
*/
private boolean isPartiallyOnScreen(RSModel m) {
return getPointOnScreen(m, true) != null;
}
/**
* Gets a point on a model that is on screen.
*
* @author !@!@
* @param m
* The RSModel to test.
* @param first
* If true, it will return the first point that it finds on
* screen.
* @return A random point on screen of an object.
*/
private Point getPointOnScreen(RSModel 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 (calc.pointOnScreen(pt)) {
if (first) {
return pt;
}
list.add(pt);
}
}
}
} catch (Exception e) {
}
return list.size() > 0 ? list.get(random(0, list.size())) : null;
}
/**
* Generates a rough central point. Performs the calculation by first
* generating a rough point, and then finding the point closest to the rough
* point that is actually on the RSModel.
*
* @author !@!@
* @param m
* The RSModel to test.
* @return The rough central point.
*/
private Point getCentralPoint(RSModel 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 (!calc.pointOnScreen(p))
continue;
double dist2 = distanceBetween(central, p);
if (curCentral == null || dist2 < dist) {
curCentral = p;
dist = dist2;
}
}
}
return curCentral;
} catch (Exception e) {
}
return null;
}
/**
* Calculates the distance between two points.
*
* @author !@!@
* @param p1
* The first point.
* @param p2
* The second point.
* @return The distance between the two points, using the distance formula.
*/
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)));
}
/**
* Walks to the given tile using the minimap with given randomness. Updates
* Java point.
*
* @author Ubuntu4life
*
* @param t
* The tile to walk to.
* @param x
* The x randomness.
* @param y
* The y randomness.
* @return <tt>true</tt> if the tile was clicked; otherwise <tt>false</tt>.
*/
private boolean walkTile(RSTile t, int x, int y) {
RSTile dest = new RSTile(t.getX() + random(0, x), t.getY()
+ random(0, y));
Point p;
for (p = calc.tileToMinimap(dest); !mouse.getLocation().equals(p); p = calc
.tileToMinimap(dest)) {
if (p.x == -1 || p.y == -1)
return false;
moveMouse(10, p);
}
mouse.click(true);
return true;
}
/**
*
* @param time
* The ms that the mouse needs to move towards the point.
* @param p
* The point to move to.
*/
private void moveMouse(int time, Point p) {
long endTime = System.currentTimeMillis() + time;
while (System.currentTimeMillis() < endTime)
mouse.move(p, 0, 0);
}
/**
* Sleeps as long as player does not walk.
*
* @param timeout
* Time to wait for the player to walk
* @return <tt>true</tt> if player moved in time; otherwise <tt>false</tt>.
*/
private boolean sleepToMove(int timeout) {
long endTime = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < endTime) {
if (getMyPlayer().isMoving())
return true;
sleep(random(5, 15));
}
return false;
}
/**
* Makes hash from player's name. This way every individual botter has it's
* own rest/run 'characteristic'.
*
* @param name
* The player's name.
* @return Random int.
*/
private java.util.Random generateSeededRandom(String name) {
MessageDigest coder;
try {
coder = MessageDigest.getInstance("MD5");
coder.update(name.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();
}
// Credits go to Enfilade for this epic walking method
/**
* Gets the tile distance between next tile and the current player position
* needed before clicking on it. Respects the Gaussian law.
*/
private int nextStep = randomGauss(16, 19, 17.5, 0.9);
private boolean tileInNextRange(RSTile t) {
return calc.distanceBetween(t, getMyPlayer().getLocation()) < nextStep;
}
/**
* Clicks on the next tile when either the next tile is in range, a shorter
* path is possible or the player has not moved for some time when it
* supposed to.
*
* @author Enfilade
* @param path
* @return <tt>-1</tt> if closest tile has been clicked; otherwise
* <tt>new int to closer tile</tt>.
*/
private int step(ArrayList<RSTile> path) {
if (calc.distanceBetween(getMyPlayer().getLocation(), path.get(path
.size() - 1)) < 2)
return path.size();
RSTile dest = walking.getDestination();
int index = -1;
int shortestDist = 0, dist, shortest = -21;
if (dest != null) {
for (int i = 0; i < path.size(); i++) {
dist = (int) calc.distanceBetween(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) || !sleepToMove(random(
20, 30)))) {
if (walkTile(path.get(index), 0, 0))
sleepToMove(random(600, 900));
nextStep = randomGauss(16, 19, 17.5, 0.9);
return index;
}
if (!sleepToMove(random(8000, 12000)))
path.get(getNearestTile(path));
return -1;
}
/**
* Gets the nearest tile from the RSTile array of path.
*
* @author Enfilade
* @param path
* @return int RSTile in array of generated path
*/
private int getNearestTile(ArrayList<RSTile> path) {
int shortest = 0;
int shortestDist = calc.distanceTo(path.get(0)), dist;
for (int i = 1; i < path.size(); i++) {
dist = calc.distanceTo(path.get(i));
if (dist < shortestDist) {
shortestDist = dist;
shortest = i;
}
}
return shortest;
}
/**
* Reverses lines.
*
* @author Enfilade
* @param lines
* @return reverdes Line
*/
private Line[] reverse(Line[] lines) {
Line[] rev = new Line[lines.length];
for (int i = 0; i < lines.length; i++)
rev[i] = lines[lines.length - (i + 1)];
return rev;
}
/**
*
* Generates the mesh from the provided lines.
*
* @author Enfilade
* @param lines
* @return
*/
private ArrayList<RSTile> generatePath(Line[] lines) {
double minStep = 3, maxStep = 16; // 14
int wander = random(4, 5);
if (lines.length < 2)
return null;
ArrayList<RSTile> path = new ArrayList<RSTile>();
Line l1, l2 = lines[0];
double distFromCenter = random(0, l2.getDistance() + 1);
RSTile 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 += random(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 += random(-cap1, cap2);
if (finished) {
RSTile 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 RSTile((int) Math.round(xdist * j + lastX),
(int) Math.round(ydist * j + lastY)));
}
last = distOnLine;
lastX = curX;
lastY = curY;
}
}
return cutUp(path);
}
/**
*
* @author Enfilade
* @param tiles
* @return path
*/
public ArrayList<RSTile> cutUp(ArrayList<RSTile> tiles) {
ArrayList<RSTile> path = new ArrayList<RSTile>();
int index = 0;
while (index < tiles.size()) {
path.add(tiles.get(index));
index += random(8, 12);
}
if (!path.get(path.size() - 1).equals(tiles.get(tiles.size() - 1)))
path.add(tiles.get(tiles.size() - 1));
return path;
}
/**
* Line class.
*
* @author Enfilade
*
*/
private class Line {
private int x, y, xdist, ydist, x2, y2, centerX, centerY;
private RSTile t1, t2;
private double dist;
public Line(int x1, int y1, int x2, int y2) {
t1 = new RSTile(x1, y1);
t2 = new RSTile(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 RSTile getTile1() {
return t1;
}
public RSTile getTile2() {
return t2;
}
/**
* Drafts the created line in the java paint.
*/
public void drawTo(Graphics g, Line line) {
Graphics2D g2 = (Graphics2D) g;
((Graphics2D) g2).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
((Graphics2D) g2).setRenderingHint(
RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
((Graphics2D) g2).setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
((Graphics2D) g2).setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
if (!calc.tileOnMap(t1) || !calc.tileOnMap(t2))
return;
if (calc.tileOnMap(line.getTile1())
&& calc.tileOnMap(line.getTile2())) {
Point p1 = calc.tileToMinimap(t1);
Point p2 = calc.tileToMinimap(t2);
Point p3 = calc.tileToMinimap(line.getTile2());
Point p4 = calc.tileToMinimap(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();
g2.setColor(fillColor);
((Graphics2D) g2).fill(path);
((Graphics2D) g2).draw(path);
}
Point last = null, p;
g2.setColor(lineColor);
for (RSTile t : pathList) {
if (calc.tileOnMap(t)) {
p = calc.tileToMinimap(t);
g2.fillOval(p.x - 2, p.y - 2, 5, 5);
if (last != null)
g2.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 double getDistance() {
return dist;
}
public RSTile translate(double length) {
return new RSTile((int) Math.round(length * (xdist / dist)) + x,
(int) Math.round(length * (ydist / dist)) + y);
}
public RSTile translateFromCenter(double length) {
return new RSTile((int) Math.round(centerX - (xdist / dist)
* length), (int) Math.round(centerY - (ydist / dist)
* length));
}
}
public class PerfectGUI extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
public boolean antiban = true, startScript = false, close = false,
screenOnLevel, screenOnHour, screenOnFinish, restMode;
public int minMouse, maxMouse;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JCheckBox jCheckBox3;
private javax.swing.JCheckBox jCheckBox4;
private javax.swing.JCheckBox jCheckBox5;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
public PerfectGUI() {
initComponents();
}
public void initComponents() {
jLabel2 = new javax.swing.JLabel();
jCheckBox1 = new JCheckBox();
jCheckBox2 = new JCheckBox();
jCheckBox3 = new JCheckBox();
jCheckBox4 = new JCheckBox();
jCheckBox5 = new JCheckBox();
jLabel4 = new JLabel();
jTextField1 = new JTextField();
jTextField2 = new JTextField();
jButton1 = new JButton();
jButton2 = new JButton();
jLabel1 = new JLabel();
jComboBox1 = new JComboBox();
setTitle("AIORuneCrafter");
jLabel2.setFont(new Font("Tahoma", 0, 18));
jLabel2.setText("AIORuneCrafter");
jLabel1.setText("Rune");
jComboBox1.setModel(new DefaultComboBoxModel(new String[] { "Air",
"Mind", "Water", "Earth", "Fire", "Body" }));
jCheckBox1.setText("Antiban");
jCheckBox1.setSelected(true);
jCheckBox2.setText("Rest");
jCheckBox3.setText("Screenshot on level");
jCheckBox4.setText("Screenshot every hour");
jCheckBox5.setText("Screenshot on finish");
jLabel4.setText("Mouse speed");
jTextField1.setFont(new Font("Monospaced", 0, 11));
jTextField1.setText("4");
jTextField2.setFont(new Font("Monospaced", 0, 11));
jTextField2.setText("7");
jButton1.setText("Start");
jButton2.setText("Cancel");
jComboBox1.addActionListener(this);
jCheckBox1.addActionListener(this);
jCheckBox2.addActionListener(this);
jCheckBox3.addActionListener(this);
jCheckBox4.addActionListener(this);
jCheckBox5.addActionListener(this);
jTextField1.addActionListener(this);
jTextField2.addActionListener(this);
jButton1.addActionListener(this);
jButton2.addActionListener(this);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout
.setHorizontalGroup(layout
.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addGroup(
layout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addContainerGap()
.addComponent(
jButton2,
GroupLayout.DEFAULT_SIZE,
141,
Short.MAX_VALUE))
.addGroup(
layout
.createSequentialGroup()
.addContainerGap()
.addComponent(
jButton1,
GroupLayout.DEFAULT_SIZE,
141,
Short.MAX_VALUE))
.addGroup(
layout
.createSequentialGroup()
.addGap(
60,
60,
60)
.addGroup(
layout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(
jComboBox1,
GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(
jLabel2))))
.addContainerGap())
.addGroup(
GroupLayout.Alignment.TRAILING,
layout
.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED,
17, Short.MAX_VALUE)
.addComponent(
jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
GroupLayout.PREFERRED_SIZE)
.addGap(14, 14, 14)).addGroup(
layout.createSequentialGroup()
.addContainerGap().addComponent(
jCheckBox5)
.addContainerGap(28,
Short.MAX_VALUE)).addGroup(
layout.createSequentialGroup()
.addContainerGap().addComponent(
jCheckBox4)
.addContainerGap(14,
Short.MAX_VALUE)).addGroup(
layout.createSequentialGroup()
.addContainerGap().addComponent(
jCheckBox3)
.addContainerGap(30,
Short.MAX_VALUE)).addGroup(
layout.createSequentialGroup()
.addContainerGap().addComponent(
jCheckBox2)
.addContainerGap(74,
Short.MAX_VALUE)).addGroup(
layout.createSequentialGroup()
.addContainerGap().addComponent(
jLabel1).addContainerGap(
121, Short.MAX_VALUE))
.addGroup(
layout.createSequentialGroup()
.addContainerGap().addComponent(
jCheckBox1)
.addContainerGap(88,
Short.MAX_VALUE)));
layout
.setVerticalGroup(layout
.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addComponent(jLabel2)
.addGap(7, 7, 7)
.addGroup(
layout
.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel1)
.addComponent(
jComboBox1,
GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox1)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox2)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox3)
.addPreferredGap(
LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBox4)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox5)
.addPreferredGap(
LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(
layout
.createParallelGroup(
GroupLayout.Alignment.TRAILING)
.addGroup(
layout
.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(
jTextField1,
GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(
jTextField2,
GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addComponent(
jLabel4))
.addPreferredGap(
LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addContainerGap(
GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)));
pack();
setLocationRelativeTo(getOwner());
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jComboBox1) {
if (jComboBox1.getSelectedItem() == "Mind") {
Rune = 558;
ruinsID = 2453;
bankBoothID = 11758;
Tiara = 5529;
altarID = 2479;
portalID = 2466;
musicianID = 5442;
altarWalkTile = new RSTile(2788, 4839);
portalWalkTile = new RSTile(2793, 4828);
ALTAR_AREA = new RSArea(new RSTile(2781, 4824), new RSTile(
2797, 4847));
TORUINS = new Line[] { new Line(2944, 3368, 2949, 3368),
new Line(2945, 3374, 2949, 3374),
new Line(2949, 3377, 2954, 3377),
new Line(2955, 3384, 2955, 3379),
new Line(2960, 3384, 2960, 3380),
new Line(2961, 3385, 2969, 3385),
new Line(2964, 3393, 2967, 3393),
new Line(2962, 3402, 2968, 3402),
new Line(2965, 3408, 2970, 3408),
new Line(2965, 3414, 2970, 3411),
new Line(2974, 3415, 2974, 3412),
new Line(2979, 3420, 2985, 3414),
new Line(2986, 3421, 2989, 3421),
new Line(2986, 3427, 2989, 3427),
new Line(2981, 3431, 2990, 3438),
new Line(2967, 3445, 2985, 3447),
new Line(2961, 3453, 2977, 3455),
new Line(2963, 3472, 2974, 3472),
new Line(2969, 3488, 2979, 3483),
new Line(2971, 3497, 2986, 3494),
new Line(2974, 3507, 2985, 3504),
new Line(2980, 3514, 2984, 3514) };
}
if (jComboBox1.getSelectedItem() == "Water") {
Rune = 555;
Tiara = 5531;
bankBoothID = 35647;
ruinsID = 2454;
altarID = 2480;
portalID = 2467;
altarWalkTile = new RSTile(3486, 4836);
portalWalkTile = new RSTile(3496, 4832);
ALTAR_AREA = new RSArea(new RSTile(3474, 4845), new RSTile(
3500, 4822));
TORUINS = new Line[] { new Line(3269, 3172, 3270, 3162),
new Line(3262, 3176, 3262, 3171),
new Line(3255, 3174, 3255, 3167),
new Line(3249, 3174, 3249, 3167),
new Line(3242, 3171, 3242, 3166),
new Line(3235, 3174, 3235, 3153),
new Line(3220, 3178, 3220, 3154),
new Line(3216, 3178, 3216, 3153),
new Line(3206, 3176, 3206, 3153),
new Line(3197, 3174, 3197, 3151),
new Line(3189, 3169, 3189, 3160),
new Line(3186, 3168, 3186, 3162) };
}
if (jComboBox1.getSelectedItem() == "Earth") {
Rune = 557;
Tiara = 5535;
musicianID = 8700;
bankBoothID = 782;
ruinsID = 2455;
altarID = 2481;
portalID = 2468;
altarWalkTile = new RSTile(2658, 4839);
portalWalkTile = new RSTile(2655, 4830);
ALTAR_AREA = new RSArea(new RSTile(2651, 4821), new RSTile(
2665, 4845));
TORUINS = new Line[] { new Line(3251, 3420, 3256, 3420),
new Line(3258, 3431, 3260, 3421),
new Line(3267, 3430, 3268, 3426),
new Line(3275, 3431, 3275, 3426),
new Line(3275, 3439, 3288, 3429),
new Line(3276, 3446, 3294, 3444),
new Line(3283, 3463, 3294, 3455),
new Line(3293, 3470, 3299, 3459),
new Line(3304, 3474, 3306, 3472) };
}
if (jComboBox1.getSelectedItem() == "Fire") {
Rune = 554;
Tiara = 5537;
ruinsID = 2456;
altarID = 2482;
portalID = 2469;
altarWalkTile = new RSTile(2583, 4839);
portalWalkTile = new RSTile(2577, 4845);
ALTAR_AREA = new RSArea(new RSTile(2574, 4832), new RSTile(
2595, 4851));
TORUINS = new Line[] { new Line(3383, 3271, 3383, 3268),
new Line(3379, 3266, 3379, 3265),
new Line(3373, 3267, 3373, 3265),
new Line(3367, 3269, 3367, 3263),
new Line(3361, 3267, 3361, 3263),
new Line(3354, 3267, 3354, 3263),
new Line(3336, 3270, 3336, 3265),
new Line(3326, 3266, 3328, 3264),
new Line(3324, 3263, 3326, 3262),
new Line(3317, 3262, 3319, 3252),
new Line(3313, 3257, 3313, 3253) };
}
if (jComboBox1.getSelectedItem() == "Body") {
Rune = 559;
Tiara = 5533;
ruinsID = 2457;
altarID = 2483;
portalID = 2470;
bankBoothID = 26972;
altarWalkTile = new RSTile(2521, 4842);
portalWalkTile = new RSTile(2521, 4834);
ALTAR_AREA = new RSArea(new RSTile(2515, 4831), new RSTile(
2531, 4849));
TORUINS = new Line[] { new Line(3094, 3489, 3094, 3493),
new Line(3090, 3483, 3084, 3487),
new Line(3082, 3482, 3078, 3482),
new Line(3083, 3467, 3079, 3467),
new Line(3082, 3461, 3069, 3461),
new Line(3075, 3459, 3070, 3459),
new Line(3072, 3450, 3066, 3449),
new Line(3060, 3441, 3062, 3447),
new Line(3053, 3443, 3053, 3447) };
}
}
if (e.getSource() == jCheckBox1) {
if (jCheckBox1.isSelected())
antiban = true;
else
antiban = false;
}
if (e.getSource() == jCheckBox2) {
if (jCheckBox2.isSelected())
restMode = true;
else
restMode = false;
}
if (e.getSource() == jCheckBox3) {
if (jCheckBox3.isSelected())
screenOnLevel = true;
else
screenOnLevel = false;
}
if (e.getSource() == jCheckBox4) {
if (jCheckBox4.isSelected())
screenOnHour = true;
else
screenOnHour = false;
}
if (e.getSource() == jCheckBox5) {
if (jCheckBox5.isSelected())
screenOnFinish = true;
else
screenOnFinish = false;
}
if (e.getSource() == jButton1) {
Start(e);
minMouse = Integer.parseInt(jTextField1.getText());
maxMouse = Integer.parseInt(jTextField2.getText());
dispose();
}
if (e.getSource() == jButton2) {
setVisible(false);
dispose();
close = true;
}
}
private void Start(ActionEvent e) {
setVisible(false);
startScript = true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment