Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Alexander on 2017-04-28.
- * Free for anyone to use or build upon.
- * Recuires OSbot API.
- */
- import com.sun.org.apache.bcel.internal.generic.SWITCH;
- import com.sun.org.apache.xpath.internal.operations.VariableSafeAbsRef;
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.map.constants.Banks;
- import org.osbot.rs07.api.model.Entity;
- import org.osbot.rs07.event.WebWalkEvent;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- //Script information and publisher, you can add your name here instead.
- @ScriptManifest(author = "zer0", name = "zer0Chopper", info = "Free source woodcutter", version = 0.1, logo = "")
- //Main class, good to have.
- public class Main extends Script
- {
- public void onStart()
- {
- log("Welcome to zer0Chopper v0.1");
- }
- public void onExit()
- {
- log("Thanks for using zer0Chopper v0.1");
- }
- //Below we create our cuttingzone, this case will be using West Varrock.
- //Feel free to make your own or expand this one.
- public int x1 = 3158;
- public int x2 = 3170;
- public int y1 = 3393;
- public int y2 = 3416;
- //Creating and setting the size of you active cuttingzone.
- private final Area westVarrock = new Area(x1,y1,x2,y2);
- //Used later in a Switch statement. The bot will have 3 states! To cut, to bank & to wait.
- private enum State
- {
- CUT, BANK, WAIT
- }
- private State getState()
- {
- //Looking for the cloest entity of the "Tree" sort.
- Entity tree = objects.closest("Tree");
- if(getInventory().isFull()) //Check for a full bag.
- {
- getWalking().webWalk(Banks.VARROCK_WEST);
- return State.BANK;
- }
- if(tree != null && !myPlayer().isAnimating()) //Checking if there is a tree and my character is done chopping.
- {
- return State.CUT;
- }
- return State.WAIT; //This will wait until one of the others are true.
- }
- //The real shit goes down below, in the onLoop method.
- @Override
- public final int onLoop() throws InterruptedException
- {
- switch (getState())
- {
- case CUT:
- {
- if(!westVarrock.contains(myPosition()))
- {
- getWalking().webWalk(westVarrock);
- }
- Entity tree = objects.closest("Tree");
- if(tree != null)
- {
- tree.interact("Chop down");
- }
- break;
- }
- case BANK:
- {
- BANK();
- break;
- }
- case WAIT:
- {
- sleep(random(4500,7000));
- break;
- }
- }
- return random(200,300);
- }
- //Banking method used to bank all the items.
- public void BANK() throws InterruptedException
- {
- if(!Banks.VARROCK_WEST.contains(myPosition()))
- {
- getWalking().webWalk(Banks.VARROCK_WEST);
- }
- else
- {
- getBank().open();
- getBank().depositAll("Logs");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement