Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Graphics2D;
  5. import java.awt.RenderingHints;
  6.  
  7. import org.rsbot.event.listeners.PaintListener;
  8. import org.rsbot.script.wrappers.RSObject;
  9. import org.rsbot.script.Script;
  10. import org.rsbot.script.ScriptManifest;
  11. import org.rsbot.script.wrappers.RSArea;
  12. import org.rsbot.script.wrappers.RSTile;
  13. import org.rsbot.script.wrappers.RSTilePath;
  14.  
  15.  
  16.  
  17. @ScriptManifest(authors = "iTzw00dzy, Dlolpics.", description = "iTzMiner, by Itzw00dzy", keywords = { "beast" }, name = "iTzMiner", version = 1.0)
  18. public class iTzMiner extends Script implements PaintListener {
  19.     public final int boothID = 11758;
  20.     private final static int[] oreID = { 11183, 11184, 11185, 11186, 11187, 11188 };
  21.     private static final String Door = null;
  22.     public final int miningAnimation = 624;
  23.     public final int doorID = 2647;
  24.     public int w;
  25.     public int k;
  26.     public int whereShouldIBeWalkingBro = 0; //0 =not walking, 1 = to the door from the mine, 2 = to the bank from the mine
  27.                                             // 3 = to the door from the bank, 4 = to the mine from the door
  28.    
  29.     public final RSTile[] pathFromOresToDoor = { new RSTile(2940,3281), new RSTile(2936,3283), new RSTile(2933,3287) };
  30.    
  31.     public final RSTile[] pathFromDoorToBank = { new RSTile(2935,3297), new RSTile(2938,3301), new RSTile(2943,3302), new RSTile(2947,3300), new RSTile(2951,3298), new RSTile(2965,3295),  
  32.             new RSTile(2965,3295), new RSTile(2974,3290), new RSTile(2980,3290), new RSTile(2984,3294), new RSTile(2988,3296), new RSTile(2993,3294), new RSTile(2998,3294),
  33.             new RSTile(3003,3298), new RSTile(3004,3303), new RSTile(3005,3309), new RSTile(3006,3315), new RSTile(3007,3321), new RSTile(3005,3328), new RSTile(3007,3333),
  34.             new RSTile(3007,3339), new RSTile(3006,3345), new RSTile(3007,3352), new RSTile(3011,3355)};//TODO finish this path
  35.    
  36.     public final RSTile[] pathFromBANKToTheDoor = { new RSTile(3011,3355), new RSTile(3007,3352), new RSTile(3006,3345), new RSTile(3007,3339), new RSTile(3007,3333), new RSTile(3005,3328),
  37.             new RSTile(3007,3321), new RSTile(3006,3315), new RSTile(3005,3309), new RSTile(3004,3303), new RSTile(3003,3298), new RSTile(2998,3294), new RSTile(2993,3294), new RSTile(2988,3296),
  38.             new RSTile(2984,3294), new RSTile(2980,3290), new RSTile(2974,3290), new RSTile(2965,3295), new RSTile(2965,3295), new RSTile(2951,3298), new RSTile(2947,3300), new RSTile(2943,3302),
  39.             new RSTile(2938,3301), new RSTile(2935,3297)};
  40.     //TODO finish this path
  41.     public final RSTile[] pathFromDOORTOOres = { new RSTile(2934,3289), new RSTile(2935,3282), new RSTile(2939,3280) };
  42.    
  43.  
  44.   public boolean onStart (){
  45.     if(game.isLoggedIn()){
  46.         return true;
  47.     }
  48.     log("You must start this script logged in!");
  49.       return false;
  50.   }
  51.   @Override
  52.   public int loop() {
  53.     if(inventory.isFull()) {
  54.       if(atBank()){
  55.           whereShouldIBeWalkingBro = 0;
  56.           doBank();
  57.       }
  58.       else if(atBank() || whereShouldIBeWalkingBro == 3 || whereShouldIBeWalkingBro == 4){// walk to ores
  59.         if(atBank() || whereShouldIBeWalkingBro == 3)
  60.                 walkThePath(pathFromBANKToTheDoor);
  61.       }
  62.       else{
  63.                   if(atBeforeDoorFromBank()){ //this is OUTSIDE of the guild
  64.           if(atBeforeDoorFromBank() || whereShouldIBeWalkingBro == 4){
  65.               walkThePath(pathFromDOORTOOres);
  66.       }
  67.          
  68.       }
  69.       else if(atMine() || whereShouldIBeWalkingBro == 1 || whereShouldIBeWalkingBro == 2) {
  70.       //walk to the bank
  71.         if(atBeforeDoorFromBank() || whereShouldIBeWalkingBro == 2){ //this is OUTSIDE of the guild
  72.             walkThePath(pathFromDoorToBank);
  73.             sleep(333,555);
  74.         }else{
  75.             whereShouldIBeWalkingBro = 1;
  76.             walkThePath(pathFromOresToDoor);
  77.             try{
  78.                 RSObject doorBitch = objects.getNearest(doorID);
  79.                 if(doorBitch.isOnScreen()){
  80.                     doorBitch.interact("Open"); //this might continue to open the door so be aware, needs testing
  81.                     sleep(787,1323);
  82.                     walkThePath(pathFromDoorToBank);
  83.                     whereShouldIBeWalkingBro = 2;
  84.                 }
  85.             }catch(Exception e){ sleep(222);}
  86.             sleep(243,656);
  87.         }
  88.      
  89.     }
  90.     else {
  91.       if(atMine()){
  92.           whereShouldIBeWalkingBro = 0;
  93.           mineOres();
  94.          
  95.       }else{
  96.                 if(atBeforeDoorFromBank()){ //this is OUTSIDE of the guild
  97.               if(atBeforeDoorFromBank() || whereShouldIBeWalkingBro == 4){
  98.                   walkThePath(pathFromBANKToTheDoor);
  99.               }
  100.           }else{
  101.          
  102.           }
  103.        
  104.     return random(600,800);}
  105.     }
  106.       }}
  107.     return 0;
  108.      
  109.   }
  110.    private void mineOres() {
  111.          RSObject rock = objects.getNearest(oreID);
  112.          if(getMyPlayer().getAnimation() != miningAnimation) {
  113.              if (rock != null) {
  114.                  if(rock.isOnScreen()){
  115.                      rock.interact("Mine");
  116.                      sleep(1500,2000);
  117.                  }else{
  118.                      walking.walkTo(rock.getLocation());
  119.                      camera.turnTo(rock.getLocation(), 30);
  120.                      rock.interact("Mine");
  121.                      sleep(1000,13000);
  122.                  }
  123.              }
  124.          }
  125.  }
  126.    
  127.   public void  onFinish(){
  128.     log("Thankyou for using iTzMiner!");
  129.   }
  130.      
  131.   //checking for bankbooth
  132.   private boolean atBank() {
  133.       whereShouldIBeWalkingBro = 0;
  134.     RSObject bank = objects.getNearest(boothID);
  135.        if(bank != null) {
  136.     if(bank.isOnScreen()) {
  137.       return true;}
  138.    
  139.  
  140.     }
  141.  
  142.     return false;
  143.  
  144. }
  145.  
  146.     private boolean  atBeforeDoorFromBank(){
  147.         RSArea area = new RSArea(new RSTile(2932,3298), new RSTile(2935,3291)); //new RSTile(most southwest tile), new RSTile(most northeast tile) //
  148.         return area.contains(getMyPlayer().getLocation());
  149.     }
  150.    
  151.     //opening bank
  152.     private void doBank() {
  153.         whereShouldIBeWalkingBro = 0;
  154.          if(bank.isOpen()) {
  155.         bank.depositAll();
  156.         sleep (523,845);
  157.         bank.close();
  158.          }else{
  159.             bank.open();}
  160.       }
  161.    
  162.  
  163.     //checks for ore
  164.   public boolean atMine() {
  165.     RSObject ore = objects.getNearest(oreID);
  166.         if(ore != null) {
  167.           return true;
  168.         }
  169.         return false;
  170.   }
  171.  
  172.   private void walkR1() {
  173.      
  174. try {
  175. RSObject door = objects.getNearest(doorID);
  176. if(door.isOnScreen()){
  177.         door.interact("Open");
  178.         sleep(454,876);
  179.        
  180.        // webToBank.step();
  181. }else{
  182.         camera.turnTo(door.getLocation(), 30);
  183.         walking.walkTo(door.getLocation());
  184.         sleep(87,155);
  185.         door.interact("Open");
  186.         sleep(454,876);
  187. }
  188. } catch (Exception e) {
  189. log("No door found, still looking");
  190. }
  191. }
  192.  
  193. private void walk() {
  194.     try{
  195.     //webToDoor.step();
  196. RSObject door = objects.getNearest(doorID);
  197. if(door.isOnScreen()){
  198.   door.interact("Open");
  199.   sleep(454,876);
  200. }else{
  201.   camera.turnTo(door.getLocation(), 30);
  202.   walking.walkTo(door.getLocation());
  203.   sleep(87,155);
  204.   door.interact("Open");
  205.   sleep(454,876);
  206. }
  207.   if(Door == null){
  208.       log("No door found, still looking");
  209.   }
  210.     }catch(Exception e) {sleep(234); log("Error: "+e.getMessage()); }
  211.    
  212. }
  213. /*
  214.  *
  215.  * @Author DlolPics(c)
  216.  *  Uses: walkThePath(RSTile[]);
  217.  */
  218. private boolean walkThePath(RSTile[] path){
  219.     w = random(4,6);
  220.     k = random(2,4);
  221.     int b = k;
  222.     int t = w;
  223.     boolean D=false;
  224.     try{
  225.         RSTilePath pathToWalk = walking.newTilePath(path);
  226.         RSTile next = pathToWalk.getNext();
  227.         RSTile start = pathToWalk.getStart();
  228.         if ((walking.getDestination() == null || calc.distanceTo(walking.getDestination()) < t ||calc.distanceBetween(next,walking.getDestination()) > b)) {
  229.             if(!walking.walkTileMM(next)){
  230.                 if(walking.walkTileMM(start)){
  231.                     sleep(412,565);
  232.                     D=true;
  233.                 }else{
  234.                     walkToTile(walking.getClosestTileOnMap(next));
  235.                     sleep(277,562);
  236.                 }
  237.             }else{
  238.                 sleep(299,565);
  239.                 D=true;
  240.             }
  241.         }
  242.         return D;
  243.     }catch(Exception e ){ sleep(554,789); }
  244.     return D;
  245. }
  246. /*
  247.  *
  248.  * @Author DlolPics(c)
  249.  *  Uses: walkThePath(RSTile[]);
  250.  */
  251. private boolean walkToTile(RSTile tile){
  252.     int q = k;
  253.     int i = w;
  254.     boolean D = false;
  255.     try{
  256.         if ((walking.getDestination() == null||(calc.distanceTo(walking.getDestination()) < q &&calc.distanceBetween(tile,walking.getDestination()) > i))) {
  257.             if(calc.tileOnScreen(tile)){
  258.                 if(walking.walkTileOnScreen(tile))
  259.                     D = true;
  260.             }
  261.             else if(calc.tileOnMap(tile)){
  262.                 if(walking.walkTileMM(tile))
  263.                     D = true;
  264.             }else{
  265.                 if(walkToTile(walking.getClosestTileOnMap(tile)))
  266.                     D = true;
  267.             }
  268.             sleep(389);
  269.         }
  270.     return D;
  271.     }catch(Exception e){ sleep(554,789); }
  272.     return D;
  273. }
  274.         //This variable is used for Antialiasing. DO NOT DELETE!
  275.         private final RenderingHints rh = new RenderingHints(
  276.             RenderingHints.KEY_TEXT_ANTIALIASING,
  277.             RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  278. @Override
  279.         public void onRepaint(Graphics g) {
  280.             //This paint was made using Enfilade's Paint Maker
  281.             ((Graphics2D)g).setRenderingHints(rh);
  282.             g.setColor(new Color(0, 0, 0, 105));
  283.             g.fillRect(162, 344, 333, 113);
  284.             g.setColor(new Color(0, 0, 0, 192));
  285.             g.drawRect(161, 343, 334, 114);
  286.             g.setColor(new Color(0, 0, 0, 192));
  287.             g.drawRect(160, 342, 335, 115);
  288.             g.setColor(new Color(0, 0, 0, 192));
  289.             g.drawRect(160, 342, 335, 114);
  290.             g.setFont(new Font("Kokila", 0, 20));
  291.             g.setColor(new Color(153, 153, 153));
  292.             g.drawString("Created by iTzw00dzy.", 570, 422);
  293.             g.setFont(new Font("Kokila", 0, 20));
  294.             g.setColor(new Color(153, 153, 153));
  295.             g.drawString("Version 1.0", 602, 441);
  296.             g.setFont(new Font("Courier New", 0, 40));
  297.             g.setColor(new Color(0, 0, 0));
  298.             g.drawString("iTzMiner", 546, 237);
  299.             g.setColor(new Color(204, 204, 204));
  300.             g.drawString("iTzMiner", 546, 240);
  301.             g.setFont(new Font("DaunPenh", 0, 30));
  302.             g.setColor(new Color(0, 0, 0));
  303.             g.drawString("Runtime:", 176, 374);
  304.             g.setFont(new Font("DaunPenh", 0, 30));
  305.             g.setColor(new Color(0, 0, 0));
  306.             g.drawString("Experience gained:", 176, 402);
  307.             g.setFont(new Font("DaunPenh", 0, 30));
  308.             g.setColor(new Color(0, 0, 0));
  309.             g.drawString("Ores mined:", 176, 431);
  310.         }
  311. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement