Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(name = "Soviet's Vial Filler", authors = {"Soviet"}, keywords = "Vial Filler", version = 2.0,
- description = "Fills empty vials with water in east varrock bank.")
- public class SovietsVialFiller extends Script implements PaintListener {
- // IDs
- int emptyVialID = 229;
- int filledVialID = 227;
- int fountainID = 24214;
- // Paint Variables
- private long filledVials = 0, vialsPH = 0;
- private long startTime = System.currentTimeMillis();
- int filledPrice = 0;
- int emptyPrice = 0;
- int profitPH;
- // Run Variable
- int neededRunEnergy = random(50, 75);
- // Area Tiles
- RSTile bankTile = new RSTile(3254, 3420);
- RSTile fountainTile = new RSTile(3240, 3434);
- RSArea fountainArea = new RSArea(new RSTile(3234, 3429), new RSTile(3244, 3438));
- RSArea bankArea = new RSArea(new RSTile(3249, 3415), new RSTile (3257, 3428));
- RSArea bugArea = new RSArea(new RSTile(3250,3420), new RSTile(3250,3419));
- RSArea bugArea2 = new RSArea(new RSTile(3253,3423), new RSTile(3253,3423));
- // Getting prices for profit calculations
- public boolean onStart(){
- emptyPrice = grandExchange.getMarketPrice(emptyVialID);
- filledPrice = grandExchange.getMarketPrice(filledVialID);
- return true;
- }
- @Override
- public int loop(){
- if(walking.getEnergy() > neededRunEnergy && walking.isRunEnabled() == false) {
- walking.setRun(true);
- neededRunEnergy = random(50, 75);
- sleep(500);
- }
- if (!inventory.contains(filledVialID) && (!inventory.contains(emptyVialID))){
- Bank();
- }
- if(inventory.contains(filledVialID) && bankArea.contains(getMyPlayer().getLocation())) {
- Bank();
- }
- if(inventory.contains(filledVialID) && !bankArea.contains(getMyPlayer().getLocation())) {
- walkTobank();
- }
- if(inventory.contains(emptyVialID) && fountainArea.contains(getMyPlayer().getLocation())){
- fillVials();
- }
- if(inventory.contains(emptyVialID) && !fountainArea.contains(getMyPlayer().getLocation())){
- walkTofountain();
- }
- if(!inventory.contains(emptyVialID) && bankArea.contains(getMyPlayer().getLocation())) {
- Bank();
- }
- if(!inventory.contains(emptyVialID) && !bankArea.contains(getMyPlayer().getLocation())) {
- walkTobank();
- }
- return 100;
- }
- public void Bank(){
- bank.open();
- sleep(random(1000, 1500));
- if(bank.isOpen()){
- if ((inventory.contains(filledVialID)) == true){
- filledVials += inventory.getCount(filledVialID);
- bank.depositAll();
- withdraw(emptyVialID, 0);
- sleep(500);
- bank.close();
- }
- else if(bank.getItem(emptyVialID) != null) {
- withdraw(emptyVialID,0);
- bank.close();
- }
- else {
- log("Out of vials! Stopping Script");
- env.saveScreenshot(true);
- stopScript();
- }
- }
- else if(inventory.contains(filledVialID) && (bugArea.contains(getMyPlayer().getLocation()))
- && (!bank.isOpen())){
- walking.walkTileMM(new RSTile(3253, 3421));
- sleep(2000);
- Bank();
- }
- else if(!bank.isOpen()){
- Bank();
- }
- }
- public void walkTofountain(){
- if(!getMyPlayer().isMoving()) {
- walking.walkTileMM(new RSTile(3250, 3429));
- sleep(random(2000,5000));
- walking.walkTileMM(fountainTile, 1, 1);
- sleep(random(2000,5000));
- }
- }
- public void walkTobank(){
- walking.walkTileMM(new RSTile(3250, 3429));
- while (getMyPlayer().isMoving()){
- }
- walking.walkTileMM(bankTile, 1, 1);
- sleep(random(3000,5000));
- }
- public void fillVials() {
- if(random(1, 10) == 5) {
- camera.setAngle(random(1, 359));
- }
- RSItem emptyVial = inventory.getItem(emptyVialID);
- RSObject fountain = objects.getNearest(fountainID);
- if (fountainArea.contains(getMyPlayer().getLocation())){
- while(inventory.getSelectedItem() == null){
- emptyVial.doAction("Use");
- sleep(500);
- }
- while(inventory.getSelectedItem() != null) {
- fountain.doAction("Use");
- sleep(500);
- }
- }
- else {
- walkTofountain();
- fillVials();
- }
- int a = inventory.getCount(emptyVialID);
- sleep(3000);
- if(a == inventory.getCount(emptyVialID)) {
- fillVials();
- }
- // Keeps script from bugging out while the vials are filling
- while(inventory.contains(emptyVialID)){
- }
- }
- private boolean withdraw(int itemId, int amount) {
- if (bank.isOpen()) {
- if (bank.getItem(itemId) == null) {
- for (int i = 0; i < 100 && bank.getItem(itemId) == null; i++) {
- sleep(10);
- }
- }
- if (bank.getItem(itemId) != null) {
- if (amount == 0) {
- if (bank.getItem(itemId).doAction("Withdraw-All")) {
- for (int i = 0; i < 100
- && inventory.getItem(itemId) == null; i++) {
- sleep(25);
- }
- if (inventory.getItem(itemId) != null) {
- return true;
- }
- }
- } else if (amount != 0) {
- if (bank.getItem(itemId).doAction("Withdraw-" + amount)) {
- for (int i = 0; i < 100
- && inventory.getItem(itemId) == null; i++) {
- sleep(25);
- }
- if (inventory.getItem(itemId) != null) {
- return true;
- }
- } else if (!bank.getItem(itemId).doAction(
- "Withdraw-" + amount)) {
- if (bank.getItem(itemId).doAction("Withdraw-X")) {
- sleep(random(1000, 1300));
- keyboard.sendText("" + amount, true);
- for (int i = 0; i < 100
- && inventory.getItem(itemId) == null; i++) {
- sleep(25);
- }
- if (inventory.getItem(itemId) != null) {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
- private final Color color1 = new Color(204, 0, 255);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Lucida Sans", 1, 15);
- private final Font font2 = new Font("Lucida Sans", 0, 12);
- public void onRepaint(Graphics g1) {
- profitPH = (int) ((vialsPH * filledPrice)-(vialsPH * emptyPrice));
- vialsPH = (int) (3600000.0 / (System.currentTimeMillis() - startTime) * filledVials);
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.fillRoundRect(0, 0, 175, 175, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(0, 0, 175, 175, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("Soviet's Vial Filler", 25, 25);
- g.setFont(font2);
- g.drawString("Vials Filled : " + filledVials, 50, 50);
- g.drawString("Time Ran : " + hours + ":" + minutes + ":" + seconds, 50, 75);
- g.drawString("Vials/H : " + vialsPH, 50, 100);
- g.drawString("Profit/H : " + profitPH, 50, 125);
- g.drawString("v2.0", 50, 150);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement