Advertisement
allerost

Final_Cutter_zer0

Apr 28th, 2017
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.19 KB | None | 0 0
  1. /**
  2.  * Created by Alexander on 2017-04-28.
  3.  * Free for anyone to use or build upon.
  4.  * Recuires OSbot API.
  5.  */
  6.  
  7. import com.sun.org.apache.bcel.internal.generic.SWITCH;
  8. import com.sun.org.apache.xpath.internal.operations.VariableSafeAbsRef;
  9. import org.osbot.rs07.api.map.Area;
  10. import org.osbot.rs07.api.map.constants.Banks;
  11. import org.osbot.rs07.api.model.Entity;
  12. import org.osbot.rs07.event.WebWalkEvent;
  13. import org.osbot.rs07.script.Script;
  14. import org.osbot.rs07.script.ScriptManifest;
  15.  
  16. //Script information and publisher, you can add your name here instead.
  17. @ScriptManifest(author = "zer0", name = "zer0Chopper", info = "Free source woodcutter", version = 0.1, logo = "")
  18.  
  19. //Main class, good to have.
  20. public class Main extends Script
  21. {
  22.     public void onStart()
  23.     {
  24.         log("Welcome to zer0Chopper v0.1");
  25.     }
  26.     public void onExit()
  27.     {
  28.         log("Thanks for using zer0Chopper v0.1");
  29.     }
  30.     //Below we create our cuttingzone, this case will be using West Varrock.
  31.     //Feel free to make your own or expand this one.
  32.     public int x1 = 3158;
  33.     public int x2 = 3170;
  34.     public int y1 = 3393;
  35.     public int y2 = 3416;
  36.     //Creating and setting the size of you active cuttingzone.
  37.     private final Area westVarrock = new Area(x1,y1,x2,y2);
  38.  
  39.     //Used later in a Switch statement. The bot will have 3 states! To cut, to bank & to wait.
  40.     private enum State
  41.     {
  42.         CUT, BANK, WAIT
  43.     }
  44.     private State getState()
  45.     {
  46.         //Looking for the cloest entity of the "Tree" sort.
  47.         Entity tree = objects.closest("Tree");
  48.  
  49.         if(getInventory().isFull()) //Check for a full bag.
  50.         {
  51.             getWalking().webWalk(Banks.VARROCK_WEST);
  52.             return State.BANK;
  53.         }
  54.         if(tree != null && !myPlayer().isAnimating()) //Checking if there is a tree and my character is done chopping.
  55.         {
  56.             return State.CUT;
  57.         }
  58.  
  59.         return State.WAIT; //This will wait until one of the others are true.
  60.     }
  61.  
  62.     //The real shit goes down below, in the onLoop method.
  63.     @Override
  64.     public final int onLoop() throws InterruptedException
  65.     {
  66.         switch (getState())
  67.         {
  68.             case CUT:
  69.             {
  70.                 if(!westVarrock.contains(myPosition()))
  71.                 {
  72.                     getWalking().webWalk(westVarrock);
  73.                 }
  74.                 Entity tree = objects.closest("Tree");
  75.                 if(tree != null)
  76.                 {
  77.                     tree.interact("Chop down");
  78.                 }
  79.                 break;
  80.             }
  81.             case BANK:
  82.             {
  83.                 BANK();
  84.                 break;
  85.             }
  86.             case WAIT:
  87.             {
  88.                 sleep(random(4500,7000));
  89.                 break;
  90.             }
  91.         }
  92.         return random(200,300);
  93.     }
  94.  
  95.     //Banking method used to bank all the items.
  96.     public void BANK() throws InterruptedException
  97.     {
  98.         if(!Banks.VARROCK_WEST.contains(myPosition()))
  99.         {
  100.             getWalking().webWalk(Banks.VARROCK_WEST);
  101.         }
  102.         else
  103.         {
  104.             getBank().open();
  105.             getBank().depositAll("Logs");
  106.         }
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement