Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 7.51 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4.  
  5. import org.rsbot.event.events.ServerMessageEvent;
  6. import org.rsbot.event.listeners.PaintListener;
  7. import java.awt.Graphics2D;
  8. import java.awt.Point;
  9. import java.awt.RenderingHints;
  10. import java.util.Map;
  11.  
  12. import org.rsbot.bot.Bot;
  13. import org.rsbot.script.*;
  14. import org.rsbot.script.wrappers.*;
  15. import org.rsbot.util.ScreenshotUtil;
  16. import org.rsbot.event.listeners.*;
  17.  
  18.  
  19.  
  20.  
  21. @ScriptManifest(authors = {"Invaderzim"}, category = "Other", name = "Invaderzims Camelot Flax Invader", version = 1.0, description = ("<html><body style=\"background-color: #ffffff; color: #0072ff;"
  22.     + "font-family: Arial; text-align: center;\">"
  23.     + "<h2 style=\"margin-bottom: 0px;\">Invaderzim Camelot Flax Invader</h2>"
  24.     + "<h2 style=\"margin-bottom: 0px;\">V1.0.0</h2>"
  25.     + "<strong>By Invaderzim</strong><br /><br />"
  26.     + "Start at the Camelot bank, or the Flax. <br />"
  27.  
  28.     + "Thanks for using my Flax Collector. Read the ToS at the bottom please.<br />"
  29.     + "<small>Thanks for actually reading my ToS. This script may not be</small><br />"
  30.     + "<small>distributed to any other site nor the code used without my consent. Thanks again <3, now go get some flax!</small><br />")
  31.     + "<input type=\"checkbox\" name=\"bankBox\" value=\"true\" />"
  32.     + "Agree to ToS? If so, check this box, or script won't work properly  =).<br />")
  33.    
  34.     public class IZFlaxInvader extends Script implements PaintListener, ServerMessageListener {
  35.    
  36.     //Id's N' such
  37.     int flaxID = 1779;
  38.     int bankboothID = 25808;    
  39.     int FlaxID = 2646;
  40.    
  41.    
  42.  
  43.     boolean banking = false;
  44.    
  45.    
  46.     long runTime = 0;
  47.     long seconds = 0;
  48.     long minutes = 0;
  49.     long hours = 0;
  50.     public int hourLog  = 0;
  51.    
  52.     private int flaxPicked = 0;
  53.    
  54.  
  55.  
  56.     public long startTime = System.currentTimeMillis();
  57.                    //Tiles
  58.                   RSTile bankTile=new RSTile(2724,3493);
  59.                   RSTile flaxTile=new RSTile(2741, 3448);
  60.                   RSTile[] toBank;
  61.                   RSTile[] toFlax;
  62.                   RSTile[]ToFlax = {new RSTile(2724, 3493), new RSTile(2727, 3480),
  63.         new RSTile(2728, 3466), new RSTile(2729, 3453), new RSTile(2740, 3445)}, ToBank;
  64.                  
  65.    
  66.     public boolean onStart(Map<String, String> args) { //What the script will do when it has been started.
  67.         camera.setAltitude(true);
  68.  
  69.         ToBank = walking.reversePath(ToFlax);
  70.  
  71.         log("Thanks for testing my script out, I really appreciate it. =)");      
  72.          banking = (args.get("bankbooth") == null) ? false : true;
  73.        
  74.        
  75.          
  76.          
  77.          return true;
  78.     }
  79.    
  80.     @Override
  81.     public int loop() {
  82.         if(inventory.isFull()) {
  83.             if(atBank()) {                
  84.               bank();
  85.              
  86.             } else {
  87.                
  88.                 walk(ToBank);
  89.             }
  90.         } else {
  91.             if(atFlax()) {                
  92.               pick();
  93.        
  94.             } else {
  95.                
  96.                 walk(ToFlax);
  97.             }
  98.         }
  99.         return random(150, 250);
  100.     }
  101.  
  102.     private boolean atFlax() {
  103.         try {
  104.             if(calc.tileOnScreen(objects.getNearest(FlaxID).getLocation())){
  105.                     return true;
  106.             }
  107.             return false;
  108.         } catch (Exception e) {
  109.             return false;
  110.   }
  111.     }
  112.  
  113.    
  114.    
  115.     private boolean walk(RSTile[] path) {    
  116.         if(calc.distanceTo(walking.getDestination()) < random(2, 4)) {
  117.             if(walking.walkPathMM(path) == true) {
  118.            
  119.               return false;
  120.             }
  121.         }
  122.         return true;
  123.     }
  124.  
  125.    
  126.    
  127.    
  128.    
  129.     private boolean pick() {
  130.         if (getMyPlayer().isIdle()) {
  131.             final RSObject Flax = objects.getNearest(FlaxID);
  132.             if (Flax == null) {
  133.                 walking.walkTileMM(walking.getClosestTileOnMap(flaxTile));
  134.             } else if (Flax !=null && calc.distanceTo(Flax)>4) {
  135.                 walking.walkTileMM(walking.getClosestTileOnMap(Flax.getLocation()));
  136.             } else {
  137.                 Flax.doAction("Pick");
  138.                 sleep(200, 500);
  139.             }
  140.         }
  141.         return true;
  142.     }
  143. private int bank() {
  144.         if (getMyPlayer().isIdle()) {
  145.             final RSObject BBoth = objects.getNearest(bankboothID);
  146.             if (BBoth == null) {
  147.                 walking.walkTileMM(walking.getClosestTileOnMap(bankTile));
  148.             } else if (BBoth!=null && calc.distanceTo(BBoth)>4) {
  149.                 walking.walkTileMM(walking.getClosestTileOnMap(BBoth.getLocation()));
  150.             } else {
  151.                 if (!bank.isOpen()) {
  152.                      BBoth.doAction("Use-quickly");
  153.                      sleep(1200, 1500);
  154.                      bank.depositAll();
  155.                 } else {
  156.                
  157.  
  158.                 }
  159.             }
  160.         }
  161.         return 50;
  162.     }
  163.            
  164.          private boolean walkBank() {
  165.                 return walking.walkPathMM(ToBank);
  166.         }
  167.    
  168.         private boolean walkFish() {
  169.                 return walking.walkPathMM(ToFlax);
  170.         }
  171.  
  172.        
  173.         public void onRepaint(Graphics g) {
  174.             long millis = System.currentTimeMillis() - startTime;
  175.             long hours = millis / (1000 * 60 * 60);
  176.             millis -= hours * (1000 * 60 * 60);
  177.             long minutes = millis / (1000 * 60);
  178.             millis -= minutes * (1000 * 60);
  179.             long seconds = millis / 1000;
  180.          
  181.        
  182.            
  183.            
  184.            
  185.            
  186.            
  187.        
  188.        
  189.           //This variable is used for Anti-aliasing. DO NOT DELETE!
  190.                 final RenderingHints rh = new RenderingHints(
  191.                         RenderingHints.KEY_TEXT_ANTIALIASING,
  192.                         RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  193.  
  194.                
  195.                         //This paint was made using Enfilade's Paint Maker <3 <3
  196.                         ((Graphics2D)g).setRenderingHints(rh);
  197.                         g.setColor(new Color(255, 0, 51));
  198.                         g.drawRoundRect(250, 350, 225, 125, 4, 4);
  199.                         g.setColor(new Color(0, 102, 204));
  200.                         g.fillRoundRect(275, 375, 175, 75, 4, 4);
  201.                         g.setFont(new Font("Agency FB", 0, 14));
  202.                         g.setColor(new Color(0, 0, 0));
  203.                         g.drawString("IZFlax Invader V1.0", 300, 390);
  204.                         g.setFont(new Font("Agency FB", 0, 13));
  205.                         g.setColor(new Color(0, 0, 0));
  206.                         g.drawString("Time Running:" + hours + ":" + minutes + ":" + seconds, 300, 425);
  207.                         g.setFont(new Font("Agency FB", 0, 13));
  208.                         g.setColor(new Color(0, 0, 0));
  209.                         g.drawString("Flax Picked:" + flaxPicked, 300, 450);
  210.                        
  211.                        
  212.         }
  213.        
  214.            
  215.            
  216.            
  217.            
  218.            
  219.                    
  220.            
  221.             public void serverMessageRecieved(ServerMessageEvent e) {
  222.                 String txt = e.getMessage();
  223.                
  224.                 if(txt.contains("You pick some")) flaxPicked++;
  225.             }
  226.            
  227.            
  228.        
  229.  
  230.  
  231.        
  232.        
  233.              
  234.        
  235.         @Override
  236.     public void onFinish() { //What the script will do when stopped.
  237.         log("Thanks for using FlaxInvader!");
  238.     }
  239.  private boolean atBank() {
  240.      try {
  241.          if(calc.tileOnScreen(objects.getNearest(bankboothID).getLocation())){
  242.             return true;
  243.          }
  244.          return false;
  245.      } catch (Exception e) {
  246.          return false;
  247.                 }
  248.         }
  249.                                
  250.  
  251. }