Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
J 21.59 KB | None | 0 0
  1. import java.awt.*;
  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4. import java.net.URL;
  5.  
  6. import javax.swing.JButton;
  7. import javax.swing.JCheckBox;
  8. import javax.swing.JFrame;
  9. import javax.swing.JLabel;
  10. import javax.swing.JPanel;
  11. import javax.swing.JTextField;
  12.  
  13. import org.rsbot.script.*;
  14. import org.rsbot.script.methods.Skills;
  15. import org.rsbot.script.wrappers.RSArea;
  16. import org.rsbot.script.wrappers.RSItem;
  17. import org.rsbot.script.wrappers.RSNPC;
  18. import org.rsbot.script.wrappers.RSObject;
  19. import org.rsbot.script.wrappers.RSTile;
  20. import org.rsbot.script.wrappers.RSTilePath;
  21. import org.rsbot.event.listeners.*;
  22.  
  23. @ScriptManifest(authors = { "RoyMastha" }, name = "RockBuster", version = 1.0, description = "In Soviet Russia, rocks fight you!")
  24. public class RockBuster extends Script implements PaintListener {
  25.  
  26.     public enum Next {
  27.         GUI, WALKTOCRABS, FIGHTCRAB, BANKOPEN, BANKWITHDRAW, BANKCLOSE, WALKTOCAVE, ENTERCAVE, EXITCAVE, WALKTOMID, REFILLHP, WALKING, INCOMBAT, WALKTOBANK, UNKNOWN
  28.     }
  29.  
  30.     // IDs
  31.     private int[] RockID = { 1266, 1268 };
  32.     private int[] CrabID = { 1265, 1267 };
  33.     private int[] bankerIDs = { 494, 495 };
  34.     private int[] boothIDs = { 25808 };
  35.     private int airRuneID = 556;
  36.     private int lawRuneID = 563;
  37.     private int teleTabID = 8010;
  38.     private int CaveOutsideID = 5008;
  39.     private int CaveInsideID = 5014;
  40.  
  41.     // Areas
  42.     private RSArea crabArea = new RSArea(new RSTile(2694, 3707), new RSTile(
  43.             2719, 3731));
  44.     private RSArea bankArea = new RSArea(new RSTile(2722, 3490), new RSTile(
  45.             2730, 3493));
  46.     private RSArea teleportArea = new RSArea(new RSTile(2755, 3475),
  47.             new RSTile(2760, 3481));
  48.     private RSArea outsideCaveArea = new RSArea(new RSTile(2725, 3710),
  49.             new RSTile(2730, 3717));
  50.  
  51.     // Paths
  52.     private RSTile[] teleToBank = { new RSTile(2757, 3478),
  53.             new RSTile(2749, 3478), new RSTile(2743, 3478),
  54.             new RSTile(2740, 3481), new RSTile(2735, 3483),
  55.             new RSTile(2733, 3485), new RSTile(2729, 3485),
  56.             new RSTile(2726, 3487), new RSTile(2725, 3491) };
  57.     private RSTile[] bankToCrabs = { new RSTile(2726, 3492),
  58.             new RSTile(2730, 3486), new RSTile(2735, 3492),
  59.             new RSTile(2740, 3498), new RSTile(2740, 3503),
  60.             new RSTile(2740, 3507), new RSTile(2740, 3513),
  61.             new RSTile(2741, 3519), new RSTile(2741, 3525),
  62.             new RSTile(2739, 3530), new RSTile(2736, 3534),
  63.             new RSTile(2733, 3538), new RSTile(2731, 3542),
  64.             new RSTile(2725, 3542), new RSTile(2719, 3543),
  65.             new RSTile(2715, 3544), new RSTile(2710, 3544),
  66.             new RSTile(2705, 3544), new RSTile(2701, 3543),
  67.             new RSTile(2697, 3544), new RSTile(2691, 3543),
  68.             new RSTile(2686, 3543), new RSTile(2682, 3545),
  69.             new RSTile(2679, 3547), new RSTile(2675, 3550),
  70.             new RSTile(2673, 3556), new RSTile(2664, 3558),
  71.             new RSTile(2661, 3564), new RSTile(2658, 3571),
  72.             new RSTile(2655, 3573), new RSTile(2654, 3579),
  73.             new RSTile(2654, 3586), new RSTile(2653, 3590),
  74.             new RSTile(2653, 3598), new RSTile(2653, 3603),
  75.             new RSTile(2655, 3606), new RSTile(2660, 3613),
  76.             new RSTile(2666, 3618), new RSTile(2672, 3621),
  77.             new RSTile(2674, 3626), new RSTile(2676, 3629),
  78.             new RSTile(2683, 3629), new RSTile(2688, 3630),
  79.             new RSTile(2694, 3634), new RSTile(2696, 3638),
  80.             new RSTile(2700, 3641), new RSTile(2700, 3645),
  81.             new RSTile(2702, 3649), new RSTile(2707, 3653),
  82.             new RSTile(2707, 3659), new RSTile(2704, 3664),
  83.             new RSTile(2701, 3667), new RSTile(2700, 3674),
  84.             new RSTile(2700, 3681), new RSTile(2700, 3686),
  85.             new RSTile(2700, 3692), new RSTile(2700, 3698),
  86.             new RSTile(2702, 3704), new RSTile(2702, 3711),
  87.             new RSTile(2702, 3716) };
  88.     private RSTile[] midToCave = { new RSTile(2707, 3719),
  89.             new RSTile(2713, 3716), new RSTile(2719, 3713),
  90.             new RSTile(2723, 3713), new RSTile(2729, 3713) };
  91.  
  92.     // GUI Settings
  93.     private boolean useTeleSpell = false;
  94.     private int FoodID = 0;
  95.     private int[] pickUpIDs = { 0 };
  96.     JFrame gui = new JFrame();
  97.     private JPanel jContentPane = null;
  98.     private JLabel jLabel = null;
  99.     private JTextField jTextField = null;
  100.     private JCheckBox jCheckBox = null;
  101.     private JButton jButton = null;
  102.     private JLabel jLabel1 = null;
  103.     private JTextField jTextField1 = null;
  104.     private JLabel jLabel2 = null;
  105.     private JTextField jTextField2 = null;
  106.  
  107.     private boolean guiDone = false;
  108.  
  109.     // Paint Stats
  110.     private long startTime = System.currentTimeMillis();
  111.     private long expStarted = 0;
  112.     private int Killed = 0;
  113.     private String Status = "";
  114.  
  115.     // Other
  116.     private boolean hasDoneReset = false;
  117.     private RSTile MiddleTile = new RSTile(2707, 3719);
  118.  
  119.     // AntiBan
  120.     private RSTile currentTile = new RSTile(0, 0);
  121.     private long timeCheck = 0;
  122.  
  123.     public boolean onStart() {
  124.         log("Welcome to Rockbuster by RoyMastha!");
  125.         log("Start the script via the GUI!");
  126.         log("All credits to RoyMastha.");
  127.         log("Latest version: 1.0!");
  128.         log("In next update: Item's pickup, Chat response, Bigger AntiBan and more!");
  129.  
  130.         initGUI();
  131.         return true;
  132.  
  133.     }
  134.  
  135.     @Override
  136.     public int loop() {
  137.         int val = 0;
  138.         switch (getNext()) {
  139.         case GUI:
  140.             val = random(1000, 2000);
  141.             break;
  142.         case WALKING:
  143.             val = random(1000, 2000);
  144.             break;
  145.         case INCOMBAT:
  146.             checkFood();
  147.             antiBan();
  148.             val = random(1500, 2500);
  149.             break;
  150.         case WALKTOCAVE:
  151.             hasDoneReset = false;
  152.             walkPath(midToCave);
  153.             val = random(500, 1300);
  154.             break;
  155.         case FIGHTCRAB:
  156.             fightCrab();
  157.             val = random(1500, 2500);
  158.             break;
  159.         case WALKTOMID:
  160.             walkToMiddleTile();
  161.             val = random(1000, 2000);
  162.             break;
  163.         case ENTERCAVE:
  164.             RSObject cave = objects.getNearest(CaveOutsideID);
  165.             if (cave != null) {
  166.                 camera.turnToObject(cave);
  167.                 cave.doAction("Enter");
  168.             }
  169.             val = random(1000, 2000);
  170.             break;
  171.         case EXITCAVE:
  172.             RSObject cave1 = objects.getNearest(CaveInsideID);
  173.             if (cave1 != null) {
  174.                 camera.turnToObject(cave1);
  175.                 cave1.doAction("Enter");
  176.             }
  177.             hasDoneReset = true;
  178.             val = random(1000, 2000);
  179.             break;
  180.         case WALKTOBANK:
  181.             walkPath(teleToBank);
  182.             val = random(300, 1500);
  183.             break;
  184.         case BANKOPEN:
  185.             openBank();
  186.             val = random(1300, 2600);
  187.             break;
  188.         case BANKWITHDRAW:
  189.             withdrawSupplies();
  190.             val = random(1300, 2600);
  191.             break;
  192.         case BANKCLOSE:
  193.             bank.close();
  194.             val = random(1000, 1800);
  195.             break;
  196.         case REFILLHP:
  197.             checkFood();
  198.             val = random(1500, 2500);
  199.             break;
  200.         case WALKTOCRABS:
  201.             walkPath(bankToCrabs);
  202.             val = random(1000, 2000);
  203.             break;
  204.         case UNKNOWN:
  205.             // log.severe("Unknown problem found. Finding workaround...");
  206.         }
  207.         return val;
  208.     }
  209.  
  210.     public Next getNext() {
  211.         if (!guiDone) {
  212.             Status = "Waiting on GUI.";
  213.             return Next.GUI;
  214.         }
  215.         if (getMyPlayer().isMoving()) {
  216.             Status = "Walking";
  217.             return Next.WALKING;
  218.         } else if (crabArea.contains(getMyPlayer().getLocation())) {
  219.             if (isFightingCrab()) {
  220.                 Status = "Fighting";
  221.                 return Next.INCOMBAT;
  222.             } else if (needsToReset()) {
  223.                 Status = "Resetting";
  224.                 return Next.WALKTOCAVE;
  225.             } else if (!isFightingCrab() && !needsToReset() && !walkMiddle()) {
  226.                 Status = "Finding Rock Crab";
  227.                 return Next.FIGHTCRAB;
  228.             } else if (!isFightingCrab() && walkMiddle()) {
  229.                 Status = "Walking back to middle";
  230.                 return Next.WALKTOMID;
  231.             }
  232.         } else if (outsideCaveArea.contains(getMyPlayer().getLocation())) {
  233.             if (!hasDoneReset) {
  234.                 Status = "Walking to cave";
  235.                 return Next.ENTERCAVE;
  236.             } else if (hasDoneReset) {
  237.                 Status = "Walking back to middle";
  238.                 return Next.WALKTOMID;
  239.             }
  240.                     } else if (insideCave()) {
  241.             if (!hasDoneReset) {
  242.                 Status = "Exiting cave";
  243.                 return Next.EXITCAVE;
  244.  
  245.             }
  246.         } else if (teleportArea.contains(getMyPlayer().getLocation())) {
  247.             Status = "Walking to bank.";
  248.             return Next.WALKTOBANK;
  249.         } else if (bankArea.contains(getMyPlayer().getLocation())) {
  250.             if (!restocked() && !bank.getInterface().isValid()) {
  251.                 Status = "Opening bank.";
  252.                 return Next.BANKOPEN;
  253.             } else if (!restocked() && bank.getInterface().isValid()) {
  254.                 Status = "Restocking supplies.";
  255.                 return Next.BANKWITHDRAW;
  256.             } else if (restocked() && bank.getInterface().isValid()) {
  257.                 Status = "Closing bank.";
  258.                 return Next.BANKCLOSE;
  259.             } else if (!bank.getInterface().isValid() && restocked()
  260.                     && (getMyPlayer().getHPPercent() < 100)) {
  261.                 Status = "Refilling HP.";
  262.                 return Next.REFILLHP;
  263.             } else if (!bank.getInterface().isValid() && restocked()
  264.                     && (getMyPlayer().getHPPercent() == 100)) {
  265.                 Status = "Walking back to crabs.";
  266.                 return Next.WALKTOCRABS;
  267.             }
  268.         } else if (!bankArea.contains(getMyPlayer().getLocation())
  269.                 && !crabArea.contains(getMyPlayer().getLocation())
  270.                 && !teleportArea.contains(getMyPlayer().getLocation())) {
  271.             if (!isFightingCrab() && !getMyPlayer().isMoving()) {
  272.                 Status = "Walking to middle.";
  273.                 return Next.WALKTOMID;
  274.             }
  275.  
  276.         }
  277.  
  278.         return Next.UNKNOWN;
  279.     }
  280.  
  281.     private void withdrawSupplies() {
  282.         if (bank.getInterface().isValid()) {
  283.             bank.depositAll();
  284.             sleep(random(1000, 1800));
  285.             if (!useTeleSpell) {
  286.                 RSItem teletab = bank.getItem(teleTabID);
  287.                 if (teletab != null) {
  288.                     teletab.doAction("Withdraw-1");
  289.                 } else {
  290.                     log("No teletab found in bank! Logging out.");
  291.                     bank.close();
  292.                     sleep(random(2000, 3500));
  293.                     doLogout();
  294.                 }
  295.             } else {
  296.                 RSItem rune1 = bank.getItem(airRuneID);
  297.                 RSItem rune2 = bank.getItem(lawRuneID);
  298.                 if ((rune1 != null) && (rune2 != null)) {
  299.                     rune1.doAction("Withdraw-5");
  300.                     sleep(random(2000, 3500));
  301.                     rune2.doAction("Withdraw-1");
  302.                     sleep(random(2000, 3500));
  303.                 } else {
  304.                     log("Runes for teleport not found! Logging out.");
  305.                     bank.close();
  306.                     sleep(random(2000, 3500));
  307.                     doLogout();
  308.                 }
  309.             }
  310.             RSItem food = bank.getItem(FoodID);
  311.             if (food != null) {
  312.                 food.doAction("Withdraw-all");
  313.                 sleep(random(2000, 3500));
  314.             } else {
  315.                 log("Food not found! Logging out.");
  316.                 bank.close();
  317.                 sleep(random(2000, 3500));
  318.                 doLogout();
  319.             }
  320.         }
  321.     }
  322.  
  323.     private boolean insideCave() {
  324.         RSObject cave = objects.getNearest(CaveInsideID);
  325.         if (cave != null) {
  326.             return true;
  327.         }
  328.         return false;
  329.     }
  330.  
  331.     private boolean walkMiddle() {
  332.         if (!isFightingCrab()) {
  333.             if ((calc.distanceTo(MiddleTile) >= 12)
  334.                     || outsideCaveArea.contains(getMyPlayer().getLocation())) {
  335.                 return true;
  336.             }
  337.         }
  338.         return false;
  339.     }
  340.  
  341.     private void openBank() {
  342.         int i = random(1, 100);
  343.         if (i >= 50) {
  344.             RSNPC banker = npcs.getNearest(bankerIDs);
  345.             if (banker != null) {
  346.                 banker.doAction("Bank banker");
  347.             }
  348.         } else {
  349.             RSObject booth = objects.getNearest(boothIDs);
  350.             if (booth != null) {
  351.                 booth.doAction("Use-quickly");
  352.             }
  353.         }
  354.         sleep(random(1300, 1600));
  355.         if (!bank.getInterface().isValid()) {
  356.             openBank();
  357.         }
  358.     }
  359.  
  360.     private boolean needsToReset() {
  361.         if (isByRock()) {
  362.             sleep(1000);
  363.             if (!isFightingCrab() && isByRock()) {
  364.                 return true;
  365.             }
  366.  
  367.         }
  368.         return false;
  369.     }
  370.  
  371.     private void checkFood() {
  372.         if (getMyPlayer().getHPPercent() <= 25) {
  373.             if (inventory.contains(FoodID)) {
  374.                 RSItem food = inventory.getItem(FoodID);
  375.                 if (food != null) {
  376.                     food.doAction("Eat");
  377.                 }
  378.             } else {
  379.                 if (!useTeleSpell) {
  380.                     if (inventory.contains(teleTabID)) {
  381.                         RSItem tele = inventory.getItem(teleTabID);
  382.                         tele.doAction("Break");
  383.                     } else {
  384.                         log.severe("No teletab found! Logging out.");
  385.                         if (getMyPlayer().isInCombat()) {
  386.                             while (getMyPlayer().isInCombat()) {
  387.                                 sleep(300);
  388.                             }
  389.                         }
  390.                         doLogout();
  391.                     }
  392.                 } else {
  393.                     if (inventory.contains(airRuneID)
  394.                             && inventory.contains(lawRuneID)) {
  395.  
  396.                         interfaces.get(146).getComponent(135).doClick();
  397.                         sleep(random(1000, 2000));
  398.                         interfaces.get(192).getComponent(51).doClick();
  399.                     } else {
  400.                         log.severe("No teletab found! Logging out.");
  401.                         if (getMyPlayer().isInCombat()) {
  402.                             while (getMyPlayer().isInCombat()) {
  403.                                 sleep(300);
  404.                             }
  405.                         }
  406.                         doLogout();
  407.                     }
  408.  
  409.                 }
  410.             }
  411.         }
  412.     }
  413.  
  414.     private void doLogout() {
  415.         if (!game.isOnLogoutTab()) {
  416.             interfaces.get(548).getComponent(181).doClick();
  417.             sleep(random(1000, 2000));
  418.             doLogout();
  419.         } else {
  420.             interfaces.get(182).getComponent(6).doClick();
  421.         }
  422.         stopScript(true);
  423.     }
  424.  
  425.     private boolean restocked() {
  426.         if (!useTeleSpell) {
  427.             if (inventory.contains(teleTabID) && inventory.contains(FoodID)
  428.                     && inventory.isFull()) {
  429.                 return true;
  430.             }
  431.         } else {
  432.             if (inventory.contains(airRuneID) && inventory.contains(lawRuneID)
  433.                     && inventory.isFull()) {
  434.                 return true;
  435.             }
  436.         }
  437.         return false;
  438.     }
  439.  
  440.     private void walkToMiddleTile() {
  441.         // new RSTile(2704, 3718)
  442.         int[] x = { 0 };
  443.         int[] y = { 0 };
  444.         int spacing = calc.distanceTo(new RSTile(2704, 3719)) / 3;
  445.         x = new int[spacing + 1];
  446.         y = new int[spacing + 1];
  447.         if (getMyPlayer().getLocation().getX() > 2704) {
  448.             for (int xVal = 0; xVal < spacing; xVal++) {
  449.                 if ((getMyPlayer().getLocation().getX() - (xVal * 3)) <= 2704) {
  450.                     x[xVal] = getMyPlayer().getLocation().getX();
  451.                 } else {
  452.                     x[xVal] = getMyPlayer().getLocation().getX() - (xVal * 3);
  453.                 }
  454.             }
  455.             x[x.length - 1] = 2704;
  456.         } else {
  457.             for (int xVal = 0; xVal < spacing; xVal++) {
  458.                 if ((getMyPlayer().getLocation().getX() + (xVal * 3)) >= 2704) {
  459.                     x[xVal] = getMyPlayer().getLocation().getX();
  460.                 } else {
  461.                     x[xVal] = getMyPlayer().getLocation().getX() + (xVal * 3);
  462.                 }
  463.             }
  464.             x[x.length - 1] = 2704;
  465.         }
  466.         if (getMyPlayer().getLocation().getY() > 3719) {
  467.             for (int yVal = 0; yVal < spacing; yVal++) {
  468.                 if ((getMyPlayer().getLocation().getY() - (yVal * 3)) <= 3719) {
  469.                     y[yVal] = getMyPlayer().getLocation().getY();
  470.                 } else {
  471.                     y[yVal] = getMyPlayer().getLocation().getY() - (yVal * 3);
  472.                 }
  473.             }
  474.             y[y.length - 1] = 3718;
  475.         } else {
  476.             for (int yVal = 0; yVal < spacing; yVal++) {
  477.                 if ((getMyPlayer().getLocation().getY() + (yVal * 3)) >= 3719) {
  478.                     y[yVal] = getMyPlayer().getLocation().getY();
  479.                 } else {
  480.                     y[yVal] = getMyPlayer().getLocation().getY() + (yVal * 3);
  481.                 }
  482.             }
  483.             y[y.length - 1] = 3719;
  484.         }
  485.         RSTile[] midPath = new RSTile[spacing + 1];
  486.         for (int i = 0; i < spacing + 1; i++) {
  487.             midPath[i] = new RSTile(x[i], y[i]);
  488.         }
  489.         walkPath(midPath);
  490.     }
  491.  
  492.     private void walkPath(RSTile[] path) {
  493.         if (!walking.isRunEnabled()) {
  494.             int i = random(55, 70);
  495.             if (walking.getEnergy() >= i) {
  496.                 walking.setRun(true);
  497.             }
  498.         }
  499.         antiBan();
  500.         RSTilePath h = walking.newTilePath(path);
  501.         h.traverse();
  502.         sleep(500);
  503.         if (calc.distanceTo(path[path.length - 1]) > 2) {
  504.             walkPath(path);
  505.         }
  506.     }
  507.  
  508.     private boolean isByRock() {
  509.         RSNPC rock = npcs.getNearest(RockID);
  510.         if (rock != null) {
  511.             int x = rock.getLocation().getX();
  512.             int y = rock.getLocation().getY();
  513.  
  514.             RSTile[] aroundCrab = { new RSTile(x - 1, y + 1),
  515.                     new RSTile(x, y + 1), new RSTile(x + 1, y + 1),
  516.                     new RSTile(x - 1, y), new RSTile(x, y),
  517.                     new RSTile(x + 1, y), new RSTile(x - 1, y - 1),
  518.                     new RSTile(x, y - 1), new RSTile(x + 1, y - 1) };
  519.             for (int i = 0; i < aroundCrab.length; i++) {
  520.  
  521.                 if (getMyPlayer().getLocation().getX() == aroundCrab[i].getX()) {
  522.                     if (getMyPlayer().getLocation().getY() == aroundCrab[i]
  523.                             .getY())
  524.                         return true;
  525.                 }
  526.             }
  527.         }
  528.         return false;
  529.     }
  530.  
  531.     private boolean canGetName(RSNPC n) {
  532.         try {
  533.             if (n != null) {
  534.                 if (n.getInteracting() != null) {
  535.                     if (n.getInteracting().getName().length() > 0) {
  536.                         return true;
  537.                     }
  538.                 }
  539.             }
  540.             return false;
  541.         } catch (NullPointerException ex) {
  542.             return false;
  543.         }
  544.     }
  545.  
  546.     private boolean isFightingCrab() {
  547.         try {
  548.             if (getMyPlayer().isMoving()) {
  549.                 sleep(500);
  550.                 return isFightingCrab();
  551.             }
  552.             RSNPC[] allNpcs = npcs.getAll();
  553.             if (allNpcs == null) {
  554.                 return false;
  555.             }
  556.             for (int i = 0; i < allNpcs.length; i++) {
  557.                 if (allNpcs[i] != null) {
  558.                     if ((allNpcs[i].getID() == 1265)
  559.                             || (allNpcs[i].getID() == 1267)) {
  560.                         if (canGetName(allNpcs[i])) {
  561.                             if (allNpcs[i].getInteracting().getName() == getMyPlayer()
  562.                                     .getName()) {
  563.                                 return true;
  564.                             }
  565.                         }
  566.                     }
  567.                 }
  568.             }
  569.         } catch (NullPointerException ex) {
  570.             log("Exception here...something to do with Interacting detection.");
  571.             return false;
  572.         }
  573.         return false;
  574.  
  575.     }
  576.  
  577.     private void fightCrab() {
  578.         if (getMyPlayer().isMoving()) {
  579.             sleep(500);
  580.             fightCrab();
  581.         }
  582.         if (!walking.isRunEnabled()) {
  583.             if (walking.getEnergy() > 35) {
  584.                 walking.setRun(true);
  585.             }
  586.         }
  587.         try {
  588.             if (!isFightingCrab()) {
  589.                 RSNPC crab = npcs.getNearest(CrabID);
  590.                 if (crab != null
  591.                         && ((crab.getInteracting() == null) || (crab
  592.                                 .getInteracting().getName() == getMyPlayer()
  593.                                 .getName()))
  594.                         && crabArea.contains(crab.getLocation())) {
  595.                     if (!calc.tileOnScreen(crab.getLocation())) {
  596.                         walking.walkTileMM(crab.getLocation());
  597.                     }
  598.                     ;
  599.                     crab.doAction("Attack");
  600.                 } else {
  601.                     RSNPC rock = npcs.getNearest(RockID);
  602.                     if (rock != null && crabArea.contains(rock.getLocation())) {
  603.                         if (!calc.tileOnScreen(rock.getLocation())) {
  604.                             walking.walkTileMM(rock.getLocation());
  605.                         } else {
  606.                             walking.walkTileOnScreen(rock.getLocation());
  607.                         }
  608.  
  609.                     }
  610.                 }
  611.             }
  612.         } catch (NullPointerException ex) {
  613.             fightCrab();
  614.         }
  615.     }
  616.  
  617.     private void antiBan() {
  618.         if (currentTile == null) {
  619.             currentTile = getMyPlayer().getLocation();
  620.         }
  621.         if (timeCheck == 0) {
  622.             timeCheck = System.currentTimeMillis();
  623.         }
  624.         if (getMyPlayer().getLocation() != currentTile) {
  625.             currentTile = null;
  626.             timeCheck = 0;
  627.         }
  628.         if (getMyPlayer().getLocation() == currentTile) {
  629.             log("hi");
  630.             if ((System.currentTimeMillis() - timeCheck) > 180000) {
  631.                 log("You have not been moved for 3 minutes, LOGGING OUT!");
  632.                 doLogout();
  633.             }
  634.         }
  635.     }
  636.  
  637.     private final Color color1 = new Color(0, 0, 0);
  638.     private final Color color2 = new Color(0, 153, 204);
  639.     private final Color color3 = new Color(255, 255, 255);
  640.  
  641.     private final BasicStroke stroke1 = new BasicStroke(2);
  642.  
  643.     private final Font font1 = new Font("Arial", 1, 13);
  644.     private final Font font2 = new Font("Arial", 0, 12);
  645.  
  646.     @Override
  647.     public void onRepaint(Graphics g1) {
  648.         if (expStarted == 0) {
  649.             expStarted = skills.getCurrentExp(Skills.ATTACK)
  650.                     + skills.getCurrentExp(Skills.STRENGTH)
  651.                     + skills.getCurrentExp(Skills.DEFENSE)
  652.                     + skills.getCurrentExp(Skills.RANGE)
  653.                     + skills.getCurrentExp(Skills.MAGIC);
  654.         }
  655.         long expGained = (skills.getCurrentExp(Skills.ATTACK)
  656.                 + skills.getCurrentExp(Skills.STRENGTH)
  657.                 + skills.getCurrentExp(Skills.DEFENSE)
  658.                 + skills.getCurrentExp(Skills.RANGE) + skills
  659.                 .getCurrentExp(Skills.MAGIC)) - expStarted;
  660.  
  661.         Killed = (int) expGained / 200;
  662.         long currentTime = System.currentTimeMillis() - startTime;
  663.         long expPerHour = (expGained * 3600000) / currentTime;
  664.         long hours = currentTime / 3600000;
  665.         currentTime -= hours * 3600000;
  666.         long mins = currentTime / 60000;
  667.         currentTime -= mins * 60000;
  668.         long secs = currentTime / 1000;
  669.        
  670.         Graphics2D g = (Graphics2D) g1;
  671.         g.drawString("RockBuster (V1.0) ~ By RoyMastha", 14, 40);
  672.         g.setFont(font2);
  673.         g.drawString("Killed: " + Killed, 14, 60);
  674.         g.drawString("Time Running: " + hours + ":" + mins + ":" + secs, 14, 75);
  675.         g.drawString("Exp Gained: " + expGained, 14, 90);
  676.         g.drawString("Exp Per Hour: " + expPerHour, 14, 105);
  677.         g.drawString("Status: " + Status, 14, 120);
  678.     }
  679.  
  680.     private void initGUI() {
  681.         gui.setSize(191, 200);
  682.         gui.setContentPane(getJContentPane());
  683.         gui.setTitle("RockBuster ~ RoyMastha");
  684.         gui.setVisible(true);
  685.     }
  686.  
  687.     private JPanel getJContentPane() {
  688.         if (jContentPane == null) {
  689.             jLabel1 = new JLabel();
  690.             jLabel1.setBounds(new Rectangle(16, 90, 114, 16));
  691.             jLabel1.setFont(new Font("SansSerif", Font.PLAIN, 12));
  692.             jLabel1.setText("Pickup IDs");
  693.             jLabel = new JLabel();
  694.             jLabel.setBounds(new Rectangle(14, 15, 116, 16));
  695.             jLabel.setFont(new Font("SansSerif", Font.PLAIN, 14));
  696.             jLabel.setText("Food IDs (Auto Eat)");
  697.             jContentPane = new JPanel();
  698.             jContentPane.setLayout(null);
  699.             jContentPane.add(jLabel, null);
  700.             jContentPane.add(getJTextField(), null);
  701.             jContentPane.add(getJCheckBox(), null);
  702.             jContentPane.add(jLabel1, null);
  703.             jContentPane.add(getJTextField1(), null);
  704.             jContentPane.add(getJButton(), null);
  705.         }
  706.         return jContentPane;
  707.     }
  708.  
  709.     private JTextField getJTextField() {
  710.         if (jTextField == null) {
  711.             jTextField = new JTextField();
  712.             jTextField.setBounds(new Rectangle(14, 33, 142, 20));
  713.         }
  714.         return jTextField;
  715.     }
  716.  
  717.     private JCheckBox getJCheckBox() {
  718.         if (jCheckBox == null) {
  719.             jCheckBox = new JCheckBox();
  720.             jCheckBox.setBounds(new Rectangle(12, 61, 139, 21));
  721.             jCheckBox.setFont(new Font("SansSerif", Font.PLAIN, 12));
  722.             jCheckBox.setText("Use Teleport Spell");
  723.         }
  724.         return jCheckBox;
  725.     }
  726.  
  727.     private JTextField getJTextField1() {
  728.         if (jTextField1 == null) {
  729.             jTextField1 = new JTextField();
  730.             jTextField1.setBounds(new Rectangle(15, 108, 138, 20));
  731.             jTextField1.setEnabled(false);
  732.             jTextField1.setText("TO BE IMPLEMENTED");
  733.         }
  734.         return jTextField1;
  735.     }
  736.  
  737.     private JButton getJButton() {
  738.         if (jButton == null) {
  739.             jButton = new JButton();
  740.             jButton.setBounds(new Rectangle(4, 133, 166, 26));
  741.             jButton.setFont(new Font("SansSerif", Font.BOLD, 12));
  742.             jButton.setText("Start Script!");
  743.             jButton.addActionListener(new java.awt.event.ActionListener() {
  744.                 public void actionPerformed(java.awt.event.ActionEvent e) {
  745.                     FoodID = getFoodId(jTextField.getText());
  746.                     useTeleSpell = jCheckBox.isSelected();
  747.                     gui.setVisible(false);
  748.                     gui.dispose();
  749.                     guiDone = true;
  750.                 }
  751.             });
  752.         }
  753.         return jButton;
  754.     }
  755.  
  756.     private int getFoodId(String s) {
  757.         int i = 0;
  758.         try {
  759.             i = Integer.parseInt(s);
  760.         } catch (Exception ex) {
  761.         }
  762.         return i;
  763.     }
  764.  
  765. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement