Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://www.mediafire.com/?q8njoooq842mnts
- // <editor-fold defaultstate="collapsed" desc="Imports">
- import org.rsbot.script.*;
- import org.rsbot.script.methods.GrandExchange.GEItem;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.script.methods.*;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.Configuration;
- import java.awt.*;
- import java.awt.Graphics;
- import java.awt.image.BufferedImage;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import javax.imageio.ImageIO;
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.io.PrintWriter;
- import java.io.IOException;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import java.net.InetAddress;
- import java.net.InetSocketAddress;
- import java.net.Socket;
- import java.net.SocketAddress;
- import java.net.MalformedURLException;
- import java.net.URL;// </editor-fold>
- @ScriptManifest(authors = {"Dew/Deww1"}, keywords = {"iron", "Rimmington", "coal", "Guild Mine"}, name = "Iron Picker Uper", description = "Picks up Iron ore from powerminers in Rimmington Mines", version = 2.61, website = "http://www.dewbots.org/")
- public class ironPickUp extends Script implements PaintListener, MouseListener {
- //<editor-fold defaultstate="collapsed" desc="Variables">
- private final int ORE[] = {440, 453};
- private final int BANK[] = {36788, 11758};
- private final int LADDER[] = {2113, 6226};
- RSObject BANK12;
- public int invCount = 0;
- public int oree;
- public int switches = 0;
- public int OreCollected = 0;
- /*
- * Area ID: 0 = None
- * Area ID: 1 = Rimmington Mines
- * Area ID: 2 = Guild Mines
- */
- public int areaID = 0; //area ID
- private int mouseHopx;
- private int mouseHopy;
- private int oreCollected = 0;
- private int oreHr = 0;
- private int price = 0;
- private int priceHr = 0;
- public int orePrice;
- private Double ver = ironPickUp.class.getAnnotation(ScriptManifest.class).version();
- private String status = "Setting up";
- private String MouseSpeed = "Unknown";
- public String status$ = "";
- public String antiBanStatus = "Setting up";
- public String cursorU;//Cursor unclicked
- public String cursorC;//Cursor clicked
- public String area = "";
- boolean showPaint1 = false; //close Paint
- boolean showPaint2 = true; //General tab
- boolean showPaint3 = false; //money tab
- Point p;
- public boolean isDoingAnti = false;
- public boolean hasStarted = false;
- public boolean takeBreaks = false;
- ipuAntiban antiban = new ipuAntiban();
- hopper hop = new hopper();
- ipuGUI gui = new ipuGUI();
- public long startTime = 0;
- public long millis = 0;
- public long hours = 0;
- public long minutes = 0;
- public long seconds = 0;
- public long last = 0;
- public long noOreTime;
- public long millis2 = 0;
- public long minutes2 = 0;
- public long seconds2 = 0;
- BufferedImage normal = null;
- BufferedImage clicked = null;
- Rectangle hide = new Rectangle(6, 312, 75, 24); //hide paint button
- Rectangle genTab = new Rectangle(446, 313, 70, 24); //general tab button
- Rectangle monTab = new Rectangle(376, 315, 68, 23); //money tab button
- private org.rsbot.script.util.Timer timer = new org.rsbot.script.util.Timer(1000 * 30 * 8); //4 mins
- private org.rsbot.script.util.Timer GUITimer = new org.rsbot.script.util.Timer(1000); //1 sec
- //GUI Stuff
- public boolean useMsRandom = false; //use Mouse Random
- public boolean doUpdate = false; //check for updates
- public boolean wHop = false; //world hop
- public boolean shot = false; //screenshot at end?
- public boolean devMode = false; //development(debug) mode - display all logs
- public int maxPastWorlds = 10, maxPing = 150, //for worldswitcher
- currentWorld = 0, newWorld = 0, hopped = 0, skillTotal = 0, wSwitches = 0;
- public int pastWorld[] = new int[maxPastWorlds];
- public boolean worldHopping = false;
- public long switchTime = 0;
- //</editor-fold>
- //<editor-fold defaultstate="collapsed" desc="Walking/Area">
- RSTile mineTile = new RSTile(2970, 3240);
- RSTile bankTile = new RSTile(3012, 3355);
- RSTile[] toBank = new RSTile[]{
- new RSTile(2969, 3239),
- new RSTile(2975, 3244),
- new RSTile(2983, 3253),
- new RSTile(2991, 3250),
- new RSTile(2996, 3246),
- new RSTile(3001, 3242),
- new RSTile(3007, 3240),
- new RSTile(3015, 3241),
- new RSTile(3021, 3241),
- new RSTile(3026, 3241),
- new RSTile(3030, 3236),
- new RSTile(3034, 3236),
- new RSTile(3038, 3236),
- new RSTile(3042, 3236),
- new RSTile(3046, 3236)} ;
- RSTile toMine[] = new RSTile[]{
- new RSTile(3046, 3236),
- new RSTile(3042, 3236),
- new RSTile(3038, 3236),
- new RSTile(3034, 3236),
- new RSTile(3030, 3236),
- new RSTile(3026, 3241),
- new RSTile(3021, 3241),
- new RSTile(3015, 3241),
- new RSTile(3007, 3240),
- new RSTile(3001, 3242),
- new RSTile(2996, 3246),
- new RSTile(2991, 3250),
- new RSTile(2983, 3253),
- new RSTile(2975, 3244),
- new RSTile(2969, 3239) };
- RSTile toLadder[] = new RSTile[] { new RSTile(3013, 3355),
- new RSTile(3013, 3359), new RSTile(3021, 3358),
- new RSTile(3024, 3352), new RSTile(3028, 3347),
- new RSTile(3029, 3341), new RSTile(3026, 3337),
- new RSTile(3021, 3339) };
- RSTile toLadder0[] = new RSTile[] { new RSTile(3013, 3355),
- new RSTile(3013, 3359), new RSTile(3021, 3358),
- new RSTile(3024, 3352), new RSTile(3028, 3347),
- new RSTile(3029, 3341), new RSTile(3026, 3337),
- new RSTile(3021, 3339) };
- RSTile toLadder2[] = new RSTile[] { new RSTile(3038, 9737),
- new RSTile(3032, 9738), new RSTile(3026, 9739),
- new RSTile(3021, 9739) };
- RSTile toMine2[] = new RSTile[] { new RSTile(3021, 9739),
- new RSTile(3026, 9739), new RSTile(3032, 9738),
- new RSTile(3038, 9737) };
- RSTile toBank2[] = new RSTile[] { new RSTile(3021, 3339),
- new RSTile(3028, 3337), new RSTile(3029, 3346),
- new RSTile(3025, 3354), new RSTile(3018, 3359),
- new RSTile(3014, 3355) };
- private boolean atBank() {
- RSArea area = new RSArea(new RSTile(3043, 3234), new RSTile(3051, 3237));
- return area.contains(getMyPlayer().getLocation());
- }
- private boolean atBank1() {
- RSArea area = new RSArea(new RSTile(3008, 3352), new RSTile(3018, 3358));
- return area.contains(getMyPlayer().getLocation());
- }
- private boolean atMine() {//rimmmington mine
- RSArea area = new RSArea(new RSTile(2974, 3244), new RSTile(2965, 3235));
- return area.contains(getMyPlayer().getLocation());
- }
- private boolean atMine1() {//guild mine
- RSArea area = new RSArea(new RSTile(3026, 9734), new RSTile(3054, 9748));
- return area.contains(getMyPlayer().getLocation());
- }
- private boolean atLadder0() {//ladder on ground zero
- RSArea area = new RSArea(new RSTile(3014, 3336), new RSTile(3024, 3343));
- return area.contains(getMyPlayer().getLocation());
- }
- private boolean atLadder1() {//ladder on ground -1
- RSArea area = new RSArea(new RSTile(3017, 9737), new RSTile(3026, 9741));
- return area.contains(getMyPlayer().getLocation());
- }
- private boolean inFally() {//check if i am on ground level in fally
- RSArea area = new RSArea(new RSTile(3004,3329), new RSTile(3036,3368));
- return area.contains(getMyPlayer().getLocation());
- }
- private boolean AtBank(String s) {
- if (s == "Guild Mine") {
- atBank1();
- if (atBank1()) {
- return true;
- }
- } else if (s == "Rimmington Mines") {
- atBank();
- if (atBank()) {
- return true;
- }
- }
- return false;
- }
- private boolean AtMine(String s) {
- if (s =="Guild Mine") {
- atMine1();
- if (atMine1()) {
- return true;
- }
- } else if(s == "Rimmington Mines") {
- atMine();
- if (atMine()) {
- return true;
- }
- }
- return false;
- }
- private void walkToMine() {
- if (area.equals("Rimmington Mines")) {
- if (!AtMine(area)) {
- RSTilePath walkingMine = walking.newTilePath(toMine);
- walkingMine.randomize(random(1, 2), random(1, 2));
- walkingMine.traverse();
- antiban.antiBanCamera();
- status = "Walking to the mine...";
- sleep(random(500, 1000));
- timer.reset();
- invCount = inventory.getCount(ORE);
- }
- } else if (area.equals("Guild Mine")) {
- if (!AtMine(area)) {
- if (!atLadder0()) {
- RSTilePath walkingMine = walking.newTilePath(toLadder);
- walkingMine.randomize(random(1,2), random(1,2));
- walkingMine.traverse();
- antiban.antiBanCamera();
- status = "Walking to the Ladder";
- sleep(random(500, 1000));
- timer.reset();
- invCount = inventory.getCount(ORE);
- }
- if (atLadder0()) {
- RSObject lad = objects.getNearest(LADDER);
- if (lad != null) {
- if (lad.isOnScreen()) {
- lad.doClick();
- } else {
- walking.walkTileMM(lad.getLocation());
- }
- } else {
- walkToMine();
- }
- }
- if (atLadder1()) {
- RSTilePath walkingMine = walking.newTilePath(toMine2);
- walkingMine.randomize(random(1,2), random(1,2));
- walkingMine.traverse();
- status = "Walking to Mine";
- sleep(random(500,1000));
- timer.reset();
- invCount = inventory.getCount(ORE);
- }
- }
- }
- }
- private void walkToBank() {
- if (area.equals("Rimmington Mines")) {
- if (!AtBank(area)) {
- RSTilePath walkingBank = walking.newTilePath(toBank);
- walkingBank.randomize(random(1, 2), random(1, 2));
- walkingBank.traverse();
- antiban.antiBanCamera();
- status = "Walking to the bank...";
- sleep(random(500, 1000));
- timer.reset();
- }
- } else if (area.equals("Guild Mine")) {
- if (!AtBank(area)) {
- if (!inFally()) {
- RSTilePath walkingMine = walking.newTilePath(toLadder2);
- walkingMine.randomize(random(1,2), random(1,2));
- walkingMine.traverse();
- antiban.antiBanCamera();
- status = "Walking to the Ladder";
- sleep(random(500, 1000));
- timer.reset();
- invCount = inventory.getCount(ORE);
- }
- if (inFally()) {
- RSTilePath walkingMine = walking.newTilePath(toBank2);
- walkingMine.randomize(random(1,2), random(1,2));
- walkingMine.traverse();
- status = "Walking to Mine";
- sleep(random(500,1000));
- timer.reset();
- invCount = inventory.getCount(ORE);
- }
- if (atLadder1()) {
- RSObject lad = objects.getNearest(LADDER);
- if (lad != null) {
- if (lad.isOnScreen()) {
- lad.doClick();
- sleep(1500, 3000);
- } else {
- walking.walkTileMM(lad.getLocation());
- }
- } else {
- walkToBank();
- }
- }
- }
- }
- }
- //</editor-fold>
- // <editor-fold defaultstate="collapsed" desc="pickup/noore stuff">
- public void pickingUp() {
- noOres();
- if (AtMine(area) && !inventory.isFull()) {
- RSGroundItem ore = groundItems.getNearest(ORE);
- int randNum = random(1, 10);
- if (randNum > 1) {
- if (ore != null) {
- if (ore.isOnScreen()) {
- status = "Picking up ores";
- ore.doAction("Take");
- timer.reset();
- } else {
- if (area.equals("Rimmington Mines")) {
- camera.turnTo(ore.getLocation());
- } else if (area.equals("Guild Mine")) {
- walking.walkTileMM(ore.getLocation());
- }
- }
- } else {
- noOres();
- sleep(100, 200);
- }
- } else {
- antiban.antiBanCamera();
- }
- }
- }
- private void noOres() {
- RSGroundItem item = groundItems.getNearest(ORE);
- if (game.isLoggedIn()) {
- if (AtMine(area)) {
- if (item == null || !item.isOnScreen() || item == null && !item.isOnScreen()) {
- status = "Waiting for ores";
- antiban.antiban();
- if (!timer.isRunning()) {
- if (wHop == true) {
- hop.worldHop(false);
- timer.setEndIn(1000 * 60 * 8);
- }
- }
- }
- }
- }
- }// </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="banking">
- private void banking(String loc) {
- RSObject bank1 = objects.getNearest(BANK[0]); //rimmington bank
- if (loc == "Rimmington Mines") {
- if (AtBank(area)) {
- if (bank1 != null) {
- if (bank1.isOnScreen()) {
- bank1.doAction("Deposit");
- sleep(random(2000, 4000));
- mouse.click(349, 280, 5, 5, true);
- sleep(random(1000, 4000));
- bank.close();
- } else {
- walking.walkTileMM(bank1.getLocation(), 2);
- }
- }
- }
- } else if (loc == "Guild Mine") {
- banking();
- }
- }
- public int bankOpen() {
- if (AtBank(area) && players.getMyPlayer().isIdle()) {
- status = "Opening Bank.";
- RSObject bankBooth = objects.getNearest(BANK[1]);
- if (random(1, 4) > 1) {
- bankBooth.doAction("Use-quickly");
- } else {
- antiban.antiban();
- }
- }
- return random(800, 1300);
- }
- public int depositBank() {
- status = "Depositing ores";
- bank.depositAll();
- return random(300, 1100);
- }
- public int bankClose() {
- if (bank.isOpen()) {
- status = "Closing Bank.";
- bank.close();
- sleep(random(200, 1000));
- }
- return random(300, 800);
- }
- public void banking() {
- if (!bank.isOpen()) {
- bankOpen();
- antiban.antiban();
- }
- if (bank.isOpen()) {
- depositBank();
- antiban.antiban();
- sleep(random(100, 500));
- }
- timer.reset();
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="extras">
- private void lowHP() {
- combat.getHealth();
- if (combat.getHealth() < 30) {
- if (atBank()) {
- int rand = random(1, 2);
- if (rand == 1) {
- antiban.antiban();
- } else {
- antiban.antiBanCamera();
- }
- sleep(100, 200);
- }
- if (!atMine() || !atBank()) {
- walking.setRun(true);
- }
- }
- }
- private void runCapable() {
- if (takeBreaks && !walking.isRunEnabled() && walking.getEnergy() < 30) {
- //TODO add resting
- }
- if (!walking.isRunEnabled() && walking.getEnergy() >= random(60, 80)) {
- walking.setRun(true);
- }
- }
- /**
- *
- * @param text the string to send
- * @param dev am I using developement mode
- * @param dev1 just for developement mode only
- * @return true if successfully sent
- */
- public boolean logger(String text, boolean dev, boolean dev1) {
- if (dev && dev1 || dev) {
- log(Color.DARK_GRAY, "dev: "+text);
- this.log(color1, p);
- }
- if (!dev && !dev1 || !dev1) {
- log(text);
- }
- return false;
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="OnStart">
- @Override
- public boolean onStart() {
- while (!game.isLoggedIn()) {
- //sleep(500);
- }
- if (!game.isFixed()) {
- onFinish();
- log("Please set game to fixed!");
- }
- cursorU = "http://i360.photobucket.com/albums/oo47/perez048/mouseReg.png";
- cursorC = "http://i360.photobucket.com/albums/oo47/perez048/mouseClicked.png";
- ipuGUI GUI = new ipuGUI();
- GUI.setVisible(true);
- while (GUI.isVisible()) {
- GUITimer.setEndIn(1000);
- }
- log("Iron Pick Up Version: " + ver);
- try {
- final URL cursorURL = new URL(cursorU);
- final URL cursor80URL = new URL(cursorC);
- 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.");
- }
- startTime = System.currentTimeMillis();
- shot = GUI.screenshot.isSelected();
- wHop = GUI.hopper.isSelected();
- useMsRandom = GUI.mousespeed.isSelected();
- doUpdate = GUI.updater.isSelected();
- devMode = GUI.devMode.isSelected();
- log("Screenshot on end = " + shot);
- log("World hopping = " + wHop);
- log("Random Mouse = " + useMsRandom);
- log("Check for updates = " + doUpdate);
- log(Color.red, "Debug mode activated");
- log("loading ore prices..... please wait");
- if (GUI.locations.getSelectedItem().toString().equals("Rimmington Mines")) {
- GEItem orePrice1 = grandExchange.lookup(ORE[0]);
- orePrice = orePrice1.getGuidePrice();
- log("Iron ore is: " + orePrice);
- } else if (GUI.locations.getSelectedItem().toString().equals("Guild Mine")) {
- GEItem orePrice1 = grandExchange.lookup(ORE[1]);
- orePrice = orePrice1.getGuidePrice();
- log("Coal ore is: " + orePrice);
- }
- area = GUI.locations.getSelectedItem().toString();
- if (doUpdate) {
- checkForUpdates();
- }
- return true;
- }// </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Loop">
- public int loop() {
- if (!AtBank(area) || !bank.isDepositOpen() || !bank.isOpen()) {
- if (invCount < inventory.getCount(ORE)) {
- oreCollected++;
- invCount = inventory.getCount(ORE);
- }
- runCapable();
- if (!AtBank(area)) {
- noOres();
- }
- lowHP();
- }
- mouseSpeed();
- if (AtBank(area)) {
- logger("we are at bank...", devMode, true);
- if (bank.getBoxCount() == 0 || inventory.getCount() < 27) {
- logger("Inv less than 27, walking to mine...", devMode, true);
- runCapable();
- walkToMine();
- }
- if (bank.isDepositOpen() && bank.getBoxCount() > 1 || inventory.getCount() >= 27) {
- logger("Inv more than 26, banking", devMode, true);
- banking(area);
- }
- }
- if (AtMine(area)) {
- logger("we are at mine...", devMode, true);
- if (bank.getBoxCount() == 0 || inventory.getCount() < 27) {
- logger("inv less than 27, picking up ores...", devMode, true);
- int rand = random(1, 150);
- if (rand > 3) {
- pickingUp();
- } else {
- antiban.antiBanCamera();
- }
- }
- if (bank.getBoxCount() > 0 || inventory.getCount() >= 27) {
- logger("Inv more than 26, walking to bank...", devMode, true);
- runCapable();
- walkToBank();
- }
- }
- if (!AtBank(area) || !AtMine(area)) {
- logger("Not at Bank OR Mine...", devMode, true);
- if (bank.getBoxCount() == 0 || inventory.getCount() < 27) {
- logger("Inv less than 27, walking to mine...", devMode, true);
- walkToMine();
- }
- if (bank.getBoxCount() > 0 || inventory.getCount() >= 27) {
- logger("Inv more than 26, walking to bank...", devMode, true);
- walkToBank();
- }
- }
- return random(1000, 1200);
- }// </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="onFinish">
- @Override
- public void onFinish() {
- if (shot == true) {
- env.saveScreenshot(false);
- }
- log("Total Ores Collected: " + oreCollected + " ores.");
- if (wHop == true) {
- log("Total world Hops: " + hopped);
- }
- log("http://www.powerbot.org/vb/showthread.php?t=770408 - my script thread. :)");
- }// </editor-fold>
- //<editor-fold defaultstate="collapsed" desc="MouseStuff">
- private void mouseSpeed() {
- if (useMsRandom == true) {
- int rand = random(1, 5);
- if (rand == 1) {
- mouse.setSpeed(random(4, 7));
- }
- if (rand == 2) {
- mouse.setSpeed(random(5, 10));
- }
- if (rand == 3) {
- mouse.setSpeed(random(2, 5));
- }
- if (rand == 4) {
- mouse.setSpeed(random(2, 10));
- }
- } else {
- mouse.setSpeed(random(4, 6));
- }
- mouseSet();
- }
- private void mouseSet() {
- if (mouse.getSpeed() >= 1 && mouse.getSpeed() <= 3) {
- MouseSpeed = "Extremely fast";
- }
- if (mouse.getSpeed() >= 4 && mouse.getSpeed() <= 6) {
- MouseSpeed = "Regular";
- }
- if (mouse.getSpeed() >= 7 && mouse.getSpeed() <= 10) {
- MouseSpeed = "Slow";
- }
- }
- //</editor-fold>
- //<editor-fold defaultstate="collapsed" desc="antiban">
- public class ipuAntiban {
- private void antiban() {
- if (random(1, 2) == 1) {
- antiBan1();
- } else {
- antiBan2();
- }
- }
- private void antiBan1() {
- int randomProd = random(1, 40);
- if (randomProd >= 2 && randomProd <= 4) {
- antiBanStatus = "Pause for a few seconds...";
- sleep(1000, 2500);
- }
- if (randomProd >= 32) {
- antiBanStatus = "Moving mouse Randomly..";
- mouse.moveRandomly(100, 600);
- } else {
- sleep(10, 30);
- }
- }
- public void antiBan2() {
- int antiType = random(0, 1);
- int b = random(0, 10);
- switch (antiType) {
- case 0:
- switch (b) {
- case 1:
- if (random(0, 10) == 5) {
- antiBanStatus = "Moving mouse randomly...";
- mouse.moveSlightly();
- sleep(200, 600);
- mouse.moveRandomly(150, 350);
- }
- break;
- case 2:
- if (random(0, 13) == 2) {
- antiBanStatus = "Changing camera angle...";
- camera.setAngle(random(30, 70));
- sleep(400, 1200);
- }
- break;
- case 3:
- if (random(0, 24) == 6) {
- antiBanStatus = "Moving mouse of screen...";
- mouse.moveOffScreen();
- sleep(random(600, random(1200, 2000)));
- }
- break;
- case 5:
- if (random(0, 28) == 0 && !bank.isOpen()) {
- antiBanStatus = "Checking friends list...";
- game.openTab(9);
- sleep(random(1000, 3400));
- } else if (game.getCurrentTab() != Game.TAB_INVENTORY) {
- game.openTab(4);
- }
- default:
- break;
- }
- case 1:
- switch (random(0, 70)) {
- case 1:
- antiBanStatus = "Mouse hopping...";
- camera.setAngle(random(0, 90));
- sleep(500, 1000);
- if (random(1, 3) == 1) {
- mouseHopx = random(0, 760);
- mouseHopy = random(0, 500);
- mouse.hop(mouseHopx, mouseHopy);
- }
- break;
- case 2:
- antiBanStatus = "Mouse hopping...";
- camera.setAngle(random(90, 180));
- sleep(500, 1000);
- if (random(1, 3) == 1) {
- mouseHopx = random(0, 760);
- mouseHopy = random(0, 500);
- mouse.hop(mouseHopx, mouseHopy);
- }
- break;
- case 3:
- antiBanStatus = "Mouse hopping...";
- mouse.moveSlightly();
- camera.setAngle(random(90, 180));
- if (random(1, 3) == 1) {
- mouseHopx = random(0, 760);
- mouseHopy = random(0, 500);
- mouse.hop(mouseHopx, mouseHopy);
- }
- break;
- case 4:
- antiBanStatus = "Mouse hopping...";
- if (random(1, 3) == 1) {
- mouseHopx = random(0, 760);
- mouseHopy = random(0, 500);
- mouse.hop(mouseHopx, mouseHopy);
- } else {
- antiBanStatus = "Mouse hopping...";
- if (random(1, 3) == 1) {
- mouseHopx = random(0, 760);
- mouseHopy = random(0, 500);
- mouse.hop(mouseHopx, mouseHopy);
- }
- }
- break;
- case 5:
- antiBanStatus = "Mouse hopping...";
- camera.setAngle(random(180, 360));
- sleep(500, 1000);
- if (random(1, 3) == 1) {
- mouseHopx = random(0, 760);
- mouseHopy = random(0, 500);
- mouse.hop(mouseHopx, mouseHopy);
- }
- break;
- }
- }
- }
- public void antiBanCamera() {
- isDoingAnti = true;
- int rand = random(1, 30);
- if (rand >= 1 && rand <= 3) {
- antiBanStatus = "randomizing Camera Movement...";
- camera.moveRandomly(random(2000, 5500));
- isDoingAnti = false;
- }
- if (rand >= 4 && rand <= 5) {
- antiBanStatus = "randomizing Camera Angle...";
- camera.setAngle(random(10, 100));
- isDoingAnti = false;
- }
- if (rand == 6) {
- antiBanStatus = "randomizing Camera Pitch...";
- camera.setPitch(random(40, 68));
- isDoingAnti = false;
- }
- if (rand == 7) {
- antiBanStatus = "randomizing Camera Pitch...";
- camera.setPitch(random(20, 45));
- isDoingAnti = false;
- }
- if (rand == 8) {
- antiBanStatus = "randomizing Camera Pitch...";
- camera.setPitch(random(68, 90));
- isDoingAnti = false;
- }
- if (rand >= 9) {
- isDoingAnti = false;
- }
- }
- }
- //</editor-fold>
- // <editor-fold defaultstate="collapsed" desc="GUI">
- public class ipuGUI extends javax.swing.JFrame {
- private static final long serialVersionUID = 1L;
- /** Creates new form ipuGUI */
- public ipuGUI() {
- initComponents();
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- main = new javax.swing.JPanel();
- devMode = new javax.swing.JCheckBox();
- tabbed = new javax.swing.JTabbedPane();
- info = new javax.swing.JPanel();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTextArea1 = new javax.swing.JTextArea();
- gen = new javax.swing.JPanel();
- screenshot = new javax.swing.JCheckBox();
- hopper = new javax.swing.JCheckBox();
- mousespeed = new javax.swing.JCheckBox();
- updater = new javax.swing.JCheckBox();
- loc = new javax.swing.JPanel();
- locations = new javax.swing.JComboBox();
- jScrollPane2 = new javax.swing.JScrollPane();
- requirements = new javax.swing.JTextArea();
- jLabel2 = new javax.swing.JLabel();
- extra = new javax.swing.JPanel();
- jScrollPane3 = new javax.swing.JScrollPane();
- credits = new javax.swing.JTextArea();
- changes = new javax.swing.JPanel();
- jScrollPane4 = new javax.swing.JScrollPane();
- jTextArea4 = new javax.swing.JTextArea();
- title = new javax.swing.JLabel();
- start = new javax.swing.JButton();
- viewthread = new javax.swing.JButton();
- donate = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
- setTitle("Iron Picker Uper GUI");
- setAlwaysOnTop(true);
- setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- setName("main"); // NOI18N
- setResizable(false);
- addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosed(java.awt.event.WindowEvent evt) {
- formWindowClosed(evt);
- }
- });
- jTextArea1.setColumns(20);
- jTextArea1.setEditable(false);
- jTextArea1.setLineWrap(true);
- jTextArea1.setRows(5);
- jTextArea1.setText("This script was Developed by Deww1 of Powerbot.\n\nPlease sell all ores 5% over the guide price in the Grand Exchange.\nIf you do not, I will be forced to close this script.\n\nIf you find any bugs, post them here:\nhttp://www.powerbot.org/vb/showthread.php?t=770408\n\nThis script collects ores from powerminers in Rimmington Mines, or the Guild Mine\nMore locations to be added soon.\nUpdated script! View change log!");
- jTextArea1.setWrapStyleWord(true);
- jScrollPane1.setViewportView(jTextArea1);
- javax.swing.GroupLayout infoLayout = new javax.swing.GroupLayout(info);
- info.setLayout(infoLayout);
- infoLayout.setHorizontalGroup(
- infoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
- );
- infoLayout.setVerticalGroup(
- infoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
- );
- tabbed.addTab("Info", info);
- screenshot.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- screenshot.setText("Take a Screenshot when script stops?");
- // screenshot.addActionListener(new java.awt.event.ActionListener() {
- // public void actionPerformed(java.awt.event.ActionEvent evt) {
- // screenshotActionPerformed(evt);
- // }
- // });
- hopper.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- hopper.setText("Use the Built In World Hopper?");
- // hopper.addActionListener(new java.awt.event.ActionListener() {
- // public void actionPerformed(java.awt.event.ActionEvent evt) {
- // hopperActionPerformed(evt);
- // }
- // });
- mousespeed.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- mousespeed.setText("Use Custom Mouse Speed Changer?");
- // mousespeed.addActionListener(new java.awt.event.ActionListener() {
- // public void actionPerformed(java.awt.event.ActionEvent evt) {
- // mousespeedActionPerformed(evt);
- // }
- // });
- updater.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- updater.setText("Do you wish to check for updates?");
- // updater.addActionListener(new java.awt.event.ActionListener() {
- // public void actionPerformed(java.awt.event.ActionEvent evt) {
- // updaterActionPerformed(evt);
- // }
- // });
- devMode.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- devMode.setText("Debug Mode(Logs all messages)");
- javax.swing.GroupLayout genLayout = new javax.swing.GroupLayout(gen);
- gen.setLayout(genLayout);
- genLayout.setHorizontalGroup(
- genLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(genLayout.createSequentialGroup()
- .addContainerGap()
- .addGroup(genLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(genLayout.createSequentialGroup()
- .addComponent(screenshot)
- .addContainerGap(200, Short.MAX_VALUE))
- .addGroup(genLayout.createSequentialGroup()
- .addComponent(hopper, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGap(244, 244, 244))
- .addGroup(genLayout.createSequentialGroup()
- .addComponent(mousespeed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGap(210, 210, 210))
- .addGroup(genLayout.createSequentialGroup()
- .addComponent(updater)
- .addContainerGap(218, Short.MAX_VALUE))
- .addGroup(genLayout.createSequentialGroup()
- .addComponent(devMode)
- .addContainerGap(236, Short.MAX_VALUE))))
- );
- genLayout.setVerticalGroup(
- genLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(genLayout.createSequentialGroup()
- .addGap(15, 15, 15)
- .addComponent(screenshot)
- .addGap(18, 18, 18)
- .addComponent(hopper)
- .addGap(18, 18, 18)
- .addComponent(mousespeed)
- .addGap(18, 18, 18)
- .addComponent(updater)
- .addGap(18, 18, 18)
- .addComponent(devMode)
- .addContainerGap(31, Short.MAX_VALUE))
- );
- tabbed.addTab("General Tab", gen);
- locations.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
- locations.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
- "Pick a Location", "Rimmington Mines", "Guild Mine" }));
- requirements.setColumns(20);
- requirements.setEditable(false);
- requirements.setLineWrap(true);
- requirements.setRows(5);
- requirements.setText("Rimmington Mines:\nNo Requirements, Apx. 400-600 ores/hr\n\nGuild Mines:\n60 Mining Required, Not Tested - Give quotes/proggies");
- requirements.setWrapStyleWord(true);
- jScrollPane2.setViewportView(requirements);
- jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- jLabel2.setText("Pick a location to pick up ores from.");
- javax.swing.GroupLayout locLayout = new javax.swing.GroupLayout(loc);
- loc.setLayout(locLayout);
- locLayout.setHorizontalGroup(
- locLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(locLayout.createSequentialGroup()
- .addContainerGap()
- .addGroup(locLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(locLayout.createSequentialGroup()
- .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
- .addContainerGap())
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, locLayout.createSequentialGroup()
- .addComponent(locations, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(60, 60, 60))))
- .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
- );
- locLayout.setVerticalGroup(
- locLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(locLayout.createSequentialGroup()
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(locations, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
- );
- tabbed.addTab("Locations", loc);
- credits.setColumns(20);
- credits.setEditable(false);
- credits.setLineWrap(true);
- credits.setRows(5);
- credits.setText("Credits:\nDeww1 - Main Script Programming\njtryba - Creating the implemented World Switcher\nEnfilade - Creating the Built in Updater(not working)\nEnfilade - Paint assistant\n\nExtras:\nI am trying to get Script Writer Status, so that my updater can soon work, but I can't do it without you guys. I need you guys to post in my thread! I need at least 100 positive feedback posts on the Iron Pick Up thread, so you can soon get updates without going to the thread! :)");
- credits.setWrapStyleWord(true);
- jScrollPane3.setViewportView(credits);
- javax.swing.GroupLayout extraLayout = new javax.swing.GroupLayout(extra);
- extra.setLayout(extraLayout);
- extraLayout.setHorizontalGroup(
- extraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
- );
- extraLayout.setVerticalGroup(
- extraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
- );
- tabbed.addTab("Extras/Credits", extra);
- jTextArea4.setColumns(20);
- jTextArea4.setEditable(false);
- jTextArea4.setLineWrap(true);
- jTextArea4.setRows(5);
- jTextArea4.setText("V 2: Initial Public Release\n \nV 2.1:\nUpdated paint\nMore accurate ore count\n2-step updater(checks two servers)\nmore informative finish() thread\n\nV. 2.23(BETA):\nNew bank location(Port Sarim)\nDownfalls:\nVery inaccurate paint info.(if you can help msg me)\n\nV 2.35(BETA):\nbanking is now more fluid(only tested for around 30 minutes)\nMuch more accurate paint\nnew banking path! :)\n\nV 2.38:\nScript now works with 2.42! - redownload the script, and it should work! :)\n\nV 2.39:\nFixed a nullPointerException - Script should now work.\n\nV 2.58:\nNew GUI\nNew location: Guild Mine (requires 60 mining) - Picks up Coal\n\nV 2.6:\nFinally got my Script Writer Rank so..\nUpdater now works\nfeel free to test it out! :)\nDebug feature in General: Displays all stesp take in the script in the logs.\nonly apply if having bot troubles...");
- jTextArea4.setWrapStyleWord(true);
- jScrollPane4.setViewportView(jTextArea4);
- javax.swing.GroupLayout changesLayout = new javax.swing.GroupLayout(changes);
- changes.setLayout(changesLayout);
- changesLayout.setHorizontalGroup(
- changesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
- );
- changesLayout.setVerticalGroup(
- changesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
- );
- tabbed.addTab("Change Log", changes);
- title.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
- title.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- title.setText("Iron Pick Up Settings - Script Developed by: Deww1");
- start.setText("Start Script");
- start.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- startActionPerformed(evt);
- }
- });
- viewthread.setText("View Thread");
- viewthread.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- viewthreadActionPerformed(evt);
- }
- });
- donate.setText("Donate");
- donate.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- donateActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout mainLayout = new javax.swing.GroupLayout(main);
- main.setLayout(mainLayout);
- mainLayout.setHorizontalGroup(
- mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(title, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
- .addComponent(tabbed, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
- .addGroup(mainLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(start, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(viewthread, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(donate, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
- .addContainerGap())
- );
- mainLayout.setVerticalGroup(
- mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(mainLayout.createSequentialGroup()
- .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(tabbed, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(start, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
- .addComponent(viewthread, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE))
- .addComponent(donate, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE))
- .addContainerGap())
- );
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(main, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(main, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- getAccessibleContext().setAccessibleName("ipuGUI");
- pack();
- }// </editor-fold>
- private void formWindowClosed(java.awt.event.WindowEvent evt) {
- stopScript();
- }
- private void screenshotActionPerformed(java.awt.event.ActionEvent evt) {
- if (screenshot.isSelected()) {
- shot = true;
- log("We will take a screenshot when we finish");
- } else {
- shot = false;
- log("We will not take a screenshot when we finish");
- }
- }
- private void hopperActionPerformed(java.awt.event.ActionEvent evt) {
- if (hopper.isSelected()) {
- wHop = true; //world hop
- log(Color.RED, "We will NOT be world hopping!");
- } else {
- wHop = false; //don't world hop
- log("We will be world hopping!");
- }
- }
- private void mousespeedActionPerformed(java.awt.event.ActionEvent evt) {
- if (mousespeed.isSelected()) {
- useMsRandom = true; //random mouse speed
- log(Color.RED, "We will NOT be using Random Mouse Speeds!");
- } else {
- useMsRandom = false; //no random mouse speed
- log("We will be using Random Mouse Speeds!");
- }
- }
- private void startActionPerformed(java.awt.event.ActionEvent evt) {
- setVisible(false);
- //dispose();
- }
- private void viewthreadActionPerformed(java.awt.event.ActionEvent evt) {
- String info = "http://www.powerbot.org/vb/showthread.php?t=770408";
- try {
- java.awt.Desktop.getDesktop().browse(java.net.URI.create(info));
- } catch (Exception e) {
- log("Error:" + e.getLocalizedMessage());
- }
- }
- private void donateActionPerformed(java.awt.event.ActionEvent evt) {
- String donate = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PJNGPMGCA4TVU";
- try {
- java.awt.Desktop.getDesktop().browse(
- java.net.URI.create(donate));
- } catch (Exception e) {
- log("Error:" + e.getLocalizedMessage());
- }
- }
- private void updaterActionPerformed(java.awt.event.ActionEvent evt) {
- if (updater.isSelected()) {
- doUpdate = true; //Don't check
- log(Color.RED, "We will NOT be checking for updates!");
- } else {
- doUpdate = false; //Do check
- log("We will be checking for updates!");
- }
- }
- // Variables declaration - do not modify
- private javax.swing.JCheckBox devMode;
- private javax.swing.JPanel changes;
- private javax.swing.JTextArea credits;
- private javax.swing.JButton donate;
- private javax.swing.JPanel extra;
- private javax.swing.JPanel gen;
- private javax.swing.JCheckBox hopper;
- private javax.swing.JPanel info;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JScrollPane jScrollPane2;
- private javax.swing.JScrollPane jScrollPane3;
- private javax.swing.JScrollPane jScrollPane4;
- private javax.swing.JTextArea jTextArea1;
- private javax.swing.JTextArea jTextArea4;
- private javax.swing.JPanel loc;
- private javax.swing.JComboBox locations;
- private javax.swing.JPanel main;
- private javax.swing.JCheckBox mousespeed;
- private javax.swing.JTextArea requirements;
- private javax.swing.JCheckBox screenshot;
- private javax.swing.JButton start;
- private javax.swing.JTabbedPane tabbed;
- private javax.swing.JLabel title;
- private javax.swing.JCheckBox updater;
- private javax.swing.JButton viewthread;
- // End of variables declaration
- }
- // </editor-fold>
- //<editor-fold defaultstate="collapsed" desc="Updater">
- private static final String UPDATER_FILE_NAME = "ironPickUp.java";
- private static final String UPDATER_URL = "http://scripters.powerbot.org/542806/scriptdir/ironPickUp.java";
- private static final Pattern UPDATER_VERSION_PATTERN = Pattern.compile("version\\s*=\\s*([0-9.]+)");
- private boolean checkForUpdates() {
- try {
- /* Get the current version from the Script Manifest annotation defined at the top of your script's class */
- double currentVer = ironPickUp.class.getAnnotation(ScriptManifest.class).version();
- double newVer = -1;
- URL url = new URL(UPDATER_URL);
- /* Open a stream to the newest script file hosted on your server */
- BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
- String line, lines = "";
- Matcher m;
- /* Look for the "version = x.x" string in the newer file to figure out the newest version number */
- while ((line = in.readLine()) != null) {
- lines += line + "\n";
- if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
- newVer = Double.parseDouble(m.group(1));
- break;
- }
- }
- /* Check if the updater was unable to read the newest version number */
- if (newVer < 0) {
- in.close();
- log("Unable to find the new version number. Update failed");
- return false;
- }
- /* Compare the current version to the newest. */
- if (currentVer == newVer) {
- in.close();
- log("You already have the latest version of the script.");
- return true;
- }
- /* The current version is less than the newest version, so we need to download it */
- log("Update found! Downloading version " + newVer);
- /* Figure out where to save the file */
- String scriptFilePath = Configuration.Paths.getScriptsSourcesDirectory() + "\\" + UPDATER_FILE_NAME;
- PrintWriter out = new PrintWriter(scriptFilePath);
- /* Print the cached lines from the version checking */
- out.print(lines);
- /* Print the rest of the file */
- while ((line = in.readLine()) != null) {
- out.println(line);
- }
- /* Close the streams */
- out.close();
- in.close();
- log(Color.RED,"Successfully saved " + UPDATER_FILE_NAME + " to " + Configuration.Paths.getScriptsSourcesDirectory());
- log(Color.MAGENTA, "File saved, now all you have to do is go to your RSBot directory, and compile\n the script!");
- log(Color.orange, "Update successful!");
- //log(Color.green, "The new version will appear near the bottom of the script selector.");
- //log(Color.red, "Stop and restart the script to run the newer version.");
- return true;
- } catch (IOException e) {
- log(e.toString());
- log("Update failed.");
- }
- return false;
- }
- //</editor-fold>
- //<editor-fold defaultstate="collapsed" desc="world hopper">
- public class hopper {
- public void worldHop(boolean members) {
- worldHop(members, 150, 1000);
- }
- public void worldHop(boolean members, int maxping) {
- worldHop(members, maxping, 1000);
- }
- public void worldHop(boolean members, int maxping, int maxpop) {
- final int LOBBY_PARENT = 906;
- final int WORLD_SELECT_TAB_PARENT = 910;
- final int WORLD_SELECT_COM = 77;
- final int WORLD_NUMBER_COM = 69;
- final int WORLD_POPULATION_COM = 71;
- final int WORLD_TYPE_COM = 74;
- final int WORLD_SELECT_BUTTON_COM = 188;
- final int WORLD_SELECT_BUTTON_BG_COM = 12;
- final int WORLD_SELECT_TAB_ACTIVE = 4671;
- final int WORLD_FULL_BACK_BUTTON_COM = 233;
- final int CURRENT_WORLD_COM = 11;
- final int SORT_POPULATION_BUTTON_PARENT = 30;
- final int SORT_PING_BUTTON_PARENT = 45;
- final int SORT_LOOTSHARE_BUTTON_PARENT = 47;
- final int SORT_TYPE_BUTTON_PARENT = 49;
- final int SORT_ACTIVITY_BUTTON_PARENT = 52;
- final int SORT_WORLD_BUTTON_PARENT = 55;
- final int SCROLL_BAR_PARENT = 86;
- final int HIGH_RISK_WARN_PARENT = 93;
- final int PLAY_BUTTON_COM = 171;
- final int RETURN_TEXT_COM = 221;
- final int SUBSCRIBE_BACK_BUTTON_COM = 233;
- final int CONNECT_ERROR_BACK_BUTTON_COM = 42;
- final int SKILL_WORLD_BACK_BUTTON_COM = 228;
- final int SKILL_WORLD_NUMBER = 113;
- long whileTimer = 0;
- log("Hopping worlds");
- status$ = "Hopping worlds";
- // logout
- while (game.isLoggedIn()) {
- if (game.logout(true)) {
- sleep(1000, 1500);
- while (game.getClientState() != 7) {
- sleep(random(200, 500));
- }
- }
- }
- status$ = "Selecting new world";
- sleep(random(1500, 2000));
- // click world select tab (if needed)
- RSComponent worldSelectTab = interfaces.getComponent(LOBBY_PARENT,
- WORLD_SELECT_BUTTON_BG_COM);
- whileTimer = System.currentTimeMillis();
- while (worldSelectTab.getBackgroundColor() != WORLD_SELECT_TAB_ACTIVE
- && System.currentTimeMillis() - whileTimer < 90000) {
- if (interfaces.get(LOBBY_PARENT).getComponent(WORLD_SELECT_BUTTON_BG_COM).doClick()) {
- //interfaces.getComponent(LOBBY_PARENT, WORLD_SELECT_BUTTON_BG_COM).doClick();
- sleep(random(1500, 2000));
- }
- }
- // get current world
- String cW = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- CURRENT_WORLD_COM).getText();
- String[] cWS = cW.split(" ");
- currentWorld = Integer.parseInt(cWS[1]);
- newWorld = currentWorld;
- // randomly sort worlds
- if (random(0, 10) < 5) {
- RSComponent com = null;
- switch (random(0, 6)) {
- case 0: // population
- com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- SORT_POPULATION_BUTTON_PARENT).getComponent(
- random(0, 2));
- break;
- case 1: // ping
- com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- SORT_PING_BUTTON_PARENT).getComponent(random(0, 2));
- break;
- case 2: // loot share
- com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- SORT_LOOTSHARE_BUTTON_PARENT).getComponent(random(0, 2));
- break;
- case 3: // type
- com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- SORT_TYPE_BUTTON_PARENT).getComponent(random(0, 2));
- break;
- case 4: // activity
- com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- SORT_ACTIVITY_BUTTON_PARENT).getComponent(random(0, 2));
- break;
- case 5: // world
- com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- SORT_WORLD_BUTTON_PARENT).getComponent(random(0, 2));
- break;
- }
- if (com.doClick()) {
- sleep(random(1250, 1500));
- }
- }
- // check if we should sort by ptp/ftp
- boolean sort = false;
- RSComponent[] wt = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- WORLD_TYPE_COM).getComponents();
- for (int i = 0; i < 10; i++) {
- if ((members && !wt[i].getText().contains("Members"))
- || (!members && wt[i].getText().contains("Members"))) {
- sort = true;
- break;
- }
- }
- // sort by ptp/ftp (if needed)
- if (sort) {
- status$ = "Sorting worlds by type";
- if (interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- SORT_TYPE_BUTTON_PARENT).getComponent(members ? 0 : 1).doClick()) {
- sleep(random(1000, 1500));
- }
- }
- /*-PICK-NEXT-WORLD-*/
- whileTimer = System.currentTimeMillis();
- while (currentWorld == newWorld
- && System.currentTimeMillis() - whileTimer < 90000) {
- RSComponent worldToHop = null;
- RSComponent[] comWorldNumber = interfaces.getComponent(
- WORLD_SELECT_TAB_PARENT, WORLD_NUMBER_COM).getComponents();
- int world = 0;
- int pop = 2000;
- int ping = -1;
- boolean member = false;
- while (worldToHop == null) {
- for (int i = 0; i < comWorldNumber.length - 1; i++) {
- RSComponent[] comWorldSelect = interfaces.getComponent(
- WORLD_SELECT_TAB_PARENT, WORLD_SELECT_COM).getComponents();
- RSComponent[] comWorldPopulation = interfaces.getComponent(
- WORLD_SELECT_TAB_PARENT, WORLD_POPULATION_COM).getComponents();
- RSComponent[] comWorldType = interfaces.getComponent(
- WORLD_SELECT_TAB_PARENT, WORLD_TYPE_COM).getComponents();
- comWorldNumber = interfaces.getComponent(
- WORLD_SELECT_TAB_PARENT, WORLD_NUMBER_COM).getComponents();
- try {
- world = Integer.parseInt(comWorldNumber[i].getText());
- } catch (NumberFormatException nfe) {
- world = 0;
- } catch (ArrayIndexOutOfBoundsException aie) {
- world = 0;
- }
- if (world == SKILL_WORLD_NUMBER && skillTotal < 1000) {
- world = 0;
- }
- try {
- pop = Integer.parseInt(comWorldPopulation[i].getText());
- } catch (NumberFormatException nfe) {
- pop = 2000;
- } catch (ArrayIndexOutOfBoundsException aie) {
- pop = 2000;
- }
- try {
- if (comWorldType[i].getText().contains("Members")) {
- member = true;
- }
- } catch (ArrayIndexOutOfBoundsException aie) {
- }
- if (world != 0 && !isPastWorld(world)
- && world != currentWorld && pop < maxpop && pop > 0
- && member == members) {
- ping = pingHost("world" + world + ".runescape.com",
- maxPing + 50);
- } else {
- ping = -1;
- }
- if (ping < maxping && ping > 0) {
- log("World " + world + " selected.");
- worldToHop = comWorldSelect[i];
- }
- if (worldToHop != null) {
- break;
- }
- }
- sleep(random(50, 150));
- }
- if (worldToHop != null) {
- int w = -1;
- String[] split = interfaces.getComponent(910, 8).getText().split(" ");
- try {
- w = Integer.parseInt(split[split.length - 1]);
- } catch (Exception e) {
- w = -1;
- }
- // click new world
- while (w != world) {
- if (worldToHop.getLocation().y <= 280
- && worldToHop.getLocation().y >= 0) {
- status$ = "Clicking new world";
- worldToHop.doClick();
- } else {
- RSComponent scrollBar = interfaces.getComponent(
- WORLD_SELECT_TAB_PARENT, SCROLL_BAR_PARENT);
- status$ = "Scrolling to new world";
- if (interfaces.scrollTo(worldToHop, scrollBar)) {
- status$ = "Clicking new world";
- worldToHop.doClick();
- }
- }
- split = interfaces.getComponent(910, 8).getText().split(" ");
- try {
- w = Integer.parseInt(split[split.length - 1]);
- } catch (Exception e) {
- w = -1;
- }
- }
- // get new world
- sleep(random(1000, 1500));
- String cW2 = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
- CURRENT_WORLD_COM).getText();
- String[] cWS2 = cW2.split(" ");
- newWorld = Integer.parseInt(cWS2[1]);
- }
- }
- /*-END-PICK-NEXT-WORLD-*/
- // set last & current world/s
- if (currentWorld != newWorld) {
- for (int i = 0; i < pastWorld.length; i++) {
- if (i < pastWorld.length - 1) {
- pastWorld[i] = pastWorld[i + 1];
- } else {
- pastWorld[i] = currentWorld;
- }
- }
- currentWorld = newWorld;
- }
- while (game.getClientState() != 10) {
- status$ = "Logging in...";
- // click play button
- if (interfaces.getComponent(LOBBY_PARENT, PLAY_BUTTON_COM).doClick()) {
- hopped++;
- timer.reset();
- }
- // check for high risk world warning during login
- long timeOut = System.currentTimeMillis() + 35000;
- while (game.getClientState() != 10
- && System.currentTimeMillis() < timeOut) {
- RSComponent hrParent = interfaces.getComponent(LOBBY_PARENT,
- HIGH_RISK_WARN_PARENT);
- if (hrParent.isValid()) {
- RSComponent LogIn = hrParent.getComponent(random(0,
- hrParent.getComponents().length));
- if (LogIn != null && LogIn.isValid()) {
- if (mouse.getLocation().getX() < 386
- || mouse.getLocation().getX() > 504
- || mouse.getLocation().getY() < 357
- || mouse.getLocation().getY() > 386) {
- if (LogIn.doHover()) {
- sleep(random(250, 500));
- if (menu.contains("Log In")) {
- // accept warning / click login
- mouse.click(true);
- log.warning("This is a high risk wilderness world.");
- sleep(random(250, 500));
- }
- }
- }
- }
- }
- sleep(100);
- }
- // check for login errors
- String returnText = interfaces.getComponent(LOBBY_PARENT, RETURN_TEXT_COM).getText().toLowerCase();
- if (!game.isLoggedIn()) {
- if (returnText.contains("update")) {
- status$ = "Stopping script";
- log("Runescape has been updated, please reload RSBot.");
- stopScript(false);
- }
- if (returnText.contains("disable")) {
- status$ = "Stopping script";
- log("Your account is banned/disabled.");
- stopScript(false);
- }
- if (returnText.contains("error connecting")) {
- status$ = "Stopping script";
- log("STOPPED = line 1045 - error connecting");
- interfaces.getComponent(LOBBY_PARENT,
- CONNECT_ERROR_BACK_BUTTON_COM).doClick();
- stopScript(false);
- }
- if (returnText.contains("full")) {
- log("World Is Full.");
- interfaces.getComponent(LOBBY_PARENT,
- WORLD_FULL_BACK_BUTTON_COM).doClick();
- sleep(random(1000, 1500));
- worldHop(members, maxping, maxpop); // try again
- }
- if (returnText.contains("subscribe")) {
- interfaces.getComponent(LOBBY_PARENT,
- SUBSCRIBE_BACK_BUTTON_COM).doClick();
- if (members) {
- status$ = "Stopping script";
- log("You neen to be a member to select this world.");
- stopScript(false);
- } else {
- sleep(random(500, 1000));
- worldHop(members, maxping, maxpop); // try again
- }
- }
- if (returnText.contains("must have a total")) {
- log("STOPPED = line 1069 - must have a total");
- interfaces.getComponent(LOBBY_PARENT,
- SKILL_WORLD_BACK_BUTTON_COM).doClick();
- sleep(random(500, 1000));
- worldHop(members, maxping, maxpop); // try again
- }
- }
- }
- }
- private boolean isPastWorld(int world) {
- for (int i = 0; i < pastWorld.length; i++) {
- if (pastWorld[i] == world) {
- return true;
- }
- }
- return false;
- }
- private int pingHost(String host, int timeout) {
- long start = -1;
- long end = -1;
- int total = -1;
- int defaultPort = 80;
- Socket theSock = new Socket();
- try {
- InetAddress addr = InetAddress.getByName(host);
- SocketAddress sockaddr = new InetSocketAddress(addr, defaultPort);
- start = System.currentTimeMillis();
- theSock.connect(sockaddr, timeout);
- end = System.currentTimeMillis();
- } catch (Exception e) {
- start = -1;
- end = -1;
- } finally {
- if (theSock != null) {
- try {
- theSock.close();
- } catch (IOException e) {
- }
- if ((start != -1) && (end != -1)) {
- total = (int) (end - start);
- log(host + "'s ping delay is " + total + "ms.");
- } else {
- log("Connection timed out or unable to connect to host: "
- + host);
- }
- }
- }
- return total; // returns -1 if timeout
- }
- }
- //</editor-fold>
- //<editor-fold defaultstate="collapsed" desc="Paint Stuff">
- //START: Code generated using Enfilade's Easel
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(0, 0, 0);
- private final Color color2 = new Color(240, 240, 240);
- private final Color color3 = new Color(255, 255, 255);
- private final Color color4 = new Color(153, 153, 153, 185);
- private final Color color5 = new Color(153, 153, 153, 155);
- private final Color color6 = new Color(212, 222, 150);
- private final Color color7 = new Color(204, 204, 0, 130);
- private final Font font1 = new Font("Times New Roman", 0, 10);
- private final Font font2 = new Font("Times New Roman", 0, 12);
- private final Image img1 = getImage("http://i360.photobucket.com/albums/oo47/perez048/paint-2.png");
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- if (normal != null) {
- final int mouse_x = mouse.getLocation().x;
- final int mouse_y = mouse.getLocation().y;
- final int mouse_x2 = mouse.getPressLocation().x;
- final int mouse_y2 = mouse.getPressLocation().y;
- final long mpt = System.currentTimeMillis()
- - mouse.getPressTime();
- if (mouse.getPressTime() == -1 || mpt >= 1000) {
- g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse when its not clicked
- }
- if (mpt < 1000) {
- g.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null); //this show the four squares where you clicked.
- g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse as normal when its/just clicked
- }
- }
- if (game.isLoggedIn()) {
- long time = System.currentTimeMillis() - startTime;
- int pricePH = (int) (price * 3600000D / time);
- int Price = (orePrice*oreCollected);
- price = orePrice*oreCollected;
- priceHr = (int) ((price) * 3600000D / (System.currentTimeMillis() - startTime));
- oreHr = (int) ((oreCollected) * 3600000D / (System.currentTimeMillis() - startTime));
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- millis2 = timer.getRemaining() - 60;
- seconds2 = millis2 / 1000;
- if (showPaint1) { //paint closed
- g.setColor(color1);
- g.fillRect(6, 312, 75, 24);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("Open Paint", 14, 331);
- } else if (showPaint2) { //general tab
- g.drawImage(img1, -2, 310, null);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString("Ores/hr: "+oreHr, 264, 443);
- g.drawString("Ores Collected: "+oreCollected, 262, 428);
- g.drawString("Run Time: "+hours+":"+minutes+":"+seconds, 263, 413);
- g.setColor(color2);
- g.drawString("Version: "+ver, 91, 385);
- g.setFont(font2);
- g.drawString("Status: "+status, 78, 473);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString("Mouse Speed: "+MouseSpeed, 16, 416);
- g.drawString("World Hops: "+hopped, 16, 431);
- g.drawString("Time to Switch: "+seconds2, 15, 446);
- g.setColor(color6);
- g.fillRect(446, 313, 70, 24);
- g.setFont(font2);
- g.setColor(color1);
- g.drawString("General Tab", 453, 332);
- g.setColor(color4);
- g.fillRect(376, 315, 68, 23);
- g.setColor(color1);
- g.drawString("Money Tab", 381, 333);
- g.setColor(color5);
- g.fillRect(6, 312, 75, 24);
- g.setColor(color1);
- g.drawString("Close Paint", 14, 331);
- } else if (showPaint3) { //money tab
- g.drawImage(img1, -2, 310, null);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString("Run Time: "+hours+":"+minutes+":"+seconds, 264, 422);
- g.setColor(color2);
- g.drawString("Version: "+ver, 91, 385);
- g.setFont(font2);
- g.drawString("Status: "+status, 78, 473);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString("Total Money Made: "+Price, 22, 419);
- g.drawString("Total Money per/hr: "+pricePH, 22, 443);
- g.drawString("Ores Collected: "+oreCollected, 262, 448);
- g.setColor(color6);
- g.fillRect(446, 313, 70, 24);
- g.setFont(font2);
- g.setColor(color1);
- g.drawString("General Tab", 453, 332);
- g.setColor(color5);
- g.fillRect(376, 315, 68, 23);
- g.setColor(color1);
- g.drawString("Money Tab", 381, 333);
- g.setColor(color4);
- g.fillRect(6, 312, 75, 24);
- g.setColor(color1);
- g.drawString("Close Paint", 14, 331);
- }
- //END: Code generated using Enfilade's Easel
- } else {
- String s = "Status: " + status$
- + " || Times hopped: " + hopped;
- g.setColor(color1);
- g.fillRoundRect(240, 104, s.length() * 6, 17, 16, 16);
- g.setFont(new Font("Arial", 1, 12));
- g.setColor(color2);
- g.drawString(s, 250, 117);
- }
- }
- //END: Code generated using Enfilade's Easel
- @Override
- public void mouseClicked(MouseEvent e) {
- p = e.getPoint();
- if(hide.contains(p) && !showPaint1){
- showPaint1 = true;
- showPaint2 = false;
- showPaint3 = false;
- } else if (hide.contains(p) && showPaint1) {
- showPaint1 = false;
- showPaint2 = true;
- showPaint3 = false;
- }
- if (genTab.contains(p) && !showPaint2) {
- showPaint2 = true;
- showPaint1 = false;
- showPaint3 = false;
- }
- if (monTab.contains(p) && !showPaint3) {
- showPaint3 = true;
- showPaint2 = false;
- showPaint1 = false;
- }
- }
- @Override
- public void mouseEntered(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- //</editor-fold>
- //<editor-fold defaultstate="collapsed" desc="backup stuff">
- // public int bankOpen() {
- // if (atBank() && players.getMyPlayer().isIdle()) {
- // status = "Opening Bank.";
- // RSObject bankBooth = objects.getNearest(BANK);
- // if (random(1, 4) > 1) {
- // bankBooth.doAction("Use-quickly");
- // } else {
- // antiban.antiban();
- // }
- // }
- // return random(800, 1300);
- // }
- //
- // public int depositBank() {
- // status = "Depositing ores";
- // bank.depositAll();
- // return random(300, 1100);
- // }
- //
- // public int bankClose() {
- // if (bank.isOpen()) {
- // status = "Closing Bank.";
- // bank.close();
- // sleep(random(200, 1000));
- // }
- // return random(300, 800);
- // }
- //
- // public void banking() {
- // if (!bank.isOpen()) {
- // bankOpen();
- // antiban.antiban();
- // }
- // if (bank.isOpen()) {
- // depositBank();
- // antiban.antiban();
- // sleep(random(100, 500));
- // banked++;
- // }
- //
- // timer.reset();
- // }
- // RSTile toBank1[] = new RSTile[]{new RSTile(2970, 3239), new RSTile(2973, 3244),
- // new RSTile(2975, 3248), new RSTile(2976, 3253),
- // new RSTile(2978, 3258), new RSTile(2978, 3263),
- // new RSTile(2978, 3268), new RSTile(2980, 3273),
- // new RSTile(2986, 3277), new RSTile(2989, 3282),
- // new RSTile(2992, 3287), new RSTile(2997, 3292),
- // new RSTile(3001, 3296), new RSTile(3002, 3301),
- // new RSTile(3006, 3306), new RSTile(3006, 3312),
- // new RSTile(3006, 3316), new RSTile(3006, 3321),
- // new RSTile(3006, 3326), new RSTile(3006, 3331),
- // new RSTile(3006, 3336), new RSTile(3006, 3341),
- // new RSTile(3006, 3347), new RSTile(3008, 3352),
- // new RSTile(3008, 3357), new RSTile(3011, 3357),
- // new RSTile(3012, 3355)};
- // RSTile toMine1[] = new RSTile[]{new RSTile(3012, 3355), new RSTile(3011, 3359),
- // new RSTile(3008, 3359), new RSTile(3008, 3355),
- // new RSTile(3008, 3351), new RSTile(3008, 3346),
- // new RSTile(3008, 3341), new RSTile(3008, 3336),
- // new RSTile(3008, 3331), new RSTile(3007, 3326),
- // new RSTile(3007, 3321), new RSTile(3007, 3316),
- // new RSTile(3007, 3311), new RSTile(3002, 3305),
- // new RSTile(2997, 3300), new RSTile(2996, 3296),
- // new RSTile(2994, 3291), new RSTile(2994, 3286),
- // new RSTile(2994, 3281), new RSTile(2995, 3275),
- // new RSTile(2992, 3270), new RSTile(2988, 3266),
- // new RSTile(2983, 3262), new RSTile(2981, 3257),
- // new RSTile(2978, 3252), new RSTile(2973, 3248),
- // new RSTile(2971, 3244), new RSTile(2970, 3240)};
- //</editor-fold>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement