Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 17.50 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*Changelog:
  2.  * 1.0 = Basic script
  3.  * 1.2 New paint
  4.  * 1.3 New Paint
  5.  * 1.4 Added features || changed anti ban || added more anti ban || changed description
  6.  * 1.5 New detection system
  7.  * 1.6 New locations added
  8.  * 1.7 New anti-ban system
  9.  */
  10.  
  11. import java.awt.*;
  12. import java.util.*;
  13. import java.io.*;
  14. import java.net.*;
  15. import javax.swing.JOptionPane;
  16. import javax.swing.JFileChooser;
  17.  
  18. import java.awt.event.KeyEvent;
  19. import org.rsbot.bot.Bot;
  20. import org.rsbot.script.*;
  21. import org.rsbot.script.wrappers.*;
  22. import org.rsbot.event.listeners.PaintListener;
  23. import org.rsbot.event.listeners.ServerMessageListener;
  24. import org.rsbot.event.events.ServerMessageEvent;
  25. import org.rsbot.util.ScreenshotUtil;
  26.  
  27. @ScriptManifest(authors = {"Prox32"}, category = "Woodcutting", name = "Prox32Ivy", version = 1.7,
  28.         description = "<html>" +
  29.                "<html><body>" +
  30.                 "<center><h2>Prox32 Ivy Chopper 1.7</h2></center>" +
  31.                 "This script supports Castle Wars only <br />" +
  32.                 "When starting, face the Ivy and the bot will do the rest.<br /><br />" +
  33.                 "<font size='3'><b>Note:</b> Try not to get banned</font><br>" +
  34.                 "Make sure you've read the forum post. www.mhty.net<br>" +
  35.                 "<b>&nbsp;&nbsp;&nbsp;Debug? <input type=\"checkbox\" name=\"debug\" value=\"no\" ><br>" +
  36.                 "<b>Antiban value:  (Bigger number = less often & smaller = more often) keep it above 12 </b><br>" +
  37.                 "<input type=\"text\" name=\"AntiBan\" value=\"1000\"><br>" +
  38.                 "<b>Multiplier value: (controls how far the mouse goes)</b><br>" +
  39.                 "<input type=\"text\" name=\"Multiplier\" value=\"20\"><br>" +
  40.                 "<b>Chopping location:</b> <select name='location'><option>Varrock Palace</option><option>Varrock Wall</option><option>CWars</option></select><br /><br />" +
  41.                 "</body></html>")
  42. public class Prox32Ivy extends Script implements PaintListener,
  43.         ServerMessageListener {
  44.  
  45.     private final ScriptManifest properties = getClass().getAnnotation(
  46.             ScriptManifest.class);
  47.     //////////////////////////////////////////////
  48.     //////CONTROLS HOW FAR THE MOUSE GOES SEARCHING!
  49.     public int Multiplier = 45;
  50.     /////////CONTROLS HOW OFTEN THE ANTIBAN ACTIVATES
  51.     /////////BIGGER NUMBER = LESS OFTEN.  KEEP IT OVER 12
  52.     public int AntibanControl = 1000;
  53.     //////////////////////////////////////////////
  54.     public final boolean CheckUpdate = true;
  55.     //////////////////////////////////////////////
  56.     //////////////////////////////////////////////
  57.         static double version = 1.7;
  58.  
  59.     boolean Debug = false;
  60.     public int[] BirdNest = {5070, 5071, 5072, 5073, 5074, 5075, 5076, 7413,
  61.             11966};
  62.     int BirdNests = 0;
  63.    
  64.         public String useAntiBan;
  65.         public String ivyLocation;
  66.         private int AMOUNT_CHOPPED;
  67.         private int[] IVY_ID = {36411, 23818, 23795};
  68.         private int[] NEST_ID = {5070, 5071, 5072, 5073, 5074, 5075, 5076, 7413, 11966};
  69.         private long lastTry = 0;
  70.         private int tryCount = 0;
  71.         public long waitTimer = System.currentTimeMillis();
  72.         private RSTile lastDoor = null;
  73.         String UpdateMSG = "This shouldn't happen???";
  74.         private String STATE = "Loading.";
  75.         boolean Wait = false;
  76.  
  77.     public boolean onStart(Map<String, String> args) {
  78.         Multiplier = Integer.parseInt(args.get("Multiplier"));
  79.         AntibanControl = Integer.parseInt(args.get("AntiBan"));
  80.        
  81.         if (args.get("debug") != null) {
  82.             Debug = true;
  83.         }
  84.         if (CheckUpdate) {
  85.             CheckUpdate();
  86.             if (Debug) {
  87.                 log("Version = " + Version);
  88.             }
  89.             if (Version != version) {
  90.                 log("The newest version is " + Version);
  91.                 if (!Debug) {
  92.                     stopAllScripts();
  93.                 }
  94.             }
  95.             if (Version == version) {
  96.                 log("Your script is up to date =)");
  97.                 log("This version is " + Version);
  98.             }
  99.         }
  100.         startTime = System.currentTimeMillis();
  101.         waitTimer = System.currentTimeMillis();
  102.         ivyLocation = args.get("location");;
  103.                 return true;
  104.     }
  105.  
  106.        
  107.         @Override
  108.         public int getMouseSpeed(){
  109.                 return random(6, 8);
  110.         }
  111.  
  112.         public int gatherNest(){
  113.                 RSItemTile birdNest = getGroundItemByID(NEST_ID);
  114.                 if (birdNest != null && !isInventoryFull()){
  115.                         STATE = "Nest.";
  116.                         atTile(birdNest, "Take ");
  117.                         wait(random(1000, 1500));
  118.                 }
  119.                 return 100;
  120.         }
  121.  
  122.         public void setCamera(){
  123.                 final int curZ = Bot.getClient().getCamPosZ();
  124.                 if (curZ <= -950 && curZ >= -1050) {
  125.                         return;
  126.                 } else {
  127.                         final char key = (char)(curZ < -1000 ? KeyEvent.VK_DOWN : KeyEvent.VK_UP);
  128.                         input.pressKey(key);
  129.                         final int finalZ = -1000 + random(-50, 51);
  130.                         while(key == (char)KeyEvent.VK_DOWN ? Bot.getClient().getCamPosZ() < finalZ : Bot.getClient().getCamPosZ() > finalZ) {
  131.                                 wait(random(10, 20));
  132.                         }
  133.                         input.releaseKey(key);
  134.                 }
  135.         }
  136.        
  137.  
  138.         public boolean atIvy(final RSObject tree, final String action) {
  139.                 try {
  140.                         {
  141.                                 if (ivyLocation.equals("CWars")) {
  142.                                 RSTile Ivy1 = new RSTile(2425, 3068);
  143.                                 RSTile Ivy2 = new RSTile(2425, 3069);
  144.                                 atIvy(Ivy1, Ivy2);
  145.                                 }
  146.                        
  147.                
  148.                                 if (ivyLocation.equals("Varrock Wall")) {
  149.                                 RSTile ivy3 = new RSTile(3233, 3458);
  150.                                 RSTile ivy4 = new RSTile(3233, 3459);
  151.                                 atIvy(ivy3, ivy4);
  152.                                 }
  153.  
  154.                                 if (ivyLocation.equals("Varrock Palace")) {
  155.                                 RSTile ivy5 = new RSTile(3217, 3498);
  156.                                 RSTile ivy6 = new RSTile(3217, 3499);
  157.                                 atIvy(ivy5, ivy6);
  158.                                 }
  159.                         }
  160.                         return atMenu(action);
  161.                  }catch (final Exception e) {
  162.                         log("Small problem...");
  163.         }               return false;
  164.         }
  165.  
  166.  
  167.     public int loop(){
  168.        
  169.                 gatherNest();
  170.                 setCamera();
  171.                
  172.                
  173.                 RSObject Ivy = getNearestObjectByID(IVY_ID);
  174.                
  175.                 if (Ivy != null && getMyPlayer().getAnimation() != -1){
  176.                                 STATE = "Chopping.";
  177.                                 waitTimer = System.currentTimeMillis();
  178.                                 performHumanAction();
  179.                         }
  180.                        
  181.                 if ( ivyLocation.equals("Varrock Wall") ){
  182.                         RSTile[] varrockWall = { new RSTile(3233, 3461), new RSTile(3233, 3460), new RSTile(3233, 3459), new RSTile(3233, 3457), new RSTile(3233, 3456) };
  183.                         if (Ivy != null && distanceTo(Ivy) < 10 && (System.currentTimeMillis() - waitTimer) > random(1850, 1950)) {
  184.                                 STATE = "Searching";
  185.                                 setCompass('w');
  186.                                 atIvy(Ivy, "Chop Ivy");
  187.                                 wait(random(2000, 2500));
  188.                                 }
  189.                         }
  190.  
  191.                 if ( ivyLocation.equals("Varrock Palace") ){
  192.                         RSTile[] varrockPalace = { new RSTile(3219, 3498), new RSTile(3218, 3498), new RSTile(3217, 3498), new RSTile(3216, 3498) };
  193.                         if (Ivy != null && distanceTo(Ivy) < 10 && (System.currentTimeMillis() - waitTimer) > random(1850, 1950)) {
  194.                                 STATE = "Searching";
  195.                                 setCompass('s');
  196.                                 atIvy(Ivy, "Chop Ivy");
  197.                                 wait(random(2000, 2500));
  198.                                 }
  199.                         }
  200.  
  201.                 if ( ivyLocation.equals("CWars") ){
  202.                         RSTile[] CWars = {new RSTile(2430, 3068), new RSTile(2429, 3068), new RSTile(2428, 3068), new RSTile(2426, 3068), new RSTile(2425, 3068), new RSTile(2424, 3068), new RSTile(2423, 3068) };
  203.                         if (Ivy != null && distanceTo(Ivy) < 10 && (System.currentTimeMillis() - waitTimer) > random(1850, 1950)) {
  204.                                 STATE = "Searching";
  205.                                 setCompass('n');
  206.                                 atIvy(Ivy, "Chop Ivy");
  207.                                 wait(random(2000, 2500));
  208.                                 }
  209.                         }
  210.  
  211. return random(200, 500);       
  212.         }
  213.  
  214.     public void serverMessageRecieved(final ServerMessageEvent arg0) {
  215.         final String serverString = arg0.getMessage();
  216.         if (serverString.toLowerCase().contains("level to use")) {
  217.             log("No axe?");
  218.             logout();
  219.             stopAllScripts();
  220.         }
  221.         if (serverString.toLowerCase().contains("at the ivy")) {
  222.             Wait = true;
  223.         }
  224.     }
  225.  
  226.     public int startLevel = 0;
  227.     public int startXP = 0;
  228.     public long startTime = System.currentTimeMillis();
  229.     public long time = System.currentTimeMillis();
  230.     int checkTime;
  231.     long lastCheck;
  232.     boolean powerMode = false;
  233.     int randomRun = random(40, 75);
  234.     long avoidedCombat;
  235.     int IvyCount;
  236.     int oldIvyCount;
  237.     int xpPerIvy;
  238.     int startExp = 0;
  239.     int oldExp;
  240.     int countToNext;
  241.     int oldLevels;
  242.     long lastAvgCheck;
  243.     int avgPerHour;
  244.     int Points = 0;
  245.     int StartPoints = 0;
  246.     String PointsString = "LuLWuT?";
  247.     String Status = "Starting.";
  248.  
  249.     public void onRepaint(Graphics g) {
  250.         if (!isLoggedIn() || isLoginScreen()) {
  251.             return;
  252.         }
  253.         RSInterface Planks = RSInterface.getInterface(766);
  254.  
  255.         // Ty to AELIN for these
  256.         // local objects:
  257.         int index = STAT_WOODCUTTING;
  258.         int exp = 0;
  259.         int levels;
  260.         long hours = 0, minutes = 0, seconds = 0;
  261.         long time;
  262.  
  263.         // Has start time been previously set?
  264.         if (startTime == 0) {
  265.             startTime = System.currentTimeMillis();
  266.         }
  267.  
  268.         // Calculate hours, minutes and seconds.
  269.         time = System.currentTimeMillis() - startTime;
  270.         seconds = time / 1000;
  271.         if (seconds >= 60) {
  272.             minutes = seconds / 60;
  273.             seconds -= minutes * 60;
  274.         }
  275.         if (minutes >= 60) {
  276.             hours = minutes / 60;
  277.             minutes -= hours * 60;
  278.         }
  279.  
  280.         // Has variables been previously defined?
  281.         if (startLevel == 0 || startExp == 0) {
  282.             // No, so define them now.
  283.             startLevel = skills.getCurrentSkillLevel(STAT_WOODCUTTING);
  284.             startExp = skills.getCurrentSkillExp(STAT_WOODCUTTING);
  285.             oldExp = 0;
  286.         }
  287.  
  288.         // Calculate catches based on experience changes.
  289.         exp = skills.getCurrentSkillExp(STAT_WOODCUTTING) - startExp;
  290.         if (exp > oldExp) {
  291.             xpPerIvy = exp - oldExp;
  292.             oldExp = exp;
  293.             IvyCount++;
  294.             countToNext = skills.getXPToNextLevel(STAT_WOODCUTTING) / xpPerIvy + 1;
  295.         }
  296.  
  297.         // Calculate levels gained.
  298.         levels = skills.getCurrentSkillLevel(index) - startLevel;
  299.         if (levels > oldLevels) {
  300.             oldLevels = levels;
  301.         }
  302.  
  303.         int XP_HOUR = (int) ((exp) * 3600000D / (System.currentTimeMillis() - startTime));
  304.  
  305.         Color BG = new Color(0, 0, 0, 125);
  306.         Color RED = new Color(255, 0, 0, 255);
  307.         Color BLACK = new Color(0, 0, 0, 255);
  308.         Color BLUE = new Color(0,0,205,255);
  309.         Color YELLOW = new Color(255,255,0,255);
  310.  
  311.         int GotPoints = Points - StartPoints;
  312.         int type = STAT_WOODCUTTING;
  313.         long millis = System.currentTimeMillis() - startTime;
  314.         millis -= hours * 1000 * 60 * 60;
  315.         millis -= minutes * 1000 * 60;
  316.         int XPChange = skills.getCurrentSkillExp(type) - startXP;
  317.         int Kills = XPChange / 240;
  318.         int KillsToLvl = skills.getXPToNextLevel(type) / 288;
  319.         int LevelChange = skills.getCurrentSkillLevel(type) - startLevel;
  320.         int perNextLvl = skills.getPercentToNextLevel(type);
  321.         int nextLvl = skills.getCurrentSkillLevel(type) + 1;
  322.  
  323.  
  324.                         /** Title Box **/
  325.         g.setColor(new Color(0, 0, 205));
  326.         g.drawRect(551, 206, 183, 39);
  327.         g.setColor(new Color(100, 149, 237, 162));
  328.                         g.fillRect(553, 207, 180, 38);
  329.                         /** Main Box OutLine **/
  330.         g.setColor(new Color(0, 0, 205));
  331.         g.drawRect(550, 249, 183, 213);
  332.         g.setColor(new Color(100, 149, 237, 165));
  333.         g.fillRect(552, 251, 180, 210);
  334.                         /** Title **/
  335.         g.setFont(new Font("Arial Black", 0, 12));
  336.         g.setColor(new Color(255, 255, 0, 237));
  337.         g.drawString("Prox32Ivy 1.7", 559, 234);
  338.  
  339.         g.setFont(new Font("Tahoma", Font.BOLD, 12));
  340.         g.setColor(new Color(255, 255, 0));
  341.         g.drawString("Running for: " + hours + "h " + minutes + "m " + seconds + "s", 557, 268);
  342.         g.drawString("XP Gained: " + exp, 557, 286);
  343.         g.drawString("XP Per hour: " + XP_HOUR, 557, 306);
  344.         g.drawString("XP To next lvl: " + skills.getXPToNextLevel(type), 557, 326);
  345.         g.drawString("Levels Gained: " + LevelChange, 557, 346);
  346.         g.drawString("Bird Nests: " + BirdNests, 557, 366);
  347.         g.drawString("Status: " + STATE, 557, 446);
  348.         g.drawString("Progress to next lvl:", 557, 386);
  349.         /** Progress Bar **/
  350.         if (millis != 0) {
  351.         g.setColor(BLUE);
  352.         g.fill3DRect(557, 406, 165, 18, true);
  353.  
  354.         g.setColor(YELLOW);
  355.         g.fill3DRect(557, 406, perNextLvl * 165 /100, 18, true);
  356.         g.setColor(new Color(0, 0, 0));
  357.         g.drawString(perNextLvl + "% to " + nextLvl, 600, 418);
  358.  
  359.         }
  360.  
  361.         if (Debug) {
  362.             g.drawString("Rotation " + getCameraAngle(), 10, 210);
  363.         }
  364.     }
  365.  
  366.                        
  367.     public void onFinish() {
  368.         ScreenshotUtil.takeScreenshot(true);
  369.     }
  370.  
  371.     public boolean atIvy(RSTile a, RSTile b) {
  372.         //      turnToTile(b);
  373.         if (random(0, 10) < random(2, 4)) {
  374.             setCameraRotation(getCameraAngle() + (random(0, 9) < random(6, 8) ? random(-20, 20)
  375.                     : random(-360, 360)));
  376.         }
  377.         if (random(0, 14) < random(0, 2)) {
  378.             setCameraAltitude(random(0, 100));
  379.         }
  380.         //      if (tryCount > 100) {
  381.         //              log("Problems finding jobboard....");
  382.         //              stopAllScripts();
  383.         //      }
  384.         if (!tileOnScreen(a) || !tileOnScreen(b) || distanceTo(a) > random(4, 7)) {
  385.             if (tileOnMap(a)) {
  386.                 walkTileMM(randomizeTile(a, 3, 3));
  387.                 wait(random(750, 1250));
  388.             } else {
  389.                 log("Problems finding Ivy tiles.");
  390.                 return false;
  391.             }
  392.         } else {
  393.             final ArrayList<RSTile> theObjs = new ArrayList<RSTile>();
  394.             theObjs.add(a);
  395.             theObjs.add(b);
  396.             try {
  397.                 final Point[] thePoints = new Point[theObjs.size()];
  398.                 for (int c = 0; c < theObjs.size(); c++) {
  399.                     thePoints[c] = Calculations.tileToScreen(theObjs.get(c));
  400.                 }
  401.                 float xTotal = 0;
  402.                 float yTotal = 0;
  403.                 for (final Point thePoint : thePoints) {
  404.                     xTotal += thePoint.getX();
  405.                     yTotal += thePoint.getY();
  406.                 }
  407.                 final Point location = new Point(
  408.                         (int) (xTotal / thePoints.length),
  409.                         (int) (yTotal / thePoints.length) - random(0, 40)); // -
  410.                 // 40
  411.                 if (location.x == -1 || location.y == -1) {
  412.                     return false;
  413.                 }
  414.  
  415.                 if (Math.sqrt(Math.pow((getMouseLocation().getX() - location.getX()), 2) + Math.pow(
  416.                         (getMouseLocation().getY() - location.getY()),
  417.                         2)) < random(20, 30)) {
  418.                     final ArrayList<String> commands = getMenuItems();
  419.                     for (int c = 0; c < commands.size(); c++) {
  420.                         if (commands.get(c).contains("Chop Ivy")) {
  421.                             if (atMenu("Chop Ivy")) {
  422.                                 lastTry = 0;
  423.                                 tryCount = 0;
  424.                                 return true;
  425.                             }
  426.                         }
  427.                     }
  428.                 }
  429.                 int ii = 0;
  430.                 while (!atMenu("Chop Ivy") && ii < 10) {
  431.                     int aa = ii * Multiplier;
  432.                     moveMouse(location, aa, 15);
  433.                     wait(random(30, 80));
  434.                     ii++;
  435.                 }
  436.                 moveMouse(location, 7, 7);
  437.                 if (atMenu("Chop Ivy")) {
  438.                     lastTry = 0;
  439.                     tryCount = 0;
  440.                     return true;
  441.                 }
  442.             } catch (final Exception e) {
  443.                 return false;
  444.             }
  445.         }
  446.         return false;
  447.     }
  448.  
  449.     public boolean CheckAnimation() {
  450.         for (int i = 0; i < 5; i++) {
  451.             if (getMyPlayer().getAnimation() != -1) {
  452.                 return true;
  453.             }
  454.             wait(random(100, 180));
  455.         }
  456.         return false;
  457.     }
  458.  
  459.     boolean AntiBanDebug = true;
  460.  
  461.     private void performHumanAction() {
  462.                 int randomNum = random(1, 30);
  463.                 int r = random(1,35);
  464.                 if (randomNum == 6){
  465.                         if (r == 1){    
  466.                                 if (getCurrentTab() != Constants.TAB_STATS){
  467.                                         openTab(Constants.TAB_STATS);
  468.                                         moveMouse(random(670, 690), random(400, 410));
  469.                                         wait(random(1000, 1500));
  470.                                 }
  471.                         }
  472.                         if (r == 2){
  473.                                 openTab(random(1, 14));
  474.                                 wait(random(5000, 10000));
  475.                         }
  476.                         if (r == 3){
  477.                                 int x = input.getX();
  478.                                 int y = input.getY();
  479.                                 moveMouse(x + random(-90, 90), y + random(-90, 90));
  480.                                 wait(random(1000, 1500));
  481.                         }
  482.                         if (r == 4){
  483.                                 int x2 = input.getX();
  484.                                 int y2 = input.getY();
  485.                                 moveMouse(x2 + random(-90, 90), y2 + random(-90, 90));
  486.                                 wait(random(1000, 1500));
  487.                         }
  488.                         if (r == 5){
  489.                                 int x3 = input.getX();
  490.                                 int y3 = input.getY();
  491.                                 moveMouse(x3 + random(-80, 80), y3 + random(-80, 80));
  492.                                 wait(random(1000, 1500));
  493.                         }
  494.                         if (r == 6){
  495.                                 int x3 = input.getX();
  496.                                 int y3 = input.getY();
  497.                                 moveMouse(x3 + random(-100, 100), y3 + random(-100, 100));
  498.                                 wait(random(1000, 1500));
  499.                         }
  500.                         if (r == 7){
  501.                                 int x3 = input.getX();
  502.                                 int y3 = input.getY();
  503.                                 moveMouse(x3 + random(-100, 100), y3 + random(-80, 80));
  504.                                 wait(random(1000, 1500));
  505.                         }
  506.                         if (r == 8){
  507.                                 setCameraRotation(random(100, 360));
  508.                                 wait(random(1000, 1500));
  509.                         }
  510.                         if (r == 9){
  511.                                 setCameraRotation(random(100, 360));
  512.                                 wait(random(1000, 1500));
  513.                         }
  514.                         if (r == 10){
  515.                                 setCameraRotation(random(100, 360));
  516.                                 wait(random(1000, 1500));
  517.                         }
  518.                 }
  519.         }
  520.  
  521.     double Version = 1.7;
  522.  
  523.     public boolean CheckUpdate() {
  524.         try {
  525.             URL url = new URL("www.google.com");
  526.             BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
  527.  
  528.         } catch (Exception e) {
  529.         }
  530.         return false;
  531.     }
  532. }