- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Insets;
- import java.awt.Point;
- 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.image.BufferedImage;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URI;
- import java.net.URL;
- import java.text.DecimalFormat;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import javax.imageio.ImageIO;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JRadioButton;
- import javax.swing.JTabbedPane;
- import javax.swing.JTextField;
- import javax.swing.border.MatteBorder;
- import javax.swing.border.SoftBevelBorder;
- import org.rsbot.bot.Bot;
- import org.rsbot.bot.input.Mouse;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Calculations;
- import org.rsbot.script.Constants;
- import org.rsbot.script.GEItemInfo;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.Timer;
- import org.rsbot.script.wrappers.RSCharacter;
- import org.rsbot.script.wrappers.RSInterface;
- import org.rsbot.script.wrappers.RSInterfaceChild;
- import org.rsbot.script.wrappers.RSInterfaceComponent;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSPlayer;
- import org.rsbot.script.wrappers.RSTile;
- //© Scaper From http//:www.rsbot.org/vb
- @ScriptManifest(authors = { "Scaper" }, category = "AAll-Scapers-Scripts", name = "graahk crafter", version = 1.4, description = "Select All Settings In GUI")
- public class graahkCraft extends Script implements PaintListener, ServerMessageListener {
- private graahkGUI frame;
- BufferedImage normal = null;
- BufferedImage clicked = null;
- public boolean startScript = false, logoutnatcraft = false, removeRing1 = false, checkspouch = false,
- checkmpouch = false, checklpouch = false, checkgpouch = false, duelring = false, autoTalk = false, bankwalk = false,
- altarwalk = false, decayed = false, lunar = true;
- public boolean timerUsed, usedPouch, summon, summongraahk, pouchfilled, pouch,
- rest, invenFull, graahktele;
- public int graahk = 7363, SHOWPAINT = 1;
- public final int natID = 561, pessID = 7936, smallpouch = 5509, mediumpouch = 5510,
- mediumpouchdecay = 5511, largepouch = 5512, largepouchdecay = 5513,
- giantpouch = 5514, giantpouchdecay = 5515;
- final int astralRune = 9075;
- final int lawRune = 563;
- int natcount = 0, airRune = 556, cosmicRune = 564, failCount = 0, fatalCount = 0, lastExp = 0, ExtraTimout = 0,
- lastCrafted = 0 , natRune = 561, runesInInv = 0;
- int Rune, crafted;
- final int[] DEGRADED_POUCH = {-1, 5511, 5513, 5515};
- long startTime, time, timer, estimatedHourly, scriptStartTime, tryAmount,
- timeToNext, lastUpdateMillis = 0;
- public String textread;
- public String user = "TOTAL";
- public int startXP,backupbank, runs, pouchCount, ringCount, essCount,
- mouseSpeedint, failcount, pouchEmpty, logoutnatcount, logoutlvl,
- logouttimeh, logouttimem, naturerunecount = 0, natPrice, pessPrice,
- ACTION;
- Timer bankTimer, graahkClicked, ring, wait, runTimer;
- public double updatedVersion;
- public final double currentVersion = getClass().getAnnotation(
- ScriptManifest.class).version();
- private boolean timePassed(long time) {
- return System.currentTimeMillis() > time;
- }
- static int timeout = 2000;
- private static final int BANK = 1;
- private static final int GRAAHK = 2;
- private static final int WALKTOALTAR = 3;
- private static final int ENTERRUINS = 4;
- private static final int CRAFT = 5;
- private static final int TELEPORT = 6;
- private static final int CONTACT = 7;
- RSTile[] mapPath = new RSTile[200];
- RSTile natPath[] = { new RSTile(2797, 3009), new RSTile(2805, 3009), new RSTile(2814, 3009),
- new RSTile(2821, 3011), new RSTile(2829, 3015), new RSTile(2836, 3022),
- new RSTile(2843, 3027), new RSTile(2854, 3028), new RSTile(2861, 3025),
- new RSTile(2867, 3020)};
- RSTile[] bankPath = { new RSTile(2444, 3083) };
- RSTile[] sumPath = { new RSTile(2451, 3089), new RSTile(2462, 3087) };
- RSTile[] sumToBankPath = { new RSTile(2451, 3089), new RSTile(2457, 3088),
- new RSTile(2443, 3083) };
- RSTile[] altarPath = { new RSTile(2400, 4838) };
- RSTile[] obeliskPath = { new RSTile(2457, 3087), new RSTile(2463, 3087) };
- RSTile[] obeliskPathBack = { new RSTile(2463, 3087),
- new RSTile(2452, 3089), new RSTile(2444, 3083) };
- private final RSTile ruinTile = new RSTile(2869, 3019);
- private final RSTile altarTile = new RSTile(2400, 4841);
- @SuppressWarnings("unused")
- private final RSTile nereAltarTile = new RSTile(2400,4839);
- @SuppressWarnings("unused")
- private final RSTile chestTile = new RSTile(2445,3083);
- public int fixPouches() {
- if(canContinue()) {
- clickContinue();
- }
- if(getInterface(230).isValid()) {
- atInterface(230, 3);
- }
- if(getInterface(88) != null) {
- Rectangle visible = getInterface(88,21).getArea();
- RSInterfaceChild mage = getInterface(88).getChild(22).getComponents()[14];
- Rectangle it = mage.getArea();
- if(visible.contains(it) && visible.contains(it)) {
- if(mage.containsAction("Speak-to")) {
- wait = new Timer(10000);
- return random(50,100);
- }
- return random(50,100);
- }
- RSInterfaceChild scrollBar = getInterface(88).getChild(20);
- if (scrollBar == null)
- return random(50, 100);
- Point scroll = new Point((int) scrollBar.getAbsoluteX() + random(2, 10), (int) scrollBar.getAbsoluteY() + scrollBar.getHeight() - random(40, 20));
- moveMouse(scroll);
- wait(random(50,100));
- clickMouse(true);
- return random(50,100);
- }
- if (!inventoryContains(556) || !inventoryContains(564) || !inventoryContains(9075))
- return withdrawCast();
- if(bank.isOpen())
- bank.close();
- openTab(TAB_MAGIC);
- RSInterfaceChild cast = getChildInterface(430, 26);
- atInterface(cast);
- return random(50,100);
- }
- public int withdrawCast() {
- if(bank.isOpen())
- bank.depositAllExcept(lawRune, pessID, smallpouch, mediumpouch,
- largepouch, giantpouch);
- if (!bank.atItem(airRune, "Withdraw-1")) {
- bank.withdraw(airRune, 1);
- }
- if (!bank.atItem(cosmicRune, "Withdraw-1")) {
- bank.withdraw(9075, 1);
- }
- if (!bank.atItem(airRune, "Withdraw-1")) {
- bank.withdraw(airRune, 1);
- }
- bank.close();
- return random(50,100);
- }
- public boolean backup() {
- RSTile tile = new RSTile(2441, 3087);
- return walkTileMM(tile);
- }
- public boolean walkToRuins() {
- if (distanceTo(getDestination()) <= random(4, 7) || getMyPlayer().isMoving()) {
- return walkPathMM(randomizePath(natPath, 2, 2), 16);
- } else {
- return false;
- }
- }
- public boolean walkToObelisk() {
- if (distanceTo(getDestination()) <= random(4, 7)
- || !getMyPlayer().isMoving()) {
- return walkPathMM(randomizePath(obeliskPath, 2, 2), 12);
- } else {
- return false;
- }
- }
- public boolean walkToObeliskBack() {
- if (distanceTo(getDestination()) <= random(4, 7)
- || !getMyPlayer().isMoving()) {
- return walkPathMM(randomizePath(obeliskPathBack, 2, 2), 16);
- } else {
- return false;
- }
- }
- public boolean walkToBank() {
- RSTile[] toBankPath = randomizePath(bankPath, 1, 1);
- if (toBankPath != null) {
- return walkPathMM(toBankPath);
- } else if (toBankPath == null) {
- antiBan();
- }
- return false;
- }
- public boolean needToWithdrawRing() {
- if (duelring) {
- return true;
- } else {
- return false;
- }
- }
- public boolean needToBank() {
- if (inventoryContains(natID)) {
- return true;
- } else {
- return false;
- }
- }
- public void obelisk() {
- RSObject obelisk = getObjectAt(2463, 3087);
- atObject(obelisk, "Renew-points");
- antiBan();
- }
- public void pouchfill() {
- openTab(TAB_INVENTORY);
- if (checkspouch) {
- pouchFill(smallpouch);
- }
- if (checkmpouch) {
- if (inventoryContains(mediumpouch)) {
- pouchFill(mediumpouch);
- } else {
- pouchFill(mediumpouchdecay);
- }
- }
- if (checklpouch) {
- if (inventoryContains(largepouch)) {
- pouchFill(largepouch);
- } else {
- pouchFill(largepouchdecay);
- }
- }
- if (checkgpouch) {
- if (inventoryContains(giantpouch)) {
- pouchFill(giantpouch);
- } else {
- pouchFill(giantpouchdecay);
- }
- }
- if (!inventoryContains(pessID) & !isInventoryFull()) {
- WithdrawEss();
- }
- }
- public void WithdrawEss() {
- if (!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- RSObject chest = getNearestObjectByID(4483);
- if(chest != null)
- atObject(chest, "Use Bank");
- wait(random(2000, 2500));
- }
- waitForIface(RSInterface.getInterface(Constants.INTERFACE_BANK),
- 3000);
- while (RSInterface.getInterface(Constants.INTERFACE_BANK).isValid()) {
- bankTimer = new Timer(random(3000,5000));
- if(!atBankInventoryItem(pessID, "Withdraw-All")) {
- //withdrawEssence();
- atBankInventoryItem(pessID, "Withdraw-All but one");
- }
- //withdrawEssence();
- if(waitForItemGrab(2500, pessID, 23)) {
- //if(getInventoryCount(pessID) >= 25) {
- bank.close();
- }
- }
- }
- public boolean atBankInventoryItem(int itemID, String txt) {
- return bank.atItem(itemID, txt);
- }
- public void WithdrawRing() {
- RSObject chest = getNearestObjectByID(4483);
- if (!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- if(chest != null && !getMyPlayer().isMoving()) {
- atObject(chest, "Use Bank");
- }
- wait(random(2500, 5500));
- }
- if (RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- if (bank.isOpen() && bank.getCount(2552) < 1) {
- bank.close();
- log("Out of Ring of Duelling. Logging out.");
- logout();
- stopScript();
- }
- waitForIface(RSInterface.getInterface(Constants.INTERFACE_BANK),
- 3000);
- while (RSInterface.getInterface(Constants.INTERFACE_BANK).isValid()) {
- wait(random(1500, 2250));
- if(!atBankInventoryItem(2552, "Withdraw-1")) {
- //withdrawRing8();
- atBankInventoryItem(2552, "Withdraw-1");
- }
- if(waitForItemGrab(2500, 2552, 1)) {
- bank.close();
- }
- }
- }
- }
- public void WithdrawPouch() {
- if (!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- RSObject chest = getNearestObjectByID(4483);
- RSTile bankTile = chest.getLocation();
- if(chest != null && !getMyPlayer().isMoving()) {
- atObject(chest, "Use Bank");
- } else
- if(distanceTo(bankTile) >= 5) {
- walkTileMM(bankTile);
- }
- wait(random(2500, 5500));
- }
- if (RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- if (bank.isOpen() && bank.getCount(12810) < 1) {
- bank.close();
- log("Out of Spirit graahk pouches. Logging out.");
- logout();
- stopScript();
- }
- waitForIface(RSInterface.getInterface(Constants.INTERFACE_BANK),
- 3000);
- while (RSInterface.getInterface(Constants.INTERFACE_BANK).isValid()) {
- wait(random(1750, 2500));
- if(!atBankInventoryItem(12810, "Withdraw-1")) {
- withdrawGraahkPouch();
- }
- if(waitForItemGrab(2000, 12810, 1)) {
- bank.close();
- }
- }
- }
- }
- public void WithdrawAstralRune() {
- if (!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- RSObject chest = getNearestObjectByID(4483);
- if(chest != null && !getMyPlayer().isMoving()) {
- atObject(chest, "Use Bank");
- }
- wait(random(2500, 5500));
- }
- if (RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- if (bank.isOpen() && bank.getCount(12810) < 1) {
- bank.close();
- log("Out of Astrals. Logging out.");
- logout();
- stopScript();
- }
- waitForIface(RSInterface.getInterface(Constants.INTERFACE_BANK),
- 3000);
- while (RSInterface.getInterface(Constants.INTERFACE_BANK).isValid()) {
- wait(random(3000, 4500));
- if(!atBankInventoryItem(astralRune, "Withdraw-1")) {
- withdrawAstral();
- }
- if(waitForItemGrab(2000, astralRune, 1)) {
- bank.close();
- }
- }
- }
- }
- public void WithdrawAirRune() {
- if (!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- RSObject chest = getNearestObjectByID(4483);
- if(chest != null && !getMyPlayer().isMoving()) {
- atObject(chest, "Use Bank");
- }
- wait(random(2500, 5500));
- }
- if (RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- if (bank.isOpen() && bank.getCount(12810) < 1) {
- bank.close();
- log("Out of Airs. Logging out.");
- logout();
- stopScript();
- }
- waitForIface(RSInterface.getInterface(Constants.INTERFACE_BANK),
- 3000);
- while (RSInterface.getInterface(Constants.INTERFACE_BANK).isValid()) {
- wait(random(3000, 4500));
- if(!atBankInventoryItem(airRune, "Withdraw-1")) {
- withdrawAir();
- }
- if(waitForItemGrab(2000, airRune, 1)) {
- bank.close();
- }
- }
- }
- }
- public void WithdrawCosmicRune() {
- if (!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- RSObject chest = getNearestObjectByID(4483);
- if(chest != null && !getMyPlayer().isMoving()) {
- atObject(chest, "Use Bank");
- }
- wait(random(2500, 5500));
- }
- if (RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- if (bank.isOpen() && bank.getCount(12810) < 1) {
- bank.close();
- log("Out of Cosmics. Logging out.");
- logout();
- stopScript();
- }
- waitForIface(RSInterface.getInterface(Constants.INTERFACE_BANK),
- 3000);
- while (RSInterface.getInterface(Constants.INTERFACE_BANK).isValid()) {
- wait(random(3000, 4500));
- if(!atBankInventoryItem(cosmicRune, "Withdraw-2")) {
- withdrawCosmic();
- }
- if(waitForItemGrab(2000, cosmicRune, 2)) {
- bank.close();
- }
- }
- }
- }
- public void withdrawGraahkPouch() {
- if (bank.isOpen()) {
- wait(random(200, 300));
- if(invCount(12810) == 0) {
- //withdraw(12810, "Spirit graahk pouch", false);
- waitForBankOpen(4500);
- bank.withdraw(12810, 1);
- tryAmount += 1;
- wait(random(1050, 1200));
- }
- wait(random(2000, 3500));
- }
- if (tryAmount > 15) {
- log("Failed " + tryAmount + " times to get Spirit graahk pouch. Logging out.");
- stopScript();
- }
- }
- public void withdrawEssence() {
- if (bank.isOpen()) {
- wait(random(200, 300));
- if (essCount < 25) {
- withdraw(pessID, "Pure Essence", true);
- wait(random(1050, 1200));
- }
- }
- }
- public void withdrawRing8() {
- if (bank.isOpen()) {
- wait(random(200, 300));
- if(invCount(2552) == 0) {//withdraw(2552, "Ring of duelling (8)", false);
- waitForBankOpen(2250);
- bank.withdraw(2552, 1);
- tryAmount += 1;
- wait(random(1050, 1200));
- }
- }
- if (tryAmount > 15) {
- log("Failed " + tryAmount + " times to get Ring of Duelling. Logging out.");
- stopScript();
- }
- }
- public void withdrawAstral() {
- if (bank.isOpen()) {
- wait(random(200, 300));
- if(invCount(astralRune) == 0) {
- waitForBankOpen(2250);
- bank.withdraw(astralRune, 1);
- tryAmount += 1;
- wait(random(1050, 1200));
- }
- }
- if (tryAmount > 15) {
- log("Failed " + tryAmount + " times to get Astral Rune. Logging out.");
- stopScript();
- }
- }
- public void withdrawAir() {
- if (bank.isOpen()) {
- wait(random(200, 300));
- if(invCount(airRune) == 0) {
- waitForBankOpen(2250);
- bank.withdraw(airRune, 1);
- tryAmount += 1;
- wait(random(1050, 1200));
- }
- }
- if (tryAmount > 15) {
- log("Failed " + tryAmount + " times to get Astral Rune. Logging out.");
- stopScript();
- }
- }
- public void withdrawCosmic() {
- if (bank.isOpen()) {
- wait(random(200, 300));
- if(invCount(cosmicRune) < 2) {
- waitForBankOpen(2250);
- bank.withdraw(cosmicRune, 2);
- tryAmount += 1;
- wait(random(1050, 1200));
- }
- }
- if (tryAmount > 15) {
- log("Failed " + tryAmount + " times to get Astral Rune. Logging out.");
- stopScript();
- }
- }
- public int invCount(final int InvItem) {
- return getInventoryCount(InvItem);
- }
- public boolean waitForItemGrab(final int timeout, final int itemID,
- final int minAmount) {
- final long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start < timeout) {
- if (invCount(itemID) >= minAmount)
- return true;
- wait(15);
- }
- return false;
- }
- public boolean waitForBankOpen(int timeout) {
- final long start = System.currentTimeMillis();
- if (ExtraTimout != 0)
- timeout += ExtraTimout;
- while (System.currentTimeMillis() - start < timeout) {
- if (!getMyPlayer().isMoving()
- && (System.currentTimeMillis() - start) > 1200)
- return false;
- if (bank.isOpen())
- return true;
- wait(15);
- }
- return false;
- }
- public boolean waitForEmptyInv(final int timeout) {
- final long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start < timeout) {
- if (getInventoryCount() == 0)
- return true;
- wait(15);
- }
- return false;
- }
- private void withdraw(final int ID, final String name, final boolean all) {
- if (!bank.isOpen())
- return;
- RSInterfaceComponent[] scrollbox = getChildInterface(INTERFACE_BANK, INTERFACE_BANK_SCROLLBAR).getComponents();
- if (scrollbox.length > 1) {
- int scrollTop = scrollbox[0].getAbsoluteY();
- if (scrollbox[1].getAbsoluteY() > scrollTop + 1) {
- clickMouse(scrollbox[0].getAbsoluteX() + random(2, 4), scrollTop + random(2, 4), true);
- }
- }
- RSInterfaceChild bankItem = bank.getItemByID(ID);
- if (bankItem == null) {
- log.severe("Unable to withraw " + name + ". You will be logged out in ten seconds.");
- wait(random(9000, 11000));
- while (bank.isOpen()) {
- bank.close();
- }
- stopScript();
- } else if (bankItem.getAbsoluteY() > 270
- && atInterface(getChildInterface(INTERFACE_BANK, INTERFACE_BANK_BUTTON_SEARCH), "Search")) {
- wait(random(1200, 1500));
- final int rand = random(0, Math.min(4, name.length() - 2));
- sendText(name.toLowerCase().substring(0, name.length() - rand), false);
- wait(random(900, 1200));
- bankItem = bank.getItemByID(ID);
- if (bankItem == null
- || bankItem.getAbsoluteY() > 270
- || !bank.withdraw(ID, all ? 0 : 1)
- && !bank.withdraw(ID, all ? 0 : 1)) {
- log.severe("Unable to withraw " + name + ". You will be logged out in ten seconds.");
- wait(random(9000, 11000));
- while (bank.isOpen()) {
- bank.close();
- }
- stopScript();
- } else {
- atInterface(getChildInterface(INTERFACE_BANK, 50));
- }
- } else {
- bank.withdraw(ID, all ? 0 : 1);
- }
- }
- public boolean atBank() {
- if (playerInArea(2445, 3086, 2440, 3082)) {
- return true;
- } else {
- return false;
- }
- }
- public boolean atObelisk() {
- RSObject obelisk = getNearestObjectByID(29954);
- if (obelisk == null)
- return false;
- return tileOnScreen(obelisk.getLocation());
- }
- public boolean atAltar() {
- RSObject aground = getNearestObjectByID(38354);
- if (aground == null)
- return false;
- return tileOnScreen(aground.getLocation());
- }
- public void setCompass(final char direction) {
- switch (direction) {
- case 'n':
- setCameraRotation(359);
- break;
- case 'e':
- setCameraRotation(89);
- break;
- case 's':
- setCameraRotation(179);
- break;
- case 'w':
- setCameraRotation(269);
- break;
- default:
- setCameraRotation(359);
- break;
- }
- }
- private void bank() {
- while (!RSInterface.getInterface(INTERFACE_BANK).isValid()
- & !pouchfilled) {
- RSObject chest = getNearestObjectByID(4483);
- if(chest != null && !getMyPlayer().isMoving())
- atObject(chest, "Use Bank");
- if (!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- antiBan();
- wait(random(1234, 1780));
- }
- }
- if (RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- if (!pouchfilled) {
- while (inventoryContains(natID) || inventoryContains(2556)) {
- bank.depositAllExcept(smallpouch, mediumpouch, largepouch, giantpouch,
- mediumpouchdecay, largepouchdecay, giantpouchdecay);
- }
- if (lunar && !inventoryContains(pessID) & !pouchfilled) {
- while (inventoryContains(mediumpouchdecay)) {
- contactNPC();
- }
- while (inventoryContains(largepouchdecay)) {
- contactNPC();
- }
- while (inventoryContains(giantpouchdecay)) {
- contactNPC();
- }
- }
- bank.depositAllExcept(smallpouch, mediumpouch, largepouch, giantpouch,
- mediumpouchdecay, largepouchdecay, giantpouchdecay);
- wait = new Timer(random (2000, 3200));
- WithdrawEss();
- if (RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- bank.close();
- }
- }
- if (inventoryContains(pessID) & !pouchfilled) {
- if (RSInterface.getInterface(INTERFACE_BANK).isValid()) {
- bank.close();
- }
- // if (lunar || !pouchfilled){
- // while (inventoryContains(mediumpouchdecay)) {
- // fixPouches();
- // }
- // while (inventoryContains(largepouchdecay)) {
- // fixPouches();
- // }
- // while (inventoryContains(giantpouchdecay)) {
- // fixPouches();
- // }
- // }
- //WithdrawEss();
- if (usedPouch) {
- if(getCurrentTab() != Constants.TAB_INVENTORY) {
- } else {
- openTab(TAB_INVENTORY);
- }
- if (checkspouch) {
- pouchFill(smallpouch);
- }
- if (checkmpouch) {
- if (inventoryContains(mediumpouch)) {
- pouchFill(mediumpouch);
- } else {
- pouchFill(mediumpouchdecay);
- }
- }
- if (checklpouch) {
- if (inventoryContains(largepouch)) {
- pouchFill(largepouch);
- } else {
- pouchFill(largepouchdecay);
- }
- }
- if (checkgpouch) {
- if (inventoryContains(giantpouch)) {
- pouchFill(giantpouch);
- } else {
- pouchFill(giantpouchdecay);
- }
- }
- while (!isInventoryFull())
- WithdrawEss();
- }
- pouchfilled = true;
- } else {
- pouchfilled = false;
- }
- }
- }
- public void enterRuins() {
- clickTile(ruinTile, "Enter");
- }
- public void craft() {
- wait = new Timer (random(1000, 2000));
- while (inventoryContains(pessID)) {
- craft(altarTile, "Craft-rune");
- wait(random(200, 300));
- if (inventoryContains(smallpouch)) {
- hoverPouch(smallpouch);
- } else if (inventoryContains(mediumpouch)) {
- hoverPouch(mediumpouch);
- } else if (inventoryContains(mediumpouchdecay)) {
- hoverPouch(mediumpouchdecay);
- }
- waitToStop();
- waitForAnimation(791);
- }
- if (inventoryContains(natID)) {
- pouchEmpty++;
- }
- if (usedPouch & pouchEmpty > 0) {
- openTab(TAB_INVENTORY);
- if (checkspouch) {
- pouchEmpty(smallpouch);
- }
- if (checkmpouch) {
- if (inventoryContains(mediumpouch)) {
- pouchEmpty(mediumpouch);
- } else {
- pouchEmpty(mediumpouchdecay);
- }
- }
- if (checklpouch) {
- if (inventoryContains(largepouch)) {
- pouchEmpty(largepouch);
- } else {
- pouchEmpty(largepouchdecay);
- }
- }
- if (checkgpouch) {
- if (inventoryContains(giantpouch)) {
- pouchEmpty(giantpouch);
- } else {
- pouchEmpty(giantpouchdecay);
- }
- }
- if (inventoryContains(pessID)) {
- craft(altarTile, "Craft-rune");
- wait(random(600, 800));
- }
- if (inventoryContains(natID)) {
- wait(random(400, 800));
- pouchEmpty = 0;
- }
- } else {
- pouchEmpty = 0;
- }
- }
- public int ring() {
- if (getCurrentTab() != Constants.TAB_EQUIPMENT) {
- openTab(Constants.TAB_EQUIPMENT);
- } else {
- Bot.getInputManager().pressKey((char) KeyEvent.VK_F2);
- wait(800);
- Bot.getInputManager().pressKey((char) KeyEvent.VK_F2);
- }
- clickMouse(random(683, 714), random(369, 400), false);
- wait(random(200, 500));
- atMenu("Castle Wars");
- wait(500);
- if (getCurrentTab() != Constants.TAB_INVENTORY) {
- Bot.getInputManager().pressKey((char) KeyEvent.VK_F1);
- wait(800);
- Bot.getInputManager().pressKey((char) KeyEvent.VK_F1);
- } else if (getCurrentTab() != Constants.TAB_INVENTORY) {
- openTab(Constants.TAB_INVENTORY);
- }
- return 100;
- }
- public void graahk() {
- RSNPC graahk1 = getNPCInteracting(7363);
- while (!getMyPlayer().isMoving() && graahk1 == null || stackedGraahk(graahk1.getLocation())
- || !atNPC(graahk1, "Interact Spirit graahk")) {
- clickNPC(graahk1, "Interact Spirit graahk");
- wait(random(800, 1000));
- }
- if (getInterface(228).isValid()) {
- // clickMouse(random(140, 370), random(424, 440), true);
- atInterface(228, 3);
- wait = new Timer(2000);
- setCompass('w');
- }
- }
- private RSNPC getNPCInteracting(final int... ids) {
- for(final RSNPC npc : getNPCArray(false)) {
- // skip ID check if npc is null or it's not interacting with the player
- if(npc == null || !getMyPlayer().equals(npc.getInteracting())) continue;
- for(final int id : ids) {
- if(npc.getID() == id) {
- // NPC is interacting with the player and id matches...
- return npc;
- }
- }
- }
- // No wanted npcs found...
- return null;
- }
- public void waitForAnimation(int j) {
- while (animationIs(j)) {
- wait(1);
- }
- }
- public void waitToStop() {
- while (getMyPlayer().isMoving()) {
- wait(1);
- }
- }
- private boolean clickNPC(final RSNPC npc, final String action) {
- final RSTile tile = npc.getLocation();
- tile.randomizeTile(1, 1);
- try {
- final int hoverRand = random(8, 13);
- for (int i = 0; i < hoverRand; i++) {
- final Point screenLoc = npc.getScreenLocation();
- if (!pointOnScreen(screenLoc)) {
- setCameraRotation(getCameraAngle() + random(-35, 150));
- return true;
- }
- moveMouse(screenLoc, 15, 15);
- final List<String> menuItems = getMenuItems();
- if (menuItems.isEmpty() || menuItems.size() <= 1) {
- continue;
- }
- if (menuItems.get(0).toLowerCase().contains(
- npc.getName().toLowerCase())
- && getMyPlayer().getInteracting() == null) {
- clickMouse(true);
- return true;
- } else {
- for (int a = 1; a < menuItems.size(); a++) {
- if (menuItems.get(a).toLowerCase().contains(
- npc.getName().toLowerCase())
- && getMyPlayer().getInteracting() == null) {
- clickMouse(false);
- return atMenu(action);
- }
- }
- }
- }
- } catch (final Exception e) {
- log.warning("ClickNPC error: " + e);
- return false;
- }
- return false;
- }
- public boolean EquipRing() {
- int ringcount = getInventoryCount(2552);
- if(getCurrentTab() != Constants.TAB_INVENTORY) {
- Bot.getInputManager().pressKey((char) KeyEvent.VK_F1);
- wait(800);
- Bot.getInputManager().pressKey((char) KeyEvent.VK_F1);
- } else {
- openTab(Constants.TAB_INVENTORY);
- }
- wait(random(500, 800));
- atInventoryItem(2552, "Wear");
- wait(random(500, 800));
- int ringcountfinal = getInventoryCount(2552);
- if (ringcount > ringcountfinal) {
- return true;
- } else {
- EquipRing();
- }
- return false;
- }
- private void equipduelring() {
- if (!inventoryContains(2552)) {
- WithdrawRing();
- }
- if (inventoryContains(2552)) {
- wait(random(1250, 2750));
- EquipRing();
- duelring = false;
- }
- }
- public void SummonGraahk() {
- while (inventoryContains(12810)) {
- atInventoryItem(12810, "Summon");
- wait(random(800, 1400));
- }
- }
- private void reNewSummonPoints() {
- setCameraAltitude(true);
- int currentlvl = skills.getCurrentSkillLevel(STAT_SUMMONING);
- int reallvl = skills.getRealSkillLevel(STAT_SUMMONING);
- if (!inventoryContains(12810)) {
- WithdrawPouch();
- }
- if (currentlvl != reallvl) {
- walkToObelisk();
- } else if(!inventoryContains(12810)) {
- }
- if (atObelisk()) {
- antiBan();
- wait(6000);
- if (!(currentlvl == reallvl)) {
- obelisk();
- currentlvl = skills.getCurrentSkillLevel(STAT_SUMMONING);
- wait(random(1000, 2000));
- } else {
- if(inventoryContains(12810)) {
- walkToObeliskBack();
- }
- }
- }
- if (playerInArea(2445, 3086, 2440, 3082) & currentlvl == reallvl) {
- SummonGraahk();
- summon = false;
- summongraahk = false;
- ACTION = BANK;
- }
- }
- private int waitForIdle(int timeout) {
- long start = System.currentTimeMillis();
- RSPlayer myPlayer = getMyPlayer();
- int anim = 1;
- while (System.currentTimeMillis() - start < timeout) {
- if ((anim = myPlayer.getAnimation()) == -1) {
- break;
- }
- wait(15);
- }
- return anim;
- }
- private int waitForInterface(int id, int timeout) {
- long start = System.currentTimeMillis();
- int anim = 1;
- while (System.currentTimeMillis() - start < timeout) {
- if (RSInterface.getInterface(id).isValid()) {
- break;
- }
- wait(15);
- }
- return anim;
- }
- private boolean talk() {
- if (getInterface(64).isValid()
- | getInterface(65).isValid()
- | getInterface(230).isValid()
- | getInterface(242).isValid()
- | getInterface(243).isValid()
- | getInterface(228, 2).containsText(
- "Can you repair my pouches?")) {
- return true;
- } else
- return false;
- }
- public int contactNPC() {
- RSObject chest = getNearestObjectByID(4483);
- RSTile bankTile = (chest.getLocation());
- if (bank.isOpen() && inventoryContains(airRune)
- && inventoryContains(cosmicRune)
- && inventoryContains(astralRune)) {
- if (bank.close()) {
- wait(random(100, 200));
- failCount = 0;
- while (bank.isOpen() && failCount < 20) {
- wait(random(50, 100));
- failCount++;
- }
- return 1;
- }
- }
- if (inventoryContains(airRune) && inventoryContains(cosmicRune)
- && inventoryContains(astralRune)) {
- if (getCurrentTab() != TAB_MAGIC) {
- openTab(TAB_MAGIC);
- failCount = 0;
- }
- if (!getInterface(88).isValid()) {
- bank.close();
- atInterface(548, 130); // Magic Spellbook
- atInterface(430, 26); // Cast
- openTab(Constants.TAB_INVENTORY);
- wait(random(400, 600));
- }
- if (getInterface(88).isValid()) {
- if (getMouseLocation().getX() <= 454
- | getMouseLocation().getX() >= 466
- | getMouseLocation().getY() <= 279
- | getMouseLocation().getY() >= 296) {
- moveMouse(random(455, 465), random(280, 295));
- }
- if (getMouseLocation().getX() >= 454
- && getMouseLocation().getX() <= 466
- && getMouseLocation().getY() >= 279
- && getMouseLocation().getY() <= 296) {
- clickMouse(true);
- wait(random(300, 600));
- clickRSComponent(getInterface(88).getChild(22), 4, true); // Speak-to
- // (Dark
- // mage)
- wait(random(800, 1000));
- if (getMyPlayer().getAnimation() == 4413) {
- waitForIdle(random(5000, 6000));
- }
- }
- }
- }
- talk();
- if (talk() == true && getInventoryCount(mediumpouchdecay) != 0
- | getInventoryCount(largepouchdecay) != 0
- | getInventoryCount(giantpouchdecay) != 0) {
- if (getInterface(64).getChild(5).isValid()) {
- atInterface(64, 5);
- waitForInterface(242, 2000);
- }
- if (getInterface(242).getChild(6).isValid()) {
- atInterface(242, 6);
- waitForInterface(65, 2000);
- }
- if (getInterface(65).getChild(6).isValid()
- && getInterface(65, 5).containsText("with you.")) {
- atInterface(65, 6);
- wait(random(400, 600));
- }
- if (getInterface(65).getChild(6).isValid()
- && getInterface(65, 5).containsText("you.")) {
- atInterface(65, 6);
- wait(random(400, 600));
- }
- if (getInterface(65).getChild(6).isValid()
- && getInterface(65, 5).containsText("something quickly.")) {
- atInterface(65, 6);
- wait(random(400, 600));
- }
- if (getInterface(243).getChild(7).isValid()) {
- atInterface(243, 7);
- wait(random(400, 600));
- }
- if (getInterface(230).getChild(3).isValid()) {
- atInterface(230, 3);
- wait(random(400, 600));
- }
- if (getInterface(228).getChild(2).isValid()
- && getInterface(228, 2).containsText(
- "Can you repair my pouches?")) {
- atInterface(228, 2);
- wait(random(400, 600));
- }
- if (getInterface(65).getChild(6).isValid()
- && getInterface(65, 5).containsText(
- "I think they might be degrading.")) {
- atInterface(65, 6);
- wait(random(400, 600));
- }
- }
- if (!inventoryContains(airRune) || !inventoryContains(cosmicRune)
- || !inventoryContains(astralRune)) {
- if (getMyPlayer().isMoving())
- return 1;
- if (distanceTo(bankTile) > 10)
- walkTileMM(bankTile);
- if (!bank.isOpen()) {
- if (onTile(bankTile, "Use", 0.5, 0.5, 0)) {
- wait(random(1500, 2000));
- failCount = 0;
- while (!bank.isOpen() && failCount < 30) {
- wait(random(600, 800));
- if (getMyPlayer().isMoving())
- failCount = 0;
- failCount++;
- }
- }
- }
- if (atInventoryItem(pessID, "Deposit-All")) {
- wait(random(600, 800));
- failCount = 0;
- while (inventoryContains(pessID) && failCount < 30) {
- wait(random(600, 800));
- failCount++;
- }
- } else
- fatalCount++;
- if (bank.atItem(airRune, "Withdraw-1"))
- if (bank.atItem(airRune, "Withdraw-1")) {
- wait(random(600, 800));
- failCount = 0;
- while (!inventoryContains(airRune) && failCount < 30) {
- wait(random(600, 800));
- failCount++;
- }
- } else
- fatalCount++;
- if (bank.atItem(cosmicRune, "Withdraw-1")) {
- wait(random(600, 800));
- failCount = 0;
- while (!inventoryContains(cosmicRune) && failCount < 30) {
- wait(random(600, 800));
- failCount++;
- }
- } else
- fatalCount++;
- if (bank.atItem(astralRune, "Withdraw-1")) {
- wait(random(600, 800));
- failCount = 0;
- while (!inventoryContains(astralRune) && failCount < 30) {
- wait(random(600, 800));
- failCount++;
- }
- } else
- fatalCount++;
- return 1;
- }
- if (!inventoryContains(mediumpouchdecay)
- && !inventoryContains(largepouchdecay)
- && !inventoryContains(giantpouchdecay)) {
- if (getMyPlayer().isMoving())
- return 1;
- if (distanceTo(bankTile) > 10)
- walkTileMM(bankTile);
- if (!bank.isOpen()) {
- if (onTile(bankTile, "Use", 0.5, 0.5, 0)) {
- wait(random(100, 200));
- failCount = 0;
- while (!bank.isOpen() && failCount < 30) {
- wait(random(50, 100));
- if (getMyPlayer().isMoving())
- failCount = 0;
- failCount++;
- }
- }
- }
- bank.depositAllExcept(lawRune, pessID, smallpouch, mediumpouch,
- largepouch, giantpouch);
- }
- return 100;
- }
- private boolean onTile(final RSTile tile, final String action,
- final double dx, final double dy, final int height) {
- if (!tile.isValid())
- return false;
- Point checkScreen = null;
- try {
- checkScreen = Calculations.tileToScreen(tile, dx, dy, height);
- if (!pointOnScreen(checkScreen)) {
- if (getMyPlayer().isMoving())
- return false;
- if (walkTileMM(tile))
- wait(random(750, 1000));
- return false;
- }
- } catch (Exception e) {
- }
- try {
- boolean stop = false;
- for (int i = 0; i <= 50; i++) {
- checkScreen = Calculations.tileToScreen(tile, dx, dy, height);
- if (!pointOnScreen(checkScreen))
- return false;
- moveMouse(checkScreen);
- final Object[] menuItems = getMenuItems().toArray();
- for (int a = 0; a < menuItems.length; a++) {
- if (menuItems[a].toString().toLowerCase().contains(
- action.toLowerCase())) {
- stop = true;
- break;
- }
- }
- if (stop)
- break;
- }
- } catch (Exception e) {
- }
- try {
- return atMenu(action);
- } catch (Exception e) {
- }
- return false;
- }
- /*public int contactNPC() {
- RSObject chest = getNearestObjectByID(4483);
- RSTile bankTile = (chest.getLocation());
- if (bank.isOpen() && inventoryContains(airRune)
- && inventoryContains(cosmicRune)
- && inventoryContains(astralRune)) {
- if (bank.close()) {
- wait(random(100, 200));
- failCount = 0;
- while (bank.isOpen() && failCount < 20) {
- wait(random(50, 100));
- failCount++;
- }
- return 100;
- }
- }
- if (inventoryContains(airRune) && inventoryContains(cosmicRune)
- && inventoryContains(astralRune)) {
- if (getCurrentTab() != TAB_MAGIC) {
- openTab(TAB_MAGIC);
- failCount = 0;
- }
- if (RSInterface.getInterface(430).isValid()) {
- atInterface(430, 26);
- }
- atInterface(430, 26);
- wait(random(1500, 1750));
- final RSInterfaceChild scrollBar = RSInterface.getChildInterface(
- 88, 20);
- if (!scrollBar.isValid())
- return 1;
- Rectangle pos = scrollBar.getArea();
- if (pos.x == -1 || pos.y == -1 || pos.width == -1
- || pos.height == -1) {
- return 100;
- }
- moveMouse((int) random(458, 465), (int) random(257, 296));
- clickMouse(true);
- wait(random(500, 750));
- clickMouse(true);
- final RSInterfaceChild darkMage = RSInterface.getChildInterface(88,
- 22);
- if (!darkMage.isValid())
- return 100;
- atComponent(darkMage, 4, "Speak-to");
- // I know this looks a bit overkill but it seems to work out
- // right... dont fix it if it ain't broke right?!?
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- moveMouse((int) random(162, 352), (int) random(416, 423));
- clickMouse(true);
- moveMouse((int) random(162, 352), (int) random(416, 423));
- wait(random(500, 750));
- moveMouse((int) random(162, 352), (int) random(416, 423));
- clickMouse(true);
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- clickContinue();
- wait(random(500, 1000));
- }
- if (!inventoryContains(airRune) || !inventoryContains(cosmicRune)
- || !inventoryContains(astralRune)) {
- if (getMyPlayer().isMoving())
- return 1;
- if (distanceTo(bankTile) > 10)
- walkTileMM(bankTile);
- if (!bank.isOpen()) {
- if (atObject(chest, "Use Bank")) {
- wait(random(1500, 2000));
- failCount = 0;
- while (!bank.isOpen() && failCount < 30) {
- wait(random(600, 800));
- if (getMyPlayer().isMoving())
- failCount = 0;
- failCount++;
- }
- }
- }
- if (atInventoryItem(pessID, "Deposit-All")) {
- wait(random(600, 800));
- failCount = 0;
- while (inventoryContains(pessID) && failCount < 30) {
- wait(random(600, 800));
- failCount++;
- }
- } else
- fatalCount++;
- if (bank.atItem(airRune, "Withdraw-1"))
- if (bank.atItem(airRune, "Withdraw-1")) {
- wait(random(600, 800));
- failCount = 0;
- while (!inventoryContains(airRune) && failCount < 30) {
- wait(random(600, 800));
- failCount++;
- }
- } else
- fatalCount++;
- if (bank.atItem(cosmicRune, "Withdraw-1")) {
- wait(random(600, 800));
- failCount = 0;
- while (!inventoryContains(cosmicRune) && failCount < 30) {
- wait(random(600, 800));
- failCount++;
- }
- } else
- fatalCount++;
- if (bank.atItem(astralRune, "Withdraw-1")) {
- wait(random(600, 800));
- failCount = 0;
- while (!inventoryContains(astralRune) && failCount < 30) {
- wait(random(600, 800));
- failCount++;
- }
- } else
- fatalCount++;
- return 100;
- }
- if (!inventoryContains(mediumpouchdecay)
- && !inventoryContains(largepouchdecay)
- && !inventoryContains(giantpouchdecay)) {
- if (getMyPlayer().isMoving())
- return 1;
- if (distanceTo(bankTile) > 10)
- walkTileMM(bankTile);
- if (!bank.isOpen()) {
- if (atObject(chest, "Use Bank")) {
- wait(random(100, 200));
- failCount = 0;
- while (!bank.isOpen() && failCount < 30) {
- wait(random(50, 100));
- if (getMyPlayer().isMoving())
- failCount = 0;
- failCount++;
- }
- }
- }
- bank.depositAllExcept(lawRune, pessID, smallpouch, mediumpouch,
- largepouch, giantpouch);
- }
- return 100;
- }*/
- public boolean rightClickInventoryItem(int id, String Option) {
- if (super.getCurrentTab() != Constants.TAB_INVENTORY) {
- super.openTab(Constants.TAB_INVENTORY);
- }
- int[] items = super.getInventoryArray();
- int index = 0;
- while(index < items.length && items[index] != id) {
- ++index;
- }
- if(index != items.length) {
- Point location = super.getInventoryItemPoint(index);
- super.moveMouse(location.x + 17, location.y + 17, 6, 6);
- super.clickMouse(true);
- return atMenu(Option);
- }
- else {
- return false;
- }
- }
- /*
- * Checks if your inventory contains all of the specific items.
- * Credits: Unknown500
- * @param id of the item you want to click
- * @return true if the item was clickd otherwise false
- */
- public boolean leftClickInventoryItem(int id) {
- if (super.getCurrentTab() != Constants.TAB_INVENTORY) {
- super.openTab(Constants.TAB_INVENTORY);
- }
- int[] items = super.getInventoryArray();
- int index = 0;
- while(index < items.length && items[index] != id) {
- ++index;
- }
- if(index != items.length) {
- Point location = super.getInventoryItemPoint(index);
- super.moveMouse(location.x + 12, location.y + 12, 4, 4);
- super.clickMouse(true);
- return true;
- }
- else {
- return false;
- }
- }
- public boolean clickTile(RSTile tile, String action) {
- try {
- Point location = Calculations.tileToScreen(tile);
- if (location.x == -1 || location.y == -1) {
- return false;
- }
- moveMouse(location, 10, 10);
- clickMouse(true);
- wait(random(500, 1000));
- while (true) {
- if (!getMyPlayer().isMoving()) {
- break;
- }
- wait(random(500, 1000));
- }
- return true;
- } catch (Exception e) {
- return false;
- }
- }
- /**
- * Performs the provided action on a random inventory item with the given
- * ID.
- *
- * @param itemID The ID of the item to look for.
- * @param option The menu action to click.
- * @return <tt>true</tt> if the action was clicked; otherwise false.
- */
- public boolean atInventoryItem(int itemID, String option) {
- try {
- if (getCurrentTab() != TAB_INVENTORY && !RSInterface.getInterface(INTERFACE_BANK).isValid() && !RSInterface.getInterface(INTERFACE_STORE).isValid()) {
- openTab(TAB_INVENTORY);
- }
- RSInterfaceChild inventory = getInventoryInterface();
- if (inventory == null || inventory.getComponents() == null)
- return false;
- java.util.List<RSInterfaceComponent> possible = new ArrayList<RSInterfaceComponent>();
- for (RSInterfaceComponent item : inventory.getComponents()) {
- if (item != null && item.getComponentID() == itemID) {
- possible.add(item);
- }
- }
- if (possible.size() == 0)
- return false;
- RSInterfaceComponent item = possible.get(random(0, Math.min(2, possible.size())));
- Rectangle pos = item.getArea();
- int dx = (int) (pos.getWidth() - 6) / 4;
- int dy = (int) (pos.getHeight() - 6) / 4;
- int midx = (int) (pos.getMinX() + item.getWidth() / 2);
- int midy = (int) (pos.getMinY() + item.getHeight() / 2);
- moveMouse(midx + random(-10, 10), midy + random(-10, 10));
- wait(random(50, 60));
- return atMenu(option);
- } catch (Exception e) {
- log("atInventoryItem(int itemID, String option) Error: " + e);
- return false;
- }
- }
- public boolean pouchFill(final int i) {
- // final int startCount = getInventoryCount(pessID);
- leftClickInventoryItem(i);
- if (i == smallpouch) {
- if (inventoryContains(mediumpouch)) {
- hoverPouch(mediumpouch);
- } else {
- hoverPouch(mediumpouchdecay);
- }
- } else if (i == mediumpouch
- || i == mediumpouchdecay) {
- if (inventoryContains(largepouch)) {
- hoverPouch(largepouch);
- } else {
- hoverPouch(largepouchdecay);
- }
- } else if (i == largepouch
- || i == largepouchdecay) {
- if (inventoryContains(giantpouch)) {
- hoverPouch(giantpouch);
- } else {
- hoverPouch(giantpouchdecay);
- }
- }
- wait(random(500, 600));
- // final int endCount = getInventoryCount(pessID);
- // if (endCount < startCount || failcount >= 5) {
- failcount = 0;
- return true;
- //} else {
- // failcount++;
- // pouchFill(i);
- //}
- //return false;
- }
- public boolean pouchEmpty(final int i) {
- final int startCount = getInventoryCount(pessID);
- //rightClickInventoryItem(i, "mpty");
- atInventoryItem(i, "mpty");
- if (i == smallpouch) {
- if (inventoryContains(mediumpouch)) {
- hoverPouch(mediumpouch);
- } else {
- hoverPouch(mediumpouchdecay);
- }
- } else if (i == mediumpouch
- || i == mediumpouchdecay) {
- if (inventoryContains(largepouch)) {
- hoverPouch(largepouch);
- } else {
- hoverPouch(largepouchdecay);
- }
- } else if (i == largepouch
- || i == largepouchdecay) {
- if (inventoryContains(giantpouch)) {
- hoverPouch(giantpouch);
- } else {
- hoverPouch(giantpouchdecay);
- }
- }
- wait(random(500, 800));
- final int endCount = getInventoryCount(pessID);
- if (endCount > startCount || failcount >= 5) {
- failcount = 0;
- return true;
- } else {
- failcount++;
- pouchEmpty(i);
- }
- return false;
- }
- public double betweenPoints(Point x, Point y) {
- return (Math.hypot((x.x - y.x), (x.y - y.y)));
- }
- public boolean hoverPouch(final int itemID) {
- final int[] pouch = getInventoryArray();
- final java.util.List<Integer> possible = new ArrayList<Integer>();
- for (int i = 0; i < pouch.length; i++) {
- if (pouch[i] == itemID) {
- possible.add(i);
- }
- }
- if (possible.size() == 0) {
- return false;
- }
- final int idx = possible.get(0);
- final Point t = getInventoryItemPoint(idx);
- if (betweenPoints(getMouseLocation(), t) > 7) {
- moveMouse(t, 5, 5);
- return true;
- } else {
- return true;
- }
- }
- public boolean isLagging() {
- return Bot.getClient().getLoginIndex() == 10;
- }
- public boolean isConnectionLost() {
- return Bot.getClient().getLoginIndex() == 12;
- }
- public void autoTalk() {
- final int myLevel = skills.getCurrentSkillLevel(Constants.STAT_RUNECRAFTING);
- int delay = random(500, 3000);
- if (getLastMessage().toLowerCase().contains("rc lvl")) {
- sendText("" + myLevel, true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("rc lvls")) {
- sendText("" + myLevel, true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("runecrafting lvl?")) {
- sendText("" + myLevel, true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("Whats your level in runecrafting?")) {
- sendText("" + myLevel, true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("What is your level in runecrafting")) {
- sendText("" + myLevel, true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("runecrafting levels")) {
- sendText("" + myLevel, true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("runecrafting level")) {
- sendText("" + myLevel, true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("bot?")) {
- sendText("sure :/", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("u bot?")) {
- sendText("pffft go away idiot", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("botter?")) {
- sendText("not at all", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("auto?")) {
- sendText("autowhat?", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("u auto?")) {
- sendText("no way dude!!!", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("how r u?")) {
- sendText("great thanks, u?", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("how are you?")) {
- sendText("cool ty", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("how are you doing?")) {
- sendText("fiine.", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("whats up?")) {
- sendText("NM, you?", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("sup?")) {
- sendText("nothing you?", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("hi")) {
- sendText("hey.", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("hello")) {
- sendText("hi :)", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("howdy")) {
- sendText("howdy partner =P", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("jo")) {
- sendText("k", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("joo")) {
- sendText("jah", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("hey")) {
- sendText("hmmm hiya", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("ello")) {
- sendText("howdie", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("hii")) {
- sendText("bonjour", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("helo")) {
- sendText("hi, bye", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("How long you been rcin?")) {
- sendText("couple of hours or so.", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("How long u been runecrafting?")) {
- sendText("quite a while", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("How long u been runecraftin?")) {
- sendText("not long m8", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("(stake)")) {
- sendText("No thanks, I'm busy.", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("(friendly)")) {
- sendText("sorry, busy.", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("cmon")) {
- sendText("no sorry", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("c'mon")) {
- sendText("busy.", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("please?")) {
- sendText("go away!", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("pleasee")) {
- sendText("go away now!", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("My runecrafting level is")) {
- sendText("Nice", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("My rc level is")) {
- sendText("i'm jealous", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("My rcin level is")) {
- sendText("nj", true);
- wait(delay);
- }
- if (getLastMessage().toLowerCase().contains("wishes to trade")) {
- sendText("can't you see i'm busy?", true);
- wait(delay);
- }
- }
- protected int getMouseSpeed() {
- if(naturerunecount <= 2000){
- return 5;
- }else if(naturerunecount > 2000 & naturerunecount < 3000){
- return 6;
- }else {
- return 8;
- }
- }
- // public int fixPouches() {
- // debug="Talking to mage";
- // if(clickContinue()) {
- // return random(700,800);
- // }
- //
- // debug="Telling mage to fix pouch.";
- // RSInterfaceChild o = getInterface(230);
- // if (o.length > 0) {
- //
- // RSInterfaceChild repair = o[0];
- // if(repair.containsAction("Continue")) {
- // Talk = new KTimer(5000);
- // busy=true;
- // }
- // return random(50,100);
- // }
- // if(RSInterface.getInterface(88).isValid()) {
- // debug = "Selecting mage";
- // Rectangle visible = RSInterface.getChildInterface(88,21).getArea();
- // RSInterfaceComponent mage = RSInterface.getChildInterface(88, 22).getComponents()[14];
- // Rectangle it = mage.getArea();
- // if(visible.contains(it) && visible.contains(it)) {
- // if(mage.containsText("Speak-to")) {
- // busy=true;
- // dialogueTimer = new KTimer(10000);
- // return random(50,100);
- // }
- //
- // return random(50,100);
- // }
- // debug = "Scrolling to mage";
- // RSInterfaceChild scrollBar = RSInterface.getInterface(88).getChild(20);
- // if (scrollBar == null)
- // return random(50, 100);
- // Point scroll = new Point((int) scrollBar.getAbsoluteX() + random(2, 10), (int) scrollBar.getAbsoluteY() + scrollBar.getHeight() - random(40, 20));
- // moveMouse(scroll);
- // if(menuItems.get(a).("Walk"))
- // return random(50,100);
- // clickMouse(true);
- // return random(50,100);
- // }
- // debug="Banking";
- // if (!inventoryContains(556) || !inventoryContains(564) || !inventoryContains(9075))
- // return withdrawCast();
- // if(bank.isOpen())
- // bank.close();
- // openTab(Constants.TAB_MAGIC);
- // atInterface(430,26);
- // busy=true;
- // InterfaceTimer = new Timer(5000);
- // return random(50,100);
- //
- // }
- public boolean craft(RSTile tile, String action) {
- try {
- if (tileOnScreen(altarTile)) {
- Point location = Calculations.tileToScreen(tile.getX(), tile
- .getY(), 0, 0, 0);
- if (location.x == -1 || location.y == -1) {
- return false;
- }
- moveMouse(location, 3, 3);
- clickMouse(true);
- }
- } catch (Exception e) {
- return false;
- }
- return false;
- }
- private boolean playerInArea(int maxX, int maxY, int minX, int minY) {
- int x = getMyPlayer().getLocation().getX();
- int y = getMyPlayer().getLocation().getY();
- if (x >= minX && x <= maxX && y >= minY && y <= maxY) {
- return true;
- }
- return false;
- }
- public boolean Run(final boolean running) {
- try {
- final long startTime = System.currentTimeMillis();
- while (System.currentTimeMillis() - startTime < graahkCraft.timeout) {
- if (running) {
- while (!isRunning())
- wait(random(200, 230));
- return true;
- } else {
- while (isRunning())
- wait(random(200, 230));
- return true;
- }
- }
- return false;
- } catch (final Exception e) {
- return false;
- }
- }
- public void Rest(final int stopEnergy) {
- rest(stopEnergy);
- }
- public class antiban extends Thread {
- public void checkFriendsList() {
- openTab(Constants.TAB_FRIENDS);
- moveMouse(random(554, 709), random(227, 444));
- }
- public void checkSkills() {
- openTab(Constants.TAB_STATS);
- moveMouse(random(552, 603), random(420, 449));
- }
- public int getRandomMouseX(final int maxDistance) {
- final Point p = getMouseLocation();
- if (random(0, 2) == 0) {
- return p.x - random(0, p.x < maxDistance ? p.x : maxDistance);
- } else {
- return p.x
- + random(1, 762 - p.x < maxDistance ? 762 - p.x
- : maxDistance);
- }
- }
- public int getRandomMouseY(final int maxDistance) {
- final Point p = getMouseLocation();
- if (random(0, 2) == 0) {
- return p.y - random(0, p.y < maxDistance ? p.y : maxDistance);
- } else {
- return p.y
- + random(1, 500 - p.y < maxDistance ? 500 - p.y
- : maxDistance);
- }
- }
- public boolean moveMouseRandomly(int maxDistance) {
- if (maxDistance == 0) {
- return false;
- }
- maxDistance = random(1, maxDistance);
- final Point p = new Point(getRandomMouseX(maxDistance),
- getRandomMouseY(maxDistance));
- if (p.x < 1 || p.y < 1) {
- p.x = p.y = 1;
- }
- moveMouse(p);
- if (random(0, 2) == 0) {
- return false;
- }
- return moveMouseRandomly(maxDistance / 2);
- }
- public long nextTime(final int waitTime) {
- return time() + waitTime;
- }
- public long nextTime(final int min, final int max) {
- return nextTime(random(min, max));
- }
- @Override
- public void run() {
- try {
- final int roll = (int) (Math.random() * 1000);
- if (timeToNext < time()) {
- if (roll > 995) {
- } else if (roll > 990 && getInventoryCount() < 23) {
- checkSkills();
- timeToNext = System.currentTimeMillis()
- + random(2000, 25000);
- } else if (roll > 985
- && getInventoryCount() < 23
- && !RSInterface.getInterface(751).getChild(15)
- .getText().contains("Off")) {
- checkFriendsList();
- timeToNext = System.currentTimeMillis()
- + random(2000, 25000);
- } else if (roll > 980 && getInventoryCount() < 23) {
- checkSkills();
- timeToNext = System.currentTimeMillis()
- + random(2000, 25000);
- } else if (roll > 960) {
- if (random(0, 2) == 0) {
- setCameraRotation((int) (getCameraAngle() + (Math
- .random() * 50 > 25 ? 1 : -1)
- * (30 + Math.random() * 90)));
- } else {
- final int key = random(0, 3) < 0 ? KeyEvent.VK_UP
- : KeyEvent.VK_DOWN;
- Bot.getInputManager().pressKey((char) key);
- Thread.sleep(random(1000, 1500));
- Bot.getInputManager().releaseKey((char) key);
- }
- } else if (roll > 940) {
- timeToNext = System.currentTimeMillis()
- + random(2000, 25000);
- openTab(Constants.TAB_INVENTORY);
- } else if (roll > 890 && !isRunning()
- && getMyPlayer().isMoving()) {
- if (getEnergy() > 50) {
- clickMouse(random(707, 762), random(90, 121), true);
- timeToNext = nextTime(500, 1200);
- } else if (rest) {
- Rest(100);
- Run(true);
- timeToNext = nextTime(500, 1200);
- }
- Thread.sleep(random(300, 1000));
- } else if (roll > 780) {
- moveMouseRandomly(500);
- timeToNext = nextTime(500, 7500);
- }
- } else {
- Thread.yield();
- }
- } catch (final InterruptedException e) {
- log("Interrupted");
- }
- }
- public long time() {
- return System.currentTimeMillis();
- }
- public boolean timePassed(final long time) {
- return time() > time;
- }
- public void turnCameraRandom() {
- setCameraRotation((int) (getCameraAngle() + (Math.random() * 50 > 25 ? 1
- : -1)
- * (30 + Math.random() * 90)));
- }
- }
- private int antiBan() {
- int random = random(1, 24);
- switch (random) {
- case 1:
- int x = random(0, 750);
- int y = random(0, 500);
- if (random(1, 10) == 5)
- moveMouse(0, 0, x, y);
- return random(1000, 1500);
- case 2:
- if (getCurrentTab() != TAB_INVENTORY) {
- openTab(TAB_INVENTORY);
- return random(500, 750);
- } else {
- return random(500, 750);
- }
- case 3:
- if (random(1, 40) == 30) {
- if (getMyPlayer().isMoving()) {
- return random(750, 1000);
- }
- if (getCurrentTab() != TAB_STATS) {
- openTab(TAB_STATS);
- }
- moveMouse(560, 420, 40, 20);
- wait(random(3000, 6000));
- return random(100, 200);
- }
- }
- return 500;
- }
- public boolean onStart(Map<String, String> args) {
- if (!isLoggedIn()) {
- log("Please log in before starting.");
- return false;
- }
- try {
- final URL cursorURL = new URL(
- "http://i47.tinypic.com/wkh6py.png");
- final URL cursor80URL = new URL(
- "http://i50.tinypic.com/2ltn7eu.png");
- normal = ImageIO.read(cursorURL);
- clicked = ImageIO.read(cursor80URL);
- } catch (MalformedURLException e) {
- log("Unable to buffer cursor.");
- } catch (IOException e) {
- log("Unable to open cursor image.");
- }
- ACTION = BANK;
- crafted = 0;
- log.severe("Please make sure you have a Spirit Graahk summoned before starting.");
- startXP = skills.getCurrentSkillExp(STAT_RUNECRAFTING);
- startTime = System.currentTimeMillis() - 1000;
- GEItemInfo natMarketPrice = grandExchange.loadItemInfo(natID);
- GEItemInfo pessMarketPrice = grandExchange.loadItemInfo(pessID);
- natPrice = natMarketPrice.getMarketPrice();
- pessPrice = pessMarketPrice.getMarketPrice();
- frame = new graahkGUI();
- frame.setVisible(true);
- while (!startScript) {
- wait(10);
- }
- return true;
- }
- public void onFinish() {
- updateStats(true);
- log("Updating Stats For " + user + " " + crafted + " natures this run");
- }
- @SuppressWarnings("unused")
- private String getFormattedTime(final long timeMillis) {
- long millis = timeMillis;
- final long seconds2 = millis / 1000;
- 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;
- String hoursString = "";
- String minutesString = "";
- String secondsString = seconds + "";
- String type = "seconds";
- if (minutes > 0) {
- minutesString = minutes + ":";
- type = "minutes";
- } else if (hours > 0 && seconds2 > 0) {
- minutesString = "0:";
- }
- if (hours > 0) {
- hoursString = hours + ":";
- type = "hours";
- }
- if (minutes < 10 && !type.equals("seconds")) {
- minutesString = "0" + minutesString;
- }
- if (hours < 10 && type.equals("hours")) {
- hoursString = "0" + hoursString;
- }
- if (seconds < 10 && !type.equals("seconds")) {
- secondsString = "0" + secondsString;
- }
- return hoursString + minutesString + secondsString + " " + type;
- }
- public void onRepaint(Graphics render) {
- ((Graphics2D)render).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- ((Graphics2D)render).setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- ((Graphics2D)render).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
- ((Graphics2D)render).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- Mouse m = Bot.getClient().getMouse();
- long runTime = System.currentTimeMillis() - startTime;
- int secs = ((int) ((runTime / 1000) % 60));
- int mins = ((int) (((runTime / 1000) / 60) % 60));
- int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
- int XPgain = skills.getCurrentSkillExp(STAT_RUNECRAFTING) - startXP;
- time = (System.currentTimeMillis() - startTime) / 1000;
- DecimalFormat d = new DecimalFormat("#,#00");
- d.setMaximumFractionDigits(0);
- if (normal != null) {
- final Mouse mouse = Bot.getClient().getMouse();
- final int mouse_x = mouse.getMouseX();
- final int mouse_y = mouse.getMouseY();
- final int mouse_x2 = mouse.getMousePressX();
- final int mouse_y2 = mouse.getMousePressY();
- final long mpt = System.currentTimeMillis()
- - mouse.getMousePressTime();
- if (mouse.getMousePressTime() == -1 || mpt >= 1000) {
- render.drawImage(normal, mouse_x - 8, mouse_y - 8, null);
- }
- if (mpt < 1000) {
- render.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null);
- render.drawImage(normal, mouse_x - 8, mouse_y - 8, null);
- }
- }
- if (isLoggedIn()) {
- //Background
- render.setColor(new Color(0, 0, 0, 194));
- render.fillRoundRect(354, 115, 150, 216, 6, 6);
- render.setColor(new Color(10, 176, 250));
- render.drawRoundRect(354, 115, 150, 216, 6, 6);
- //Top Bar
- render.setColor(new Color(0, 0, 0, 145));
- render.fillRoundRect(367, 124, 129, 30, 5,5); //Backdrop
- render.setColor(new Color(255, 255, 255, 71));
- render.fillRect(367, 125, 128, 14); //gloss
- render.setColor(new Color(10, 176, 250));
- render.drawRoundRect(367, 124, 129, 30, 5, 5);
- //Top Dividing Line
- render.setColor(new Color(54, 189, 255));
- render.drawLine(389, 166, 471, 166);
- render.setColor(new Color(20, 130, 184));
- render.drawLine(389, 167, 471, 167);
- //Bottom Dividing Line
- render.setColor(new Color(54, 189, 255));
- render.drawLine(389, 280, 471, 280);
- render.setColor(new Color(20, 130, 184));
- render.drawLine(389, 281, 471, 281);
- //Bottom Bar
- render.setColor(new Color(0, 128, 209));
- render.fillRect(366, 293, 123, 30); //Background
- render.setColor(new Color(255, 255, 255, 40));
- render.fillRect(366, 293, 123, 16); //gloss
- render.setColor(new Color(0, 0, 0, 255));
- render.drawRect(366, 293, 123, 30);
- //Text
- render.setFont(new Font("SansSerif", 0, 10));
- render.setColor(new Color(255, 255, 255));
- render.drawString("Time Running: ", 371, 182);
- render.drawString("Nats Crafted: ", 371, 203);
- render.drawString("Nats per Hour: " , 371, 224);
- render.drawString("Exp Gained: ", 371, 245);
- render.drawString("Exp per Hour: ", 371, 265);
- render.setFont(new Font("SansSerif", 0, 10));
- render.setColor(new Color(10, 176, 250));
- render.drawString(d.format(hours) + ":" + d.format(mins)
- + ":" + d.format(secs), 445, 182); //Time
- render.drawString("" + crafted, 444, 203); //Runes Crafted
- render.drawString("" + (crafted * 60 * 60) / time, 442, 224); //Craft per Hour
- render.drawString("" + XPgain, 434, 245); //Exp Gain
- render.drawString("" + (XPgain * 60 * 60) / time, 438, 266); //Exp Hour
- render.setFont(new Font("Arial", 0, 12));
- render.setColor(new Color(255, 255, 255));
- render.drawString("GraahkNatureCrafter", 372, 143);
- //Bar Text
- render.setFont(new Font("SansSerif", 0, 10));
- render.setColor(new Color(0, 0, 0, 255));
- render.drawString("Profit Made: ", 382, 303);
- render.setColor(new Color(255, 255, 255, 255));
- int profit = (natPrice - pessPrice) * crafted;
- render.drawString("" + p