Jump to content

PotatoPicker


Shaft

Recommended Posts

PotatoPicker

What does it do:

    -Picks potatoes in draynor

    -Banks

Screen shot:

nMFNJnj.png

Source:

Spoiler

Main:


import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import PotatoMeister.Calculations;

@ScriptManifest(author = "PotatoSalad", info = "Picks potatoes at draynor", logo = "", name = "PotatoPicker", version = 1.0)
public class PotatoPicker extends Script{
	
	private Image chat = getImage("http://i.imgur.com/gDz0NuG.png");
	
	private final Area bank = new Area(3092, 3242, 3094, 3245);
	private final Area field = new Area(3139, 3289, 3150, 3279);
	
	private RS2Object potato, booth;
	
	private int price;
	private int count, count2, collected;
	private long startTime;


	public void onStart(){
		price = Calculations.getPrice(1942);
		startTime = System.currentTimeMillis();
	}
	
	public void onMessage(Message m){
		if(m.getMessage().contains("You pick a potato.")){
			count++;
			collected++;
		}
	}
	
	public int onLoop() throws InterruptedException {
		if(getInventory().isFull()){
			bank();
		}else{
			if(field.contains(myPlayer())){
				if(!myPlayer().isAnimating() && !myPlayer().isMoving()){
					potato = getObjects().closest(g -> g != null && g.getName().equalsIgnoreCase("Potato") && g.hasAction("Pick") && field.contains(g));
					potato.interact("Pick");
					count = 0;
					int r = Calculations.Random(1200, 1600);
					while(count == 0 && count2 < r){
						sleep(1);
						count2++;
					}
					count2 = 0;
				}
			}else{
				getWalking().webWalk(field);
			}
		}
		
		return Calculations.Random(452, 569);
	}
	
	
    public void onPaint(Graphics2D g) {
        g.drawImage(chat, 1, 254, null);
        long Runtime = System.currentTimeMillis() - startTime;
        
        long runtime = (int)(Runtime / 1000);
        long collectph = 3600 / runtime * collected;
        long profitph = collectph * price;
        long profit = collected * price;
 
        g.setColor(new Color(31, 221, 223));
        g.drawString("" + collected, 30, 390);
        g.drawString("" + collectph, 30, 433);
        g.drawString("" + profit, 330, 390);
        g.drawString("" + profitph, 330, 433);
        g.setColor(Color.WHITE);
    }
    

	private void bank() {
		if(bank.contains(myPlayer())){
			if(getBank().isOpen()){
				getBank().depositAll();
				getBank().close();
			}else{
				booth = getObjects().closest(g -> g != null && g.getName().equalsIgnoreCase("Bank booth") && g.hasAction("Bank"));
				booth.interact("Bank");
				new ConditionalSleep(4500, Calculations.Random(100, 200)) {

					public boolean condition() throws InterruptedException {
						return getBank().isOpen();
					}

				}.sleep();
			}
		}else{
			getWalking().webWalk(bank);
		}
	}

	private Image getImage(String url) {
        try {
            return ImageIO.read(new URL(url));
        } catch (IOException e) {
            return null;
        }
    }

}

Calculations:


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Random;

public class Calculations {
	
    private final static String BASE_URL = "http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=";
    private final static int MILLION = 1000000;
    private final static int THOUSAND = 1000;
	
	public static int Random(int min, int max){
		Random r = new Random();
		return r.nextInt((max - min) + 1) +min;
	}
	
    public static int getPrice(final int id) {
        try (final BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(BASE_URL + id).openStream()))) {
            final String raw = reader.readLine().replace(",", "").replace("\"", "").split("price:")[1].split("}")[0];
            return raw.endsWith("m") || raw.endsWith("k") ? (int) (Double.parseDouble(raw.substring(0, raw.length() - 1))
                    * (raw.endsWith("m") ? MILLION : THOUSAND)) : Integer.parseInt(raw);
        } catch (final Exception e) {
            e.printStackTrace();
        }
        return -1;
    }


}

Download:

https://mega.nz/#!E5hGUTgR!zuMbibdUnECd7bncfE-6tWpsrlqxn7E6awJ0KVKbuDE

 

Edited by Shaft
Link to comment
Share on other sites

15 minutes ago, Shaft said:

PotatoPicker

 

  Reveal hidden contents

Main:



import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import PotatoMeister.Calculations;

@ScriptManifest(author = "PotatoSalad", info = "Picks potatoes at draynor", logo = "", name = "PotatoPicker", version = 1.0)
public class PotatoPicker extends Script{
	
	private Image chat = getImage("http://i.imgur.com/gDz0NuG.png");
	
	private final Area bank = new Area(3092, 3242, 3094, 3245);
	private final Area field = new Area(3139, 3289, 3150, 3279);
	
	private RS2Object potato, booth;
	
	private int price;
	private int count, count2, collected;
	private long startTime;


	public void onStart(){
		price = Calculations.getPrice(1942);
		startTime = System.currentTimeMillis();
	}
	
	public void onMessage(Message m){
		if(m.getMessage().contains("You pick a potato.")){
			count++;
			collected++;
		}
	}
	
	public int onLoop() throws InterruptedException {
		if(getInventory().isFull()){
			bank();
		}else{
			if(field.contains(myPlayer())){
				if(!myPlayer().isAnimating() && !myPlayer().isMoving()){
					potato = getObjects().closest(g -> g != null && g.getName().equalsIgnoreCase("Potato") && g.hasAction("Pick") && field.contains(g));
					potato.interact("Pick");
					count = 0;
					int r = Calculations.Random(1200, 1600);
					while(count == 0 && count2 < r){
						sleep(1);
						count2++;
					}
					count2 = 0;
				}
			}else{
				walk(field);
			}
		}
		
		return Calculations.Random(452, 569);
	}
	
	
    public void onPaint(Graphics2D g) {
        g.drawImage(chat, 1, 254, null);
        long Runtime = System.currentTimeMillis() - startTime;
        
        long runtime = (int)(Runtime / 1000);
        long collectph = 3600 / runtime * collected;
        long profitph = collectph * price;
        long profit = collected * price;
 
        g.setColor(new Color(31, 221, 223));
        //g.setFont(new Font("Arial", 1, 11));
        g.drawString("" + collected, 30, 390);
        g.drawString("" + collectph, 30, 433);
        g.drawString("" + profit, 330, 390);
        g.drawString("" + profitph, 330, 433);
        g.setColor(Color.WHITE);
    }
    

	private void bank() {
		if(bank.contains(myPlayer())){
			if(getBank().isOpen()){
				getBank().depositAll();
				getBank().close();
			}else{
				booth = getObjects().closest(g -> g != null && g.getName().equalsIgnoreCase("Bank booth") && g.hasAction("Bank"));
				booth.interact("Bank");
				new ConditionalSleep(4500, Calculations.Random(100, 200)) {

					public boolean condition() throws InterruptedException {
						return getBank().isOpen();
					}

				}.sleep();
			}
		}else{
			walk(bank);
		}
	}
    

	
	private void walk(Area a){
		if(!getSettings().isRunning() && getSettings().getRunEnergy() >= Calculations.Random(34, 42) + Calculations.Random(-5, 4)) {
			getSettings().setRunning(true);
		}
		getWalking().webWalk(a);
	}

	private Image getImage(String url) {
        try {
            return ImageIO.read(new URL(url));
        } catch (IOException e) {
            return null;
        }
    }

}

    Calculations:



import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Random;

public class Calculations {
	
    private final static String BASE_URL = "http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=";
    private final static int MILLION = 1000000;
    private final static int THOUSAND = 1000;
	
	public static int Random(int min, int max){
		Random r = new Random();
		return r.nextInt((max - min) + 1) +min;
	}
	
    public static int getPrice(final int id) {
        try (final BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(BASE_URL + id).openStream()))) {
            final String raw = reader.readLine().replace(",", "").replace("\"", "").split("price:")[1].split("}")[0];
            return raw.endsWith("m") || raw.endsWith("k") ? (int) (Double.parseDouble(raw.substring(0, raw.length() - 1))
                    * (raw.endsWith("m") ? MILLION : THOUSAND)) : Integer.parseInt(raw);
        } catch (final Exception e) {
            e.printStackTrace();
        }
        return -1;
    }


}

https://mega.nz/#!FtwXkbia!TUMikzODQObFfk1RiGMTGlXKHpKqZuoOYS-Yey8I0hg

 

58941c50926f6_iloled.jpg.26ef1262ec62d72faa982f1effb752d1.jpg

the literal Irish script

 

congrats on the release!:D:D:D

Link to comment
Share on other sites

3 hours ago, Shaft said:

PotatoPicker

What does it do:

    -Picks potatoes in draynor

    -Banks

Screen shot:

nMFNJnj.png

Source:

  Reveal hidden contents

Main:



import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import PotatoMeister.Calculations;

@ScriptManifest(author = "PotatoSalad", info = "Picks potatoes at draynor", logo = "", name = "PotatoPicker", version = 1.0)
public class PotatoPicker extends Script{
	
	private Image chat = getImage("http://i.imgur.com/gDz0NuG.png");
	
	private final Area bank = new Area(3092, 3242, 3094, 3245);
	private final Area field = new Area(3139, 3289, 3150, 3279);
	
	private RS2Object potato, booth;
	
	private int price;
	private int count, count2, collected;
	private long startTime;


	public void onStart(){
		price = Calculations.getPrice(1942);
		startTime = System.currentTimeMillis();
	}
	
	public void onMessage(Message m){
		if(m.getMessage().contains("You pick a potato.")){
			count++;
			collected++;
		}
	}
	
	public int onLoop() throws InterruptedException {
		if(getInventory().isFull()){
			bank();
		}else{
			if(field.contains(myPlayer())){
				if(!myPlayer().isAnimating() && !myPlayer().isMoving()){
					potato = getObjects().closest(g -> g != null && g.getName().equalsIgnoreCase("Potato") && g.hasAction("Pick") && field.contains(g));
					potato.interact("Pick");
					count = 0;
					int r = Calculations.Random(1200, 1600);
					while(count == 0 && count2 < r){
						sleep(1);
						count2++;
					}
					count2 = 0;
				}
			}else{
				getWalking().webWalk(field);
			}
		}
		
		return Calculations.Random(452, 569);
	}
	
	
    public void onPaint(Graphics2D g) {
        g.drawImage(chat, 1, 254, null);
        long Runtime = System.currentTimeMillis() - startTime;
        
        long runtime = (int)(Runtime / 1000);
        long collectph = 3600 / runtime * collected;
        long profitph = collectph * price;
        long profit = collected * price;
 
        g.setColor(new Color(31, 221, 223));
        g.drawString("" + collected, 30, 390);
        g.drawString("" + collectph, 30, 433);
        g.drawString("" + profit, 330, 390);
        g.drawString("" + profitph, 330, 433);
        g.setColor(Color.WHITE);
    }
    

	private void bank() {
		if(bank.contains(myPlayer())){
			if(getBank().isOpen()){
				getBank().depositAll();
				getBank().close();
			}else{
				booth = getObjects().closest(g -> g != null && g.getName().equalsIgnoreCase("Bank booth") && g.hasAction("Bank"));
				booth.interact("Bank");
				new ConditionalSleep(4500, Calculations.Random(100, 200)) {

					public boolean condition() throws InterruptedException {
						return getBank().isOpen();
					}

				}.sleep();
			}
		}else{
			getWalking().webWalk(bank);
		}
	}

	private Image getImage(String url) {
        try {
            return ImageIO.read(new URL(url));
        } catch (IOException e) {
            return null;
        }
    }

}

Calculations:



import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Random;

public class Calculations {
	
    private final static String BASE_URL = "http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=";
    private final static int MILLION = 1000000;
    private final static int THOUSAND = 1000;
	
	public static int Random(int min, int max){
		Random r = new Random();
		return r.nextInt((max - min) + 1) +min;
	}
	
    public static int getPrice(final int id) {
        try (final BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(BASE_URL + id).openStream()))) {
            final String raw = reader.readLine().replace(",", "").replace("\"", "").split("price:")[1].split("}")[0];
            return raw.endsWith("m") || raw.endsWith("k") ? (int) (Double.parseDouble(raw.substring(0, raw.length() - 1))
                    * (raw.endsWith("m") ? MILLION : THOUSAND)) : Integer.parseInt(raw);
        } catch (final Exception e) {
            e.printStackTrace();
        }
        return -1;
    }


}

Download:

https://mega.nz/#!E5hGUTgR!zuMbibdUnECd7bncfE-6tWpsrlqxn7E6awJ0KVKbuDE

 

Bug report: Potatoes collected count on Screenie ^ is wrong.

Link to comment
Share on other sites

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...