Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 17th, 2010 | Syntax: None | Size: 4.92 KB | Hits: 23 | Expires: Never
Copy text to clipboard
  1. import java.awt.*;
  2. import java.util.*;
  3. import java.util.List;
  4. import java.util.logging.Level;
  5. import javax.accessibility.*;
  6. import javax.swing.*;
  7.  
  8. import org.rsbot.bot.Bot;
  9. import org.rsbot.script.*;
  10. import org.rsbot.script.wrappers.*;
  11. import org.rsbot.event.listeners.PaintListener;
  12. import org.rsbot.event.listeners.ServerMessageListener;
  13. import org.rsbot.event.events.ServerMessageEvent;
  14. import org.rsbot.util.ScreenshotUtil;
  15.  
  16. @ScriptManifest(authors = "Charlie", category = "Fishing", name = "CFisher", version = 1.0, description =
  17.         "<html><head>" +
  18.         "</head><body>" +
  19.         "<center><strong><h2>CFisher - a Revolution in Fly Fishing</h2></strong></center>" +
  20.         "<br /><strong>Location?</strong>" +
  21.         "<center><select name='LOC'>" +
  22.         "<option>Barbarian Village" +
  23.         "<option>Shilo Village</select></center>" +
  24.         "</body></html>")
  25.  
  26. public class CFisher extends Script implements PaintListener, ServerMessageListener {
  27.  
  28.     private final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
  29.      
  30.      // Int's and Stuff
  31.      public int ID1 = 309;
  32.      public int ID2 = 314;
  33.      public int startXp;
  34.     public int fishCaught;
  35.     public int exp;
  36.     public int Animation = 867;
  37.     private int RunningEnergy = random(15, 30);
  38.     private String status = "";
  39.     public long startTime = System.currentTimeMillis();
  40.     private long waitTimer;
  41.      
  42.     public boolean onStart(Map<String, String> args) {
  43.         return true;
  44.     }
  45.  
  46.     public int loop() {
  47.                 try {
  48.                 setCameraAltitude(true);
  49.                         if (isInventoryFull()) {
  50.                         dropAllExcept(ID1, ID2);
  51.                                 wait(random(30,40));
  52.                         }
  53.                                                                                                
  54.                         if (!isInventoryFull()) {
  55.                                 if(isIdle())
  56.                                         Fish();
  57.                                         wait(random(800,1000));
  58.                                         }
  59.                 } catch (Exception e) {
  60.                                 }
  61.                        
  62.                         return random(600, 800);
  63.     }
  64.        
  65.    
  66.     public int Fish(){
  67.                 RSNPC spot = getNearestNPCByID(328);
  68.             RSTile mloc = spot.getLocation();
  69.             if (distanceTo(mloc) > 4) {
  70.                 walkTileMM(mloc);
  71.                 wait(random(800,1000));
  72.             }
  73.            if (spot != null && tileOnScreen(spot.getLocation())) {
  74.                 atNPC(spot, "Lure");
  75.                 wait(random(800,1000));
  76.            
  77. } else {
  78.                  turnToTile(spot.getLocation());
  79.                
  80.             }
  81.                         return random(800,1000);
  82.      }
  83.  
  84.    
  85.        
  86.     public void onRepaint(Graphics g) {
  87.                 long millis = System.currentTimeMillis() - startTime;
  88.                 long FishPerHour = 0;
  89.                 long expPerHour = 0;
  90.                 int startlvl = 0;
  91.                 if(startlvl == 0){
  92.                                 startlvl = skills.getCurrentSkillLevel(STAT_FISHING);
  93.                         }
  94.                 int xpToLvl = skills.getXPToNextLevel(STAT_FISHING);
  95.                 if ( startXp == 0) {
  96.                                 startXp = skills.getCurrentSkillExp(STAT_FISHING);
  97.                         }
  98.                         exp = skills.getCurrentSkillExp(STAT_FISHING) - startXp;
  99.                 if (fishCaught > 0)
  100.                                 FishPerHour = fishCaught * 3600 / (millis / 1000);
  101.                         if(exp > 0)
  102.                                 expPerHour = exp * 3600 / (millis / 1000);
  103.                        
  104.                         long hours = millis / (1000 * 60 * 60);
  105.                         millis -= hours * (1000 * 60 * 60);
  106.                         long minutes = millis / (1000 * 60);
  107.                         millis -= minutes * (1000 * 60);
  108.                         long seconds = millis / 1000;
  109.                        
  110.                         //Time Ran
  111.                         g.setColor( new Color(70, 234, 40, 150));
  112.                         g.fillRect(226, 322, 110, 16);
  113.                         g.setColor(new Color(0, 0, 0));
  114.                         g.drawRect(226, 322, 110, 16);
  115.                         g.setColor( new Color(70, 234, 40, 200));
  116.                         g.drawRect(227, 323, 108, 14);
  117.                         g.setColor(new Color(255, 255, 255));
  118.                         g.setFont(new Font("Comic Sans", Font.BOLD, 12));
  119.                         g.setColor(Color.black);
  120.                         g.drawString(
  121.                         hours
  122.                         +"h "
  123.                         +minutes
  124.                         +"min "
  125.                         +seconds
  126.                         +"sec ", 234,334);
  127.                         g.setColor( new Color(70, 234, 40, 100));
  128.                        
  129.                        
  130.                             g.setColor( new Color(70, 234, 40, 150));
  131.                             g.fillRect(0, 0, 0, 0);
  132.                                 g.setColor(new Color(0, 0, 0));
  133.                             g.drawRect(337, 175, 182, 147);
  134.                                 g.setColor(new Color(255, 255, 255));
  135.                                 g.setColor(Color.blue);
  136.                                 g.setFont(new Font("Times New Roman", Font.BOLD, 12));
  137.                                 g.drawString("Fish Caught: " + Integer.toString(fishCaught) + "", 360,217);
  138.                                 g.drawString("Exp Gained: " + exp, 360, 237);
  139.                                 g.drawString("Fish Per Hr: " +FishPerHour, 360, 257);
  140.                                 g.drawString("Experience Per Hr: " + expPerHour, 360, 277);
  141.                                 g.drawString("Exp until: " + xpToLvl + " Xp", 360, 297);
  142.                                 g.setColor(new Color(255, 255, 255));
  143.                                 g.setColor(Color.black);
  144.                                 g.drawString("CFisher - Revolved", 360, 197);
  145.                                 g.setColor(Color.white);
  146.                                 final int percent = skills.getPercentToNextLevel
  147.  
  148. (Constants.STAT_FISHING);
  149.                                
  150.                                
  151.         }
  152.     //Server Message   
  153.     @Override
  154.          public void serverMessageRecieved(final ServerMessageEvent m) {
  155.        final String message = m.getMessage();
  156.        if (message.contains("You catch a")) {
  157.            fishCaught++;
  158.        }
  159.       }
  160.     public void onFinish() {
  161.         ScreenshotUtil.takeScreenshot(true);
  162.     }
  163. }