Recent Posts
None | 1 sec ago
None | 5 sec ago
None | 6 sec ago
C++ | 23 sec ago
Lua | 55 sec ago
None | 1 min ago
AutoIt | 1 min ago
Haskell | 1 min ago
Java | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By wantedcrisis on the 4th of Jul 2009 04:31:44 AM Download | Raw | Embed | Report
  1. package com.scripts;
  2.  
  3. import java.awt.*;
  4. import javax.swing.*;
  5. import java.awt.Point;
  6. import java.awt.event.KeyEvent;
  7. import com.kbot2.scriptable.Script;
  8. import com.kbot2.scriptable.methods.wrappers.*;
  9. import com.kbot2.scriptable.methods.data.Objects;
  10. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  11. import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
  12.  
  13.  
  14. public class CrisisGuildMiner extends Script implements ServerMessageListener, PaintListener {
  15.  
  16.     private int ladderUpID = 2113;
  17.     private int ladderDownID = 30941;
  18.     private Tile[] toGuildUp = new Tile[]{new Tile(3013,3356), new Tile(3017,3359), new Tile(3022,3357),
  19.                                 new Tile(3024,3352), new Tile(3029,3351), new Tile(3032,3346), new Tile(3034,3341),
  20.                                 new Tile(3030,3338), new Tile(3025,3337), new Tile(3020,3338), };
  21.     private Tile[] toBankUp = walking.reversePath(toGuildUp);
  22.     private Tile[] toGuildDown = new Tile[]{new Tile(3019,9737), new Tile(3024,9739), new Tile(3029,9738),
  23.                                     new Tile(3034,9738),new Tile(3039,9737), new Tile(3045,9738), };
  24.     private Tile[] toBankDown = walking.reversePath(toGuildDown);
  25.     private Tile[] guildPath = new Tile[]{new Tile(3046,9755), new Tile(3046,9750), new Tile(3046,9745), new Tile(3044,9740), };
  26.     private int bankBoothID = 11758;
  27.     private int[] coalID = new int[] { 11930, 11931, 11932, 11930, 11963, 11964, 2096,
  28.                             2097, 14850, 14851, 14852, 32426, 32426, 31068, 31069,
  29.                             31070, 31068 };
  30.     private int[] mithID = new int[] { 11942, 11943, 11944, 11943, 32438, 32439, 31086, 31088 };
  31.        
  32.     private int[] rockID = coalID;
  33.     private Obj rock;
  34.     private int[] axeID = { 1265, 1275, 1269, 1271, 1273, 1267 };
  35.     private boolean mith = false;
  36.     private int[] priorityRock1ID;
  37.  
  38.     private final static int TO_BANK_DOWN = 10;
  39.     private final static int TO_BANK_UP = 15;
  40.     private final static int TO_GUILD_UP = 20;
  41.     private final static int TO_GUILD_DOWN = 25;
  42.     private final static int MINE = 50;
  43.     String state;
  44.     private gui gui;
  45.     private boolean startScript = false;
  46.     long estimatedHourly;
  47.     int startExp = 0;
  48.     private long startTime = System.currentTimeMillis();
  49.     String mining;
  50.     int mined;
  51.     int startLevel = 0;
  52.     int antiBanSpeed = 10;
  53.  
  54.     public boolean active() {
  55.         return true;
  56.     }
  57.  
  58.     public String getName() {
  59.         return "Crisis Guild Miner";
  60.     }
  61.  
  62.     @Override
  63.     public String getAuthor() {
  64.         return "WantedCrisis";
  65.     }
  66.  
  67.     @Override
  68.     public String getDescription() {
  69.         return "Mines at guild";
  70.     }
  71.    
  72.     public double getVersion() {
  73.         return 0.2;
  74.     }
  75.        
  76.     public boolean onStart() {
  77.         try {
  78.             gui = new gui();
  79.             gui.setVisible(true);
  80.             state = "Set Your Settings On GUI!!! >.<";
  81.             return true;
  82.         } catch (Exception e) {
  83.             e.printStackTrace();
  84.             return false;
  85.         }
  86.     }
  87.  
  88.     public int loop() {
  89.         while(!startScript) {
  90.             wait(10, 20);
  91.             log("Waiting");
  92.         }
  93.         if(startExp == 0)
  94.             startExp = skills.getExperience(skills.SKILL_MINING);
  95.         if(startLevel == 0)
  96.             startLevel = skills.getLevel(skills.SKILL_MINING);
  97.         if(getMyPlayer().isMoving() && state != "Walking to ladders!" && state != "Walking to rocks" && state != "Walking to bank.. finally :)")
  98.                 return random(200,300);
  99.         if(getMyPlayer().getAnimation() != -1) {
  100.             return random(100,200);
  101.         }
  102.         if(walking.getEnergy() >= random(20, 30) && botEnv.settings.getSetting(173) != (true ? 1 : 0)) {
  103.             state = "Setting Run Energy";
  104.             walking.setRunning(true);
  105.             sleep(random(500,1000));
  106.         }
  107.         camera.setAltitude(true);
  108.         /*if(inArea(3055, 9730, 3027, 9755)
  109.                 log("At Guild Rocks!!!!");
  110.         if(inArea(3026, 9732, 3016, 9755))
  111.                 log("AT GUILD ENTRANCE!!!!");
  112.         if(inArea(3032, 3329, 3006, 3361))
  113.                 log("Above Guild");*/
  114.         setMouseSpeed();
  115.         switch (state()) {
  116.             case 3: //Walking to guild ladders
  117.                 log("Walking to guild ladders");
  118.                 state = "Walking to Guild Ladders";
  119.                 if(distanceTo(objects.getClosestObject(30, ladderUpID)) > 3)
  120.                         walking.walkPath(walking.randomizePath(toGuildUp, 3, 3));
  121.                 wait(300, 500);
  122.                 break;
  123.             case 4: //Clicking ladder!
  124.                 log("Clicking ladder");
  125.                 state = "Climbing Down Da Ladder!";
  126.                 if(distanceTo(objects.getClosestObject(30, ladderUpID)) <= 3) {
  127.                     Obj ladder2 = objects.getClosestObject(30, ladderUpID);
  128.                     if(ladder2 != null) {
  129.                         if(!clickLadder(ladder2, "Climb"))
  130.                             camera.setAngle(camera.getAngle() + random(20,30));
  131.                     }
  132.                 }
  133.                 wait(300, 500);
  134.                 break;
  135.             case 5:
  136.                 log("state = 5; ");
  137.                 state = "Walking to rocks";
  138.                 walking.walkPath(walking.randomizePath(toGuildDown, -5, 5));
  139.                 log("Should be near rocks now!");
  140.                 break;
  141.             case 6:
  142.                 log("state = 6; ");
  143.                 log("Mining");
  144.                 if(mith) {
  145.                     clickRock();
  146.                 } else {
  147.                     clickPriority1Rock();
  148.                 }
  149.                
  150.  
  151.                 break;
  152.             case 7:
  153.                 log("state = 7; ");
  154.                 state = "Walking to ladders!";
  155.                 walking.walkPath(walking.randomizePath(toBankDown, 5, -5));
  156.                 wait(300, 500);
  157.                 break;
  158.             case 8:
  159.                 log("state = 8; ");
  160.                 state = "Climbing Ahoy!";
  161.                 Obj ladder1 = objects.getClosestObject(30, ladderDownID);
  162.                 if(ladder1 != null) {
  163.                     if(!clickLadder(ladder1, "Climb")){
  164.                         camera.setAngle(camera.getAngle() + random(20,30));
  165.                     }
  166.                 }
  167.                 wait(300, 500);
  168.                 break;
  169.             case 9:
  170.                 log("state = 9; ");
  171.                 state = "Walking to bank.. finally :)";
  172.                 walking.walkPath(walking.randomizePath(toBankUp, -3, 3));
  173.                 wait(300, 500);
  174.                 break;
  175.             case 10:
  176.                 log("state = 10; ");
  177.                 state = "Depositing.. zz!";
  178.                 depositOres();
  179.                 wait(300, 500);
  180.                 break;
  181.         }
  182.         return random(100, 300);
  183.     }
  184.        
  185.     public int state() {
  186.         if(!isInventoryFull()) {
  187.             if(inArea(3036, 3329, 3006, 3361)) {
  188.                     if(distanceTo(objects.getClosestObject(30, ladderUpID)) > 3)
  189.                             return 3;
  190.                     if(distanceTo(objects.getClosestObject(30, ladderUpID)) <= 3)
  191.                             return 4;
  192.             }
  193.             if(inArea(3026, 9732, 3016, 9755)) {
  194.                     return 5;
  195.             }else if(inArea(3057, 9729, 3025, 9756)) {
  196.                     return 6;
  197.             }
  198.         }
  199.         if(isInventoryFull()) {
  200.             if(inArea(3055, 9730, 3027, 9743)) {
  201.                 return 7;
  202.             }
  203.             if(inArea(3026, 9732, 3016, 9755)) {
  204.                 return 8;
  205.             }
  206.             if(inArea(3036, 3329, 3006, 3361)) {
  207.                 if(distanceTo(toBankUp[toBankUp.length - 1]) > 5)
  208.                     return 9;
  209.                 if(distanceTo(toBankUp[toBankUp.length - 1]) <= 3)
  210.                     return 10;
  211.             }
  212.  
  213.         }
  214.         return 100;
  215.     }
  216.        
  217.     public boolean inArea(int maxX, int minY, int minX, int maxY) {
  218.         int x = getMyPlayer().getLocation().getX();
  219.         int y = getMyPlayer().getLocation().getY();
  220.             //log("is " + x + " > " + minX + " is " + x + " < " + maxX + " is " + y + " > " + minY + " is " + y + " < " + maxY);
  221.         if (x >= minX && x <= maxX && y >= minY && y <= maxY) {
  222.             return true;
  223.         }
  224.         return false;
  225.     }
  226.  
  227.     private boolean isInventoryFull() {
  228.         if(inventory.isFull())
  229.             return true;
  230.         return false;
  231.     }
  232.    
  233.     public boolean checkRest() {
  234.         if(walking.getEnergy() < 10 && walking.getEnergy() > -1)
  235.             return true;
  236.         return false;
  237.     }
  238.  
  239.     public void activateRest() {
  240.         interfaces.getInterface(750, 1).doAction("Rest");
  241.         while(walking.getEnergy() < random(20, 30)) {
  242.             sleep(random(300,500));
  243.         }
  244.     }
  245.        
  246.     private void wait(int z, int c) {
  247.         sleep(random(z, c));
  248.     }
  249.        
  250.     public boolean clickRock() {
  251.         try {
  252.             rock = getClosestObject(30, mithID);
  253.             if(rock == null){
  254.                 clickPriority1Rock();
  255.                 return false;
  256.             }
  257.             if(!inRockArea(3055, 9730, 3027, 9755, rock.getLocation().getX(), rock.getLocation().getY())) {
  258.                 walking.walkToMM(toGuildDown[toGuildDown.length -1]);
  259.                 walking.walkPath(walking.randomizePath(guildPath, 5, 5));
  260.                 return false;
  261.             }
  262.             if(rock != null) {
  263.                 if(distanceTo(rock) > 7) {
  264.                     state = "Walking To Rock";
  265.                     walking.walkToMM(rock.getLocation());
  266.                 }
  267.                 state = "Mining Rock";
  268.                 if(!clickRock(rock, "Mine"));
  269.                     camera.setAngle(camera.getAngle() + random(-50,50));
  270.                 int gamble = random(0, 2);
  271.                 if(gamble >= 1)
  272.                     moveMouse(new Point(random(1, 500), random(1, 334)), 30, 30);
  273.                 else
  274.                     actHuman();
  275.                 sleep(random(100,200));
  276.             }
  277.             return true;
  278.         } catch (Exception e) {
  279.             e.printStackTrace();
  280.         }
  281.         return false;
  282.     }
  283.    
  284.     public boolean clickPriority1Rock() {
  285.         try {
  286.                 Obj rock = getClosestObject(20, priorityRock1ID);
  287.                 if(rock == null) {
  288.                         state = "Trying to find a rock..";
  289.                         return false;
  290.                 }
  291.                 if(!inRockArea(3055, 9730, 3027, 9755, rock.getLocation().getX(), rock.getLocation().getY())) {
  292.                     walking.walkToMM(toGuildDown[toGuildDown.length -1]);
  293.                     walking.walkPath(walking.randomizePath(guildPath, 5, 5));
  294.                     return false;
  295.                 }
  296.                 if(rock != null) {
  297.                         if(distanceTo(rock) > 7) {
  298.                                 state = "Walking To Rock";
  299.                                 walking.walkToMM(rock.getLocation());
  300.                         }
  301.                         state = "Mining Rock";
  302.                         if(!rock.doAction("Mine"))
  303.                                 camera.setAngle(camera.getAngle() + random(30,50));
  304.                         int gamble = random(0, 2);
  305.                         if(gamble >= 1)
  306.                                 moveMouse(new Point(random(1, 500), random(1, 334)), 30, 30);  
  307.                         else
  308.                             actHuman();
  309.                         sleep(random(100,200));
  310.                 }
  311.                 return true;
  312.         } catch (Exception e) {
  313.                 e.printStackTrace();
  314.         }
  315.         return false;
  316. }
  317.        
  318.    
  319.     public boolean inRockArea(int maxX, int minY, int minX, int maxY, int x3, int y3) {
  320.         int x = getMyPlayer().getLocation().getX();
  321.         int y = getMyPlayer().getLocation().getY();
  322.             log("is " + x3 + " > " + minX + " is " + x3 + " < " + maxX + " is " + y3 + " > " + minY + " is " + y3 + " < " + maxY);
  323.         if (x3 >= minX && x3 <= maxX && y3 >= minY && y3 <= maxY) {
  324.             log("Rock is mineable");
  325.             return true;
  326.         }
  327.         log("Rock is not minable");
  328.         return false;
  329.     }
  330.        
  331.     public boolean openBank() {
  332.         Obj bankBooth = getClosestObject(100, bankBoothID);
  333.         if (bank.isOpen()) return false;
  334.             if (bankBooth != null && !bank.isOpen()) {
  335.                 state = "Opening Bank";
  336.                 return bankBooth.doAction("Use-quickly");
  337.             }
  338.         return false;
  339.     }
  340.        
  341.     public boolean depositOres() {
  342.         if(!bank.isOpen()) return openBank();
  343.         if(bank.isOpen()) {
  344.             state = "Depositing..";
  345.             bank.depositAllExcept(axeID);
  346.         }
  347.         return true;
  348.     }
  349.        
  350.     public void setMouseSpeed() {
  351.         int gambleInt = random(1, 20);
  352.         double speed;
  353.         switch (gambleInt) {
  354.             case 1:
  355.                 speed = 1.5;
  356.                 setMouseSpeed(speed);
  357.                 log("Mouse Speed Set To " + speed);
  358.             case 2:
  359.                 speed = 1.8;
  360.                 setMouseSpeed(speed);
  361.                 log("Mouse Speed Set To " + speed);
  362.             case 3:
  363.                 speed = 2.1;
  364.                 setMouseSpeed(speed);
  365.                 log("Mouse Speed Set To " + speed);
  366.         }
  367.     }
  368.    
  369.     public boolean clickRock(Obj r, String action) {
  370.         for (int i = 0; i < 20; i++) {
  371.             if (r != null && getCalculations().onScreen(r.getScreenPos())) {
  372.                 mouse.moveMouse(r.getScreenPos().x, r.getScreenPos().y, 3, 3);
  373.                 for (String s : menu.getMenuItems()) {
  374.                     if (s.contains(action)) {
  375.                         if (atMenu(action)) {
  376.                             return true;
  377.                         }
  378.                     }
  379.                 }
  380.             }
  381.         }
  382.         return false;
  383.     }
  384.    
  385.     public boolean clickLadder(Obj ladder, String action) {
  386.         for (int i = 0; i < 20; i++) {
  387.             if (ladder != null && getCalculations().onScreen(ladder.getScreenPos())) {
  388.                 mouse.moveMouse(ladder.getScreenPos().x, ladder.getScreenPos().y, 10, 10);
  389.                 for (String s : menu.getMenuItems()) {
  390.                     if (s.contains(action)) {
  391.                         if (atMenu(action)) {
  392.                             return true;
  393.                         }
  394.                     }
  395.                 }
  396.             }
  397.         }
  398.         return false;
  399.     }
  400.    
  401.     public void actHuman() {
  402.         int gamble = random(0, 2);
  403.         log("Gamble = " + gamble + " and is now antibanning");
  404.         switch (gamble) {
  405.             case 1:
  406.                 if(gameScreen.getCurrentTab() != gameScreen.TAB_STATS)
  407.                     gameScreen.openTab(gameScreen.TAB_STATS);
  408.                 mouse.moveMouse(new Point(688, 239), 9, 9);
  409.                 wait(1000,1500);
  410.             case 2:
  411.                 Point randMouse = null;
  412.                 int randA = random(1, 5);
  413.                 for(int i = 0; i <= randA; i++) {
  414.                     randMouse = new Point(random(15, 730), random(15, 465));
  415.                     moveMouse(randMouse);
  416.                     sleep(random(50, 800));
  417.                 }
  418.             case 3:
  419.                 final int currentAngle = camera.getAngle();
  420.                 switch (random(0, 1)) {
  421.                     case 0:
  422.                         botEnv.camera.setAngle(currentAngle + random(0, 650));
  423.                         sleep(random(710, 1000));
  424.                     case 1:
  425.                         botEnv.camera.setAngle(currentAngle - random(0, 650));
  426.                         sleep(random(600, 1000));
  427.                 }
  428.         }
  429.     }
  430.  
  431.  
  432.  
  433.     public void onRepaint(Graphics g) {
  434.         int expGained = skills.getExperience(skills.SKILL_MINING) - startExp;
  435.         long millis = System.currentTimeMillis() - startTime;
  436.         long time = (System.currentTimeMillis() - startTime) / 1000;
  437.         if(time > 0 )
  438.             estimatedHourly = (mined * 60 * 60 ) / time;
  439.         final long hours = millis / (1000 * 60 * 60);
  440.         millis -= hours * 1000 * 60 * 60;
  441.         final long minutes = millis / (1000 * 60);
  442.         millis -= minutes * 1000 * 60;
  443.         final long seconds = millis / 1000;
  444.         int gainedLevels = skills.getLevel(skills.SKILL_MINING) - startLevel;
  445.         g.setColor(new Color(0, 0, 0, 100));
  446.         g.fillRoundRect(12, 173, 245, 160, 10, 10);
  447.         g.setColor(new Color(100, 10, 20, 100));
  448.         g.fillRoundRect(9, 170, 245, 160, 10, 10);
  449.         g.setColor(Color.white);
  450.         g.setFont(new Font("Verdana", Font.BOLD, 12));
  451.         g.drawString("Crisis Guild Miner ~ Version:" + getVersion(), 20, 190);
  452.         g.setFont(new Font("Verdana", Font.PLAIN, 10));
  453.         int y = 210;
  454.         g.drawString("Time Running: " + hours + "h " + minutes + "m "+ seconds + "s", 20, y);
  455.         y += 15;
  456.         g.drawString("Mining: " + mining, 20, y);
  457.         y += 15;
  458.         g.drawString("Mined: " + mined, 20, y);
  459.         y += 15;
  460.         g.drawString("Rocks Per Hour: " + estimatedHourly , 20, y);
  461.         y += 15;
  462.         g.drawString("Exp To Next Level: " + skills.getExperienceToNextLevel(skills.SKILL_MINING), 20, y);
  463.         y += 15;
  464.         g.drawString("Current Level: " + skills.getLevel(skills.SKILL_MINING), 20, y);
  465.         y += 15;
  466.         g.drawString("Levels Gained: " + gainedLevels, 20, y);
  467.         y += 15;
  468.         g.drawString("State : " + state, 20, y);
  469.         y += 15;
  470.     }
  471.  
  472.     public void onServerMessage(String e) {
  473.         if (e.contains("manage to mine")) {
  474.             mined++;
  475.         }
  476.     }
  477.    
  478.     public class gui extends javax.swing.JFrame {
  479.  
  480.         public gui() {
  481.             initComponents();
  482.         }
  483.  
  484.         private void initComponents() {
  485.             startButton = new javax.swing.JButton();
  486.             mithCheck = new javax.swing.JCheckBox();
  487.             jLabel1 = new javax.swing.JLabel();
  488.  
  489.             setTitle("Crisis Guild Miner");
  490.             setBackground(new java.awt.Color(51, 0, 51));
  491.             setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
  492.             setForeground(new java.awt.Color(0, 0, 0));
  493.             startButton.setText("Start");
  494.             startButton.addActionListener(new java.awt.event.ActionListener() {
  495.                 public void actionPerformed(java.awt.event.ActionEvent evt) {
  496.                     startHandler(evt);
  497.                 }
  498.             });
  499.  
  500.             mithCheck.setText("Mine Mith ores?");
  501.             mithCheck.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
  502.             mithCheck.setMargin(new java.awt.Insets(0, 0, 0, 0));
  503.  
  504.             jLabel1.setFont(new java.awt.Font("Arial Black", 0, 11));
  505.             jLabel1.setText("Crisis Guild Miner");
  506.  
  507.             javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  508.             getContentPane().setLayout(layout);
  509.             layout.setHorizontalGroup(
  510.                 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  511.                 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  512.                     .addContainerGap(149, Short.MAX_VALUE)
  513.                     .addComponent(startButton)
  514.                     .addGap(22, 22, 22))
  515.                 .addGroup(layout.createSequentialGroup()
  516.                     .addContainerGap()
  517.                     .addComponent(mithCheck)
  518.                     .addContainerGap(127, Short.MAX_VALUE))
  519.                 .addGroup(layout.createSequentialGroup()
  520.                     .addGap(9, 9, 9)
  521.                     .addComponent(jLabel1)
  522.                     .addContainerGap(111, Short.MAX_VALUE))
  523.             );
  524.             layout.setVerticalGroup(
  525.                 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  526.                 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  527.                     .addGap(11, 11, 11)
  528.                     .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
  529.                     .addGap(12, 12, 12)
  530.                     .addComponent(mithCheck)
  531.                     .addGap(38, 38, 38))
  532.                 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  533.                     .addContainerGap(62, Short.MAX_VALUE)
  534.                     .addComponent(startButton)
  535.                     .addContainerGap())
  536.             );
  537.             pack();
  538.         }                  
  539.  
  540.         private void startHandler(java.awt.event.ActionEvent evt) {                              
  541.             gui.setVisible(false);
  542.             if(mithCheck.isSelected()){
  543.                 mith = true;
  544.                 priorityRock1ID = coalID;
  545.                 log("Mith = " + mith);
  546.                 mining = "Mith And Coal";
  547.                
  548.                 startScript = true;
  549.             }
  550.             if(!mithCheck.isSelected()) {
  551.                 log("Mith = " + mith);
  552.                 mith = false;
  553.                 mining = "Coal";
  554.                 priorityRock1ID = coalID;
  555.                 startScript = true;
  556.             }
  557.             startScript = true;
  558.         }                            
  559.         private javax.swing.JLabel jLabel1;
  560.         private javax.swing.JCheckBox mithCheck;
  561.         private javax.swing.JButton startButton;
  562.              
  563.  
  564.     }
  565. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: