Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 30.90 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Cursor;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.Point;
  7. import java.awt.RenderingHints;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10. import java.awt.event.InputEvent;
  11. import java.awt.event.KeyEvent;
  12. import java.util.HashSet;
  13. import java.util.Set;
  14.  
  15. import javax.swing.ButtonGroup;
  16. import javax.swing.DefaultComboBoxModel;
  17. import javax.swing.GroupLayout;
  18. import javax.swing.JButton;
  19. import javax.swing.JCheckBox;
  20. import javax.swing.JComboBox;
  21. import javax.swing.JFrame;
  22. import javax.swing.JLabel;
  23. import javax.swing.JMenu;
  24. import javax.swing.JMenuBar;
  25. import javax.swing.JMenuItem;
  26. import javax.swing.JPanel;
  27. import javax.swing.JRadioButton;
  28. import javax.swing.JSeparator;
  29. import javax.swing.JTabbedPane;
  30. import javax.swing.JTextField;
  31. import javax.swing.KeyStroke;
  32. import javax.swing.LayoutStyle;
  33. import javax.swing.SwingConstants;
  34. import javax.swing.UIManager;
  35. import javax.swing.WindowConstants;
  36.  
  37. import org.rsbot.event.listeners.PaintListener;
  38. import org.rsbot.script.Script;
  39. import org.rsbot.script.ScriptManifest;
  40. import org.rsbot.script.methods.Game;
  41. import org.rsbot.script.methods.Skills;
  42. import org.rsbot.script.util.Filter;
  43. import org.rsbot.script.util.Timer;
  44. import org.rsbot.script.wrappers.*;
  45.  
  46. @SuppressWarnings("unused")
  47. @ScriptManifest(name = "Rock Crabs", authors = { "Vastico" }, version = 1.6, description = "Rock Crab Killer")
  48. public class RockCrabs extends Script implements PaintListener {
  49.  
  50.     public static interface Constants {
  51.  
  52.         RSArea CAMELOT_AREA = new RSArea(2721, 3475, 2760, 3493);
  53.  
  54.         RSArea BANK_AREA = new RSArea(2721, 3489, 2730, 3493);
  55.  
  56.         RSArea CRABS_AREA = new RSArea(2662, 3712, 2688, 3722);
  57.  
  58.         RSArea RESET_CRABS_AREA = new RSArea(2677, 3688, 2667, 3682);
  59.  
  60.         int TELETAB = 8010;
  61.  
  62.         int[] FOOD = new int[] { 1161, 1965, 1969, 1967, 1895, 1893, 1891,
  63.                 1971, 4293, 2142, 4291, 2140, 3228, 9980, 7223, 6297, 6293,
  64.                 6295, 6299, 7521, 9988, 7228, 2878, 7568, 2343, 1861, 13433,
  65.                 315, 325, 319, 3144, 347, 355, 333, 339, 351, 329, 3381, 361,
  66.                 10136, 5003, 379, 365, 373, 7946, 385, 397, 391, 3369, 3371,
  67.                 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335, 7178, 7180,
  68.                 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003, 2011,
  69.                 2289, 2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893,
  70.                 1895, 1897, 1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082,
  71.                 7066, 7068, 1942, 6701, 6703, 7054, 6705, 7056, 7060, 2130,
  72.                 1985, 1993, 1989, 1978, 5763, 5765, 1913, 5747, 1905, 5739,
  73.                 1909, 5743, 1907, 1911, 5745, 2955, 5749, 5751, 5753, 5755,
  74.                 5757, 5759, 5761, 2084, 2034, 2048, 2036, 2217, 2213, 2205,
  75.                 2209, 2054, 2040, 2080, 2277, 2225, 2255, 2221, 2253, 2219,
  76.                 2281, 2227, 2223, 2191, 2233, 2092, 2032, 2074, 2030, 2281,
  77.                 2235, 2064, 2028, 2187, 2185, 2229 };
  78.  
  79.         Color PLAYER_FILL_COLOR = new Color(0, 255, 0, 50);
  80.  
  81.         Color AREA_FILL_COLOR = new Color(0, 48, 128, 20);
  82.  
  83.         Color TEXT_COLOR = new Color(255, 255, 255, 255);
  84.  
  85.         Color CRAB_MODEL_COLOR = new Color(0, 0, 255, 50);
  86.  
  87.         Color BACKGROUND_COLOR = new Color(0, 0, 0, 50);
  88.  
  89.         RenderingHints ANTI_ALIASING = new RenderingHints(
  90.                 RenderingHints.KEY_ANTIALIASING,
  91.                 RenderingHints.VALUE_ANTIALIAS_ON);
  92.  
  93.     }
  94.  
  95.     public static abstract class Action {
  96.  
  97.         public abstract void process();
  98.  
  99.         public abstract boolean isValid();
  100.  
  101.         public abstract String getDescription();
  102.  
  103.         public void complete() {
  104.         }
  105.  
  106.         public void paint(Graphics render) {
  107.         }
  108.  
  109.     }
  110.  
  111.     public class Bank extends Action {
  112.  
  113.         private RSArea area;
  114.  
  115.         public Bank(RSArea area) {
  116.             this.area = area;
  117.         }
  118.  
  119.         public void process() {
  120.             if (bank.isOpen()) {
  121.                 if (inventory.getCount() > 0) {
  122.                     if (inventory.getCount(Constants.TELETAB) == 0) {
  123.                         bank.depositAll();
  124.                     } else {
  125.                         bank.depositAllExcept(Constants.TELETAB);
  126.                     }
  127.                     sleep(400);
  128.                 }
  129.                 if (inventory.getCount(Constants.TELETAB) == 0) {
  130.                     if (bank.getCount(Constants.TELETAB) > 0) {
  131.                         bank.withdraw(Constants.TELETAB, 1);
  132.                         sleep(400);
  133.                     }
  134.                 }
  135.                 if (bank.getCount(Constants.FOOD) > 0) {
  136.                     for (int id : Constants.FOOD) {
  137.                         bank.withdraw(id, 0);
  138.                     }
  139.                 } else {
  140.                     log("No food found when required. Stopping script.");
  141.                     stopScript();
  142.                     return;
  143.                 }
  144.                 if (inventory.getCount(Constants.FOOD) == 0) {
  145.                     sleep(400);
  146.                 }
  147.             } else {
  148.                 bank.open();
  149.             }
  150.         }
  151.  
  152.         public boolean isValid() {
  153.             return !hasFood() && area.contains(getMyPlayer().getLocation())
  154.                     && banking;
  155.         }
  156.  
  157.         public String getDescription() {
  158.             return "Banking";
  159.         }
  160.  
  161.     }
  162.  
  163.     public abstract class EatFood extends Action {
  164.  
  165.         public abstract boolean isTargetValid();
  166.  
  167.         public void process() {
  168.             for (int id : Constants.FOOD) {
  169.                 if (!eatingFood) {
  170.                     log("We aren't eating but we require food!");
  171.                     log("Stopping script.");
  172.                     stopScript();
  173.                     return;
  174.                 }
  175.                 if (bank.isOpen()) {
  176.                     bank.close();
  177.                 } else {
  178.                     if (inventory.getCount(id) == 0) {
  179.                         continue;
  180.                     }
  181.                     inventory.getItem(id).interact("Eat");
  182.                     sleep(500);
  183.                     break;
  184.                 }
  185.             }
  186.         }
  187.  
  188.         public boolean isValid() {
  189.             return hasFood() && isTargetValid();
  190.         }
  191.  
  192.         public String getDescription() {
  193.             return "Eating";
  194.         }
  195.  
  196.     }
  197.  
  198.     public abstract class WalkToArea extends Action {
  199.  
  200.         private RSArea dest;
  201.         private String name;
  202.         private RSTile last;
  203.  
  204.         public WalkToArea(RSArea dest, String name) {
  205.             this.dest = dest;
  206.             this.name = name;
  207.         }
  208.  
  209.         protected abstract boolean isTargetValid();
  210.  
  211.         public void process() {
  212.             if (!walking.isRunEnabled() && walking.getEnergy() > 30) {
  213.                 walking.setRun(true);
  214.                 sleep(200);
  215.             }
  216.             RSTile tile = dest.getCentralTile();
  217.             if (last == null || getMyPlayer().isIdle()
  218.                     || (calc.distanceTo(last) < 10 && !dest.contains(last))) {
  219.                 if (!walking.walkTo(tile)) {
  220.                     walking.walkTileOnScreen(calc.getTileOnScreen(tile));
  221.                 }
  222.                 last = walking.getDestination();
  223.                 sleep(random(1000, 1800));
  224.             } else {
  225.                 idle();
  226.             }
  227.         }
  228.  
  229.         public boolean isValid() {
  230.             return isTargetValid()
  231.                     && !dest.contains(getMyPlayer().getLocation());
  232.         }
  233.  
  234.         public void complete() {
  235.             last = null;
  236.         }
  237.  
  238.         public void paint(Graphics render) {
  239.             render.setColor(Constants.AREA_FILL_COLOR);
  240.             for (RSTile t : dest.getTileArray()) {
  241.                 Point pn = calc.tileToScreen(t, 0, 0, 0);
  242.                 Point px = calc.tileToScreen(t, 1, 0, 0);
  243.                 Point py = calc.tileToScreen(t, 0, 1, 0);
  244.                 Point pxy = calc.tileToScreen(t, 1, 1, 0);
  245.                 if (pn.x > -1 && px.x > -1 && py.x > -1 && pxy.x > -1) {
  246.                     render.fillPolygon(new int[] { py.x, pxy.x, px.x, pn.x },
  247.                             new int[] { py.y, pxy.y, px.y, pn.y }, 4);
  248.                 }
  249.             }
  250.         }
  251.  
  252.         public String getDescription() {
  253.             return "Walking to " + name + ".";
  254.         }
  255.  
  256.     }
  257.  
  258.     private Set<Action> actions;
  259.     private Action action;
  260.  
  261.     private long scriptStartTime = 0;
  262.     private int kills = 0;
  263.     private int attempts = 0;
  264.     private final int[] startXp = new int[6];
  265.     private final int[] startLevel = new int[6];
  266.     private RSNPC last = null;
  267.     private AdminGUI gui;
  268.     private Action eatAction;
  269.  
  270.     private boolean usingTabs;
  271.     private boolean eatingFood;
  272.     private boolean banking;
  273.     private boolean pickinguparrows = false;
  274.  
  275.     private int INTERFACE_BANK_TAB = 1;
  276.  
  277.     private int[] pickupArrowID = { 864, 882, 884, 886, 888, 890, 892, 2866,
  278.             877, 9140, 9141, 9142, 13083, 9143, 9144 };
  279.     /*
  280.      * Bronze arrow, Iron arrow, Steel arrow, Mithril arrow, Adamant arrow, Rune
  281.      * arrow, Ogre arrow, Bronze bolts, Iron Bolts, Steel Bolts, Black Bolts,
  282.      * Mithril Bolts, Adamant Bolts, Rune Bolts
  283.      */
  284.  
  285.     /**
  286.      * RSTile[] BankToCrabs = new RSTile[]{ new RSTile(2727, 3484), new
  287.      * RSTile(2727, 3484), new RSTile(2735, 3492), new RSTile(2741, 3502), new
  288.      * RSTile(2741, 3511), new RSTile(2741, 3525), new RSTile(2738, 3537), new
  289.      * RSTile(2728, 3543), new RSTile(2720, 3544), new RSTile(2711, 3544), new
  290.      * RSTile(2702, 3543), new RSTile(2694, 3545), new RSTile(2685, 3546), new
  291.      * RSTile(2674, 3551), new RSTile(2668, 3558), new RSTile(2660, 3562), new
  292.      * RSTile(2657, 3572), new RSTile(2654, 3581), new RSTile(2654, 3589), new
  293.      * RSTile(2654, 3602), new RSTile(2663, 3615), new RSTile(2665, 3624), new
  294.      * RSTile(2667, 3640), new RSTile(2659, 3655), new RSTile(2668, 3668), new
  295.      * RSTile(2671, 3681), new RSTile(2674, 3693), new RSTile(2673, 3706), new
  296.      * RSTile(2670, 3715) };
  297.      */
  298.  
  299.     private RSTile CrabsTile = new RSTile(2670, 3715);
  300.     private RSTile BankTile = new RSTile(2727, 3484);
  301.  
  302.     public boolean onStart() {
  303.         mouse.setSpeed(8);
  304.         gui = new AdminGUI();
  305.         gui.setVisible(true);
  306.  
  307.         while (!gui.start) {
  308.             sleep(200, 300);
  309.         }
  310.  
  311.         startL = skills.getCurrentLevel(Skills.STRENGTH);
  312.  
  313.         if (!isAutoRetaliationOn()) {
  314.             toggleAutoRetaliation();
  315.         }
  316.  
  317.         usingTabs = gui.chk_teletabs.isSelected();
  318.         banking = gui.chk_banking.isSelected();
  319.         eatingFood = gui.chk_food_eat.isSelected();
  320.         // pickinguparrows = gui.chk_pickinguparrows.isSelected();
  321.  
  322.         actions = new HashSet<Action>();
  323.  
  324.         eatAction = new EatFood() {
  325.             public boolean isTargetValid() {
  326.                 return requiresFood() && eatingFood;
  327.             }
  328.         };
  329.  
  330.         actions.add(eatAction);
  331.  
  332.         actions.add(new EatFood() {
  333.             public boolean isTargetValid() {
  334.                 return inBank() && requiresFullHealth() && eatingFood;
  335.             }
  336.         });
  337.  
  338.         actions.add(new WalkToArea(Constants.BANK_AREA, "bank") {
  339.             protected boolean isTargetValid() {
  340.                 return (!hasFood() && eatingFood) && !inBank() && banking;
  341.             }
  342.  
  343.             public void process() {
  344.                 if (usingTabs && inventory.getCount(Constants.TELETAB) > 0
  345.                         && !inCamelot()) {
  346.                     inventory.getItem(Constants.TELETAB).doAction("Break");
  347.                     sleep(3500);
  348.                 } else {
  349.                     super.process();
  350.                 }
  351.             }
  352.         });
  353.  
  354.         actions.add(new WalkToArea(Constants.CRABS_AREA, "crabs") {
  355.             protected boolean isTargetValid() {
  356.                 return ((hasFood() && eatingFood) && !inCrabs() && attempts <= 3)
  357.                         || inResetCrabs();
  358.             }
  359.  
  360.             public void process() {
  361.                 attempts = 0;
  362.                 super.process();
  363.             }
  364.         });
  365.  
  366.         actions.add(new WalkToArea(Constants.CRABS_AREA, "crabs again") {
  367.             protected boolean isTargetValid() {
  368.                 return (inventory.contains(Constants.TELETAB) && !inBank()
  369.                         && !inCrabs() && !inResetCrabs());
  370.             }
  371.         });
  372.  
  373.         actions.add(new WalkToArea(Constants.RESET_CRABS_AREA, "reset area") {
  374.             @Override
  375.             protected boolean isTargetValid() {
  376.                 return attempts > 3 && !inBank();
  377.             }
  378.         });
  379.  
  380.         actions.add(new Bank(Constants.BANK_AREA));
  381.  
  382.         return true;
  383.     }
  384.  
  385.     public int loop() {
  386.         if (!game.isLoggedIn() && skills.getRealLevel(Skills.CONSTITUTION) < 10) {
  387.             return random(100, 200);
  388.         }
  389.         mouse.setSpeed(random(6, 8));
  390.         if (getMyPlayer().getInteracting() != null) {
  391.             idle();
  392.             attempts = 0;
  393.         }
  394.         for (int id : Constants.FOOD) {
  395.             if (inBank() && inventory.contains(id)) {
  396.                 walkToCrabs();
  397.             }
  398.         }
  399.  
  400.         if (eatAction.isValid()) {
  401.             eatAction.process();
  402.         }
  403.         if (action != null) {
  404.             if (action.isValid()) {
  405.                 action.process();
  406.             } else {
  407.                 action.complete();
  408.                 action = null;
  409.             }
  410.         } else {
  411.             for (Action a : actions) {
  412.                 if (a.isValid()) {
  413.                     action = a;
  414.                     break;
  415.                 }
  416.             }
  417.         }
  418.  
  419.         if (needToPickUpArrows()) {
  420.             pickinguparrows = true;
  421.             pickUpArrows();
  422.             return random(50, 70);
  423.         }
  424.  
  425.         if (last != null) {
  426.             if (last == getMyPlayer().getInteracting()) {
  427.                 return random(200, 300);
  428.             }
  429.             if (last.getHPPercent() <= 0) {
  430.                 kills++;
  431.                 last = null;
  432.             }
  433.         }
  434.         if (action == null) {
  435.             action = getNewCrab();
  436.         }
  437.         antiBan();
  438.         return random(300, 500);
  439.     }
  440.  
  441.     public void onFinish() {
  442.         log(kills + " crabs killed and gained " + generateTotalXpGained()
  443.                 + " xp in "
  444.                 + Timer.format(System.currentTimeMillis() - scriptStartTime)
  445.                 + ".");
  446.         env.saveScreenshot(game.isLoggedIn());
  447.     }
  448.  
  449.     private boolean needToPickUpArrows() {
  450.         if (pickinguparrows) {
  451.             for (int ar : pickupArrowID) {
  452.                 RSGroundItem arrowToPickUp = groundItems.getNearest(3, ar);
  453.                 if (getMyPlayer().getLocation().getY() >= 3710) {
  454.                     if (arrowToPickUp != null && !inventory.isFull()) {
  455.                         return true;
  456.                     } else {
  457.                         if (inventory.isFull() && inventory.contains(ar)) {
  458.                             return true;
  459.                         }
  460.                     }
  461.                 }
  462.             }
  463.         }
  464.         return false;
  465.     }
  466.  
  467.     private void pickUpArrows() {
  468.         if (pickinguparrows) {
  469.             for (int ar2 : pickupArrowID) {
  470.                 if (last != null) {
  471.                     if (last.getHPPercent() <= 0) {
  472.                         if (inventory.isFull() && inventory.contains(ar2)) {
  473.                             RSGroundItem arrowToPickUp = groundItems
  474.                                     .getNearest(pickupArrowID);
  475.                             arrowToPickUp.interact("Take");
  476.                             sleep(500);
  477.                         }
  478.                         if (!inventory.isFull()) {
  479.                             RSGroundItem arrowToPickUp = groundItems
  480.                                     .getNearest(pickupArrowID);
  481.                             arrowToPickUp.interact("Take");
  482.                             sleep(500);
  483.                         }
  484.                         sleep(random(200, 400));
  485.                         if (inventory.contains(ar2)) {
  486.                             RSItem arrow = inventory.getItem(pickupArrowID);
  487.                             arrow.interact("Wield");
  488.                         }
  489.                     }
  490.                 }
  491.             }
  492.         }
  493.     }
  494.  
  495.     public boolean isAutoRetaliationOn() {
  496.         return settings.getSetting(172) == 0;
  497.     }
  498.  
  499.     @SuppressWarnings("deprecation")
  500.     public void toggleAutoRetaliation() {
  501.         if (game.getCurrentTab() != Game.TAB_ATTACK) {
  502.             game.openTab(Game.TAB_ATTACK);
  503.         }
  504.         mouse.click(random(579, 706), random(363, 395), true);
  505.         sleep(random(600, 800));
  506.     }
  507.  
  508.     private void walkToCrabs() {
  509.         RSWeb walkWeb = web.getWeb(getMyPlayer().getLocation(), CrabsTile);
  510.         if (walkWeb != null) {
  511.             if (!getMyPlayer().isMoving()
  512.                     || calc.distanceTo(walking.getDestination()) < 4) {
  513.                 try {
  514.                     walkWeb.step();
  515.                 } catch (Exception e) {
  516.                 }
  517.             }
  518.         }
  519.     }
  520.  
  521.     private Action getNewCrab() {
  522.         final RSNPC n = npcs.getNearest(new Filter<RSNPC>() {
  523.             public boolean accept(RSNPC t) {
  524.                 if (!t.isOnScreen() && t.getInteracting() != null
  525.                         && !t.getInteracting().equals(getMyPlayer()))
  526.                     return false;
  527.                 if (t.getHPPercent() == 0)
  528.                     if (t.getHPPercent() == 0)
  529.                         return false;
  530.                 if (t.getLocation().getY() >= 3722
  531.                         || t.getLocation().getX() >= 2688)
  532.                     return false;
  533.                 if (t.getName().equals("Rocks")
  534.                         || t.getName().equals("Rock Crab"))
  535.                     return true;
  536.                 return false;
  537.             }
  538.         });
  539.         if (n != null && n.getModel() != null) {
  540.             last = n;
  541.             if (n.getName().equals("Rocks") || !n.isOnScreen()) {
  542.                 if (isInArea(getNpcArea(n.getLocation()))) {
  543.                     attempts++;
  544.                 }
  545.                 if (attempts > 3) {
  546.                     log("Rocks not popping?");
  547.                     return null;
  548.                 }
  549.                 return new WalkToArea(getNpcArea(n.getLocation()), "crab") {
  550.  
  551.                     public void complete() {
  552.                         super.complete();
  553.                         sleep(300);
  554.                     }
  555.  
  556.                     protected boolean isTargetValid() {
  557.                         return inCrabs() && !inCombat();
  558.                     }
  559.                 };
  560.             } else {
  561.             }
  562.         }
  563.         return null;
  564.     }
  565.  
  566.     public void onRepaint(Graphics render) {
  567.         if (game.isLoggedIn() && skills.getRealLevel(Skills.CONSTITUTION) > 1) {
  568.             gainedL = currentL - startL;
  569.             currentL = skills.getCurrentLevel(Skills.STRENGTH);
  570.             if (scriptStartTime == 0) {
  571.                 scriptStartTime = System.currentTimeMillis();
  572.                 for (int index = 0; index < 6; index++) {
  573.                     if (index == 5) {
  574.                         startXp[index] = skills.getCurrentExp(6);
  575.                     } else {
  576.                         startXp[index] = skills.getCurrentExp(index);
  577.                     }
  578.                 }
  579.                 for (int index = 0; index < 6; index++) {
  580.                     if (index == 5) {
  581.                         startLevel[index] = skills.getCurrentLevel(6);
  582.                     } else {
  583.                         startLevel[index] = skills.getCurrentLevel(index);
  584.                     }
  585.                 }
  586.             }
  587.             Graphics2D g = (Graphics2D) render;
  588.             g.setRenderingHints(Constants.ANTI_ALIASING);
  589.             g.setColor(Constants.BACKGROUND_COLOR);
  590.             g.fillRect(10, 25, 175, 205);
  591.             g.setColor(Constants.TEXT_COLOR);
  592.             g.drawString("Rock Crab Killer by Vastico", 20, 55);
  593.             if (action != null) {
  594.                 action.paint(g);
  595.                 g.setColor(Constants.TEXT_COLOR);
  596.                 g.drawString(action.getDescription(), 20, 75);
  597.             } else {
  598.                 g.setColor(Constants.TEXT_COLOR);
  599.                 g.drawString(getMyPlayer().getInteracting() == null ? "Idle"
  600.                         : "Attacking", 20, 75);
  601.             }
  602.             g.setColor(Constants.TEXT_COLOR);
  603.             g.drawString("Kills: " + kills, 20, 95);
  604.             g.drawString(
  605.                     "Runtime: "
  606.                             + Timer.format(System.currentTimeMillis()
  607.                                     - scriptStartTime), 20, 115);
  608.             g.drawString("Total XP Gained: " + generateTotalXpGained(), 20, 135);
  609.             g.drawString("XP Per Hour: " + generateXpPerHour(), 20, 155);
  610.             g.drawString("Kills Per Hour: " + generateKillsPerHour(), 20, 175);
  611.             // g.drawString("Current Level: " + currentL + " (" + gainedL + ")",
  612.             // 20, 195);
  613.             g.drawString(
  614.                     "Current Version: "
  615.                             + getClass().getAnnotation(ScriptManifest.class)
  616.                                     .version(), 20, 215);
  617.         }
  618.     }
  619.  
  620.     int currentL;
  621.     int startL;
  622.     int gainedL;
  623.  
  624.     private int generateTotalXpGained() {
  625.         int gained = 0;
  626.         for (int index = 0; index < 6; index++) {
  627.             if (index == 5) {
  628.                 gained += this.skills.getCurrentExp(6);
  629.             } else {
  630.                 gained += this.skills.getCurrentExp(index);
  631.             }
  632.         }
  633.         for (int xp : this.startXp) {
  634.             gained -= xp;
  635.         }
  636.         return gained;
  637.     }
  638.  
  639.     private int generateXpPerHour() {
  640.         return (int) (generateTotalXpGained() * 3600000D / (System
  641.                 .currentTimeMillis() - scriptStartTime));
  642.     }
  643.  
  644.     private int generateKillsPerHour() {
  645.         return (int) (kills * 3600000D / (System.currentTimeMillis() - scriptStartTime));
  646.     }
  647.  
  648.     private RSArea getNpcArea(RSTile t) {
  649.         int x = t.getX();
  650.         int y = t.getY();
  651.         return new RSArea(x - 1, y - 1, x + 1, y + 1);
  652.     }
  653.  
  654.     private void idle() {
  655.         if (random(0, 50) == 0) {
  656.             int rand2 = random(1, 3);
  657.             for (int i = 0; i < rand2; i++) {
  658.                 mouse.move(random(100, 700), random(100, 500));
  659.                 sleep(random(200, 700));
  660.             }
  661.             mouse.move(random(0, 800), 647, 50, 100);
  662.             sleep(random(100, 1500));
  663.             mouse.move(random(75, 400), random(75, 400), 30);
  664.         }
  665.         if (random(0, 50) == 0) {
  666.             Point curPos = mouse.getLocation();
  667.             mouse.move(random(0, 750), random(0, 500), 20);
  668.             sleep(random(100, 300));
  669.             mouse.move(curPos, 20, 20);
  670.         }
  671.         if (random(0, 50) == 0) {
  672.             int angle = camera.getAngle() + random(-40, 40);
  673.             if (angle < 0) {
  674.                 angle += 359;
  675.             }
  676.             if (angle > 359) {
  677.                 angle -= 359;
  678.             }
  679.             camera.setAngle(angle);
  680.         }
  681.         if (random(0, 50) == 0) {
  682.             if (random(0, 4) == 0) {
  683.                 camera.setPitch(random(50, 80));
  684.             } else {
  685.                 camera.setPitch(true);
  686.             }
  687.         }
  688.     }
  689.  
  690.     public void antiBan() {
  691.  
  692.         int b = random(0, 10);
  693.         switch (b) {
  694.  
  695.         case 1: // Checking HP XP
  696.             if (random(0, 4) == 4) {
  697.  
  698.                 game.openTab(1);
  699.                 skills.doHover(Skills.INTERFACE_CONSTITUTION);
  700.                 sleep(random(3000, 4000));
  701.             }
  702.             break;
  703.  
  704.         case 2: // Mouse off Screen
  705.             if (random(0, 4) == 3) {
  706.  
  707.                 mouse.moveOffScreen();
  708.                 sleep(random(2000, 5500));
  709.             }
  710.             break;
  711.  
  712.         case 3: // Move Mouse
  713.             if (random(0, 4) == 2) {
  714.  
  715.                 mouse.moveSlightly();
  716.                 sleep(300, 700);
  717.                 mouse.moveRandomly(40, 860);
  718.             }
  719.             break;
  720.  
  721.         case 4: // Turn Screen
  722.             if (random(0, 4) == 1) {
  723.  
  724.                 camera.setAngle(random(100, 359));
  725.                 sleep(500, 1500);
  726.             }
  727.             break;
  728.  
  729.         default:
  730.  
  731.             break;
  732.  
  733.         }
  734.     }
  735.  
  736.     private boolean hasFood() {
  737.         return inventory.getCount(Constants.FOOD) > 0;
  738.     }
  739.  
  740.     private boolean requiresFood() {
  741.         return combat.getLifePoints() < (skills
  742.                 .getRealLevel(Skills.CONSTITUTION) * 10) / 2;
  743.     }
  744.  
  745.     private boolean requiresFullHealth() {
  746.         return combat.getLifePoints() < (skills
  747.                 .getRealLevel(Skills.CONSTITUTION) * 10);
  748.     }
  749.  
  750.     private boolean inBank() {
  751.         return Constants.BANK_AREA.contains(getMyPlayer().getLocation());
  752.     }
  753.  
  754.     private boolean inCamelot() {
  755.         return Constants.CAMELOT_AREA.contains(getMyPlayer().getLocation());
  756.     }
  757.  
  758.     private boolean inCombat() {
  759.         return getMyPlayer().isInCombat()
  760.                 && getMyPlayer().getInteracting() != null;
  761.     }
  762.  
  763.     private boolean inCrabs() {
  764.         return Constants.CRABS_AREA.contains(getMyPlayer().getLocation());
  765.     }
  766.  
  767.     private boolean inResetCrabs() {
  768.         return Constants.RESET_CRABS_AREA.contains(getMyPlayer().getLocation());
  769.     }
  770.  
  771.     private boolean isInArea(RSArea area) {
  772.         return area.contains(getMyPlayer().getLocation());
  773.     }
  774.  
  775.     public class AdminGUI extends JFrame {
  776.  
  777.         public boolean start = false;
  778.  
  779.         private static final long serialVersionUID = 1L;
  780.  
  781.         public AdminGUI() {
  782.             try {
  783.                 UIManager.setLookAndFeel(UIManager
  784.                         .getSystemLookAndFeelClassName());
  785.             } catch (Exception e) {
  786.             }
  787.             initComponents();
  788.         }
  789.  
  790.         private void initComponents() {
  791.             btn_Start = new JButton();
  792.             tbp_main = new JTabbedPane();
  793.             lbl_created = new JLabel();
  794.             pnl_preferences = new JPanel();
  795.             lbl_preferences = new JLabel();
  796.             lbl_food_eat = new JLabel();
  797.             txt_food_eat = new JTextField();
  798.             btn_food_eat_browse = new JButton();
  799.             chk_food_eat = new JCheckBox();
  800.             chk_banking = new JCheckBox();
  801.             chk_teletabs = new JCheckBox();
  802.             chk_arrows = new JCheckBox();
  803.             mnu_bar = new JMenuBar();
  804.             mnu_file = new JMenu();
  805.             mit_exit = new JMenuItem();
  806.  
  807.             setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  808.             setTitle("Rock Crab Killer");
  809.             setAlwaysOnTop(true);
  810.             setFont(new Font("Georgia", 0, 12));
  811.             setName("frm_main");
  812.             setResizable(false);
  813.  
  814.             btn_Start.setFont(new Font("Verdana", 0, 12));
  815.             btn_Start.setText("Start");
  816.             btn_Start.setToolTipText("Start the Script!");
  817.             btn_Start.setCursor(new Cursor(Cursor.HAND_CURSOR));
  818.             btn_Start.setFocusable(false);
  819.             btn_Start.addActionListener(new ActionListener() {
  820.                 public void actionPerformed(ActionEvent evt) {
  821.                     btn_StartActionPerformed(evt);
  822.                 }
  823.             });
  824.  
  825.             lbl_preferences.setFont(new Font("Verdana", 0, 18));
  826.             lbl_preferences.setHorizontalAlignment(SwingConstants.CENTER);
  827.             lbl_preferences.setText("Preferences");
  828.  
  829.             lbl_food_eat.setFont(new Font("Verdana", 0, 12));
  830.             lbl_food_eat.setText("Food to Eat:");
  831.  
  832.             txt_food_eat.setFont(new Font("Verdana", 0, 11));
  833.             txt_food_eat.setToolTipText("Seperate each item with a comma (,)");
  834.             txt_food_eat.setEnabled(false);
  835.  
  836.             btn_food_eat_browse.setFont(new Font("Verdana", 0, 11));
  837.             btn_food_eat_browse.setText("...");
  838.             btn_food_eat_browse
  839.                     .setToolTipText("Click here to search your inventory for food item id's");
  840.             btn_food_eat_browse.setEnabled(false);
  841.  
  842.             chk_food_eat.setFont(new Font("Verdana", 0, 11));
  843.             chk_food_eat.setText("Eat Food?");
  844.             chk_food_eat.setToolTipText("Will we be eating food?");
  845.  
  846.             chk_banking.setFont(new Font("Verdana", 0, 11));
  847.             chk_banking.setText("Banking?");
  848.             chk_banking
  849.                     .setToolTipText("Will we be banking if we run out of food?");
  850.  
  851.             chk_teletabs.setFont(new Font("Verdana", 0, 11));
  852.             chk_teletabs.setText("Using Teletabs?");
  853.             chk_teletabs.setToolTipText("Are we using Teletabs?");
  854.  
  855.             chk_arrows.setFont(new Font("Verdana", 0, 11));
  856.             chk_arrows.setText("Pickup arrows?");
  857.             chk_arrows.setEnabled(false);
  858.  
  859.             GroupLayout pnl_preferencesLayout = new GroupLayout(pnl_preferences);
  860.             pnl_preferences.setLayout(pnl_preferencesLayout);
  861.             pnl_preferencesLayout
  862.                     .setHorizontalGroup(pnl_preferencesLayout
  863.                             .createParallelGroup(GroupLayout.Alignment.LEADING)
  864.                             .addGroup(
  865.                                     pnl_preferencesLayout
  866.                                             .createSequentialGroup()
  867.                                             .addContainerGap()
  868.                                             .addGroup(
  869.                                                     pnl_preferencesLayout
  870.                                                             .createParallelGroup(
  871.                                                                     GroupLayout.Alignment.LEADING)
  872.                                                             .addComponent(
  873.                                                                     lbl_preferences,
  874.                                                                     GroupLayout.DEFAULT_SIZE,
  875.                                                                     425,
  876.                                                                     Short.MAX_VALUE)
  877.                                                             .addComponent(
  878.                                                                     lbl_food_eat)
  879.                                                             .addGroup(
  880.                                                                     GroupLayout.Alignment.TRAILING,
  881.                                                                     pnl_preferencesLayout
  882.                                                                             .createSequentialGroup()
  883.                                                                             .addGroup(
  884.                                                                                     pnl_preferencesLayout
  885.                                                                                             .createParallelGroup(
  886.                                                                                                     GroupLayout.Alignment.TRAILING)
  887.                                                                                             .addComponent(
  888.                                                                                                     txt_food_eat,
  889.                                                                                                     GroupLayout.Alignment.LEADING,
  890.                                                                                                     GroupLayout.DEFAULT_SIZE,
  891.                                                                                                     374,
  892.                                                                                                     Short.MAX_VALUE))
  893.                                                                             .addPreferredGap(
  894.                                                                                     LayoutStyle.ComponentPlacement.RELATED)
  895.                                                                             .addGroup(
  896.                                                                                     pnl_preferencesLayout
  897.                                                                                             .createParallelGroup(
  898.                                                                                                     GroupLayout.Alignment.LEADING)
  899.                                                                                             .addComponent(
  900.                                                                                                     btn_food_eat_browse)))
  901.                                                             .addGroup(
  902.                                                                     pnl_preferencesLayout
  903.                                                                             .createSequentialGroup()
  904.                                                                             .addGroup(
  905.                                                                                     pnl_preferencesLayout
  906.                                                                                             .createParallelGroup(
  907.                                                                                                     GroupLayout.Alignment.LEADING)
  908.                                                                                             .addComponent(
  909.                                                                                                     chk_banking)
  910.                                                                                             .addComponent(
  911.                                                                                                     chk_food_eat))
  912.                                                                             .addGap(14,
  913.                                                                                     14,
  914.                                                                                     14)
  915.                                                                             .addGroup(
  916.                                                                                     pnl_preferencesLayout
  917.                                                                                             .createParallelGroup(GroupLayout.Alignment.LEADING))
  918.                                                                             .addGap(18,
  919.                                                                                     18,
  920.                                                                                     18)
  921.                                                                             .addGroup(
  922.                                                                                     pnl_preferencesLayout
  923.                                                                                             .createParallelGroup(
  924.                                                                                                     GroupLayout.Alignment.LEADING)
  925.                                                                                             .addComponent(
  926.                                                                                                     chk_teletabs))
  927.                                                                             .addPreferredGap(
  928.                                                                                     LayoutStyle.ComponentPlacement.RELATED,
  929.                                                                                     90,
  930.                                                                                     Short.MAX_VALUE)))
  931.                                             .addContainerGap())
  932.                             .addGroup(
  933.                                     pnl_preferencesLayout
  934.                                             .createSequentialGroup()
  935.                                             .addGap(10, 10, 10)
  936.                                             .addGroup(
  937.                                                     pnl_preferencesLayout
  938.                                                             .createParallelGroup(
  939.                                                                     GroupLayout.Alignment.LEADING)
  940.                                                             .addGroup(
  941.                                                                     pnl_preferencesLayout
  942.                                                                             .createSequentialGroup()
  943.                                                                             .addGap(249,
  944.                                                                                     249,
  945.                                                                                     249)
  946.                                                                             .addComponent(
  947.                                                                                     chk_arrows)))
  948.                                             .addContainerGap()));
  949.             pnl_preferencesLayout
  950.                     .setVerticalGroup(pnl_preferencesLayout
  951.                             .createParallelGroup(GroupLayout.Alignment.LEADING)
  952.                             .addGroup(
  953.                                     pnl_preferencesLayout
  954.                                             .createSequentialGroup()
  955.                                             .addContainerGap()
  956.                                             .addComponent(lbl_preferences,
  957.                                                     GroupLayout.PREFERRED_SIZE,
  958.                                                     19,
  959.                                                     GroupLayout.PREFERRED_SIZE)
  960.                                             .addPreferredGap(
  961.                                                     LayoutStyle.ComponentPlacement.UNRELATED)
  962.                                             .addPreferredGap(
  963.                                                     LayoutStyle.ComponentPlacement.RELATED)
  964.                                             .addGroup(
  965.                                                     pnl_preferencesLayout
  966.                                                             .createParallelGroup(GroupLayout.Alignment.BASELINE))
  967.                                             .addPreferredGap(
  968.                                                     LayoutStyle.ComponentPlacement.RELATED)
  969.                                             .addComponent(lbl_food_eat)
  970.                                             .addPreferredGap(
  971.                                                     LayoutStyle.ComponentPlacement.RELATED)
  972.                                             .addGroup(
  973.                                                     pnl_preferencesLayout
  974.                                                             .createParallelGroup(
  975.                                                                     GroupLayout.Alignment.BASELINE)
  976.                                                             .addComponent(
  977.                                                                     txt_food_eat,
  978.                                                                     GroupLayout.PREFERRED_SIZE,
  979.                                                                     GroupLayout.DEFAULT_SIZE,
  980.                                                                     GroupLayout.PREFERRED_SIZE)
  981.                                                             .addComponent(
  982.                                                                     btn_food_eat_browse))
  983.                                             .addPreferredGap(
  984.                                                     LayoutStyle.ComponentPlacement.UNRELATED)
  985.                                             .addGroup(
  986.                                                     pnl_preferencesLayout
  987.                                                             .createParallelGroup(
  988.                                                                     GroupLayout.Alignment.BASELINE)
  989.                                                             .addComponent(
  990.                                                                     chk_food_eat)
  991.                                                             .addComponent(
  992.                                                                     chk_teletabs))
  993.                                             .addPreferredGap(
  994.                                                     LayoutStyle.ComponentPlacement.RELATED)
  995.                                             .addGroup(
  996.                                                     pnl_preferencesLayout
  997.                                                             .createParallelGroup(
  998.                                                                     GroupLayout.Alignment.BASELINE)
  999.                                                             .addComponent(
  1000.                                                                     chk_banking))
  1001.                                             .addPreferredGap(
  1002.                                                     LayoutStyle.ComponentPlacement.RELATED,
  1003.                                                     GroupLayout.DEFAULT_SIZE,
  1004.                                                     Short.MAX_VALUE)
  1005.                                             .addPreferredGap(
  1006.                                                     LayoutStyle.ComponentPlacement.RELATED)
  1007.                                             .addPreferredGap(
  1008.                                                     LayoutStyle.ComponentPlacement.RELATED)
  1009.                                             .addGroup(
  1010.                                                     pnl_preferencesLayout
  1011.                                                             .createParallelGroup(
  1012.                                                                     GroupLayout.Alignment.BASELINE)
  1013.                                                             .addComponent(
  1014.                                                                     chk_arrows))
  1015.                                             .addPreferredGap(
  1016.                                                     LayoutStyle.ComponentPlacement.RELATED)
  1017.                                             .addPreferredGap(
  1018.                                                     LayoutStyle.ComponentPlacement.RELATED)
  1019.                                             .addGap(16, 16, 16)));
  1020.  
  1021.             tbp_main.addTab("Preferences", pnl_preferences);
  1022.  
  1023.             mnu_file.setText("File");
  1024.  
  1025.             mit_exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4,
  1026.                     InputEvent.ALT_MASK));
  1027.             mit_exit.setText("Exit");
  1028.             mit_exit.addActionListener(new ActionListener() {
  1029.                 public void actionPerformed(ActionEvent evt) {
  1030.                     mit_exitActionPerformed(evt);
  1031.                 }
  1032.             });
  1033.             mnu_file.add(mit_exit);
  1034.  
  1035.             mnu_bar.add(mnu_file);
  1036.  
  1037.             setJMenuBar(mnu_bar);
  1038.  
  1039.             GroupLayout layout = new GroupLayout(getContentPane());
  1040.             getContentPane().setLayout(layout);
  1041.             layout.setHorizontalGroup(layout
  1042.                     .createParallelGroup(GroupLayout.Alignment.LEADING)
  1043.                     .addComponent(tbp_main)
  1044.                     .addGroup(
  1045.                             GroupLayout.Alignment.TRAILING,
  1046.                             layout.createSequentialGroup()
  1047.                                     .addContainerGap(341, Short.MAX_VALUE)
  1048.                                     .addComponent(btn_Start,
  1049.                                             GroupLayout.PREFERRED_SIZE, 89,
  1050.                                             GroupLayout.PREFERRED_SIZE)
  1051.                                     .addContainerGap()));
  1052.             layout.setVerticalGroup(layout.createParallelGroup(
  1053.                     GroupLayout.Alignment.LEADING).addGroup(
  1054.                     layout.createSequentialGroup()
  1055.                             .addComponent(tbp_main, GroupLayout.PREFERRED_SIZE,
  1056.                                     330, GroupLayout.PREFERRED_SIZE)
  1057.                             .addPreferredGap(
  1058.                                     LayoutStyle.ComponentPlacement.RELATED)
  1059.                             .addComponent(btn_Start,
  1060.                                     GroupLayout.PREFERRED_SIZE, 41,
  1061.                                     GroupLayout.PREFERRED_SIZE)
  1062.                             .addContainerGap(GroupLayout.DEFAULT_SIZE,
  1063.                                     Short.MAX_VALUE)));
  1064.  
  1065.             pack();
  1066.         }
  1067.  
  1068.         private void mit_exitActionPerformed(ActionEvent evt) {
  1069.             stopScript();
  1070.             setVisible(false);
  1071.         }
  1072.  
  1073.         private void btn_StartActionPerformed(ActionEvent evt) {
  1074.             start = true;
  1075.             setVisible(false);
  1076.         }
  1077.  
  1078.         private JButton btn_Start;
  1079.         private JButton btn_food_eat_browse;
  1080.         private JCheckBox chk_arrows;
  1081.         private JCheckBox chk_banking;
  1082.         private JCheckBox chk_food_eat;
  1083.         private JCheckBox chk_teletabs;
  1084.         private JLabel lbl_created;
  1085.         private JLabel lbl_food_eat;
  1086.         private JLabel lbl_preferences;
  1087.         private JMenuItem mit_exit;
  1088.         private JMenuBar mnu_bar;
  1089.         private JMenu mnu_file;
  1090.         private JPanel pnl_preferences;
  1091.         private JTabbedPane tbp_main;
  1092.         private JTextField txt_food_eat;
  1093.     }
  1094. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement