Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.26 KB | None | 0 0
  1. package zen;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics2D;
  6. import java.awt.RenderingHints;
  7.  
  8. import org.dreambot.api.methods.map.Area;
  9. import org.dreambot.api.methods.skills.Skill;
  10. import org.dreambot.api.script.AbstractScript;
  11. import org.dreambot.api.script.Category;
  12. import org.dreambot.api.script.ScriptManifest;
  13. import org.dreambot.api.utilities.Timer;
  14. import org.dreambot.api.wrappers.interactive.GameObject;
  15. import org.dreambot.api.wrappers.interactive.NPC;
  16. @ScriptManifest(author = "Pixel", category = Category.WOODCUTTING, description = "It Cuts and banks trees anywhere! :D", name = "PixelCutter", version = 1.1)
  17.  
  18.  
  19.  
  20. public class Woodcutter extends AbstractScript {
  21.    
  22.    private GameObject tree;
  23.    private long startTime;
  24.    private NPC banker;
  25.    Area bankArea = new Area(3092, 3240, 3097, 3246, 0);
  26.    Area TreeArea = new Area(3086, 3264, 3074, 3273, 0 );
  27.    
  28.    
  29.     public void onStart() {
  30.         getClient().getInstance().setDrawMouse(true);
  31.         getSkillTracker().start(Skill.WOODCUTTING);
  32.         getSkillTracker().start(Skill.WOODCUTTING);
  33.         startTime = System.currentTimeMillis();
  34.         log("Hey this is my first script.");
  35.         log("Hope ya like it! :D");
  36.    }
  37.        
  38.        
  39.        
  40.     @Override
  41.     public int onLoop() {
  42.         tree = getGameObjects ().closest (gameObject -> gameObject != null && gameObject.getName ().equals ("Tree"));
  43.         tree.interact("Chop down");
  44.         int countLog = getInventory().count("Logs");
  45.         sleepUntil(() -> getInventory().count("Logs") > countLog, 8000);
  46.        
  47.         if(getInventory().isFull()) { //Walking to bank!
  48.             if(bankArea.contains(getLocalPlayer())) { // instead of interacting with a npc you could do the same with a bank booth
  49.                 NPC banker = getNpcs().closest(npc -> npc != null && npc.hasAction("Bank"));
  50.                 if(banker.interact("Bank")) {
  51.                     if(sleepUntil(() -> getBank().isOpen(), 9000))
  52.                         getBank().depositAllExcept (item -> item !=null && item.getName().contains("axe"));
  53.                     if(sleepUntil(() -> !getInventory().isFull(), 8000)){
  54.                         if(getBank().close()){
  55.                             sleepUntil(() -> !getBank().isOpen(), 8000);
  56.                         }
  57.                     }
  58.                 }
  59.             }
  60.         }
  61.  
  62.         return 1000;
  63.      
  64.    }
  65.            
  66.            
  67.            
  68.             public void onExit() {
  69.                 getClient().getInstance().setDrawMouse(true);
  70.                 log("Thanks for using my script you sexy beast :)");
  71.                 log("If there were any errors please report them on the thread! :P");
  72.                
  73.             }
  74.                
  75.                
  76.             public void onPaint(Graphics2D paint) {
  77.                 long runTime = System.currentTimeMillis() - startTime;
  78.                 Color blueTrans = new Color(0, 0, 0, 127);
  79.                 paint.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  80.                 paint.setFont(new Font("RuneScape Chat Regular", Font.PLAIN, 16));
  81.          
  82.                 // paint.drawImage(image, 0, 290, null);
  83.                 paint.setColor(blueTrans);
  84.                 paint.fillRect(4, 280, 512, 58);
  85.                 paint.setColor(Color.WHITE);
  86.                 paint.drawString("Pixel Woodcutter  v: " +getVersion(), 10, 298);
  87.                 paint.drawString("Run Time: " + Timer.formatTime(runTime), 10, 315);
  88.                 //paint.drawString("Status: " +status, 10, 332);
  89.                // paint.drawString("Mode: "  , 10, 419);
  90.                 paint.drawString("EXP: " +getSkillTracker().getGainedExperience(Skill.WOODCUTTING), 195, 298);
  91.                 paint.drawString("EXP H/R: " + getSkillTracker().getGainedExperiencePerHour(Skill.WOODCUTTING), 195, 315);
  92.                 paint.drawString("TTL: " + Timer.formatTime(getSkillTracker().getTimeToLevel(Skill.WOODCUTTING)), 195, 332);
  93.               // paint.drawString("Profit Made: "+ getPrice(itemID) + " ("+"e"+")", 380, 298);
  94.                 paint.drawString("Woodcutting Level: " +getSkills().getRealLevel(Skill.WOODCUTTING) + " ("+getSkillTracker().getGainedLevels(Skill.WOODCUTTING)+")", 380, 315);
  95.                
  96.             }
  97.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement