Jump to content

My first Script! (SimpleBerryPicker)


makileke

Recommended Posts

THE SOURCE IS CURRENTLY BROKEN (DL jar still working)!

 

 

 

 

 

 

 

 

So i recently made my first script, and i am quite happy with how it turned out.

 

What the script does

 

The script simply picks cadava berries and redberries just southvest of varrock

 

How to use it

 

Its really simple, start out with a empty inventory in Varrocks east bank or just vest of varrocks south east mining site and the bot will start to pick berries and bank them

 

Why use it?

 

I dont really know, maybe for money, i really just made it for fun as my first script.

 

Download link: http://www.mediafire.com/download/i6rdskwfv6qoglz/BerryPicker.jar

 

Here's the source:

import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.util.concurrent.TimeUnit; 
 


import java.awt.*;
 
@ScriptManifest(author = "Makileke", info = "This is my first script, It will simply pick berries outside varrock for profit!", name = "BerryPicker", version = 0.1, logo = "")
public class main extends Script {
 
    @Override
    public void onStart() {
        log("Started script!");
        log("Hope you like it, if you find a bug, please report it on the forum!");
        timeBegan = System.currentTimeMillis();
    }
    
    private enum State {
		USE, BANK, WAIT, BUSH
	};
	
	// Here is the paint shit
	
	private long timeBegan;
	private long timeRan;

	
	Position[] pathToBerries = { new Position(3254, 3421, 0), new Position(3254, 3424, 0),
			 new Position(3255, 3429, 0), new Position(3260, 3429, 0), new Position(3266, 3429, 0),
			 new Position(3271, 3428, 0), new Position(3276, 3428, 0), new Position(3280, 3426, 0),
			 new Position(3284, 3423, 0), new Position(3286, 3418, 0), new Position(3288, 3413, 0),
			 new Position(3289, 3408, 0), new Position(3290, 3397, 0), new Position(3290, 3392, 0),
			 new Position(3291, 3386, 0), new Position(3291, 3381, 0), new Position(3292, 3376, 0),
			 new Position(3288, 3373, 0), new Position(3283, 3373, 0), new Position(3278, 3371, 0),
			 new Position(3273, 3369, 0), new Position(3268, 3368, 0) };
	
	
	Position[] pathToBank = { new Position(3265, 3368, 0), new Position(3269, 3369, 0),
			 new Position(3274, 3371, 0), new Position(3279, 3372, 0), new Position(3284, 3374, 0),
			 new Position(3289, 3374, 0), new Position(3293, 3377, 0), new Position(3294, 3382, 0),
			 new Position(3290, 3394, 0), new Position(3291, 3399, 0), new Position(3291, 3402, 0),
			 new Position(3292, 3407, 0), new Position(3290, 3411, 0), new Position(3287, 3416, 0),
			 new Position(3284, 3420, 0), new Position(3282, 3425, 0), new Position(3278, 3428, 0),
			 new Position(3273, 3429, 0), new Position(3268, 3429, 0), new Position(3263, 3429, 0),
			 new Position(3258, 3429, 0), new Position(3254, 3426, 0), new Position(3254, 3420, 0) };

	private State getState() {
		Entity bush = objects.closest("Cadava Bush", "Redberry bush");
		if (inventory.isFull())
			return State.BANK;
		if (bush != null)
			return State.USE;
		if (!inventory.isFull())
			return State.BUSH;
		return State.WAIT;
	}
    
    @Override
    public int onLoop() throws InterruptedException {
    	switch (getState()) {
		case USE:
			Entity bush = objects.closest("Cadava Bush", "Redberry bush");
			if (bush != null) {
				bush.interact("Pick-from");
				sleep(random(200, 300));
				log("Picking Them Berries");
			}
			break;
		case BANK:
			localWalker.walkPath(pathToBank);
			log("Trying to walk");
		    RS2Object bankBooth = objects.closest("Bank booth");
		    if (bankBooth != null) {
		        if (bankBooth.interact("Bank")) {
		            while (!bank.isOpen())
		                sleep(250);
		            bank.depositAll();
		        }
		    }
		    break;    
		case BUSH:
			localWalker.walkPath(pathToBerries);
			break;
		case WAIT:
			sleep(random(500, 700));
			break;
		}
    	return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Script stopped!");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
    	timeRan = System.currentTimeMillis() - this.timeBegan;
    	g.drawString(ft(timeRan), 50, 50); 
    }
    // How long the script has been running!
    private String ft(long duration) 
	{
		String res = "Time ran:";
		long days = TimeUnit.MILLISECONDS.toDays(duration);
		long hours = TimeUnit.MILLISECONDS.toHours(duration)
		- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
		long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
		- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
		.toHours(duration));
		long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
		- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
		.toMinutes(duration));
		if (days == 0) {
		res = (hours + ":" + minutes + ":" + seconds);
		} else {
		res = (days + ":" + hours + ":" + minutes + ":" + seconds);
		}
		return res;
	} 
}


Edited by makileke
  • Like 1
Link to comment
Share on other sites

  • 7 months later...
  • 2 weeks later...
  • 2 months later...
  • 2 weeks later...
  • 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...