Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
65
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.    
  28.     private final Color color1 = new Color(255, 255, 255);
  29.     private final Color color2 = new Color(255, 51, 51);
  30.     private final Color color3 = new Color(0, 0, 0);
  31.     private final Color color4 = new Color(102, 255, 102);
  32.     private final Color color5 = new Color(51, 102, 255);
  33.  
  34.     private final BasicStroke stroke1 = new BasicStroke(1);
  35.  
  36.     private final Font font1 = new Font("Arial", 0, 10);
  37.     private final Font font2 = new Font("Arial", 1, 11);
  38.     private final Font font3 = new Font("Times New Roman", 1, 23);
  39.        
  40.     RSTile[] BankFromTrees = { new RSTile(3088, 3237), new RSTile(3094, 3243)};
  41.     RSTile[] TreesFromBank = { new RSTile(3094, 3243), new RSTile(3088, 3237)};
  42.    
  43.    
  44.    
  45.    
  46.     public boolean onStart(){
  47.         log("You are using DrOstler's Willow Cutter, Enjoy.");
  48.         startExp = skills.getCurrentExp(skills.WOODCUTTING);
  49.         return true;
  50.        
  51.     }
  52.    
  53.    
  54.    
  55.    
  56.     private boolean AtWillows(){
  57.         RSArea area = new RSArea(new RSTile(3091, 3239), new RSTile(3070, 3225));
  58.         return area.contains(getMyPlayer().getLocation());
  59.     }
  60.    
  61.     private boolean AtBank(){
  62.         RSArea area = new RSArea(new RSTile(3095, 3246), new RSTile(3085, 3240));
  63.         return area.contains(getMyPlayer().getLocation());
  64.     }
  65.    
  66.     private void ChopTree(){
  67.         RSObject tree = objects.getNearest(WillowTreeID);
  68.         if (tree != null && getMyPlayer().getAnimation() == -1) {
  69.             tree.doAction("chop");
  70.             status = "Chopping";
  71.         }
  72.     }
  73.    
  74.     private boolean WalkToBank() {
  75.         status = "Walking To Bank";
  76.         return walking.walkPathMM(BankFromTrees);
  77.     }
  78.    
  79.     private boolean WalkToTrees() {
  80.         status = "Walking To Trees";
  81.         return walking.walkPathMM(TreesFromBank);
  82.     }
  83.  
  84.     private void openBank() {
  85.         status = "Opening Bank";
  86.         RSObject bankBooth = objects.getNearest(BankBoothID);
  87.         if (bankBooth != null && !bank.isOpen()) {
  88.             bankBooth.doAction("uickly");
  89.         }
  90.     }
  91.    
  92.     private void depositWillows() {
  93.         status = "Depositing Willows";
  94.         if (bank.isOpen()) {
  95.             bank.deposit(WillowsID, 0);
  96.             sleep(200, 500);
  97.         }
  98.     }
  99.  
  100.     private void closeBank() {
  101.         status = "Closing Bank";
  102.         if (bank.isOpen()) {
  103.             mouse.move(490, 36, 3, 3);
  104.             sleep(200, 500);
  105.             mouse.click(true);
  106.         }
  107.     }
  108.  
  109.     private void bank() {
  110.         openBank();
  111.         depositWillows();
  112.         closeBank();
  113.     }
  114.    
  115.     private void MoveCamera(){
  116.         camera.setAngle(random(1, 360));
  117.         camera.setPitch(random(1,180));
  118.     }
  119.    
  120.     private void MoveMouse(){
  121.         mouse.move(random(1,764), random(1,500));
  122.     }
  123.  
  124.  
  125.     public void messageRecieved(MessageEvent e){
  126.         String text = e.getMessage();
  127.         if (text.contains("You get some")){
  128.             LogsCut += 1;
  129.         }
  130.     }  
  131.  
  132.  
  133.     public void onRepaint(Graphics g1) {
  134.        
  135.         expGained = skills.getCurrentExp(skills.WOODCUTTING) - startExp ;
  136.        
  137.         long millis = System.currentTimeMillis() - startTime;
  138.         long hours = millis / (1000 * 60 * 60);
  139.         millis -= hours * (1000 * 60 * 60);
  140.         long minutes = millis / (1000 * 60);
  141.         millis -= minutes * (1000 * 60);
  142.         long seconds = millis / 1000;
  143.        
  144.         float xpsec = 0;
  145.         if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0){
  146.             xpsec = ((float) expGained)/ (float)(seconds + (minutes * 60) + (hours*60*60));
  147.         }
  148.         float xpmin = xpsec * 60;
  149.         float xphour = xpmin * 60;
  150.        
  151.        
  152.             Graphics2D g = (Graphics2D)g1;
  153.             g.setColor(color1);
  154.             g.fillRect(6, 52, 127, 91);
  155.             g.setColor(color2);
  156.             g.fillRoundRect(7, 313, 503, 19, 16, 16);
  157.             g.setColor(color3);
  158.             g.setStroke(stroke1);
  159.             g.drawRoundRect(7, 313, 503, 19, 16, 16);
  160.             g.setColor(color4);
  161.             g.fillRoundRect(7, 313, 503, 19, 16, 16);
  162.             g.setColor(color3);
  163.             g.drawRoundRect(7, 313, 503, 19, 16, 16);
  164.             g.setFont(font1);
  165.             g.drawString("Time Running:" + hours + ": " + minutes + ": " + seconds, 7, 66);
  166.             g.drawString("Exp Gained : " + expGained, 8, 83);
  167.             g.drawString("Logs Cut : " + LogsCut, 8, 137);
  168.             g.drawString("Exp Per Hour : " + (int)xphour, 8, 101);
  169.             g.drawString("Profit Made : ", 7, 120);
  170.             g.setFont(font2);
  171.             g.drawString("How Much Exp til what Level", 179, 327);
  172.             g.setFont(font3);
  173.             g.setColor(color5);
  174.             g.drawString("DrOstler's Willow Cutter", 7, 39);
  175.  
  176.     }
  177.  
  178.    
  179.  
  180.    
  181.    
  182.     public void onFinish(){
  183.         log("Thank you and Goodbye.");
  184.     }
  185.  
  186.    
  187.  
  188.    
  189.     @Override
  190.     public int loop() {
  191.         if (AtWillows() && inventory.isFull()) {
  192.                 WalkToBank();
  193.             }
  194.             else if (AtBank() && inventory.isFull()) {
  195.                 bank();
  196.             }
  197.             else if (AtBank() && !inventory.isFull()) {
  198.                 WalkToTrees();
  199.             }
  200.             else if (AtWillows() && !inventory.isFull()) {
  201.                 ChopTree();
  202.         }
  203.        
  204.         if (TimeToMoveCamera == 50) {
  205.                 MoveCamera();
  206.                 TimeToMoveCamera = 0;
  207.             }
  208.             else if (TimeToMoveCamera != 50){
  209.                 TimeToMoveCamera += 1;
  210.         }
  211.        
  212.         if (status == "Chopping"){
  213.             MoveMouse();
  214.         }
  215.        
  216.         return (random(650, 950));
  217.     }
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement