Advertisement
Guest User

pug cutter oaks

a guest
Aug 1st, 2015
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.47 KB | None | 0 0
  1. import java.awt.Graphics;
  2.  
  3. import org.dreambot.api.methods.Calculations;
  4. import org.dreambot.api.methods.map.Area;
  5. import org.dreambot.api.script.AbstractScript;
  6. import org.dreambot.api.script.Category;
  7. import org.dreambot.api.script.ScriptManifest;
  8. import org.dreambot.api.utilities.Timer;
  9. import org.dreambot.api.wrappers.interactive.GameObject;
  10.  
  11.  
  12. @ScriptManifest(author = "Pug", name = "Pug cutter", version = 0.01, description = "1", category = Category.WOODCUTTING)
  13. public class cutter extends AbstractScript
  14. {
  15.      //Area treeArea = new Area(2946, 3240, 2955, 3229);
  16.     Area treeArea = new Area(2952,3236,2960,3228);
  17.     private Timer timer;
  18.      private String log = "Starting up";
  19.    
  20.     private void chopTree(String nameOfTree){
  21.         GameObject tree = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().equals(nameOfTree));
  22.         if(tree != null && tree.interact("Chop down")){
  23.             int countLog = getInventory().count("Logs");
  24.             sleepUntil(() -> getInventory().count("Logs") > countLog, 12000);
  25.         }
  26.     }
  27.  
  28.     public void onStart()
  29.     {
  30.         timer = new Timer();
  31.     }
  32.    
  33.     @Override
  34.     public int onLoop()
  35.     {
  36.         if(getLocalPlayer().getAnimation() != -1)
  37.         {
  38.             log = "Animating";
  39.             sleep(600);
  40.         }
  41.         if(!getInventory().isFull())
  42.         {
  43.             if(treeArea.contains(getLocalPlayer()))
  44.             {
  45.                 log = "going to cut / cutting";
  46.                 chopTree("Oak"); //change "Tree" to the name of your tree.
  47.                 sleep(600);
  48.                 getMouse().moveMouseOutsideScreen();
  49.                 while(getLocalPlayer().getAnimation() != -1)
  50.                 {
  51.                     log = "cutting";
  52.                     sleep(300);
  53.                 }
  54.             }
  55.             else
  56.             {
  57.                 if(getWalking().walk(treeArea.getRandomTile()))
  58.                 {
  59.                     log = "going to oaks";
  60.                     sleep(Calculations.random(1000, 2500));
  61.                 }
  62.             }
  63.         }
  64.        
  65.         if(getInventory().isFull())
  66.         {
  67.             log = "dropping";
  68.             getInventory().dropAll();
  69.             sleep(600);
  70.             while(getInventory().isFull())
  71.             {
  72.                 sleep(300);
  73.             }
  74.         }
  75.        
  76.        
  77.        
  78.         return Calculations.random(200,400);
  79.     }
  80.    
  81.     public void onPaint(Graphics g)
  82.     {
  83.         g.drawString("Timer: " + timer.formatTime(), 20, 200);
  84.         g.drawString("action: " + log, 20, 220);
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement