Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import org.dreambot.api.methods.container.impl.bank.BankType;
  2. import org.dreambot.api.methods.map.Area;
  3. import org.dreambot.api.script.AbstractScript;
  4.  
  5. import org.dreambot.api.methods.Calculations;
  6. import org.dreambot.api.script.Category;
  7. import org.dreambot.api.script.ScriptManifest;
  8. import org.dreambot.api.script.listener.InventoryListener;
  9. import org.dreambot.api.utilities.Timer;
  10. import org.dreambot.api.wrappers.interactive.GameObject;
  11. import org.dreambot.api.wrappers.items.Item;
  12.  
  13. import java.awt.*;
  14. import java.text.DecimalFormat;
  15.  
  16. @ScriptManifest(
  17.         author = "WolfsRain",
  18.         description = "Fills buckets in Lumby PVP.",
  19.         category = Category.MONEYMAKING,
  20.         version = 1.0,
  21.         name = "WolfsRain's Bucket Filler"
  22. )
  23.  
  24. public class BucketFiller extends AbstractScript implements InventoryListener{
  25.  
  26.     //Paint
  27.     private Timer timer;
  28.     private long startTime;
  29.     private long timeRan;
  30.     private int bucketsFilled;
  31.     private int bucketsPerHour;
  32.  
  33.     //IDs
  34.     public static final int BUCKET = 1925;
  35.     //public static final int BUCKET_NOTE = 1926;
  36.     //public static final int BUCKET_WATER = 1229;
  37.     //public static final int BUCKET_WATER_NOTE = 1230;
  38.  
  39.     //Tiles
  40.     private static Area fountainArea = new Area(3220,3210,3223,3212);
  41.  
  42.     //Other
  43.     private static GameObject bankChest;
  44.     private static GameObject fountain;
  45.     private Item bucket;
  46.  
  47.     public void onStart() {
  48.         log("Starting script...");
  49.  
  50.         //Timer
  51.         //log("Starting Timer");
  52.         startTime = System.currentTimeMillis();
  53.         timer = new Timer();
  54.     }
  55.  
  56.     @Override
  57.     public int onLoop() {
  58.  
  59.         //Set Variables
  60.         bankChest = getGameObjects().closest("Bank chest");
  61.         fountain = getGameObjects().closest("Fountain");
  62.         bucket = getInventory().get(BUCKET);
  63.  
  64.         //Roofs
  65.         if(getClientSettings().roofsEnabled()){
  66.             log("Turning off roofs.");
  67.             getClientSettings().toggleRoofs(false);
  68.             sleepUntil(() -> !getClientSettings().roofsEnabled(), 2500);
  69.         }
  70.         //Camera Pitch
  71.         if(getCamera().getPitch() < 325){
  72.             getCamera().rotateToPitch(Calculations.random( 325, 383));
  73.             sleepUntil(() -> getCamera().getPitch() > 325, 2500);
  74.         }
  75.  
  76.         //Open Bank
  77.         if(!getInventory().contains(BUCKET)) {
  78.             if(!getBank().isOpen()) {
  79.                 getBank().getClosestBank(BankType.CHEST).interact("Use");
  80.                 log("Waiting for transactions");
  81.                 sleepUntil(() -> getBank().isOpen(), 2500);
  82.             }
  83.         }
  84.         //Using Bank
  85.         if (getBank().isOpen()){
  86.             log("Bank is Open");
  87.             if (!getInventory().isEmpty()){
  88.                 log("Depot the water");
  89.                 getBank().depositAllItems();
  90.                 sleepUntil(() -> !getInventory().isFull(), 5000);
  91.             } else {
  92.                 log("Taking the buckets");
  93.                 getBank().withdrawAll(BUCKET);
  94.                 sleepUntil(() -> getInventory().isFull(), 1500);
  95.             }
  96.         }
  97.         //Using Buckets on Fountain
  98.         if(getInventory().isFull() && getInventory().contains(BUCKET)){
  99.             log("Inventory is full and we have buckets.");
  100.             if(!getBank().isOpen()){
  101.                 if(!fountainArea.contains(getLocalPlayer())){
  102.                     getWalking().walk(fountainArea.getRandomTile());
  103.                     sleepUntil(() -> fountainArea.contains(getLocalPlayer()), 2500);
  104.                 } else {
  105.                     if (bucket != null && fountain != null) {
  106.                         log("Filling the buckets!");
  107.                         bucket.useOn(fountain);
  108.                         sleepUntil(() -> !getInventory().contains(BUCKET), 20000);
  109.                     }
  110.                 }
  111.             } else {
  112.                 getBank().close();
  113.                 sleepUntil(() -> !getBank().isOpen(), 2500);
  114.             }
  115.         }
  116.  
  117.         return Calculations.random(25, 75);
  118.     }
  119.  
  120.     @Override
  121.     public void onPaint(Graphics g) {
  122.  
  123.         //Calculations
  124.         timeRan = System.currentTimeMillis() - startTime;
  125.         bucketsPerHour = (int) (bucketsFilled / ((System.currentTimeMillis() - this.startTime) / 3600000.0D));
  126.         DecimalFormat df = new DecimalFormat("#");
  127.  
  128.         //Box
  129.         g.setColor(Color.GRAY);
  130.         g.fillRect(5, 35, 200, 55);
  131.  
  132.         //Heading
  133.         //Formatting
  134.         g.setFont(new Font("Arial", Font.BOLD, 14));
  135.         g.setColor(Color.WHITE);
  136.         //Paint
  137.         g.drawString("WolfsRain's Bucket Filler", 10, 50);
  138.  
  139.         //Formatting
  140.         g.setFont(new Font("Arial", Font.PLAIN, 12));
  141.         g.setColor(Color.white);
  142.         //Body
  143.         //Paint
  144.         g.drawString("Time Ran: " + timer.formatTime(), 10, 70);
  145.         g.drawString("Buckets Filled: " + bucketsFilled + " (" + bucketsPerHour + ")/hr", 10, 85);
  146.  
  147.     }
  148.  
  149.     public void onItemChange(Item[] items) {
  150.         for (Item item : items) {
  151.             if (item != null && item.getName().equals("Bucket of water") && item.getAmount() > 0) {
  152.                 bucketsFilled += item.getAmount();
  153.             }
  154.         }
  155.     }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement