Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.32 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.Point;
  6. import java.awt.Rectangle;
  7. import java.util.ArrayList;
  8.  
  9. import org.tribot.bot.Methods;
  10. import org.tribot.bot.TRiBot;
  11. import org.tribot.input.Mouse;
  12. import org.tribot.loader.Client;
  13. import org.tribot.methods.*;
  14. import org.tribot.script.Script;
  15. import org.tribot.script.ScriptManifest;
  16. import org.tribot.wrappers.RSArea;
  17. import org.tribot.wrappers.RSInterface;
  18. import org.tribot.wrappers.RSInventItem;
  19. import org.tribot.wrappers.RSModel;
  20. import org.tribot.wrappers.RSObject;
  21. import org.tribot.wrappers.RSTile;
  22.  
  23. @ScriptManifest(authors = { "J_Pizzle" }, category = "Runecrafting", name = "Earth Rune Crafter", version = 0.1, description = "<html>"
  24.     + "<h1><center>Earth Rune Crafter</center></h1>Crafts earth runes.</html>")
  25. public class EarthRuneCrafter extends Script {
  26.    
  27.     int Crafted;
  28.     int runeEss = 1436;
  29.     int earthTally = 1440;
  30.     int[] tallyArray = {1440};
  31.     int alterID = 2481;
  32.     int ruinsID = 2455;
  33.     int portalID = 2468;
  34.     RSTile releaseTile = tile(3302, 3477);
  35.     RSTile endTile = tile(2657, 4830);
  36.     RSTile alterLoc = tile(2658, 4838);
  37.     RSTile[] toAlter = {tile(3254, 3420), tile(3258, 3429), tile(3268, 3429),
  38.             tile(3278, 3435), tile(3286, 3448), tile(3291, 3460), tile(3304, 3474)};
  39.     RSTile[] toBank = walking.invertPath(toAlter);
  40.    
  41.            
  42.  
  43.     public EarthRuneCrafter(Client bot) {
  44.         super(bot);
  45.     }
  46.    
  47.    public boolean waitForTile(RSTile theTile, int timeout){
  48.        long t = timing.currentTimeM();
  49.        while (timing.timeFromMark(t) < timeout){
  50.          if (character.getPos().equals(theTile))
  51.              return true;
  52.        }
  53.        return false;
  54.    }
  55.    
  56.    public boolean waitForStop(int timeout){
  57.        long t = timing.currentTimeM();
  58.        while (timing.timeFromMark(t) < timeout){
  59.          RSTile currTile = character.getPos();
  60.          sleep(10 + random(100, 250));
  61.          if (currTile.equals(currTile))
  62.              return true;
  63.        }
  64.        return false;
  65.    }
  66.    
  67.    public boolean enterPortal(){
  68.        RSObject portal = objects.findNearestObject(portalID, 1000);
  69.        if (portal != null){
  70.          RSTile loc = portal.getPos();
  71.          sleep(500 + random(0, 250));
  72.          if (calculations.isTileOnScreen(loc, 0)){
  73.          Point portalCoords = calculations.tileToScreen(loc, 0);
  74.          clickMouse(portalCoords, 5, 5, 1);
  75.          return waitForTile(releaseTile, 1000);
  76.          } else {
  77.                walking.walkPathUntilFlag(walking.randomizePath(
  78.                         walking.generateStraightPath(loc), 2, 2));
  79.                waitForStop(1000);
  80.                sleep(100 + random(123, 345));
  81.                enterPortal();
  82.                }
  83.        }
  84.        return false;
  85.    }
  86.    
  87.    public boolean Bank(){
  88.        if (banking.openBankNPC()){
  89.            banking.depositByInvExcept(tallyArray);
  90.            banking.withdrawItem(runeEss, 27);
  91.            banking.closeBank();
  92.            if (inventory.countItemsByID(runeEss) > 0)
  93.                return true; else
  94.                    return false;
  95.        }
  96.        return false;
  97.    }
  98.    
  99.    public int amountCrafted(){
  100.        RSInventItem runes = inventory.getItemByID(557);
  101.        return runes.getStackSize();
  102.    }
  103.    
  104.    public boolean craftRunes(){
  105.            if (inventory.countItemsByID(runeEss) > 0){
  106.            RSObject alter= objects.findNearestObject(alterID, 100);
  107.            RSTile alterLoc = alter.getPos();
  108.            if (calculations.isTileOnScreen(alterLoc, 0)){
  109.            Point alterCoords = calculations.tileToScreen(alterLoc, 0);
  110.            clickMouse(alterCoords, 5, 5, 1);
  111.            long t = timing.currentTimeM();
  112.            while (timing.timeFromMark(t) < 10000 && inventory.countItemsByID(runeEss) > 0)
  113.              sleep(10);
  114.            } else {
  115.                walking.walkPathUntilFlag(walking.randomizePath(
  116.                         walking.generateStraightPath(alterLoc), 2, 2));
  117.                craftRunes();
  118.                }
  119.            if (inventory.countItemsByID(runeEss) == 0){
  120.                Crafted += amountCrafted();
  121.                return true;
  122.            }
  123.        
  124.        }
  125.        return false;
  126.    
  127.    }
  128.  
  129.    
  130.    
  131.    
  132.     public boolean enterAlter(){
  133.         if (inventory.countItemsByID(earthTally) ==0)
  134.           return false;
  135.         RSInventItem item = inventory.getItemByID(earthTally);
  136.         if (item == null)
  137.           return false;
  138.         Point coords = item.getRandomPoint();
  139.         clickMouse(coords, 1, 1, 1);
  140.         RSObject alter = objects.findNearestObject(ruinsID, 1000);
  141.         if (alter != null){
  142.         RSTile alterTile = alter.getPos();
  143.         Point alterCoords = calculations.tileToScreen(alterTile, 0);
  144.         clickMouse(alterCoords, 5, 5, 1);
  145.         return waitForTile(endTile, 1000000);
  146.         }
  147.         return false;
  148.     }
  149.    
  150.    
  151.  
  152.     @Override
  153.     public void onBreakEnd() {
  154.         // TODO Auto-generated method stub
  155.        
  156.     }
  157.  
  158.     @Override
  159.     public void onBreakStart() {
  160.         // TODO Auto-generated method stub
  161.        
  162.     }
  163.  
  164.     @Override
  165.     public void onEnd() {
  166.         // TODO Auto-generated method stub
  167.        
  168.     }
  169.  
  170.     @Override
  171.     public void onPaint(Graphics g) {
  172.         g.setColor(Color.red);
  173.         g.drawString("GE Chop'N Bank", 10, 320);
  174.         g.drawString("Trees Cut: " + Crafted, 10, 335);
  175.     }
  176.        
  177.  
  178.     @Override
  179.     public void onPause() {
  180.         // TODO Auto-generated method stub
  181.        
  182.     }
  183.  
  184.     @Override
  185.     public void onResume() {
  186.         // TODO Auto-generated method stub
  187.        
  188.     }
  189.  
  190.     @Override
  191.     public void run() {
  192.     while (true){
  193.       if (Bank()){
  194.         walking.walkPath(walking.randomizePath(toAlter, 1, 1));
  195.         if (enterAlter()){
  196.           if (craftRunes()){
  197.             if (enterPortal())
  198.                 walking.walkPath(walking.randomizePath(toBank, 1, 1));
  199.           }
  200.         }
  201.     }
  202.     }
  203.     }
  204.    
  205.  
  206.     //}
  207.    
  208.     public RSTile tile(int x, int y){
  209.         return new RSTile(x, y);
  210.     }
  211.  
  212. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement