Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Version 2.4
- /**
- * Added automatic updater
- */
- //Version 2.3
- /**
- * Faster banking
- * More efficient antiban
- * More reliable paint
- */
- //Version 2.2
- /**
- * Fixed resting error, stopping the script
- */
- //Version 2.1
- /**
- * Fixed the null pointer exception error, stopping the script
- */
- //Version 2.0!!
- /**
- * Added GUI and antiban
- * Fixed error where it didnt walk back to fountain
- * Added more options and changed the name
- */
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.image.BufferedImage;
- import java.io.BufferedInputStream;
- import java.io.BufferedOutputStream;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.text.DecimalFormat;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import com.rarebot.script.Script;
- import com.rarebot.client.m;
- import com.rarebot.event.events.MessageEvent;
- import com.rarebot.event.listeners.*;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.methods.Game.Tab;
- import com.rarebot.script.wrappers.*;
- // Script Info
- @ScriptManifest(authors = { "MegaAlgos" }, version = 2.4, keywords = ("Vial, Money Making, Filler"), description = "Fills vials at Grand Exchange", name = "MegaFiller")
- public class MegaFiller extends Script implements PaintListener,
- MessageListener {
- // Script Info for paint and proggies...
- public double getVersion() {
- return (2.4);
- }
- public String getName() {
- return ("MegaFiller");
- }
- public String getAuthor() {
- return ("MegaAlgos");
- }
- // Script Variables
- RSNPC banker;
- RSObject fountain;
- int gePrice = 0, moneyMade, profitHour, vials, counter, fullPrice,
- emptyPrice;
- int emptyObjectID, filledObjectID;
- String status, eName, fName;
- String[] list = { "Vials", "Jugs", "Buckets", "Bowls" };
- private static final String GE_URL = "http://services.runescape.com/m=itemdb_rs/g=runescape/viewitem.ws?obj=";
- long startTime, checkForFilling;
- double work = 0;
- boolean fillingVials = false, start = false, fOnScreen = false,
- startUP = false;
- int vP;
- int jP;
- int buP;
- int boP;
- // What it does on the start of the script
- public boolean onStart() {
- mouse.setSpeed(7);
- startTime = System.currentTimeMillis();
- log("MegaFiller! Aimed to make you money,"
- + " filling one thing at a time... or 28 ;)");
- java.awt.EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- new MegaGUI().setVisible(true);
- }
- });
- if (getOVersion() != getVersion()) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- new VersionGUI().setVisible(true);
- }
- });
- }
- while (!start) {
- sleep(1000);
- }
- fullPrice = getPrice(filledObjectID);
- emptyPrice = getPrice(emptyObjectID);
- log("Filled " + whereandwhat.getSelectedItem().toString() + " price: "
- + fullPrice);
- return true;
- }
- // Sees the messages in game
- @Override
- public void messageReceived(MessageEvent arg0) {
- if (arg0.getMessage().contains("You fill")) {
- fillingVials = true;
- }
- }
- // Script's graphics
- public void onRepaint(Graphics g) {
- long runTime = System.currentTimeMillis() - startTime;
- long TotalSecs = runTime / 1000;
- long TotalMins = TotalSecs / 60;
- long TotalHours = TotalMins / 60;
- int seconds = (int) TotalSecs % 60;
- int minutes = (int) TotalMins % 60;
- int hours = (int) TotalHours % 60;
- StringBuilder b = new StringBuilder();
- if (hours < 10)
- b.append('0');
- b.append(hours);
- b.append(':');
- if (minutes < 10)
- b.append('0');
- b.append(minutes);
- b.append(':');
- if (seconds < 10)
- b.append('0');
- b.append(seconds);
- if (start) {
- work = vials / (minutes + hours * 60 + seconds / 60f) * 60f;
- moneyMade = (vials * fullPrice) + (vials * emptyPrice);
- profitHour = (int) (moneyMade
- / (minutes + hours * 60 + seconds / 60f) * 60f);
- if (minutes == 30 && seconds == 1 || minutes == 0 && seconds == 30
- && game.isLoggedIn()) {
- String fS = File.separator;
- String path = null;
- File directory;
- try {
- path = new File(".").getCanonicalPath();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- directory = new File(path + fS + getName() + " " + getVersion());
- if (!directory.exists()) {
- directory.mkdirs();
- log("Made the directory for proggies");
- }
- BufferedImage img = new BufferedImage(155, 140,
- BufferedImage.TYPE_INT_RGB);
- File file = new File(directory + fS + "MegaVial " + counter
- + ".gif");
- g = img.getGraphics();
- g.setColor(new Color(76, 67, 69));
- g.fill3DRect(0, 0, 155, 140, true);
- int w = 0;
- int z = 0;
- g.setColor(new Color(80, 207, 58));
- g.drawString(getName() + " " + getVersion(), w, z += 20);
- g.drawString("Ran for: " + b.toString(), w, z += 25);
- g.drawString("Filled: " + vials + " " + eName + "s", w, z += 20);
- g.drawString("Filling: " + roundToTenth(work) + " per hour.",
- w, z += 20);
- g.drawString("Made: " + moneyMade + " profit", w, z += 20);
- g.drawString("Making: " + profitHour + " an hour", w, z += 20);
- try {
- ImageIO.write(img, "gif", file);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- log("Sent a proggy image to the MegaVial folder in program files folder...");
- counter++;
- sleep(2000);
- }
- }
- if (game.isLoggedIn()) {
- g.setColor(new Color(76, 67, 69, 185));
- g.fill3DRect(360, 180, 158, 165, true);
- int x = 365;
- int y = 185;
- g.setColor(new Color(80, 207, 58));
- g.drawString(getName() + " " + getVersion(), x, y += 20);
- g.drawString("Ran for: " + b.toString(), x, y += 25);
- g.drawString("Filled: " + vials + " vials", x, y += 20);
- g.drawString("Filling: " + roundToTenth(work) + " per hour.", x,
- y += 20);
- g.drawString("Made: " + moneyMade + " proffit", x, y += 20);
- g.drawString("Making: " + profitHour + " an hour", x, y += 20);
- g.drawString("Status: " + status, x, y += 20);
- }
- }
- // Main method to run.. the methods.
- @Override
- public int loop() {
- // Checks if we are logged in!
- if (!game.isLoggedIn()) {
- return 1000;
- }
- // Moves camera up if down
- if (camera.getPitch() < 50) {
- camera.setPitch(true);
- }
- if (getMyPlayer().getAnimation() == 5713
- || getMyPlayer().getAnimation() == 11786
- && walking.getEnergy() == 100) {
- mouse.move(calc.tileToScreen(getMyPlayer().getLocation()));
- mouse.click(true);
- }
- // Checks if energy is low
- if (walking.getEnergy() < 10 && getMyPlayer().isIdle()) {
- walking.rest();
- }
- // Checks if the run is off and the energy is above 75
- if (!walking.isRunEnabled() && walking.getEnergy() > 75) {
- // If run is off we should turn it on
- walking.setRun(true);
- }
- // Make the fillingVials boolean false
- if (inventory.getItems(filledObjectID).length == 28) {
- fillingVials = false;
- }
- // Checks if player is filling vials
- if (getMyPlayer().getAnimation() == 823 || fillingVials) {
- if (Filling()) {
- fillingVials = false;
- return 0;
- }
- while (inventory.getCount(filledObjectID) < 20) {
- antiBan();
- if (Filling()) {
- fillingVials = false;
- return 0;
- }
- }
- return 1;
- }
- // Checks if inventory is full
- if (inventory.isFull()) {
- switch (stateFull()) {
- case 1:
- // Checks if we are walking
- if (getMyPlayer().isMoving()) {
- return random(100, 300);
- }
- walkToFountain();
- return 223;
- case 2:
- fillVials();
- return 243;
- case 3:
- // Checks if we are walking
- if (getMyPlayer().isMoving()) {
- return random(100, 300);
- }
- walkToBank();
- return 233;
- case 4:
- depositVials();
- return 253;
- case 0:
- return 1;
- }
- } else { // IF NOT FULL
- RSTile bankerTile = new RSTile(3181, 3480);
- // banker = npcs.getNearest("Banker"); // bank
- if (calc.distanceTo(bankerTile) < 3) { // If close to bank
- if (bank.open()) {
- if (bank.withdraw(eName, 0)) {
- while (!inventory.isFull()) {
- sleep(100);
- }
- return random(33, 100);
- }
- } else {
- if (clickTile(bankerTile, "Bank Banker")) {
- sleep(random(33, 210));
- }
- }
- // if (banker.interact("Bank Banker")) {
- // return random(33, 210);
- // }
- return 50;
- }
- if (getMyPlayer().isMoving()) {
- return 50;
- } else {
- if (walkToBank()) {
- // Walking back to bank!
- return 500;
- } else {
- // Something is wrong.
- return 100;
- }
- }
- }
- return random(300, 500);
- }
- // Other Methods!
- // The state we are in when inventory is full.
- public int stateFull() {
- fountain = objects.getNearest("Fountain");
- RSTile f = new RSTile(3165, 3490);
- if (calc.tileOnScreen(f)) {
- fOnScreen = true;
- } else {
- fOnScreen = false;
- }
- if (inventory.containsAll(emptyObjectID) && !fOnScreen) {
- status = "Walking to fountain";
- return 1;
- }
- if (inventory.containsAll(emptyObjectID) && fOnScreen) {
- status = "Filling " + eName;
- return 2;
- }
- // banker = npcs.getNearest(2718);
- // if(banker == null) {
- // walkToBank();
- // return 0;
- // }
- RSTile bankerTile = new RSTile(3181, 3480);
- if (inventory.containsAll(filledObjectID)
- && !calc.tileOnScreen(bankerTile)) {
- status = "Walking to bank";
- return 3;
- }
- if (inventory.containsAll(filledObjectID)
- && calc.tileOnScreen(bankerTile)) {
- status = "Depositing";
- return 4;
- }
- return 0;
- }
- // Walks to bank
- public boolean walkToBank() {
- RSTile bankTile = new RSTile(3179, 3481);
- mouse.click(calc.tileToMinimap(bankTile), 5, 5, true);
- sleep(1000);
- return true;
- }
- // Walks to fountain
- public boolean walkToFountain() {
- RSTile fTile = new RSTile(3167, 3488);
- if (calc.tileOnMap(fTile)) {
- mouse.click(calc.tileToMinimap(fTile), 5, 5, true);
- } else {
- mouse.click(calc.tileToMinimap(walking.getClosestTileOnMap(fTile)),
- true);
- }
- sleep(1000);
- return true;
- }
- // Fills vials
- public boolean fillVials() {
- fountain = objects.getNearest("Fountain"); // ID 47150
- if (inventory.selectItem(emptyObjectID)) {
- if (fountain.isOnScreen()) {
- fountain.doClick();
- sleep(2500);
- return true;
- }
- return true;
- }
- return false;
- }
- public boolean Filling() {
- int iCount = inventory.getCount(filledObjectID);
- sleep(2000);
- if (inventory.getCount(filledObjectID) == iCount) {
- return true;
- }
- return false;
- }
- // Deposits vials
- public boolean depositVials() {
- // banker = npcs.getNearest("Banker"); // bank
- // if (banker.interact("Bank Banker")) {
- // sleep(random(350, 500));
- // }
- RSTile bankerTile = new RSTile(3181, 3480);
- if (clickTile(bankerTile, "Bank Banker")) {
- while (!bank.isOpen()) {
- sleep(100);
- }
- }
- if (bank.isOpen()) {
- bank.depositAll();
- vials = vials + 28;
- while (inventory.isFull()) {
- sleep(100);
- }
- } else {
- return false;
- }
- return true;
- }
- public boolean clickTile(RSTile c, String action) {
- try {
- while (getMyPlayer().isMoving()) {
- sleep(750);
- }
- Point screenLoc = calc.tileToScreen(c);
- mouse.move(screenLoc);
- if (!mouse.getLocation().equals(screenLoc))
- return false;
- mouse.click(screenLoc, false);
- return menu.doAction(action);
- } catch (NullPointerException e) {
- }
- return true;
- }
- // Clicks tile accurately
- public boolean clickTile2(RSTile c, String action) {
- try {
- Point screenLoc = null;
- screenLoc = calc.tileToScreen(c);
- if (c == null || !calc.pointOnScreen(screenLoc)) {
- System.out.println("Not on screen " + action);
- return false;
- }
- mouse.move(screenLoc);
- screenLoc = calc.tileToScreen(c);
- String[] items = menu.getItems();
- if (items.length <= 1)
- return false;
- if (items[0].toLowerCase().contains(action.toLowerCase())) {
- mouse.click(screenLoc, true);
- return true;
- } else {
- mouse.click(screenLoc, false);
- return menu.doAction(action);
- }
- } catch (NullPointerException e) {
- }
- return true;
- }
- // Rounds a double to the nearest tenth
- public double roundToTenth(double d) {
- DecimalFormat twoDForm = new DecimalFormat("#.#");
- twoDForm = new DecimalFormat("#.#");
- return Double.valueOf(twoDForm.format(d));
- }
- // Checks for the recent version
- public double getOVersion() {
- try {
- URL url = new URL("http://megascripts.comyr.com/MegaFIller");
- BufferedReader br = new BufferedReader(new InputStreamReader(
- new BufferedInputStream(url.openConnection()
- .getInputStream())));
- double ver = Double.parseDouble(br.readLine().trim());
- br.close();
- return ver;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- // ANTI-BAN STUFF
- public int antiBan() {
- Point m;
- int x = random(0, 750);
- int y = random(0, 500);
- int xx = random(710, 554);
- int yy = random(444, 230);
- int screenx = random(1, 510);
- int screeny = random(1, 450);
- int gamble = random(0, 22);
- final long start = System.currentTimeMillis();
- final RSPlayer myPlayer = getMyPlayer();
- int anim = -1;
- while (System.currentTimeMillis() - start > 2000) {
- if ((anim = myPlayer.getAnimation()) != -1) {
- break;
- }
- sleep(15);
- }
- switch (gamble) {
- case 1:
- sleep(random(1000, 2500));
- break;
- case 2:
- mouse.move(x, y);
- while (System.currentTimeMillis() - start > 2000) {
- if ((anim = myPlayer.getAnimation()) != -1) {
- break;
- }
- sleep(random(15, 55));
- }
- sleep(random(1000, 2500));
- break;
- case 3:
- game.openTab(Tab.INVENTORY);
- sleep(random(1000, 2500));
- break;
- case 4:
- if (getMyPlayer().isMoving()) {
- sleep(random(1000, 2500));
- break;
- }
- case 5:
- mouse.move(x, y);
- int checkTime = 0;
- long lastCheck = 0;
- sleep(random(1000, 2500));
- if (System.currentTimeMillis() - lastCheck >= checkTime) {
- lastCheck = System.currentTimeMillis();
- checkTime = random(60000, 180000);
- break;
- }
- case 6:
- if (game.getTab() != Tab.STATS) {
- game.openTab(Tab.STATS);
- mouse.move(xx, yy);
- sleep(random(2000, 3500));
- game.openTab(Tab.INVENTORY);
- break;
- }
- case 7:
- sleep(random(750, 1500));
- break;
- case 8:
- mouse.move(screenx, screeny);
- sleep(random(750, 1500));
- break;
- case 9:
- mouse.move(screenx, screeny);
- sleep(random(750, 1500));
- break;
- case 10:
- game.openTab(game.getRandomTab());
- sleep(random(750, 1500));
- break;
- case 11:
- mouse.move(x, y);
- sleep(random(750, 1500));
- break;
- case 13:
- mouse.move(x, y);
- sleep(random(750, 1500));
- break;
- case 12:
- mouse.move(x, y);
- sleep(random(750, 1500));
- break;
- case 14:
- m = mouse.getLocation();
- sleep(random(300, 500));
- mouse.move(m, 20, 20);
- sleep(random(100, 200));
- break;
- case 15:
- m = mouse.getLocation();
- sleep(random(300, 500));
- mouse.move(m, 20, 20);
- sleep(random(100, 200));
- break;
- case 16:
- m = mouse.getLocation();
- sleep(random(300, 500));
- mouse.move(m, 20, 20);
- sleep(random(100, 200));
- break;
- case 17:
- m = mouse.getLocation();
- sleep(random(300, 500));
- mouse.move(m, 20, 20);
- sleep(random(100, 200));
- break;
- case 19:
- mouse.move(x, y);
- sleep(random(750, 1500));
- break;
- case 20:
- mouse.move(x, y);
- sleep(random(750, 1500));
- break;
- case 21:
- mouse.move(x, y);
- sleep(random(750, 1500));
- break;
- }
- return 100;
- }
- // Grand exchange price lookup
- private int getPrice(int itemID) {
- try {
- URL url = new URL(GE_URL + String.valueOf(itemID));
- BufferedReader x = new BufferedReader(new InputStreamReader(
- url.openStream()));
- String inputLine;
- while ((inputLine = x.readLine()) != null) {
- if (inputLine
- .contains("<th scope=\"row\">Current guide price:</th>")) {
- return (int) parsePrice(x.readLine());
- }
- }
- x.close();
- } catch (MalformedURLException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return -1;
- }
- private double parsePrice(String str) {
- if (str != null && !str.isEmpty()) {
- str = stripFormatting(str);
- str = str.substring(str.indexOf(58) + 1, str.length());
- str = str.replace(",", "");
- str = str.trim();
- if (!str.endsWith("%")) {
- if (!str.endsWith("k") && !str.endsWith("m")
- && !str.endsWith("b")) {
- return Double.parseDouble(str);
- }
- return Double.parseDouble(str.substring(0, str.length() - 1))
- * (str.endsWith("b") ? 1000000000
- : str.endsWith("m") ? 1000000 : 1000);
- }
- final int k = str.startsWith("+") ? 1 : -1;
- str = str.substring(0);
- return Double.parseDouble(str.substring(0, str.length() - 1)) * k;
- }
- return -1D;
- }
- private String stripFormatting(final String str) {
- if (str != null && !str.isEmpty()) {
- return str.replaceAll("(^[^<]+>|<[^>]+>|<[^>]+$)", "");
- }
- return "";
- }
- // End Grand exchange price lookup
- JButton startButton;
- JButton mPButton;
- JComboBox whereandwhat;
- JLabel text;
- JLabel profit;
- JPanel jp1;
- public class MegaGUI extends JFrame implements ActionListener {
- public MegaGUI() {
- setTitle("MegaFiller");
- startButton = new JButton("Start");
- mPButton = new JButton("CHECK");
- text = new JLabel("What to fill?");
- profit = new JLabel("Most profitable right now: ");
- whereandwhat = new JComboBox(list);
- setLayout(null);
- setResizable(false);
- setSize(390, 255);
- setLocationRelativeTo(null);
- mPButton.setBounds(245, 20, 83, 28);
- mPButton.addActionListener(this);
- text.setBounds(20, 20, 182, 21);
- profit.setBounds(100, 20, 182, 21);
- startButton.setBounds(135, 148, 83, 28);
- startButton.addActionListener(this);
- whereandwhat.setBounds(65, 71, 200, 22);
- add(text);
- add(profit);
- add(whereandwhat);
- add(startButton);
- add(mPButton);
- setVisible(true);
- }
- public String mostProfit() {
- int vP = getPrice(227) - getPrice(229);
- int jP = getPrice(1937 - getPrice(1935));
- int buP = getPrice(1929) - getPrice(1925);
- int boP = getPrice(1921) - getPrice(1923);
- if (vP > jP && vP > buP && vP > boP) {
- return "Vials";
- }
- if (jP > vP && jP > buP && jP > boP) {
- return "Jugs";
- }
- if (buP > vP && buP > jP && buP > boP) {
- return "Buckets";
- }
- if (boP > vP && boP > buP && boP > jP) {
- return "Bowls";
- }
- return "IDK";
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().contains("Start")) {
- if (whereandwhat.getSelectedItem().toString().equals("Vials")) {
- filledObjectID = 227;
- emptyObjectID = 229;
- eName = "Vial";
- fName = "Vial of Water";
- log("Filling Vials");
- } else if (whereandwhat.getSelectedItem().toString()
- .equals("Jugs")) {
- filledObjectID = 1937;
- emptyObjectID = 1935;
- eName = "Jug";
- fName = "Jug of Water";
- log("Filling jugs");
- } else if (whereandwhat.getSelectedItem().toString()
- .equals("Buckets")) {
- filledObjectID = 1929;
- emptyObjectID = 1925;
- eName = "Bucket";
- fName = "Bucket of Water";
- log("Filling Buckets");
- } else if (whereandwhat.getSelectedItem().toString()
- .equals("Bowls")) {
- filledObjectID = 1921;
- emptyObjectID = 1923;
- eName = "Bowl";
- fName = "Bowl of Water";
- log("Filling Bowls");
- }
- dispose();
- setVisible(false);
- start = true;
- }
- if (e.getActionCommand().contains("CHECK")) {
- log("Loading prices and finding profits, "
- + "make take a minute");
- profit.setText("Most profitable right now: " + mostProfit());
- remove(mPButton);
- repaint();
- }
- }
- }
- JButton oB;
- JButton gN;
- JLabel oL;
- public class VersionGUI extends JFrame implements ActionListener {
- public VersionGUI() {
- setTitle("OUTDATED");
- oB = new JButton("Okay");
- oL = new JLabel("OUTDATED");
- gN = new JButton("Get new version");
- setLayout(null);
- setResizable(false);
- setSize(150, 185);
- setLocationRelativeTo(null);
- oB.setBounds(20, 35, 65, 25);
- gN.setBounds(20, 85, 115, 25);
- oB.addActionListener(this);
- gN.addActionListener(this);
- oL.setBounds(20, 5, 182, 21);
- add(oL);
- add(gN);
- add(oB);
- setVisible(true);
- }
- public void getNewVersion() {
- File directory = getCacheDirectory();
- File newDirectory =
- new File(new File(new File(directory.getParent()).getParent()).getParent()
- + File.separator + "Scripts" + File.separator +
- "Sources" + File.separator + "MegaFiller.java");
- BufferedInputStream in;
- try {
- in = new BufferedInputStream(
- new URL("http://megascripts.comyr.com/MegaFiller.java").openStream());
- FileOutputStream fos = new FileOutputStream(newDirectory);
- BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
- byte[] data = new byte[1024];
- int x=0;
- while((x=in.read(data,0,1024))>=0) {
- bout.write(data,0,x);
- }
- bout.close();
- in.close();
- } catch (MalformedURLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().contains("Okay")) {
- dispose();
- setVisible(false);
- }
- if (e.getActionCommand().contains("Get new version")) {
- getNewVersion();
- sleep(1000);
- oL.setText("Recompile the script");
- repaint();
- stopScript();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment