- import java.awt.*;
- import java.awt.image.BufferedImage;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.*;
- import javax.imageio.ImageIO;
- import org.rsbot.script.*;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.bot.Bot;
- import org.rsbot.bot.input.Mouse;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.event.events.ServerMessageEvent;
- @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")
- public class ColdSunspowerfisher extends Script implements PaintListener, ServerMessageListener {
- public RSTile fishingTile = new RSTile(3109, 3433);
- public int lvlsgained = 0;
- private int fishingspotID = 328 ;
- private int[] fishingthings = {309, 314};
- private int fishesCaught = 0;
- private int salmonXP = 0;
- private int troutXP = 0;
- private int exp = 0;
- public float secondXP = 0;
- public float minuteXP = 0;
- public float hourXP = 0;
- public long startTime = System.currentTimeMillis();
- public int startXP;
- public int nextEnergy = random(60, 90);
- BufferedImage normal = null; //optional for custom cursor
- BufferedImage clicked = null; //optional for custom cursor
- NAMMouse getMouse; //optional for custom cursor
- Thread m; //optional for custom cursor
- public boolean onStart(Map<String, String> args) {
- log("Loading...");
- getMouse = new NAMMouse(); //optional for custom cursor
- m = new Thread(getMouse); //optional for custom cursor
- m.start(); //optional for custom cursor
- wait(random(5000, 5500));
- return true;
- }
- public int loop() {
- setCameraAltitude(true);
- inventoryCheck();
- antiban();
- RSNPC fishingspot = getNearestNPCByID(fishingspotID);
- if(fishingspot == null){
- log("Looking for a spot...");
- wait(random(1000, 1800));
- } else if(isInventoryFull()) {
- log("Dropping Inventory...");
- dropAllExcept(fishingthings);
- } if(!isInventoryFull() && isIdle()) {
- Fish();
- }
- return random(550, 650);
- }
- public boolean inventoryCheck() {
- if(inventoryContains(fishingthings)) {
- return true;
- } else if(!inventoryContains(fishingthings)) {
- log("You do not have the required items, stopping script.");
- logout();
- stopScript(true);
- return true;
- }
- return false;
- }
- public int Fish() {
- RSNPC fishingspot = getNearestNPCByID(328);
- RSTile mloc = fishingspot.getLocation();
- if (distanceTo(mloc) > 4) {
- walkTileMM(mloc);
- wait(random(550,700));
- } if (fishingspot != null && tileOnScreen(fishingspot.getLocation())) {
- atNPC(fishingspot, "Lure");
- wait(random(550,700));
- } else {
- turnToTile(fishingspot.getLocation());
- }
- return random(550,700);
- }
- public int antiban() {
- final int randomn = random(0, 30);
- if (randomn == 1) {
- if (getCurrentTab() != Constants.TAB_STATS) {
- openTab(Constants.TAB_STATS);
- moveMouse(new Point(674, 266), 59, 26);
- wait(random(650, 950));
- return random(1500, 3000);
- }
- } else if (randomn == 2) {
- moveMouse(random(0, 450), random(0, 400));
- return random(400, 700);
- } else if (randomn == 3) {
- openTab(Constants.TAB_INVENTORY);
- return random(400, 700);
- } else if (randomn == 4) {
- moveMouse(random(0, 700), random(0, 500));
- return random(400, 700);
- } else if (randomn == 5) {
- setCameraRotation(random(1, 359));
- return random(400, 700);
- } else if (randomn == 6) {
- setCameraRotation(random(1, 359));
- return random(400, 700);
- } else if (randomn == 7) {
- moveMouseSlightly();
- return random(400, 700);
- }
- return random(400, 700);
- }
- //everything below here is optional (small antiban)
- public void tradeMethod() {
- final int randomnum = random(1, 6);
- if(randomnum == 1) {
- sendText("no thx", true);
- } else if(randomnum == 2) {
- sendText("sry to busy to trade", true);
- } else if(randomnum == 3) {
- sendText("cant trade right now", true);
- } else if(randomnum == 4) {
- sendText("noty", true);
- } else if(randomnum == 5) {
- sendText("no trades right now sry", true);
- } else if(randomnum == 6) {
- sendText("to busy sry", true);
- } else if(randomnum == 7) {
- sendText("to busy to trade sry", true);
- }
- }
- //everything above here is optional(small antiban)
- public void onFinish() {
- /*I'm not sure if this is needed for the script to run but
- * even if it isn't it's good measure to have it.
- */
- }
- public void serverMessageRecieved(ServerMessageEvent s) {
- String msg = s.getMessage();
- if(msg.contains("You catch a trout")) {
- fishesCaught++ ;
- troutXP += 50;
- } if(msg.contains("You catch a salmon")) {
- fishesCaught++ ;
- salmonXP += 70;
- } if (msg.contains("You've just advanced a Fishing")) {
- lvlsgained++;
- }
- //everything below here is optional(small antiban)
- if (msg.contains("wishes to trade")) {
- tradeMethod();
- }
- //everything above here is optional(small antiban)
- }
- //everything below here is optional(for custom cursor)
- private class NAMMouse implements Runnable {
- public boolean stopThread = false;
- public void run() {
- while (!stopThread) {
- try {
- final URL cursorURL = new URL(
- "http://i48.tinypic.com/313623n.png");
- final URL cursor80URL = new URL(
- "http://i46.tinypic.com/9prjnt.png");
- normal = ImageIO.read(cursorURL);
- clicked = ImageIO.read(cursor80URL);
- } catch (MalformedURLException e) {
- log("Unable to buffer cursor.");
- } catch (IOException e) {
- log("Unable to open cursor image.");
- }
- stopThread = true;
- }
- }
- }
- //everything above here is optional(for custom cursor)
- public void onRepaint(Graphics g) {
- if (isLoggedIn()) {
- //everything below here is optional(for better looking paint)
- ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
- //everything above here is optional(for better looking paint)
- //everything below here is optional (for custom cursor)
- if (normal != null) {
- final Mouse mouse = Bot.getClient().getMouse();
- final int mouse_x = mouse.getMouseX();
- final int mouse_y = mouse.getMouseY();
- final int mouse_x2 = mouse.getMousePressX();
- final int mouse_y2 = mouse.getMousePressY();
- final long mpt = System.currentTimeMillis() - mouse.getMousePressTime();
- if (mouse.getMousePressTime() == -1 || mpt >= 1000) {
- g.drawImage(normal, mouse_x - 8, mouse_y - 8, null);
- } if (mpt < 1000) {
- g.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null);
- g.drawImage(normal, mouse_x - 8, mouse_y - 8, null);
- }
- }
- //everything above here is optional (for custom cursor)
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- //everything below is optional(for progress bar)
- final int percent = skills.getPercentToNextLevel(Constants.STAT_FISHING);
- g.setColor(Color.red);
- g.fillRoundRect(48, 140, 100, 10, 15, 15);
- g.setColor(Color.green);
- g.fillRoundRect(48, 140, percent, 10, 15, 15);
- g.setColor(Color.black);
- g.drawString("" + percent, 94, 150);
- g.drawRoundRect(48, 140, 100, 10, 15, 15);
- //everything above is optional(for progress bar)
- if (startXP <= 0) {
- startXP = skills.getCurrentSkillExp(STAT_FISHING);
- }
- exp = (skills.getCurrentSkillExp(STAT_FISHING) - startXP);
- if ((minutes > 0 || hours > 0 || seconds > 0) && exp > 0) {
- secondXP = (int) exp / (int) (seconds + minutes * 60 + hours * 60 * 60);
- }
- minuteXP = secondXP * 60;
- hourXP = minuteXP * 60;
- g.setColor(new Color(0, 147, 150, 120));
- g.fillRoundRect(20, 20, 240, 160, 8, 8);
- g.setColor(Color.white);
- g.drawString("ColdSun's Barbpowerfisher", 25, 35);
- g.drawString("Ran For: " + hours + ":" + minutes + ":" + seconds, 25, 50);
- g.drawString("Fish Caught: " + fishesCaught, 25, 65);
- g.drawString("Levels Gained: " + lvlsgained, 25, 80);
- g.drawString("Exp Gained: " + exp, 25 , 95);
- g.drawString("Exp/h: " + hourXP, 25 , 110);
- g.drawString("Percent Untill Next Level: ", 25, 125);
- g.setColor(Color.red);
- g.fillRoundRect(48, 140, 100, 10, 15, 15);
- g.setColor(Color.green);
- g.fillRoundRect(48, 140, percent, 10, 15, 15);
- g.setColor(Color.black);
- g.drawString("" + percent, 94, 150);
- g.drawRoundRect(48, 140, 100, 10, 15, 15);
- //everything above is optional(for progress bar
- g.drawString("Credits to Drew an Nebula for helping us... ", 25, 170);
- }
- }
- }