Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Map;
  2. import org.rsbot.event.events.MessageEvent;
  3. import org.rsbot.event.listeners.MessageListener;
  4. import org.rsbot.script.Script;
  5. import org.rsbot.script.ScriptManifest;
  6. import org.rsbot.script.wrappers.RSArea;
  7. import org.rsbot.script.wrappers.RSObject;
  8. import org.rsbot.script.wrappers.RSTile;
  9. import org.rsbot.event.listeners.PaintListener;
  10.  
  11. import java.awt.*;
  12.  
  13. @ScriptManifest(authors = "DrOstler", name = "Willow Cutter", version = 1.0, description = "Cuts and banks willows at Draynor.")
  14. public class DraynorWillows extends Script implements PaintListener, MessageListener {
  15.    
  16.     int[] WillowTreeID = {5551,5552,5553};
  17.     int[] HatchetsID = {1359};
  18.     int BankBoothID = 2213;
  19.     int WillowsID = 1519;
  20.     int TimeToMoveCamera = 0;
  21.     int MoveTime = 0;
  22.     String status = "Waiting";
  23.     public long startTime = System.currentTimeMillis();
  24.     int expGained = 0;
  25.     int startExp = 0;
  26.     int LogsCut = 0;
  27.     int pctToNextLevel = 0;
  28.    
  29.     int LevelsGained = 0;
  30.    
  31.     private final Color color1 = new Color(204, 204, 204, 130);
  32.     private final Color color2 = new Color(255, 51, 51);
  33.     private final Color color3 = new Color(0, 0, 0);
  34.     private final Color color4 = new Color(102, 255, 102);
  35.     private final Color color5 = new Color(51, 102, 255);
  36.  
  37.     private final BasicStroke stroke1 = new BasicStroke(1);
  38.  
  39.     private final Font font1 = new Font("Arial", 0, 10);
  40.     private final Font font2 = new Font("Arial", 1, 11);
  41.     private final Font font3 = new Font("Times New Roman", 1, 23);
  42.        
  43.     RSTile[] BankFromTrees = { new RSTile(3088, 3237), new RSTile(3094, 3243)};
  44.     RSTile[] TreesFromBank = { new RSTile(3094, 3243), new RSTile(3088, 3237)};
  45.    
  46.    
  47.    
  48.    
  49.     public boolean onStart(){
  50.         log("You are using DrOstler's Willow Cutter, Enjoy.");
  51.         startExp = skills.getCurrentExp(skills.WOODCUTTING);
  52.         return true;
  53.        
  54.     }
  55.    
  56.    
  57.    
  58.    
  59.     private boolean AtWillows(){
  60.         RSArea area = new RSArea(new RSTile(3091, 3239), new RSTile(3070, 3225));
  61.         return area.contains(getMyPlayer().getLocation());
  62.     }
  63.    
  64.     private boolean AtBank(){
  65.         RSArea area = new RSArea(new RSTile(3085, 3240), new RSTile(3095, 3246));
  66.         return area.contains(getMyPlayer().getLocation());
  67.     }
  68.    
  69.     private void ChopTree(){
  70.         RSObject tree = objects.getNearest(WillowTreeID);
  71.         if (tree != null && getMyPlayer().getAnimation() == -1) {
  72.             tree.doAction("chop");
  73.             status = "Chopping";
  74.         }
  75.     }
  76.    
  77.     private boolean WalkToBank() {
  78.         status = "Walking To Bank";
  79.          RSTile[] randomizedPath = walking.randomizePath(BankFromTrees, 2, 2);
  80.          return walking.walkPathMM(randomizedPath, 15);
  81.     }
  82.    
  83.     private boolean WalkToTrees() {
  84.         status = "Walking To Trees";
  85.          RSTile[] randomizedPath = walking.randomizePath(TreesFromBank, 2, 2);
  86.          return walking.walkPathMM(randomizedPath, 15);
  87.     }
  88.    
  89.     private boolean PositionFix(){
  90.         return walking.walkPathMM(TreesFromBank);
  91.     }
  92.  
  93.     private void openBank() {
  94.         status = "Opening Bank";
  95.         RSObject bankBooth = objects.getNearest(BankBoothID);
  96.         if (bankBooth != null && !bank.isOpen()) {
  97.             bankBooth.doAction("uickly");
  98.         }
  99.     }
  100.    
  101.     private void depositWillows() {
  102.         status = "Depositing Willows";
  103.         if (bank.isOpen()) {
  104.             bank.deposit(WillowsID, 0);
  105.             sleep(200, 500);
  106.         }
  107.     }
  108.  
  109.     private void closeBank() {
  110.         status = "Closing Bank";
  111.         if (bank.isOpen()) {
  112.             mouse.move(490, 36, 3, 3);
  113.             sleep(200, 500);
  114.             mouse.click(true);
  115.         }
  116.     }
  117.  
  118.     private void bank() {
  119.         openBank();
  120.         depositWillows();
  121.         closeBank();
  122.     }
  123.    
  124.     private void MoveCamera(){
  125.         camera.setAngle(random(1, 360));
  126.         camera.setPitch(random(1,180));
  127.     }
  128.    
  129.     private void MoveMouse(){
  130.         mouse.move(random(1,764), random(1,500));
  131.     }
  132.  
  133.    
  134.     @Override
  135.     public void messageReceived(MessageEvent e){
  136.         String text = e.getMessage();
  137.         if (text.contains("You get some")){
  138.             LogsCut += 1;
  139.         }
  140.         else if (text.contains("advanced a Woodcutting")){
  141.             LevelsGained += 1;
  142.         }
  143.     }  
  144.  
  145.  
  146.     public void onRepaint(Graphics g1) {
  147.        
  148.         expGained = skills.getCurrentExp(skills.WOODCUTTING) - startExp ;
  149.        
  150.         long millis = System.currentTimeMillis() - startTime;
  151.         long hours = millis / (1000 * 60 * 60);
  152.         millis -= hours * (1000 * 60 * 60);
  153.         long minutes = millis / (1000 * 60);
  154.         millis -= minutes * (1000 * 60);
  155.         long seconds = millis / 1000;
  156.        
  157.         float xpsec = 0;
  158.         if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0){
  159.             xpsec = ((float) expGained)/ (float)(seconds + (minutes * 60) + (hours*60*60));
  160.         }
  161.         float xpmin = xpsec * 60;
  162.         float xphour = xpmin * 60;
  163.        
  164.         pctToNextLevel = skills.getPercentToNextLevel(skills.getIndex("woodcutting"));
  165.        
  166.        
  167.             Graphics2D g = (Graphics2D)g1;
  168.             g.setColor(color1);
  169.             g.fillRect(6, 52, 127, 91);
  170.             g.setColor(color2);
  171.             g.fillRoundRect(7, 313, 503, 19, 16, 16);
  172.             g.setColor(color3);
  173.             g.setStroke(stroke1);
  174.             g.drawRoundRect(7, 313, 503, 19, 16, 16);
  175.             g.setColor(color4);
  176.             g.fillRoundRect(7, 313, (int)(skills.getPercentToNextLevel(skills.getIndex("woodcutting"))*5.03), 19, 16, 16);
  177.             g.setColor(color3);
  178.             g.drawRoundRect(7, 313, 503, 19, 16, 16);
  179.             g.setFont(font1);
  180.             g.drawString("Time Running : " + hours + ": " + minutes + ": " + seconds, 7, 66);
  181.             g.drawString("Exp Gained : " + expGained, 8, 90);
  182.             g.drawString("Logs Cut : " + LogsCut, 8, 137);
  183.             g.drawString("Exp Per Hour : " + (int)xphour, 8, 115);
  184.             g.setFont(font2);
  185.             g.drawString(pctToNextLevel + "% Untill level " + (skills.getCurrentLevel(skills.getIndex("woodcutting"))+1) + "       Exp Needed ( " + (skills.getExpToNextLevel(skills.getIndex("woodcutting"))) + " )", 179, 327);
  186.             g.setFont(font3);
  187.             g.setColor(color5);
  188.             g.drawString("DrOstler's Willow Cutter", 7, 39);
  189.  
  190.     }
  191.  
  192.    
  193.  
  194.    
  195.    
  196.     public void onFinish(){
  197.         log("Thank you and Goodbye.");
  198.         log("You gained " + LevelsGained + " Levels this session.");
  199.     }
  200.  
  201.    
  202.  
  203.    
  204.     @Override
  205.     public int loop() {
  206.         if (AtWillows() && inventory.isFull()) {
  207.                 WalkToBank();
  208.             }
  209.             else if (AtBank() && inventory.isFull()) {
  210.                 bank();
  211.             }
  212.             else if (AtBank() && !inventory.isFull()) {
  213.                 WalkToTrees();
  214.             }
  215.             else if (AtWillows() && !inventory.isFull()) {
  216.                 ChopTree();
  217.             }
  218.             else if (!AtWillows() && !inventory.isFull()) {
  219.                 PositionFix();
  220.         }
  221.        
  222.         if (TimeToMoveCamera == 50) {
  223.                 MoveCamera();
  224.                 TimeToMoveCamera = 0;
  225.             }
  226.             else if (TimeToMoveCamera != 50){
  227.                 TimeToMoveCamera += 1;
  228.         }
  229.        
  230.         if (status == "Chopping"){
  231.             MoveMouse();
  232.         }
  233.        
  234.         return (random(650, 950));
  235.     }
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement