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

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 10.01 KB  |  hits: 14  |  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.*;
  2. import java.awt.image.BufferedImage;
  3. import java.io.IOException;
  4. import java.net.MalformedURLException;
  5. import java.net.URL;
  6. import java.util.*;
  7.  
  8. import javax.imageio.ImageIO;
  9.  
  10. import org.rsbot.script.*;
  11. import org.rsbot.script.wrappers.*;
  12. import org.rsbot.bot.Bot;
  13. import org.rsbot.bot.input.Mouse;
  14. import org.rsbot.event.listeners.PaintListener;
  15. import org.rsbot.event.listeners.ServerMessageListener;
  16. import org.rsbot.event.events.ServerMessageEvent;
  17.  
  18. @ScriptManifest(authors = { "ColdSun (based on Drew's powerminer)" }, category = "Fishing", name = "ColdSun's BarbarianPowerFisher", version = 1.00, description = "<html><head></head><body><center><br><br>Barbpowerfisher <br>Made by: ColdSun: Cold-A-Muse and DarkSundays<br> Special thanks to: Drew and TwinYan<br> </center> </body></html>\n")
  19.         public class ColdSunspowerfisher extends Script implements PaintListener, ServerMessageListener {
  20.  
  21.         public RSTile fishingTile = new RSTile(3109, 3433);
  22.         public int lvlsgained = 0;
  23.         private int fishingspotID = 328 ;
  24.     private int[] fishingthings = {309, 314};
  25.     private int fishesCaught = 0;
  26.     private int salmonXP = 0;
  27.     private int troutXP = 0;
  28.     private int exp = 0;
  29.     public float secondXP = 0;
  30.     public float minuteXP = 0;
  31.     public float hourXP = 0;
  32.     public long startTime = System.currentTimeMillis();
  33.     public int startXP;
  34.     public int nextEnergy = random(60, 90);
  35.     BufferedImage normal = null; //optional for custom cursor
  36.     BufferedImage clicked = null; //optional for custom cursor
  37.  
  38.     NAMMouse getMouse; //optional for custom cursor
  39.     Thread m; //optional for custom cursor
  40.  
  41.     public boolean onStart(Map<String, String> args) {
  42.         log("Loading...");
  43.         getMouse = new NAMMouse(); //optional for custom cursor
  44.         m = new Thread(getMouse); //optional for custom cursor
  45.         m.start(); //optional for custom cursor
  46.         wait(random(5000, 5500));
  47.         return true;
  48.     }
  49.  
  50.     public int loop() {
  51.         setCameraAltitude(true);
  52.         inventoryCheck();
  53.         antiban();
  54.         RSNPC fishingspot = getNearestNPCByID(fishingspotID);
  55.                 if(fishingspot == null){
  56.                         log("Looking for a spot...");
  57.                 wait(random(1000, 1800));
  58.                 } else if(isInventoryFull()) {
  59.                         log("Dropping Inventory...");
  60.                 dropAllExcept(fishingthings);
  61.                 } if(!isInventoryFull() && isIdle()) {
  62.                         Fish();
  63.                 }
  64.         return random(550, 650);
  65.     }
  66.  
  67.     public boolean inventoryCheck() {
  68.         if(inventoryContains(fishingthings)) {
  69.                 return true;
  70.         } else if(!inventoryContains(fishingthings)) {
  71.                 log("You do not have the required items, stopping script.");
  72.                 logout();
  73.                 stopScript(true);
  74.                 return true;
  75.                 }
  76.         return false;
  77.     }
  78.  
  79.     public int Fish() {
  80.         RSNPC fishingspot = getNearestNPCByID(328);
  81.         RSTile mloc = fishingspot.getLocation();
  82.                 if (distanceTo(mloc) > 4) {
  83.                         walkTileMM(mloc);
  84.                 wait(random(550,700));
  85.                 } if (fishingspot != null && tileOnScreen(fishingspot.getLocation())) {
  86.                         atNPC(fishingspot, "Lure");
  87.                 wait(random(550,700));
  88.                 } else {
  89.                         turnToTile(fishingspot.getLocation());
  90.                         }
  91.                 return random(550,700);
  92.         }
  93.  
  94.     public int antiban() {
  95.         final int randomn = random(0, 30);
  96.         if (randomn == 1) {
  97.                 if (getCurrentTab() != Constants.TAB_STATS) {
  98.                         openTab(Constants.TAB_STATS);
  99.                         moveMouse(new Point(674, 266), 59, 26);
  100.                         wait(random(650, 950));
  101.                         return random(1500, 3000);
  102.                 }
  103.         } else if (randomn == 2) {
  104.                 moveMouse(random(0, 450), random(0, 400));
  105.                 return random(400, 700);
  106.         } else if (randomn == 3) {
  107.                 openTab(Constants.TAB_INVENTORY);
  108.                 return random(400, 700);
  109.         } else if (randomn == 4) {
  110.                 moveMouse(random(0, 700), random(0, 500));
  111.                 return random(400, 700);
  112.         } else if (randomn == 5) {
  113.                 setCameraRotation(random(1, 359));
  114.                 return random(400, 700);
  115.         } else if (randomn == 6) {
  116.                 setCameraRotation(random(1, 359));
  117.                 return random(400, 700);
  118.         } else if (randomn == 7) {
  119.                 moveMouseSlightly();
  120.                 return random(400, 700);
  121.         }
  122.         return random(400, 700);
  123.     }
  124.     //everything below here is optional (small antiban)
  125.     public void tradeMethod() {
  126.         final int randomnum = random(1, 6);
  127.         if(randomnum == 1) {
  128.                 sendText("no thx", true);
  129.         } else if(randomnum == 2) {
  130.                 sendText("sry to busy to trade", true);
  131.         } else if(randomnum == 3) {
  132.                 sendText("cant trade right now", true);
  133.         } else if(randomnum == 4) {
  134.                 sendText("noty", true);
  135.         } else if(randomnum == 5) {
  136.                 sendText("no trades right now sry", true);
  137.         } else if(randomnum == 6) {
  138.                 sendText("to busy sry", true);
  139.         } else if(randomnum == 7) {
  140.                 sendText("to busy to trade sry", true);
  141.         }
  142.     }
  143.     //everything above here is optional(small antiban)
  144.     public void onFinish() {
  145.     /*I'm not sure if this is needed for the script to run but
  146.      * even if it isn't it's good measure to have it.
  147.     */
  148.     }
  149.  
  150.     public void serverMessageRecieved(ServerMessageEvent s) {
  151.         String msg = s.getMessage();
  152.         if(msg.contains("You catch a trout")) {
  153.             fishesCaught++ ;
  154.             troutXP += 50;
  155.         } if(msg.contains("You catch a salmon")) {
  156.                 fishesCaught++ ;
  157.                 salmonXP += 70;
  158.         } if (msg.contains("You've just advanced a Fishing")) {
  159.                 lvlsgained++;
  160.         }
  161.                
  162.       //everything below here is optional(small antiban)
  163.         if (msg.contains("wishes to trade")) {
  164.                 tradeMethod();
  165.         }
  166.       //everything above here is optional(small antiban)
  167.     }
  168.   //everything below here is optional(for custom cursor)
  169.     private class NAMMouse implements Runnable {
  170.         public boolean stopThread = false;
  171.         public void run() {
  172.                 while (!stopThread) {
  173.                         try {
  174.                                 final URL cursorURL = new URL(
  175.                         "http://i48.tinypic.com/313623n.png");
  176.                                 final URL cursor80URL = new URL(
  177.                                         "http://i46.tinypic.com/9prjnt.png");
  178.                                 normal = ImageIO.read(cursorURL);
  179.                                 clicked = ImageIO.read(cursor80URL);
  180.                         } catch (MalformedURLException e) {
  181.                                 log("Unable to buffer cursor.");
  182.                         } catch (IOException e) {
  183.                                 log("Unable to open cursor image.");
  184.                         }
  185.                         stopThread = true;
  186.                 }
  187.         }
  188.     }
  189.   //everything above here is optional(for custom cursor)
  190.  
  191.    public void onRepaint(Graphics g) {
  192.         if (isLoggedIn()) {
  193.                 //everything below here is optional(for better looking paint)
  194.                 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  195.                 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
  196.                 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
  197.                 //everything above here is optional(for better looking paint)
  198.                 //everything below here is optional (for custom cursor)
  199.                 if (normal != null) {
  200.                         final Mouse mouse = Bot.getClient().getMouse();
  201.                         final int mouse_x = mouse.getMouseX();
  202.                         final int mouse_y = mouse.getMouseY();
  203.                         final int mouse_x2 = mouse.getMousePressX();
  204.                         final int mouse_y2 = mouse.getMousePressY();
  205.                         final long mpt = System.currentTimeMillis() - mouse.getMousePressTime();
  206.                         if (mouse.getMousePressTime() == -1 || mpt >= 1000) {
  207.                         g.drawImage(normal, mouse_x - 8, mouse_y - 8, null);
  208.                         } if (mpt < 1000) {
  209.                         g.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null);
  210.                         g.drawImage(normal, mouse_x - 8, mouse_y - 8, null);
  211.                 }
  212.                 }
  213.                 //everything above here is optional (for custom cursor)
  214.                 long millis = System.currentTimeMillis() - startTime;
  215.                 long hours = millis / (1000 * 60 * 60);
  216.                 millis -= hours * (1000 * 60 * 60);
  217.                 long minutes = millis / (1000 * 60);
  218.                 millis -= minutes * (1000 * 60);
  219.                 long seconds = millis / 1000;
  220.                 //everything below is optional(for progress bar)
  221.                 final int percent = skills.getPercentToNextLevel(Constants.STAT_FISHING);
  222.                
  223.             g.setColor(Color.red);
  224.             g.fillRoundRect(48, 140, 100, 10, 15, 15);
  225.             g.setColor(Color.green);
  226.             g.fillRoundRect(48, 140, percent, 10, 15, 15);
  227.             g.setColor(Color.black);
  228.             g.drawString("" + percent, 94, 150);
  229.             g.drawRoundRect(48, 140, 100, 10, 15, 15);
  230.             //everything above is optional(for progress bar)
  231.             if (startXP <= 0) {
  232.                         startXP = skills.getCurrentSkillExp(STAT_FISHING);
  233.                 }
  234.                 exp = (skills.getCurrentSkillExp(STAT_FISHING) - startXP);
  235.                 if ((minutes > 0 || hours > 0 || seconds > 0) && exp > 0) {
  236.                         secondXP = (int) exp / (int) (seconds + minutes * 60 + hours * 60 * 60);
  237.                 }
  238.                 minuteXP = secondXP * 60;
  239.                 hourXP = minuteXP * 60;
  240.                 g.setColor(new Color(0, 147, 150, 120));
  241.                 g.fillRoundRect(20, 20, 240, 160, 8, 8);
  242.                 g.setColor(Color.white);
  243.                 g.drawString("ColdSun's Barbpowerfisher", 25, 35);  
  244.                 g.drawString("Ran For: " + hours + ":" + minutes + ":" + seconds, 25, 50);
  245.                 g.drawString("Fish Caught: " + fishesCaught, 25, 65);
  246.                 g.drawString("Levels Gained: " + lvlsgained, 25, 80);
  247.                 g.drawString("Exp Gained: " + exp, 25 , 95);
  248.                 g.drawString("Exp/h: " + hourXP, 25 , 110);
  249.                 g.drawString("Percent Untill Next Level: ", 25, 125);
  250.                 g.setColor(Color.red);
  251.             g.fillRoundRect(48, 140, 100, 10, 15, 15);
  252.             g.setColor(Color.green);
  253.             g.fillRoundRect(48, 140, percent, 10, 15, 15);
  254.             g.setColor(Color.black);
  255.             g.drawString("" + percent, 94, 150);
  256.             g.drawRoundRect(48, 140, 100, 10, 15, 15);
  257.             //everything above is optional(for progress bar
  258.                 g.drawString("Credits to Drew an Nebula for helping us... ", 25, 170);
  259.         }
  260.       }
  261. }