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

Untitled

By: a guest on Apr 19th, 2012  |  syntax: None  |  size: 8.07 KB  |  hits: 15  |  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. package Potion;
  2.  
  3.  
  4. import com.kbotpro.scriptsystem.events.PaintEventListener;
  5. import com.kbotpro.scriptsystem.interfaces.Looped;
  6. import com.kbotpro.scriptsystem.runnable.Script;
  7. import com.kbotpro.scriptsystem.various.KTimer;
  8. import com.kbotpro.scriptsystem.wrappers.IComponent;
  9. import com.kbotpro.scriptsystem.wrappers.PhysicalObject;
  10. import com.kbotpro.scriptsystem.wrappers.Tile;
  11. import com.kbotpro.scriptsystem.fetch.Game;
  12. import com.kbotpro.scriptsystem.wrappers.Item;
  13.  
  14.  
  15. import java.awt.*;
  16.  
  17. public class Potion extends Script implements PaintEventListener {
  18.  
  19.     public int Vial = 227;
  20.     public int Flax = 2998;
  21.     public int unf = 3002;
  22.     public int wellID = 11661;
  23.     private final int[] boothID = {11758,11402,36786,2213,14367};
  24.     public Tile wellLocation = new Tile(2949, 3382),bankLocation = new Tile(2946, 3368);
  25.     private final Tile[] bankpath = new Tile[]{new Tile(2950, 3379), new Tile(2946,3374),new Tile(2946,3369)};
  26.     public PhysicalObject bankBooth;
  27.     private PhysicalObject well;
  28.     private int paintX = 0;
  29.     private int paintY = 0;
  30.     private boolean paintSetup = true;
  31.     private KTimer runTime = new KTimer();
  32.     private KTimer waitTime;
  33.     public String status;
  34.     public boolean NoMore = false;
  35.     public int numBucket =0;
  36.     public boolean justClicked = false;    
  37.         public void onRepaint(Graphics g) {
  38.  
  39.             paintX = 15;
  40.             paintY = 195;
  41.             Color transBlack = new Color(0, 0, 0, 170);
  42.             g.setColor(transBlack);
  43.             g.drawRoundRect(paintX - 17, paintY - 20, 200, 190, 20, 20);
  44.             g.fillRoundRect(paintX - 17, paintY - 20, 200, 190, 20, 20);
  45.             g.setColor(Color.WHITE);
  46.             g.drawString(getName() + " v" + getVersion(), paintX, paintY);
  47.             paintY += 15;
  48.             g.drawString("By " + getAuthor(), paintX, paintY);
  49.             paintY += 15;
  50.             g.drawString("Running for "
  51.                     + runTime.getFormattedTime(runTime.getTimeElapsed()),
  52.                     paintX, paintY);
  53.             paintY += 15;
  54.             g.drawString(" -Current Status- " , paintX, paintY);
  55.             paintY += 15;
  56.             g.drawString( status , paintX, paintY);
  57.  
  58.     }
  59.  
  60.  
  61.  
  62.     @Override
  63.     public void stop() {
  64.         //To change body of implemented methods use File | Settings | File Templates.
  65.     }
  66.  
  67.     public void onStart(){
  68.     setUserInputEnabled(false);
  69.     }
  70.     private Tile randomizeTile(Tile t) {
  71.         return new Tile(t.getX() + random(-2, 3), t.getY() + random(-2, 3));
  72.     }
  73.  
  74.     private boolean clickItem(int id, String act) {
  75.         for(Item i : inventory.getItems()) {
  76.             if(i.getID() != id) continue;
  77.             return i.doAction(act);
  78.         }
  79.         return false;
  80.     }
  81.  
  82.     public boolean inventoryItem(){
  83.         status = "Inventory at item";
  84.  
  85.      if(!inventory.isOpen()){
  86.          game.openTab(Game.TAB_INVENTORY);
  87.          while (game.getCurrentTab() != Game.TAB_INVENTORY) {
  88.              sleep(200);
  89.          }
  90.      }
  91.      if(inventory.contains(Vial) && inventory.contains(Flax)){
  92.       if(random(0, 1) == 0) {
  93.            if(clickItem(Vial, "Use")){
  94.               sleep(100,200);
  95.               if(clickItem(Flax, "Clean toadflax"))
  96.  
  97.  
  98.               return true;
  99.  
  100.      } else{
  101.               if(inventory.atItem(Flax, "Use")){
  102.               sleep(100,200);
  103.               if(inventory.atItem(Vial, "water"))
  104.               return true;
  105.             }
  106.       }
  107.  
  108.  
  109.         }
  110.  
  111.     }
  112.  
  113.         return true;
  114.     }
  115.  
  116.  
  117.  
  118.  
  119.     public boolean clickAll(){
  120.         status = "Clicking Interface";
  121.  
  122.      if(interfaces.interfaceExists(513)){
  123.         IComponent ClickAll = interfaces.getInterface(513).getComponent(4); //Gets an IComponent of the interface with the specified ID
  124.          if(ClickAll.doAction("Make All")){
  125.         justClicked = true;
  126.         return true;
  127.         }else return false;
  128.     } else return false;
  129.                                                          // close the other one, opena  new tab
  130.       }
  131.    
  132.  
  133.     public boolean openBank(){           //thanks but why dose it do 2 times? let me check somethingkk go on :P
  134.  
  135.  
  136.         status = "Opening Bank";
  137.                     if(bank.isOpen()){
  138.                             return true;
  139.                     }
  140.                             bankBooth = objects.getClosestObject(15, boothID);
  141.  
  142.                              if(bankBooth != null && calculations.onScreen(bankBooth.getScreenPos())) {
  143.                    bankBooth.doAction("quick");
  144.                                  sleep(1000,1500);
  145.                                    if(getMyPlayer().isMoving())
  146.                                    sleep(1000,2500);
  147.                                 return bank.isOpen();
  148.  
  149.                             } else return false;
  150.  
  151.  
  152.             }
  153.  
  154.     public void withdraw(){
  155.         status = "Withdrawing items.";
  156.             if(bank.isOpen()){
  157.                     if(!inventory.contains(Vial)){
  158.                        if(bank.contains(Vial))  {
  159.                            if(bank.getCount(Vial) < 14)
  160.                               bank.withdrawAll(Vial);
  161.  
  162.                          bank.withdrawX(Vial,14);
  163.                          sleep(1000,2000);
  164.                        } else NoMore = true;
  165.                      }
  166.  
  167.  
  168.  
  169.                     if(!inventory.contains(Flax)){
  170.                        if(bank.contains(Flax)){
  171.                               if(bank.getCount(Flax) < 14)
  172.                               bank.withdrawAll(Flax);
  173.  
  174.                          bank.withdrawX(Flax,14);
  175.                          sleep(1000,2000);
  176.  
  177.                        } else NoMore = true;
  178.                     }
  179.  
  180.                         bank.close();
  181.               }
  182.     }
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.     public void deposit(){
  190.         status = "Depositing items";
  191.             if(bank.isOpen()){
  192.                 if(inventory.contains(Vial) || inventory.contains(Flax) || inventory.contains(unf))
  193.   //                  bank.depositAll(softclayID);
  194.                 bank.depositAllInventory();
  195.  
  196. //                 if(inventory.contains(bucketID))
  197.  //                   bank.depositAll(bucketID);
  198.             }
  199.     }
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.     @Override
  208.     public void registerWorkers() {
  209.         createWorker(new Looped() {
  210.             public int loop() {
  211.         if(!isLoggedIn()) {
  212.           return random(1000, 2000);
  213.         }
  214.  
  215.       if(inventoryItem()){
  216.           sleep(1500,2000);
  217.           clickAll();
  218.       }
  219.  
  220.      while(justClicked){
  221.          status = "Making Ur Pots";
  222.  
  223.           KTimer waitTime = new KTimer(17000);
  224.            sleep(100);
  225.  
  226.       if(waitTime.isDone())
  227.           justClicked = false;
  228.  
  229.  
  230.         if(!inventory.contains(Vial) || !inventory.contains(Flax) || waitTime.isDone()){
  231.          justClicked = false;
  232.         }
  233.  
  234.  
  235.      }
  236.  
  237.  if(!inventory.contains(Vial) || !inventory.contains(Flax)){
  238.     if(openBank()){
  239.       deposit();
  240.       withdraw();
  241.    }
  242.  }
  243.  
  244.  
  245.  
  246.  
  247.          if(NoMore){
  248.              status = "Script Stopping";
  249.              sleep(1000,2000);
  250.              log("NEXT TIME BRING MORE STUFF :)<3");
  251.              stopAllScripts();
  252.  
  253.          }
  254.  
  255.                 return random(100, 200);
  256.  
  257.             }
  258.         });
  259.  
  260.                 createWorker(new Looped() {
  261.           public int loop() {
  262.          if(justClicked){
  263.  
  264.            switch (random(0, 20)) {
  265.               case 1:
  266.                     if(random(0,4)==0)
  267.                   camera.setAngle((int) (camera.getAngle()+random(-180,180)));
  268.                   break;
  269.  
  270.  
  271.               case 2:  if(random(0,4)==0)
  272.                   camera.setAltitude(random(0, 2) == 0, random(100,1000));
  273.  
  274.                         break;
  275.            }
  276.          }
  277.  
  278.                    return 100;
  279.           }
  280.         });
  281.  
  282.         // Create more workers here as needed
  283.     }
  284.  
  285.     @Override
  286.     public String getName() {
  287.         return "WhenEazy'sDrunk";  //To change body of implemented methods use File | Settings | File Templates.
  288.     }
  289.      public double getVersion() {
  290.         return 1.0;
  291.     }
  292.  
  293.     public String getAuthor() {
  294.         return "Eazy-II :)<3";
  295.     }
  296. }