Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 46.65 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Point;
  5. import java.awt.Polygon;
  6. import java.awt.Rectangle;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.util.ArrayList;
  10. import javax.swing.GroupLayout;
  11. import javax.swing.JButton;
  12. import javax.swing.JFrame;
  13. import javax.swing.JLabel;
  14. import javax.swing.JPanel;
  15. import javax.swing.LayoutStyle;
  16. import org.rsbot.event.listeners.PaintListener;
  17. import org.rsbot.script.Script;
  18. import org.rsbot.script.ScriptManifest;
  19. import org.rsbot.script.methods.Bank;
  20. import org.rsbot.script.wrappers.RSComponent;
  21. import org.rsbot.script.wrappers.RSInterface;
  22. import org.rsbot.script.wrappers.RSModel;
  23. import org.rsbot.script.wrappers.RSNPC;
  24. import org.rsbot.script.wrappers.RSObject;
  25. import org.rsbot.script.wrappers.RSPlayer;
  26. import org.rsbot.script.wrappers.RSTile;
  27.  
  28. @ScriptManifest(authors={"Marneus901"}, name="Runite Miner", version=0.2, description="")
  29. public class MarneusRunite extends Script
  30.   implements PaintListener
  31. {
  32.   public long runTime = 0L;
  33.   public long millis;
  34.   public long hours;
  35.   public long minutes;
  36.   public long seconds;
  37.   public int currentLevel = -1;
  38.   public int startXP = -1;
  39.   public double currentXP = -1.0D;
  40.   public int startLevel = -1;
  41.   public RSObject objectToDisplay;
  42.   public RSTile tileToWalkTo;
  43.   public boolean shuttingDown = false;
  44.   public boolean PAUSE = false;
  45.   public long idleTime;
  46.   public boolean stop = false;
  47.   public TheWalker theWalker = new TheWalker();
  48.   public LoginBot loginBot = new LoginBot();
  49.   public GUI gui = new GUI();
  50.   public boolean displayDebug = true;
  51.   public int expTillLevel = 0;
  52.   public static final int[] BankChests = { 27663, 4483, 12308, 21301, 42192 };
  53.  
  54.   public static final int[] validWorlds = { 2, 6, 9, 12, 15, 22, 23, 24, 27, 28,
  55.     31, 36, 39, 42, 44, 45, 46, 48, 51, 52,
  56.     53, 54, 58, 59, 60, 64, 66, 67, 68,
  57.     69, 70, 71, 76, 77, 78, 79, 82, 83, 84,
  58.     88, 89, 91, 92, 97, 98, 99, 100, 103, 104,
  59.     112, 115, 116, 117, 119, 129, 130, 131,
  60.     132, 138, 142, 143, 144, 145, 148, 151, 156,
  61.     157, 158, 159, 160, 164, 166 };
  62.  
  63.   public static final int[] allWorlds = { 1, 2, 3, 4, 5, 6, 7, 8,
  64.     9, 10, 11, 12, 13, 14, 15, 16,
  65.     17, 18, 19, 20, 21, 22, 23, 24,
  66.     25, 26, 27, 28, 29, 30, 31, 32,
  67.     33, 34, 35, 36, 37, 38, 39, 40,
  68.     41, 42, 43, 44, 45, 46, 47, 48,
  69.     49, 50, 51, 52, 53, 54, 55, 56,
  70.     57, 58, 59, 60, 61, 62, 64, 65,
  71.     66, 67, 68, 69, 70, 71, 72, 73,
  72.     74, 75, 76, 77, 78, 79, 80, 81,
  73.     82, 83, 84, 85, 86, 87, 88, 89,
  74.     90, 91, 92, 93, 96, 97, 98, 99,
  75.     100, 102, 103, 104, 105, 106, 108, 112,
  76.     113, 114, 115, 116, 117, 118, 119, 120,
  77.     121, 123, 124, 129, 130, 131, 132, 134,
  78.     135, 136, 137, 138, 139, 141, 142, 143,
  79.     144, 145, 148, 149, 151, 152, 153, 154,
  80.     155, 156, 157, 158, 159, 160, 161, 164,
  81.     165, 166, 167, 169 };
  82.  
  83.   public int worldToSwitchTo = -1;
  84.   public static int welcomeScreenTabTextureID = 2629;
  85.   public static int clickHereToPlayID = 145;
  86.   public static int worldSelectTabID = 197;
  87.   public static int worldInterfaceID = 76;
  88.   public static int playersInterfaceID = 70;
  89.   public static int scrollbarID = 85;
  90.   public static int worldSwitchCheckID = 10;
  91.  
  92.   public static int faladorTabID = 8009;
  93.   public static int runeOreID = 451;
  94.   public static int sapphireID = 1623;
  95.   public static int emeraldID = 1621;
  96.   public static int rubyID = 1619;
  97.   public static int diamondID = 1617;
  98.   public static int runePickaxeID = 1275;
  99.   public static int dragonPickaxeID = 15259;
  100.   public int[] runeRockIDs = { 33078, 33079 };
  101.   public int miningAnimation = 624;
  102.   public int oresMined = 0;
  103.  
  104.   public RSTile[] bankToRunePath1 = { new RSTile(2946, 3373), new RSTile(2952, 3378), new RSTile(2958, 3383), new RSTile(2964, 3388),
  105.     new RSTile(2965, 3394), new RSTile(2965, 3399), new RSTile(2964, 3404), new RSTile(2960, 3410), new RSTile(2958, 3416),
  106.     new RSTile(2952, 3421), new RSTile(2948, 3426), new RSTile(2948, 3431), new RSTile(2948, 3436), new RSTile(2948, 3442),
  107.     new RSTile(2945, 3447), new RSTile(2939, 3451) };
  108.  
  109.   public RSTile[] bankToRunePath2 = { new RSTile(2929, 3451), new RSTile(2922, 3454), new RSTile(2915, 3456), new RSTile(2909, 3456),
  110.     new RSTile(2902, 3456), new RSTile(2897, 3462), new RSTile(2897, 3468), new RSTile(2898, 3473), new RSTile(2900, 3479),
  111.     new RSTile(2903, 3484), new RSTile(2905, 3489), new RSTile(2905, 3495), new RSTile(2905, 3502), new RSTile(2904, 3507),
  112.     new RSTile(2903, 3510) };
  113.  
  114.   public RSTile[] bankToRunePath3 = { new RSTile(2900, 9910), new RSTile(2910, 9913), new RSTile(2922, 9912), new RSTile(2933, 9910), new RSTile(2934, 9902), new RSTile(2935, 9893), new RSTile(2938, 9884) };
  115.   public RSTile[] runeToBankPath = new RSTile[0];
  116.  
  117.   public String getName()
  118.   {
  119.     return "Runite Miner"; }
  120.   public String getAuthor() { return "Marneus901"; }
  121.   public double getVersion() { return 0.1D;
  122.   }
  123.  
  124.   public int getMouseSpeed()
  125.   {
  126.     return 0;
  127.   }
  128.  
  129.   public boolean open() {
  130.     try {
  131.       if (this.menu.isOpen()) {
  132.         this.mouse.moveSlightly();
  133.         wait(random(20, 30));
  134.       }
  135.       RSObject bankBooth = this.objects.getNearest(Bank.BANK_BOOTHS);
  136.       RSNPC banker = this.npcs.getNearest(Bank.BANKERS);
  137.       RSObject bankChest = this.objects.getNearest(BankChests);
  138.       int lowestDist = this.calc.distanceTo(bankBooth);
  139.       if ((banker != null) && (this.calc.distanceTo(banker) < lowestDist)) {
  140.         lowestDist = this.calc.distanceTo(banker);
  141.         bankBooth = null;
  142.       }
  143.       if ((bankChest != null) && (this.calc.distanceTo(bankChest) < lowestDist)) {
  144.         bankBooth = null;
  145.         banker = null;
  146.       }
  147.       if (((bankBooth != null) && (this.calc.distanceTo(bankBooth) < 8) &&
  148.         (this.calc.tileOnMap(bankBooth.getLocation())) &&
  149.         (this.calc.canReach(bankBooth.getLocation(), true))) || ((banker != null) &&
  150.         (this.calc.distanceTo(banker) < 8) &&
  151.         (this.calc.tileOnMap(banker.getLocation())) &&
  152.         (this.calc.canReach(banker.getLocation(), true))) || (
  153.         (bankChest != null) &&
  154.         (this.calc.distanceTo(bankChest) < 8) &&
  155.         (this.calc.tileOnMap(bankChest.getLocation())) &&
  156.         (this.calc.canReach(bankChest.getLocation(), true)) && (!this.bank.isOpen()))) {
  157.         if (bankBooth != null) {
  158.           this.objectToDisplay = bankBooth;
  159.           bankBooth.doAction("Use-Quickly");
  160.           sleep(random(200, 400));
  161.         } else if (banker != null) {
  162.           banker.doAction("Bank ");
  163.           sleep(random(200, 400));
  164.         } else if (bankChest != null) {
  165.           this.objectToDisplay = bankChest;
  166.           bankChest.doAction("Use");
  167.           sleep(random(200, 400));
  168.         }
  169.       } else {
  170.         if (bankBooth != null) {
  171.           this.walking.walkTileMM(bankBooth.getLocation(), 1, 1);
  172.           while (this.calc.distanceTo(this.walking.getDestination()) > 8) {
  173.             sleep(random(200, 400));
  174.           }
  175.           return open();
  176.         }if (banker != null) {
  177.           this.walking.walkTileMM(banker.getLocation(), 1, 1);
  178.           while (this.calc.distanceTo(this.walking.getDestination()) > 8) {
  179.             sleep(random(200, 400));
  180.           }
  181.           return open();
  182.         }if (bankChest != null) {
  183.           this.walking.walkTileMM(bankChest.getLocation(), 1, 1);
  184.           while (this.calc.distanceTo(this.walking.getDestination()) > 8) {
  185.             sleep(random(200, 400));
  186.           }
  187.           return open();
  188.         }
  189.       }
  190.       return this.bank.isOpen();
  191.     } catch (Exception e) {
  192.       e.printStackTrace();
  193.     }return false;
  194.   }
  195.  
  196.   public boolean onStart() {
  197.     this.mouse.setSpeed(getMouseSpeed());
  198.     this.runTime = System.currentTimeMillis();
  199.     this.gui.setVisible(true);
  200.     return true;
  201.   }
  202.   public void onFinish() {
  203.     this.gui.setVisible(false);
  204.   }
  205.   public Point[] getObjectModelPoints(RSTile t) {
  206.     ArrayList pts = new ArrayList();
  207.     for (RSObject o : this.objects.getAllAt(t)) {
  208.       RSModel model = o.getModel();
  209.       if (model != null) {
  210.         for (Polygon polygon : model.getTriangles()) {
  211.           for (int i = 0; i < polygon.npoints; i++)
  212.             pts.add(new Point(polygon.xpoints[i], polygon.ypoints[i]));
  213.         }
  214.       }
  215.     }
  216.     if (pts.size() < 1) return new Point[0];
  217.     Point[] rtnPts = new Point[pts.size()];
  218.     for (int i = 0; i < pts.size(); i++)
  219.       rtnPts[i] = ((Point)pts.get(i));
  220.     return rtnPts;
  221.   }
  222.  
  223.   public int loop() {
  224.     String returnText = this.interfaces.get(906).getComponent(221).getText().toLowerCase();
  225.     if (returnText.contains("full")) {
  226.       log("World is full. Switching worlds.");
  227.       this.worldToSwitchTo = -1;
  228.       this.interfaces.get(906).getComponent(228).doClick();
  229.       return 1000;
  230.     }
  231.     if (returnText.contains("logged out")) {
  232.       log("Odd login glitch. Fixing then sleeping for 1-30min.");
  233.       this.worldToSwitchTo = -1;
  234.       for (int i = 0; i < 20; i++) {
  235.         if (!this.interfaces.get(906).getComponent(221).isValid()) {
  236.           break;
  237.         }
  238.         this.interfaces.get(906).getComponent(228).doClick();
  239.         sleep(random(100, 250));
  240.       }
  241.       sleep(1000);
  242.       this.game.logout(false);
  243.       int sleepTime = random(60000, 1800000);
  244.       log("Sleeping for " + sleepTime + " milliseconds");
  245.       for (int i = sleepTime / 30000 + 30000; i > 60; i--) {
  246.         log("Sleeping for about " + i * 30000 + " milliseconds");
  247.         sleep(30000);
  248.       }
  249.       return 1000;
  250.     }
  251.     if (returnText.contains("members-only")) {
  252.       log("Wrong world selected. Fixing.");
  253.       this.worldToSwitchTo = -1;
  254.       this.interfaces.get(906).getComponent(228).doClick();
  255.       return 1000;
  256.     }
  257.     if (returnText.contains("transferred"))
  258.       return 10;
  259.     if (this.game.getClientState() == 7) {
  260.       if (this.worldToSwitchTo == -1)
  261.         this.worldToSwitchTo = random(0, validWorlds.length);
  262.       switchToWorld(validWorlds[this.worldToSwitchTo]);
  263.       return 10;
  264.     }
  265.     if (this.game.isLoggedIn()) {
  266.       if (this.startLevel == -1) {
  267.         this.startLevel = this.skills.getCurrentLevel(14);
  268.         this.startXP = this.skills.getCurrentExp(14);
  269.       }
  270.       if (this.interfaces.getComponent(740, 3).isValid()) {
  271.         this.interfaces.getComponent(740, 3).doClick();
  272.       }
  273.       if (this.inventory.isFull()) {
  274.         if (this.inventory.contains(faladorTabID)) {
  275.           bankUsingFallyTab();
  276.         }
  277.  
  278.       }
  279.       else
  280.       {
  281.         walkToHerosGuild();
  282.       }
  283.       return 10;
  284.     }
  285.  
  286.     if (this.loginBot.activateCondition()) {
  287.       int sleep = this.loginBot.loop();
  288.       if (sleep == -1) return 10;
  289.       return sleep;
  290.     }
  291.  
  292.     return 10;
  293.   }
  294.   public boolean insideHeroGuild() {
  295.     RSTile myPlayerLoc = this.players.getMyPlayer().getLocation();
  296.  
  297.     return ((myPlayerLoc.getX() < 2902) && (myPlayerLoc.getX() > 2898) &&
  298.       (myPlayerLoc.getY() < 3513) && (myPlayerLoc.getY() > 3508)) || (
  299.       (myPlayerLoc.getX() > 2891) && (myPlayerLoc.getX() < 2899) &&
  300.       (myPlayerLoc.getY() > 3506) && (myPlayerLoc.getY() < 3515));
  301.   }
  302.   public void walkToHerosGuild() {
  303.     if (this.players.getMyPlayer().getLocation().getY() > 9000) {
  304.       if (this.calc.tileOnScreen(new RSTile(2939, 9883))) {
  305.         RSObject runeRock = this.objects.getNearest(this.runeRockIDs);
  306.         if (runeRock == null) {
  307.           log("No runite on this world.");
  308.           this.game.logout(true);
  309.           for (int i = 0; i < 20; i++) {
  310.             if (!this.game.isLoggedIn()) {
  311.               this.worldToSwitchTo = -1;
  312.               sleep(3000);
  313.               return;
  314.             }
  315.             sleep(100, 200);
  316.           }
  317.           return;
  318.         }
  319.         this.objectToDisplay = runeRock;
  320.         Point[] runePts = getObjectModelPoints(runeRock.getLocation());
  321.         if (runePts.length == 0) return;
  322.         this.mouse.move(runePts[random(0, runePts.length)]);
  323.  
  324.         sleep(random(50, 150));
  325.         int invCount = this.inventory.getCount(new int[] { runeOreID });
  326.         this.mouse.click(true);
  327.         for (int i = 0; i < 20; i++) {
  328.           if (!this.players.getMyPlayer().isIdle()) {
  329.             log("Attempting to get the rune from the rock.");
  330.             for (int k = 0; k < 20; k++) {
  331.               if (this.objects.getNearest(new int[] { runeRock.getID() }) == null) {
  332.                 if (this.inventory.getCount(new int[] { runeOreID }) > invCount) {
  333.                   log("You mined some rune.");
  334.                   this.oresMined += 1;
  335.                 }
  336.                 else {
  337.                   log("Someone else got the rune ore.");
  338.                 }return;
  339.               }
  340.               if (!this.players.getMyPlayer().isIdle())
  341.                 k = 0;
  342.               sleep(300, 500);
  343.             }
  344.             return;
  345.           }
  346.           sleep(75, 150);
  347.         }
  348.         return;
  349.       }
  350.       walkPath(this.bankToRunePath3);
  351.       for (int i = 0; i < 20; i++) {
  352.         if (this.players.getMyPlayer().isMoving()) {
  353.           log("Walking to next tile on path to runite.");
  354.           return;
  355.         }
  356.         sleep(100, 250);
  357.       }
  358.       return;
  359.     }
  360.     if (insideHeroGuild()) {
  361.       if (this.objects.getNearest(new int[] { 1754 }) != null) if (this.objects.getNearest(new int[] { 1754 }).isOnScreen()) {
  362.           this.objectToDisplay = this.objects.getTopAt(new RSTile(2892, 3507));
  363.           Point[] ladderPts = getObjectModelPoints(new RSTile(2892, 3507));
  364.           if (ladderPts.length == 0) return;
  365.           this.mouse.move(ladderPts[random(0, ladderPts.length)]);
  366.           if ((this.menu.getActions() == null) || (!this.menu.getActions()[0].contains("Climb"))) return;
  367.           sleep(random(50, 150));
  368.           this.mouse.click(true);
  369.           for (int i = 0; i < 20; i++) {
  370.             if (this.players.getMyPlayer().getLocation().getY() > 9000) {
  371.               log("Climbed down ladder.");
  372.               return;
  373.             }
  374.             sleep(75, 150);
  375.           }
  376.           return;
  377.         }
  378.       this.walking.walkTileMM(new RSTile(2894, 3509));
  379.       for (int i = 0; i < 20; i++) {
  380.         if (this.players.getMyPlayer().isMoving()) {
  381.           log("Walked to ladder.");
  382.           return;
  383.         }
  384.         sleep(150, 300);
  385.       }
  386.       return;
  387.     }
  388.     if (this.objects.getNearest(new int[] { 2624 }) != null)
  389.       if (this.objects.getNearest(new int[] { 2624 }).isOnScreen()) {
  390.         this.objectToDisplay = this.objects.getNearest(new int[] { 2624 });
  391.         Point[] doorPts = getObjectModelPoints(new RSTile(2902, 3510));
  392.         if (doorPts.length == 0) return;
  393.         this.mouse.move(doorPts[random(0, doorPts.length)]);
  394.         if ((this.menu.getActions() == null) || (!this.menu.getActions()[0].contains("Open"))) return;
  395.         sleep(random(50, 150));
  396.         this.mouse.click(true);
  397.         for (int i = 0; i < 20; i++) {
  398.           if (this.players.getMyPlayer().getLocation().equals(new RSTile(2901, 3510))) {
  399.             log("Heros Guild Door opened.");
  400.             return;
  401.           }
  402.           sleep(75, 150);
  403.         }
  404.       }
  405.     if ((this.players.getMyPlayer().getLocation().getX() < 2945) &&
  406.       (this.players.getMyPlayer().getLocation().getY() > 3445)) {
  407.       if (this.objects.getNearest(new int[] { 28690, 28691 }) == null) {
  408.         walkPath(this.bankToRunePath2);
  409.         for (int i = 0; i < 20; i++) {
  410.           if (this.players.getMyPlayer().isMoving()) {
  411.             log("Walking to next tile on path to runite.");
  412.             return;
  413.           }
  414.           sleep(100, 250);
  415.         }
  416.         return;
  417.       }
  418.     }
  419.     this.objectToDisplay = this.objects.getTopAt(new RSTile(2936, 3451));
  420.     Point[] doorPts = getObjectModelPoints(new RSTile(2936, 3451));
  421.     if (doorPts.length > 0) {
  422.       this.mouse.move(doorPts[random(0, doorPts.length)]);
  423.       if ((this.menu.getActions() == null) || (!this.menu.getActions()[0].contains("Open"))) return;
  424.       sleep(random(50, 150));
  425.       this.mouse.click(true);
  426.       for (int i = 0; i < 20; i++) {
  427.         if (this.objects.getNearest(new int[] { 28690, 28691 }) == null) {
  428.           log("Taverly door opened.");
  429.           return;
  430.         }
  431.         sleep(75, 150);
  432.       }
  433.  
  434.     }
  435.  
  436.     walkPath(this.bankToRunePath1);
  437.     for (int i = 0; i < 20; i++) {
  438.       if (this.players.getMyPlayer().isMoving()) {
  439.         log("Walking to next tile on path to runite.");
  440.         return;
  441.       }
  442.       sleep(100, 250);
  443.     }
  444.   }
  445.  
  446.   public void bankUsingFallyTab()
  447.   {
  448.     if (this.bank.isOpen()) {
  449.       for (int i = 0; i < 20; i++) {
  450.         this.bank.depositAllExcept(new int[] { faladorTabID, runePickaxeID, dragonPickaxeID });
  451.         sleep(250, 500);
  452.         if (this.inventory.getCountExcept(new int[] { faladorTabID, runePickaxeID, dragonPickaxeID }) == 0)
  453.           return;
  454.       }
  455.       return;
  456.     }
  457.     if ((2948 > this.players.getMyPlayer().getLocation().getX()) &&
  458.       (this.players.getMyPlayer().getLocation().getX() > 2942) &&
  459.       (3371 > this.players.getMyPlayer().getLocation().getY()) &&
  460.       (this.players.getMyPlayer().getLocation().getY() > 3367)) {
  461.       open();
  462.       for (int i = 0; i < 20; i++) {
  463.         if (this.bank.isOpen()) {
  464.           log("Bank Opened.");
  465.           return;
  466.         }
  467.         sleep(100, 250);
  468.       }
  469.       return;
  470.     }
  471.     if ((this.players.getMyPlayer().getLocation().getY() <= 3394) &&
  472.       (this.players.getMyPlayer().getLocation().getX() >= 2937) &&
  473.       (this.players.getMyPlayer().getLocation().getY() >= 3360) &&
  474.       (this.players.getMyPlayer().getLocation().getX() <= 2975)) {
  475.       this.walking.walkTo(new RSTile(2945, 3370));
  476.       for (int i = 0; i < 20; i++) {
  477.         if (this.players.getMyPlayer().isMoving()) {
  478.           log("Walking to next tile on path to bank.");
  479.           return;
  480.         }
  481.         sleep(100, 250);
  482.       }
  483.       return;
  484.     }
  485.     if (!this.players.getMyPlayer().isIdle()) return;
  486.     this.inventory.getItem(new int[] { faladorTabID }).doClick(true);
  487.     for (int i = 0; i < 20; i++) {
  488.       if (this.players.getMyPlayer().getAnimation() == 9598) {
  489.         log("Successfully used falador tab.");
  490.         return;
  491.       }
  492.       sleep(75, 150);
  493.     }
  494.   }
  495.  
  496.   public int getWorldComponentID(int world) {
  497.     for (int i = 0; i < allWorlds.length; i++)
  498.       if (allWorlds[i] == world)
  499.         return i;
  500.     return -1;
  501.   }
  502.   public boolean switchToWorld(int world) {
  503.     if ((world < 1) || (world > 169)) return false;
  504.     if (!this.interfaces.getComponent(906, worldSelectTabID).containsText("World<br>Select")) {
  505.       log("Interfaces have updated. Shutting down.");
  506.       stopScript();
  507.       return false;
  508.     }
  509.     if (this.interfaces.getComponent(906, worldSelectTabID - 2).getBackgroundColor() == welcomeScreenTabTextureID) {
  510.       RSInterface mainInterface = this.interfaces.get(910);
  511.       if (mainInterface.getComponent(worldSwitchCheckID).containsText("World " + Integer.toString(world))) {
  512.         for (int k = 0; k < 20; k++) {
  513.           this.interfaces.getComponent(906, clickHereToPlayID).doClick();
  514.           if ((this.interfaces.getComponent(906, clickHereToPlayID).getText() == null) ||
  515.             (this.interfaces.getComponent(906, clickHereToPlayID).containsText("Entering Game..."))) {
  516.             for (int i = 0; i < 40; i++) {
  517.               if (this.game.isLoggedIn()) {
  518.                 log("Logged in.");
  519.                 this.worldToSwitchTo = -1;
  520.                 sleep(5000);
  521.                 return true;
  522.               }
  523.               sleep(1000);
  524.             }
  525.           }
  526.           sleep(75, 150);
  527.         }
  528.         return false;
  529.       }
  530.       int worldCompID = getWorldComponentID(world);
  531.       if (this.interfaces.scrollTo(mainInterface.getComponent(worldInterfaceID).getComponent(worldCompID), 59637760 + scrollbarID)) {
  532.         log("Selecting world : " + validWorlds[this.worldToSwitchTo]);
  533.         mainInterface.getComponent(worldInterfaceID).getComponent(worldCompID).doClick();
  534.         for (int i = 0; i < 20; i++) {
  535.           if (mainInterface.getComponent(worldSwitchCheckID).containsText("World " + Integer.toString(world))) {
  536.             log("World Selected.");
  537.             return false;
  538.           }
  539.           sleep(random(75, 150));
  540.         }
  541.         this.worldToSwitchTo = random(0, validWorlds.length);
  542.         log("Trouble selecting world. Changing to : " + validWorlds[this.worldToSwitchTo]);
  543.         return false;
  544.       }
  545.       return false;
  546.     }
  547.     this.interfaces.getComponent(906, worldSelectTabID).doClick();
  548.     for (int i = 0; i < 20; i++) {
  549.       if (this.interfaces.getComponent(906, worldSelectTabID).getBackgroundColor() == welcomeScreenTabTextureID) {
  550.         log("World Select Tab Clicked.");
  551.         return false;
  552.       }
  553.       sleep(50, 75);
  554.     }
  555.     return false;
  556.   }
  557.  
  558.   public void onRepaint(Graphics g) {
  559.     this.millis = (System.currentTimeMillis() - this.runTime);
  560.     this.hours = (this.millis / 3600000L);
  561.     this.millis -= this.hours * 3600000L;
  562.     this.minutes = (this.millis / 60000L);
  563.     this.millis -= this.minutes * 60000L;
  564.     this.seconds = (this.millis / 1000L);
  565.     g.setColor(Color.RED);
  566.     if ((this.objectToDisplay != null) && (this.displayDebug)) {
  567.       for (Point p : getObjectModelPoints(this.objectToDisplay.getLocation())) {
  568.         if ((p.x != -1) && (p.y != -1))
  569.           g.drawRect(p.x, p.y, 1, 1);
  570.       }
  571.     }
  572.     if ((this.game.isLoggedIn()) && (!this.game.isWelcomeScreen())) {
  573.       if ((this.startLevel == -1) || (this.startXP == -1)) {
  574.         this.startLevel = this.skills.getCurrentLevel(14);
  575.         this.startXP = this.skills.getCurrentExp(14);
  576.       }
  577.       this.currentLevel = this.skills.getCurrentLevel(14);
  578.       this.currentXP = this.skills.getCurrentExp(14);
  579.       this.expTillLevel = this.skills.getExpToNextLevel(14);
  580.     }
  581.     this.gui.runTimeDisplay.setText(this.hours + ":" + this.minutes + ":" + this.seconds);
  582.     this.gui.currentLevelDisplay.setText(Integer.toString(this.currentLevel));
  583.     this.gui.levelsGainedDisplay.setText(Integer.toString(this.currentLevel - this.startLevel));
  584.     this.gui.gainedExpDisplay.setText(Integer.toString((int)this.currentXP - this.startXP));
  585.     this.gui.expRateDisplay.setText(Integer.toString((int)((this.currentXP - this.startXP) * 3600.0D / (this.hours * 60L * 60L + this.minutes * 60L + this.seconds))));
  586.     this.gui.runeMinedDisplay.setText(Integer.toString(this.oresMined));
  587.     this.gui.jLabel10.setText(Double.toString(this.oresMined * 3600 / (this.hours * 60L * 60L + this.minutes * 60L + this.seconds)));
  588.     this.gui.expTillLevelDisplay.setText(Integer.toString(this.expTillLevel));
  589.   }
  590.  
  591.   public boolean walkPath(RSTile[] path) {
  592.     if ((!getMyPlayer().isMoving()) || (this.calc.distanceTo(this.walking.getDestination()) <= 5))
  593.       return this.theWalker.walkTo(path, true);
  594.     return false; }
  595.   public class GUI extends JFrame { private static final long serialVersionUID = 1L;
  596.     public JLabel currentLevelDisplay;
  597.     public JLabel expRateDisplay;
  598.     public JLabel expTillLevelDisplay;
  599.     public JLabel gainedExpDisplay;
  600.     private JButton jButton1;
  601.     private JLabel jLabel1;
  602.     private JLabel jLabel10;
  603.     private JLabel jLabel11;
  604.     private JLabel jLabel12;
  605.     private JLabel jLabel13;
  606.     private JLabel jLabel14;
  607.     private JLabel jLabel15;
  608.     private JLabel jLabel2;
  609.     private JLabel jLabel3;
  610.     private JLabel jLabel4;
  611.     private JLabel jLabel5;
  612.     private JLabel jLabel6;
  613.     private JLabel jLabel7;
  614.     private JLabel jLabel8;
  615.     private JLabel jLabel9;
  616.     private JPanel jPanel1;
  617.     public JLabel levelsGainedDisplay;
  618.     public JLabel profitDisplay;
  619.     public JLabel profitPerHourDisplay;
  620.     public JLabel runTimeDisplay;
  621.     public JLabel runeMinedDisplay;
  622.  
  623.     public GUI() { initComponents();
  624.     }
  625.  
  626.     private void initComponents()
  627.     {
  628.       this.jPanel1 = new JPanel();
  629.       this.jLabel1 = new JLabel();
  630.       this.jLabel2 = new JLabel();
  631.       this.jLabel3 = new JLabel();
  632.       this.currentLevelDisplay = new JLabel();
  633.       this.jLabel4 = new JLabel();
  634.       this.levelsGainedDisplay = new JLabel();
  635.       this.jLabel5 = new JLabel();
  636.       this.expRateDisplay = new JLabel();
  637.       this.jLabel6 = new JLabel();
  638.       this.gainedExpDisplay = new JLabel();
  639.       this.jLabel7 = new JLabel();
  640.       this.runTimeDisplay = new JLabel();
  641.       this.jLabel8 = new JLabel();
  642.       this.runeMinedDisplay = new JLabel();
  643.       this.jLabel9 = new JLabel();
  644.       this.jLabel10 = new JLabel();
  645.       this.jLabel11 = new JLabel();
  646.       this.profitDisplay = new JLabel();
  647.       this.jLabel13 = new JLabel();
  648.       this.profitPerHourDisplay = new JLabel();
  649.       this.jLabel12 = new JLabel();
  650.       this.expTillLevelDisplay = new JLabel();
  651.       this.jLabel14 = new JLabel();
  652.       this.jLabel15 = new JLabel();
  653.       this.jButton1 = new JButton();
  654.  
  655.       setDefaultCloseOperation(1);
  656.       setBackground(new Color(0, 204, 204));
  657.  
  658.       this.jPanel1.setBackground(new Color(0, 0, 0));
  659.  
  660.       this.jLabel1.setFont(new Font("Kredit", 1, 24));
  661.       this.jLabel1.setForeground(new Color(102, 255, 255));
  662.       this.jLabel1.setText("Runite Miner v0.1");
  663.  
  664.       this.jLabel2.setFont(new Font("Tahoma", 1, 14));
  665.       this.jLabel2.setForeground(new Color(0, 153, 153));
  666.       this.jLabel2.setText("By : Marneus901");
  667.  
  668.       this.jLabel3.setForeground(new Color(102, 255, 255));
  669.       this.jLabel3.setText("Current Level :");
  670.  
  671.       this.currentLevelDisplay.setForeground(new Color(102, 255, 255));
  672.       this.currentLevelDisplay.setText("1");
  673.  
  674.       this.jLabel4.setForeground(new Color(102, 255, 255));
  675.       this.jLabel4.setText("Level(s) Gained :");
  676.  
  677.       this.levelsGainedDisplay.setForeground(new Color(102, 255, 255));
  678.       this.levelsGainedDisplay.setText("0");
  679.  
  680.       this.jLabel5.setForeground(new Color(102, 255, 255));
  681.       this.jLabel5.setText("Experience Per Hour :");
  682.  
  683.       this.expRateDisplay.setForeground(new Color(102, 255, 255));
  684.       this.expRateDisplay.setText("0");
  685.  
  686.       this.jLabel6.setForeground(new Color(102, 255, 255));
  687.       this.jLabel6.setText("Gained Experience :");
  688.  
  689.       this.gainedExpDisplay.setForeground(new Color(102, 255, 255));
  690.       this.gainedExpDisplay.setText("0");
  691.  
  692.       this.jLabel7.setForeground(new Color(102, 255, 255));
  693.       this.jLabel7.setText("Run Time :");
  694.  
  695.       this.runTimeDisplay.setForeground(new Color(102, 255, 255));
  696.       this.runTimeDisplay.setText("0:0:0");
  697.  
  698.       this.jLabel8.setForeground(new Color(102, 255, 255));
  699.       this.jLabel8.setText("Runite Mined :");
  700.  
  701.       this.runeMinedDisplay.setForeground(new Color(102, 255, 255));
  702.       this.runeMinedDisplay.setText("0");
  703.  
  704.       this.jLabel9.setForeground(new Color(102, 255, 255));
  705.       this.jLabel9.setText("Ore(s) Per Hour :");
  706.  
  707.       this.jLabel10.setForeground(new Color(102, 255, 255));
  708.       this.jLabel10.setText("0");
  709.  
  710.       this.jLabel11.setForeground(new Color(102, 255, 255));
  711.       this.jLabel11.setText("Profit :");
  712.  
  713.       this.profitDisplay.setForeground(new Color(102, 255, 255));
  714.       this.profitDisplay.setText("0");
  715.  
  716.       this.jLabel13.setForeground(new Color(102, 255, 255));
  717.       this.jLabel13.setText("Profit Per Hour :");
  718.  
  719.       this.profitPerHourDisplay.setForeground(new Color(102, 255, 255));
  720.       this.profitPerHourDisplay.setText("0");
  721.  
  722.       this.jLabel12.setForeground(new Color(102, 255, 255));
  723.       this.jLabel12.setText("Exp Till Level :");
  724.  
  725.       this.expTillLevelDisplay.setForeground(new Color(102, 255, 255));
  726.       this.expTillLevelDisplay.setText("0");
  727.  
  728.       this.jLabel14.setForeground(new Color(102, 255, 255));
  729.       this.jLabel14.setText("Time Till Level :");
  730.  
  731.       this.jLabel15.setForeground(new Color(102, 255, 255));
  732.       this.jLabel15.setText("0");
  733.  
  734.       this.jButton1.setText("Debug On/Off");
  735.       this.jButton1.addActionListener(new ActionListener() {
  736.         public void actionPerformed(ActionEvent evt) {
  737.           GUI.this.jButton1ActionPerformed(evt);
  738.         }
  739.       });
  740.       GroupLayout jPanel1Layout = new GroupLayout(this.jPanel1);
  741.       this.jPanel1.setLayout(jPanel1Layout);
  742.       jPanel1Layout.setHorizontalGroup(
  743.         jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  744.         .addGroup(jPanel1Layout.createSequentialGroup()
  745.         .addGap(156, 156, 156)
  746.         .addComponent(this.jLabel7)
  747.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  748.         .addComponent(this.runTimeDisplay)
  749.         .addContainerGap(193, 32767))
  750.         .addGroup(jPanel1Layout.createSequentialGroup()
  751.         .addGap(30, 30, 30)
  752.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  753.         .addGroup(GroupLayout.Alignment.TRAILING,
  754.         jPanel1Layout.createSequentialGroup()
  755.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
  756.         .addGroup(jPanel1Layout.createSequentialGroup()
  757.         .addComponent(this.jButton1)
  758.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 146, 32767)
  759.         .addComponent(this.jLabel2))
  760.         .addComponent(this.jLabel1))
  761.         .addGap(38, 38, 38))
  762.         .addGroup(jPanel1Layout.createSequentialGroup()
  763.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  764.         .addGroup(jPanel1Layout.createSequentialGroup()
  765.         .addComponent(this.jLabel3)
  766.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  767.         .addComponent(this.currentLevelDisplay))
  768.         .addGroup(jPanel1Layout.createSequentialGroup()
  769.         .addComponent(this.jLabel6)
  770.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  771.         .addComponent(this.gainedExpDisplay))
  772.         .addGroup(jPanel1Layout.createSequentialGroup()
  773.         .addComponent(this.jLabel8)
  774.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  775.         .addComponent(this.runeMinedDisplay))
  776.         .addGroup(jPanel1Layout.createSequentialGroup()
  777.         .addComponent(this.jLabel11)
  778.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  779.         .addComponent(this.profitDisplay))
  780.         .addGroup(jPanel1Layout.createSequentialGroup()
  781.         .addComponent(this.jLabel12)
  782.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  783.         .addComponent(this.expTillLevelDisplay)))
  784.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 118, 32767)
  785.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  786.         .addGroup(jPanel1Layout.createSequentialGroup()
  787.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  788.         .addComponent(this.jLabel4)
  789.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  790.         .addComponent(this.levelsGainedDisplay, -2, 10, -2))
  791.         .addGroup(jPanel1Layout.createSequentialGroup()
  792.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  793.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  794.         .addGroup(jPanel1Layout.createSequentialGroup()
  795.         .addComponent(this.jLabel9)
  796.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  797.         .addComponent(this.jLabel10))
  798.         .addGroup(jPanel1Layout.createSequentialGroup()
  799.         .addComponent(this.jLabel5)
  800.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  801.         .addComponent(this.expRateDisplay))
  802.         .addGroup(jPanel1Layout.createSequentialGroup()
  803.         .addComponent(this.jLabel13)
  804.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  805.         .addComponent(this.profitPerHourDisplay))
  806.         .addGroup(jPanel1Layout.createSequentialGroup()
  807.         .addComponent(this.jLabel14)
  808.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  809.         .addComponent(this.jLabel15)))))
  810.         .addGap(59, 59, 59)))));
  811.  
  812.       jPanel1Layout.setVerticalGroup(
  813.         jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  814.         .addGroup(jPanel1Layout.createSequentialGroup()
  815.         .addContainerGap()
  816.         .addComponent(this.jLabel1)
  817.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  818.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  819.         .addComponent(this.jLabel2)
  820.         .addComponent(this.jButton1))
  821.         .addGap(13, 13, 13)
  822.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  823.         .addComponent(this.runTimeDisplay)
  824.         .addComponent(this.jLabel7))
  825.         .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
  826.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  827.         .addComponent(this.jLabel3)
  828.         .addComponent(this.currentLevelDisplay)
  829.         .addComponent(this.jLabel4)
  830.         .addComponent(this.levelsGainedDisplay))
  831.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  832.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  833.         .addGroup(jPanel1Layout.createSequentialGroup()
  834.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  835.         .addComponent(this.jLabel6)
  836.         .addComponent(this.gainedExpDisplay))
  837.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  838.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  839.         .addComponent(this.jLabel8)
  840.         .addComponent(this.runeMinedDisplay))
  841.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  842.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  843.         .addComponent(this.jLabel11)
  844.         .addComponent(this.profitDisplay))
  845.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  846.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  847.         .addComponent(this.jLabel12)
  848.         .addComponent(this.expTillLevelDisplay)))
  849.         .addComponent(this.expRateDisplay)
  850.         .addGroup(jPanel1Layout.createSequentialGroup()
  851.         .addComponent(this.jLabel5)
  852.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  853.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  854.         .addComponent(this.jLabel9)
  855.         .addComponent(this.jLabel10))
  856.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  857.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  858.         .addComponent(this.jLabel13)
  859.         .addComponent(this.profitPerHourDisplay))
  860.         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  861.         .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  862.         .addComponent(this.jLabel14)
  863.         .addComponent(this.jLabel15))))
  864.         .addContainerGap(-1, 32767)));
  865.  
  866.       GroupLayout layout = new GroupLayout(getContentPane());
  867.       getContentPane().setLayout(layout);
  868.       layout.setHorizontalGroup(
  869.         layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  870.         .addGroup(layout.createSequentialGroup()
  871.         .addContainerGap()
  872.         .addComponent(this.jPanel1, -1, -1, 32767)
  873.         .addContainerGap()));
  874.  
  875.       layout.setVerticalGroup(
  876.         layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  877.         .addGroup(layout.createSequentialGroup()
  878.         .addContainerGap()
  879.         .addComponent(this.jPanel1, -1, -1, 32767)
  880.         .addContainerGap()));
  881.  
  882.       pack();
  883.     }
  884.  
  885.     private void jButton1ActionPerformed(ActionEvent evt) {
  886.         displayDebug = (!displayDebug);
  887.     }
  888.   }
  889.  
  890.   public class LoginBot
  891.   {
  892.     private static final int INTERFACE_MAIN = 905;
  893.     private static final int INTERFACE_MAIN_CHILD = 59;
  894.     private static final int INTERFACE_MAIN_CHILD_COMPONENT_ID = 4;
  895.     private static final int INTERFACE_LOGIN_SCREEN = 596;
  896.     private static final int INTERFACE_USERNAME = 65;
  897.     private static final int INTERFACE_USERNAME_WINDOW = 37;
  898.     private static final int INTERFACE_PASSWORD = 71;
  899.     private static final int INTERFACE_PASSWORD_WINDOW = 39;
  900.     private static final int INTERFACE_BUTTON_LOGIN = 42;
  901.     private static final int INTERFACE_TEXT_RETURN = 11;
  902.     private static final int INTERFACE_BUTTON_BACK = 55;
  903.     private static final int INTERFACE_GRAPHICS_NOTICE = 976;
  904.     private static final int INTERFACE_GRAPHICS_LEAVE_ALONE = 6;
  905.     private static final int INDEX_LOGGED_OUT = 3;
  906.     private int invalidCount;
  907.  
  908.     public LoginBot()
  909.     {
  910.     }
  911.  
  912.     public boolean activateCondition()
  913.     {
  914.       int idx = game.getClientState();
  915.       return (idx == 3) && (account.getName() != null);
  916.     }
  917.  
  918.     public int loop() {
  919.       String username = account.getName().toLowerCase().trim();
  920.       String returnText = interfaces.get(596)
  921.         .getComponent(11).getText().toLowerCase();
  922.  
  923.       if (game.getClientState() != 3) {
  924.         if (!game.isWelcomeScreen()) {
  925.           sleep(random(1000, 2000));
  926.         }
  927.         return -1;
  928.       }
  929.       if (!game.isLoggedIn()) {
  930.         if (returnText.contains("update")) {
  931.           log("Runescape has been updated, please reload RSBot.");
  932.           stopScript(false);
  933.         }
  934.         if (returnText.contains("disable")) {
  935.           log("Your account is banned/disabled.");
  936.           stopScript(false);
  937.         }
  938.         if (returnText.contains("incorrect")) {
  939.           log("Failed to login five times in a row. Stopping script.");
  940.           stopScript(false);
  941.         }
  942.         if (returnText.contains("invalid")) {
  943.           if (this.invalidCount > 6) {
  944.             log("Unable to login after 6 attempts. Stopping script.");
  945.             log("Please verify that your RSBot account profile is correct.");
  946.             stopScript(false);
  947.           }
  948.           interfaces.get(596).getComponent(55).doClick();
  949.           this.invalidCount += 1;
  950.           return random(500, 2000);
  951.         }
  952.         if (returnText.contains("error connecting")) {
  953.           interfaces.get(596).getComponent(55).doClick();
  954.           stopScript(false);
  955.           return random(500, 2000);
  956.         }
  957.       }
  958.       if (game.getClientState() == 3) {
  959.         if (interfaces.getComponent(976, 6).isValid()) {
  960.           interfaces.getComponent(976, 6).doClick();
  961.           return random(500, 600);
  962.         }
  963.         if (!atLoginScreen()) {
  964.           interfaces.getComponent(905, 59).getComponent(4).doAction("");
  965.           return random(500, 600);
  966.         }
  967.         if ((isUsernameFilled()) && (isPasswordFilled())) {
  968.           interfaces.get(596).getComponent(42).doClick();
  969.           return random(500, 600);
  970.         }
  971.         if (!isUsernameFilled()) {
  972.           atLoginInterface(interfaces.get(596).getComponent(37));
  973.           sleep(random(500, 700));
  974.           int textlength = interfaces.get(596).getComponent(65).getText().length() + random(3, 5);
  975.           for (int i = 0; i <= textlength + random(1, 5); i++) {
  976.             keyboard.sendText("\b", false);
  977.             if (random(0, 2) == 1) {
  978.               sleep(random(25, 100));
  979.             }
  980.           }
  981.           keyboard.sendText(username, false);
  982.           return random(500, 600);
  983.         }
  984.         if ((isUsernameFilled()) && (!isPasswordFilled())) {
  985.           atLoginInterface(interfaces.get(596).getComponent(39));
  986.           sleep(random(500, 700));
  987.           int textlength = interfaces.get(596).getComponent(71).getText().length() + random(3, 5);
  988.           for (int i = 0; i <= textlength + random(1, 5); i++) {
  989.             keyboard.sendText("\b", false);
  990.             if (random(0, 2) == 1) {
  991.               sleep(random(25, 100));
  992.             }
  993.           }
  994.           keyboard.sendText(account.getPassword(), false);
  995.         }
  996.       }
  997.       return random(500, 2000);
  998.     }
  999.  
  1000.     private boolean atLoginInterface(RSComponent i)
  1001.     {
  1002.       if (!i.isValid())
  1003.         return false;
  1004.       Rectangle pos = i.getArea();
  1005.       if ((pos.x == -1) || (pos.y == -1) || (pos.width == -1) || (pos.height == -1))
  1006.         return false;
  1007.       int dy = (int)(pos.getHeight() - 4.0D) / 2;
  1008.       int maxRandomX = (int)(pos.getMaxX() - pos.getCenterX());
  1009.       int midx = (int)pos.getCenterX();
  1010.       int midy = (int)(pos.getMinY() + pos.getHeight() / 2.0D);
  1011.       if (i.getIndex() == 39)
  1012.         mouse.click(minX(i), midy + random(-dy, dy), true);
  1013.       else {
  1014.         mouse.click(midx + random(1, maxRandomX), midy + random(-dy, dy), true);
  1015.       }
  1016.       return true;
  1017.     }
  1018.  
  1019.     private int minX(RSComponent a)
  1020.     {
  1021.       int x = 0;
  1022.       Rectangle pos = a.getArea();
  1023.       int dx = (int)(pos.getWidth() - 4.0D) / 2;
  1024.       int midx = (int)(pos.getMinX() + pos.getWidth() / 2.0D);
  1025.       if ((pos.x == -1) || (pos.y == -1) || (pos.width == -1) || (pos.height == -1))
  1026.         return 0;
  1027.       for (int i = 0; i < interfaces.get(596).getComponent(71).getText().length(); i++) {
  1028.         x += 11;
  1029.       }
  1030.       if (x > 44) {
  1031.         return (int)(pos.getMinX() + x + 15.0D);
  1032.       }
  1033.       return midx + random(-dx, dx);
  1034.     }
  1035.  
  1036.     private boolean atLoginScreen()
  1037.     {
  1038.       return interfaces.get(596).isValid();
  1039.     }
  1040.  
  1041.     private boolean isUsernameFilled() {
  1042.       String username = account.getName().toLowerCase().trim();
  1043.       return interfaces.get(596).getComponent(65).getText().toLowerCase().equalsIgnoreCase(username);
  1044.     }
  1045.  
  1046.     private boolean isPasswordFilled() {
  1047.       return interfaces.get(596).getComponent(71).getText().toLowerCase().length() == account.getPassword().length();
  1048.     }
  1049.   }
  1050.  
  1051.   public class TheWalker {
  1052.     Thread walker = null;
  1053.     RSTile[] path = null;
  1054.  
  1055.     public TheWalker() {  }
  1056.     private void sleep(int i) throws InterruptedException { Thread.sleep(i); }
  1057.  
  1058.     public void wait(int toSleep) {
  1059.       try {
  1060.         long start = System.currentTimeMillis();
  1061.         Thread.sleep(toSleep);
  1062.         long now;
  1063.         while (start + toSleep > (now = System.currentTimeMillis()))
  1064.         {
  1065.           Thread.sleep(start + toSleep - now);
  1066.         }
  1067.       } catch (InterruptedException e) {
  1068.         e.printStackTrace();
  1069.       }
  1070.     }
  1071.  
  1072.     public boolean waitToMove(int timeout) {
  1073.       long start = System.currentTimeMillis();
  1074.       RSPlayer myPlayer = getMyPlayer();
  1075.       while (System.currentTimeMillis() - start < timeout) {
  1076.         if (myPlayer.isMoving())
  1077.           return true;
  1078.         wait(15);
  1079.       }
  1080.       return false;
  1081.     }
  1082.     public void drawMap(Graphics g) {
  1083.       if ((this.walker != null) && (this.walker.isAlive())) {
  1084.         Point myTile = calc.tileToMinimap(getMyPlayer().getLocation());
  1085.         Point center = new Point(myTile.x + 2, myTile.y + 2);
  1086.         g.drawOval(center.x - 70, center.y - 70, 140, 140);
  1087.         if (this.path == null) return;
  1088.         for (int i = 0; i < this.path.length; i++) {
  1089.           RSTile tile = this.path[i];
  1090.           Point p = calc.tileToMinimap(tile);
  1091.           if ((p.x != -1) && (p.y != -1)) {
  1092.             g.setColor(Color.BLACK);
  1093.             g.fillRect(p.x + 1, p.y + 1, 3, 3);
  1094.             if (i > 0) {
  1095.               Point p1 = calc.tileToMinimap(this.path[(i - 1)]);
  1096.               g.setColor(Color.ORANGE);
  1097.               if ((p1.x != -1) && (p1.y != -1))
  1098.                 g.drawLine(p.x + 2, p.y + 2, p1.x + 2, p1.y + 2);
  1099.             }
  1100.           }
  1101.         }
  1102.         Point tile = calc.tileToMinimap(nextTile(this.path));
  1103.         g.setColor(Color.RED);
  1104.         if ((tile.x != -1) && (tile.y != -1)) {
  1105.           g.fillRect(tile.x + 1, tile.y + 1, 3, 3);
  1106.         }
  1107.         g.setColor(Color.BLACK);
  1108.       }
  1109.     }
  1110.  
  1111.     public boolean walkTo(RSTile[] path, boolean waitUntilDest) {
  1112.       TheWalker.Walker walkto = new TheWalker.Walker(path, 3, 10000);
  1113.       this.walker = new Thread(walkto);
  1114.       this.walker.start();
  1115.       waitToMove(random(800, 1200));
  1116.       if (waitUntilDest) {
  1117.         while (this.walker.isAlive())
  1118.           try {
  1119.             sleep(random(300, 600));
  1120.           }
  1121.           catch (InterruptedException localInterruptedException) {
  1122.           }
  1123.         return walkto.done;
  1124.       }return true;
  1125.     }
  1126.     public Point tileToMM(RSTile tile) {
  1127.       return new Point(calc.tileToMinimap(tile).x + 2, calc.tileToMinimap(tile).y + 2);
  1128.     }
  1129.     public boolean tileOnMM(RSTile tile) {
  1130.       return pointOnMM(tileToMM(tile));
  1131.     }
  1132.     public boolean pointOnMM(Point point) {
  1133.       Point myTile = tileToMM(getMyPlayer().getLocation());
  1134.       Point center = new Point(myTile.x, myTile.y);
  1135.       return center.distance(point) < 70.0D;
  1136.     }
  1137.     public RSTile getClosestTileOnMap(RSTile tile) {
  1138.       if (game.isLoggedIn() && (!tileOnMM(tile)))
  1139.         try {
  1140.           RSTile loc = getMyPlayer().getLocation();
  1141.           RSTile walk = new RSTile((loc.getX() + tile.getX()) / 2, (loc.getY() + tile.getY()) / 2);
  1142.           return tileOnMM(walk) ? walk : getClosestTileOnMap(walk);
  1143.         } catch (Exception localException) {
  1144.         }
  1145.       return tile;
  1146.     }
  1147.     public RSTile nextTile(RSTile[] path) {
  1148.       for (int i = path.length - 1; i >= 0; i--) {
  1149.         if (tileOnMM(path[i])) {
  1150.           return path[i];
  1151.         }
  1152.       }
  1153.       return new RSTile(0, 0);
  1154.     }
  1155.     class Walker implements Runnable {
  1156.       RSTile tile = null;
  1157.       boolean done = false;
  1158.       int movementTimer = 10000;
  1159.       int distanceTo = 3;
  1160.  
  1161.       Walker(RSTile[] userpath) { this.tile = userpath[(userpath.length - 1)];
  1162.         TheWalker.this.path = userpath; }
  1163.  
  1164.       Walker(RSTile[] userpath, int distanceTo, int movementTimer) {
  1165.         this.tile = userpath[(userpath.length - 1)];
  1166.         this.movementTimer = movementTimer;
  1167.         this.distanceTo = distanceTo;
  1168.         TheWalker.this.path = userpath;
  1169.       }
  1170.       public void run() {
  1171.         long timer = System.currentTimeMillis();
  1172.         RSTile lastTile = getMyPlayer().getLocation();
  1173.         int randomReturn = random(5, 8);
  1174.         while ((calc.distanceTo(this.tile) > this.distanceTo) && (!shuttingDown) && (!PAUSE) && (!stop)) {
  1175.           if ((!getMyPlayer().isMoving()) || (walking.getDestination() == null) || (calc.distanceTo(walking.getDestination()) < randomReturn)) {
  1176.             RSTile nextTile = TheWalker.this.nextTile(TheWalker.this.path);
  1177.             if (walking.getDestination() != null && (calc.distanceBetween(walking.getDestination(), nextTile) <= this.distanceTo))
  1178.               continue;
  1179.             walking.walkTileMM(nextTile);
  1180.             TheWalker.this.waitToMove(random(800, 1200));
  1181.             randomReturn = random(5, 8);
  1182.           }
  1183.           RSTile myLoc = getMyPlayer().getLocation();
  1184.           if (myLoc != lastTile) {
  1185.             if (calc.distanceBetween(myLoc, lastTile) > 30.0D) {
  1186.               log("Teleportation Detected. Stopping The Walking Loop.");
  1187.               stop = true;
  1188.             }
  1189.             timer = System.currentTimeMillis();
  1190.             lastTile = myLoc;
  1191.           }
  1192.           if (System.currentTimeMillis() - timer > this.movementTimer)
  1193.             stop = true;
  1194.           try
  1195.           {
  1196.             sleep(random(20, 40));
  1197.           } catch (InterruptedException localInterruptedException) {
  1198.           }
  1199.         }
  1200.         if (calc.distanceTo(this.tile) <= this.distanceTo)
  1201.           this.done = true;
  1202.       }
  1203.     }
  1204.   }
  1205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement