Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 8.91 KB | None | 0 0
  1. import java.awt.*;
  2. import org.rsbot.event.listeners.PaintListener;
  3. import org.rsbot.script.Script;
  4. import org.rsbot.script.ScriptManifest;
  5. import org.rsbot.script.wrappers.RSArea;
  6. import org.rsbot.script.wrappers.RSItem;
  7. import org.rsbot.script.wrappers.RSObject;
  8. import org.rsbot.script.wrappers.RSTile;
  9.  
  10. @ScriptManifest(name = "Soviet's Vial Filler", authors = {"Soviet"}, keywords = "Vial Filler", version = 2.0,
  11.         description = "Fills empty vials with water in east varrock bank.")
  12. public class SovietsVialFiller extends Script implements PaintListener {
  13.    
  14.     // IDs
  15.     int emptyVialID = 229;
  16.     int filledVialID = 227;
  17.     int fountainID = 24214;
  18.    
  19.     // Paint Variables
  20.     private long filledVials = 0, vialsPH = 0;
  21.     private long startTime = System.currentTimeMillis();
  22.     int filledPrice = 0;
  23.     int emptyPrice = 0;
  24.     int profitPH;
  25.    
  26.     // Run Variable
  27.     int neededRunEnergy = random(50, 75);
  28.    
  29.     // Area Tiles
  30.     RSTile bankTile = new RSTile(3254, 3420);
  31.     RSTile fountainTile = new RSTile(3240, 3434);
  32.     RSArea fountainArea = new RSArea(new RSTile(3234, 3429), new RSTile(3244, 3438));
  33.     RSArea bankArea = new RSArea(new RSTile(3249, 3415), new RSTile (3257, 3428));
  34.     RSArea bugArea = new RSArea(new RSTile(3250,3420), new RSTile(3250,3419));
  35.     RSArea bugArea2 = new RSArea(new RSTile(3253,3423), new RSTile(3253,3423));
  36.    
  37.    
  38.     // Getting prices for profit calculations
  39.     public boolean onStart(){
  40.   emptyPrice = grandExchange.getMarketPrice(emptyVialID);
  41.   filledPrice = grandExchange.getMarketPrice(filledVialID);
  42.   return true;
  43.      }
  44.  
  45.     @Override
  46.     public int loop(){
  47.         if(walking.getEnergy() > neededRunEnergy && walking.isRunEnabled() == false) {
  48.            walking.setRun(true);
  49.             neededRunEnergy = random(50, 75);
  50.             sleep(500);
  51.         }
  52.         if (!inventory.contains(filledVialID) && (!inventory.contains(emptyVialID))){
  53.          Bank();
  54.         }
  55.                
  56.             if(inventory.contains(filledVialID) && bankArea.contains(getMyPlayer().getLocation())) {
  57.            Bank();
  58.             }
  59.             if(inventory.contains(filledVialID) && !bankArea.contains(getMyPlayer().getLocation())) {
  60.              walkTobank();
  61.             }
  62.        
  63.         if(inventory.contains(emptyVialID) && fountainArea.contains(getMyPlayer().getLocation())){
  64.            fillVials();
  65.         }
  66.         if(inventory.contains(emptyVialID) && !fountainArea.contains(getMyPlayer().getLocation())){
  67.            walkTofountain();
  68.            
  69.         }
  70.         if(!inventory.contains(emptyVialID) && bankArea.contains(getMyPlayer().getLocation())) {
  71.            Bank();
  72.         }
  73.        
  74.         if(!inventory.contains(emptyVialID) && !bankArea.contains(getMyPlayer().getLocation())) {
  75.            walkTobank();
  76.         }
  77.         return 100;
  78.     }
  79.  
  80.     public void Bank(){    
  81.       bank.open();
  82.         sleep(random(1000, 1500));
  83.         if(bank.isOpen()){
  84.           if ((inventory.contains(filledVialID)) == true){
  85.             filledVials += inventory.getCount(filledVialID);
  86.             bank.depositAll();
  87.             withdraw(emptyVialID, 0);
  88.             sleep(500);
  89.             bank.close();
  90.           }
  91.           else if(bank.getItem(emptyVialID) != null) {
  92.                 withdraw(emptyVialID,0);
  93.                    bank.close();
  94.             }
  95.        
  96.         else {
  97.                    log("Out of vials! Stopping Script");
  98.                 env.saveScreenshot(true);
  99.                 stopScript();
  100.           }
  101.        
  102.         }
  103.         else if(inventory.contains(filledVialID) && (bugArea.contains(getMyPlayer().getLocation()))
  104.               && (!bank.isOpen())){
  105.          walking.walkTileMM(new RSTile(3253, 3421));
  106.           sleep(2000);
  107.           Bank();
  108.         }
  109.          else if(!bank.isOpen()){
  110.             Bank();
  111.           }
  112.      
  113.     }
  114.    
  115.     public void walkTofountain(){
  116.       if(!getMyPlayer().isMoving()) {
  117.                     walking.walkTileMM(new RSTile(3250, 3429));
  118.                    sleep(random(2000,5000));
  119.                     walking.walkTileMM(fountainTile, 1, 1);
  120.                     sleep(random(2000,5000));
  121.                 }
  122.     }
  123.    
  124.     public void walkTobank(){
  125.       walking.walkTileMM(new RSTile(3250, 3429));
  126.       while (getMyPlayer().isMoving()){
  127.       }
  128.               walking.walkTileMM(bankTile, 1, 1);
  129.               sleep(random(3000,5000));
  130.      
  131.     }
  132.      
  133.     public void fillVials() {
  134.      
  135.       if(random(1, 10) == 5) {
  136.             camera.setAngle(random(1, 359));
  137.         }
  138.  
  139.         RSItem emptyVial = inventory.getItem(emptyVialID);
  140.         RSObject fountain = objects.getNearest(fountainID);
  141.        
  142.         if (fountainArea.contains(getMyPlayer().getLocation())){
  143.           while(inventory.getSelectedItem() == null){
  144.             emptyVial.doAction("Use");
  145.             sleep(500);
  146.         }
  147.         while(inventory.getSelectedItem() != null) {
  148.             fountain.doAction("Use");
  149.             sleep(500);
  150.         }
  151.         }
  152.        
  153.         else {
  154.         walkTofountain();
  155.         fillVials();
  156.         }
  157.        
  158.         int a = inventory.getCount(emptyVialID);
  159.         sleep(3000);
  160.         if(a == inventory.getCount(emptyVialID)) {
  161.             fillVials();
  162.         }
  163.  
  164.        
  165.         // Keeps script from bugging out while the vials are filling
  166.         while(inventory.contains(emptyVialID)){
  167.         }
  168.  
  169.        
  170.     }
  171.    
  172.     private boolean withdraw(int itemId, int amount) {
  173.         if (bank.isOpen()) {
  174.             if (bank.getItem(itemId) == null) {
  175.                 for (int i = 0; i < 100 && bank.getItem(itemId) == null; i++) {
  176.                    sleep(10);
  177.                }
  178.            }
  179.            if (bank.getItem(itemId) != null) {
  180.                if (amount == 0) {
  181.                    if (bank.getItem(itemId).doAction("Withdraw-All")) {
  182.                        for (int i = 0; i < 100
  183.                                && inventory.getItem(itemId) == null; i++) {
  184.                            sleep(25);
  185.                        }
  186.                        if (inventory.getItem(itemId) != null) {
  187.                            return true;
  188.                        }
  189.                    }
  190.                } else if (amount != 0) {
  191.                    if (bank.getItem(itemId).doAction("Withdraw-" + amount)) {
  192.                        for (int i = 0; i < 100
  193.                                && inventory.getItem(itemId) == null; i++) {
  194.                            sleep(25);
  195.                        }
  196.                        if (inventory.getItem(itemId) != null) {
  197.                            return true;
  198.                        }
  199.                    } else if (!bank.getItem(itemId).doAction(
  200.                            "Withdraw-" + amount)) {
  201.                        if (bank.getItem(itemId).doAction("Withdraw-X")) {
  202.                            sleep(random(1000, 1300));
  203.                            keyboard.sendText("" + amount, true);
  204.                            for (int i = 0; i < 100
  205.                                    && inventory.getItem(itemId) == null; i++) {
  206.                                sleep(25);
  207.                            }
  208.                            if (inventory.getItem(itemId) != null) {
  209.                                return true;
  210.                            }
  211.                        }
  212.                    }
  213.                }
  214.            }
  215.        }
  216.        return false;
  217.    }
  218.        
  219.    private final Color color1 = new Color(204, 0, 255);
  220.    private final Color color2 = new Color(0, 0, 0);
  221.    private final Color color3 = new Color(255, 255, 255);
  222.  
  223.    private final BasicStroke stroke1 = new BasicStroke(1);
  224.  
  225.    private final Font font1 = new Font("Lucida Sans", 1, 15);
  226.    private final Font font2 = new Font("Lucida Sans", 0, 12);
  227.  
  228.    public void onRepaint(Graphics g1) {
  229.    profitPH = (int) ((vialsPH * filledPrice)-(vialsPH * emptyPrice));
  230.    vialsPH = (int) (3600000.0 / (System.currentTimeMillis() - startTime) * filledVials);
  231.    long millis = System.currentTimeMillis() - startTime;
  232.    long hours = millis / (1000 * 60 * 60);
  233.    millis -= hours * (1000 * 60 * 60);
  234.    long minutes = millis / (1000 * 60);
  235.    millis -= minutes * (1000 * 60);
  236.    long seconds = millis / 1000;
  237.    Graphics2D g = (Graphics2D)g1;
  238.        g.setColor(color1);
  239.        g.fillRoundRect(0, 0, 175, 175, 16, 16);
  240.        g.setColor(color2);
  241.        g.setStroke(stroke1);
  242.        g.drawRoundRect(0, 0, 175, 175, 16, 16);
  243.        g.setFont(font1);
  244.        g.setColor(color3);
  245.        g.drawString("Soviet's Vial Filler", 25, 25);
  246.        g.setFont(font2);
  247.        g.drawString("Vials Filled : " + filledVials, 50, 50);
  248.        g.drawString("Time Ran : " + hours + ":" + minutes + ":" + seconds, 50, 75);
  249.        g.drawString("Vials/H : " + vialsPH, 50, 100);
  250.        g.drawString("Profit/H : " + profitPH, 50, 125);
  251.        g.drawString("v2.0", 50, 150);
  252.    }
  253. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement