Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: None | Size: 7.19 KB | Hits: 117 | Expires: Never
Copy text to clipboard
  1. import java.awt.*;
  2. import java.util.*;
  3. import java.util.List;
  4. import java.lang.reflect.Method;
  5.  
  6.  
  7. import java.util.logging.Level;
  8. import javax.accessibility.*;
  9. import javax.swing.*;
  10.  
  11. import org.rsbot.bot.Bot;
  12. import org.rsbot.script.*;
  13. import org.rsbot.script.wrappers.*;
  14. import org.rsbot.event.listeners.PaintListener;
  15. import org.rsbot.event.listeners.ServerMessageListener;
  16. import org.rsbot.event.events.ServerMessageEvent;
  17. import org.rsbot.util.ScreenshotUtil;
  18.  
  19. @ScriptManifest(authors = { "Charlie" }, category = "CSeries", name = "CIvies", version = 1.00,
  20.  
  21. description = "<html><head></head><body>CIvies - Beta Introduces: Charlie's new Paint! Flawless Ivy Chopping!</body></html\n")
  22.  
  23. public class CIvies extends Script implements PaintListener {
  24.    
  25.     //INTS AND VARIABLES
  26.     public int[] IvyID = {17464, 36411, 46318, 46320, 46322, 46324, 17462};
  27.     public int[] BirdNest = {5070, 5071, 5072, 5073, 5074, 5075, 5076, 7413,
  28.             11966};
  29.     public int cutAnimation = 872;
  30.     int BirdNests = 0;
  31.     public int startXp;
  32.     public int choppedIvy;
  33.     public int expGained;
  34.     public int exp;
  35.     public long startTime = System.currentTimeMillis();
  36.     private long waitTimer;
  37.     //ENDS INTS
  38.  
  39.     public boolean onStart(Map<String, String> args) {
  40.        final int welcome = JOptionPane
  41.                                 .showConfirmDialog(
  42.                                                 null,
  43.                                                 "Would you like to click some adverts to support me?",
  44.                                                 "Welcome", JOptionPane.YES_NO_OPTION);
  45.                 if (welcome == 0) {
  46.                         final String message = "<html><h1>Thank you for your support!</h1><br/>"
  47.                                         + "<p>You will now be redirected to my adverts page. <br/>"
  48.                                         + "Click the adverts on the page few times a day if you can.</p>"
  49.                                         + "</html>";
  50.                         JOptionPane.showMessageDialog(null, message);
  51.                         openURL("http://cb570af6.linkbucks.com");
  52.                 }
  53.         return true;
  54.    
  55.      }
  56.     public void openURL(final String url) { // Credits to Dave who gave credits
  57.                 // to
  58.                 // some guy who made this.
  59.                 final String osName = System.getProperty("os.name");
  60.                 try {
  61.                         if (osName.startsWith("Mac OS")) {
  62.                                 final Class<?> fileMgr = Class
  63.                                 .forName("com.apple.eio.FileManager");
  64.                                 final Method openURL = fileMgr.getDeclaredMethod("openURL",
  65.                                                 new Class[] { String.class });
  66.                                 openURL.invoke(null, new Object[] { url });
  67.                         } else if (osName.startsWith("Windows")) {
  68.                                 Runtime.getRuntime().exec(
  69.                                                 "rundll32 url.dll,FileProtocolHandler " + url);
  70.                         } else { // assume Unix or Linux
  71.                                 final String[] browsers = { "firefox", "opera", "konqueror",
  72.                                                 "epiphany", "mozilla", "netscape" };
  73.                                 String browser = null;
  74.                                 for (int count = 0; count < browsers.length && browser == null; count++) {
  75.                                         if (Runtime.getRuntime().exec(
  76.                                                         new String[] { "which", browsers[count] })
  77.                                                         .waitFor() == 0) {
  78.                                                 browser = browsers[count];
  79.                                         }
  80.                                 }
  81.                                 if (browser == null) {
  82.                              
  83.           throw new Exception("Could not find web browser");
  84.                                 } else {
  85.                                         Runtime.getRuntime().exec(new String[] { browser, url });
  86.                                 }
  87.                         }
  88.                 } catch (final Exception e) {
  89.                 }
  90.         }
  91.     public boolean Chop() {
  92.                         final RSObject tree = getNearestObjectByID(IvyID);
  93.                         if(tree == null){
  94.                             return true;
  95.                         }
  96.                         if(animationIs(cutAnimation)){
  97.                             return true;
  98.  
  99.                         }
  100.                         else if(tree != null){
  101.                             atObject(tree, "Chop");
  102.                             wait(random(500,600));
  103.                             return false;
  104.                         }
  105.                         return false;
  106.                     }
  107.     public int loop() {
  108.         if(isIdle()) {
  109.                                         Chop();
  110.                                         wait(random(800,1000));
  111.                                         }
  112.         RSItemTile Nest = getGroundItemByID(BirdNest);
  113.         if (Nest != null && !isInventoryFull()) {
  114.             atTile(Nest, "Take");
  115.             BirdNests++;
  116.             wait(random(750, 1500));
  117.         }
  118.         return 100;
  119.     }
  120.        
  121.     public void onRepaint(Graphics g) {
  122.                 long millis = System.currentTimeMillis() - startTime;
  123.                 int y = 211;
  124.                 long ivyPerHour = 0;
  125.                 long expPerHour = 0;
  126.                 long expGained = 0;
  127.                 long levelsGained = 0;
  128.                 int startlvl = 0;
  129.                 if(startlvl == 0){
  130.                                 startlvl = skills.getCurrentSkillLevel(STAT_WOODCUTTING);
  131.                         }
  132.                 int xpToLvl = skills.getXPToNextLevel(STAT_WOODCUTTING);
  133.                
  134.                 if ( startXp == 0) {
  135.                                 startXp = skills.getCurrentSkillExp(STAT_WOODCUTTING);
  136.                         }
  137.                         exp = skills.getCurrentSkillExp(STAT_WOODCUTTING) - startXp;
  138.                 if (choppedIvy > 0)
  139.                                 ivyPerHour = choppedIvy * 3600 / (millis / 1000);
  140.                        
  141.                 if(exp > 0)
  142.                                 expPerHour = exp * 3600 / (millis / 1000);
  143.                        
  144.                         long hours = millis / (1000 * 60 * 60);
  145.                         millis -= hours * (1000 * 60 * 60);
  146.                         long minutes = millis / (1000 * 60);
  147.                         millis -= minutes * (1000 * 60);
  148.                         long seconds = millis / 1000;
  149.                        
  150.                        
  151.                         g.setFont(new Font("Arial", Font.BOLD, 12));
  152.                         g.setColor(Color.green);
  153.                         g.setColor(Color.black);
  154.                         g.drawString("CIvies - Beta      Runtime: " + hours + ":" + minutes + ":" + seconds,
  155.                                                  15, y += 14);
  156.                         g.drawString("Gained Exp: " + exp, 15, y += 14);
  157.                         g.drawString("Ivies Chopped: " + choppedIvy, 15, y += 14);
  158.                         g.drawString("Current Level: " + skills.getCurrentSkillLevel(Constants.STAT_WOODCUTTING),
  159.                                                  15, y += 14);
  160.                         g.drawString("EXP/Hour: "+ expPerHour, 15, y += 14);
  161.                         g.setColor(new Color(255, 0, 0, 140));
  162.                         g.fillRoundRect(15, y += 5, 100, 12, 10, 12);
  163.                         g.setColor(new Color(0, 255, 0, 140));
  164.                         g.fillRoundRect(15, y, skills.getPercentToNextLevel(8), 12, 10, 12);
  165.                         g.setColor(Color.black);
  166.                         g.drawString("" + skills.getPercentToNextLevel(8) + "%", 55,
  167.                                                  y += 10);
  168.                                 final int percent = skills.getPercentToNextLevel
  169.  
  170. (Constants.STAT_WOODCUTTING);
  171.                                
  172.                                
  173.         }
  174.     //Server Message   
  175.    
  176.          public void serverMessageRecieved(final ServerMessageEvent m) {
  177.        final String message = m.getMessage();
  178.        if (message.contains("You succ")) {
  179.            choppedIvy++;
  180.        }
  181.       }
  182.    
  183.     public void onFinish() {
  184.         log("Thanks for using the CSeries!");
  185.     }
  186. }