//
// Script:
// Pro Fisher v0.17
//
// Author:
// Daniel Reed [Aelin]
//
// Features:
// Antiban [Random Exp Checker/Random Mouse Movement/Tab switches/Random camera
// movement]
// Anticombat
// Banking
// Multiple Fishing Modes
// Withdraw bait/gear
// Recover gear when lost.
// Power fishing
// Anti-whirlpool
// Paint debug, including xp gained, levels gained, percent to next level,
// catches, times avoided combat
// whirlpools avoided and time running.
// Added new paths for run from combat (More efficient than running all the way
// to the bank.)
//
// Credits:
// Flight - Used his whirlpool IDs.
// Transactions for loaning me a fishing guild account.
//
// Revision 0.17
// Starting in power mode and then restarting in banking mode now works.
//
// Revision 0.16
// Fixed barbarian village paths and fixed anti-whirlpool code.
//
// Revision 0.15
// Fixed a simple problem in banking.
//
// Revision 0.14
// Added paint functions by Photonman for est to next level.
//
// Revision 0.13
// Revised paths for barbarian village, both more efficient and doesn't seem to
// get stuck anymore.
//
// Revision 0.12
// Updated to work with non-deprecated RSBot #199+
//
// Revision 0.11
// Revised the average per hour counter.
//
// Revision 0.10
// Added catches per hour.
//
// Revision 0,09
// Added catches to next level.
//
// Revision 0.08
// Added parts of post and recovery (Will be added as they are discovered.)
//
// Revision 0.07
// Revised paths and ids for the fishing guild.
//
// Revision 0.06
// Further revised banking to fix bait fishing mode.
//
// Revision 0.05
// Revised banking code, seems to work better.
//
// Revision 0.04
// Fixed Catherby Double clicks.
//
// Revision 0.03
// Updated to work with latest Runescape revision.
// Updated run code.
//
// Revision 0.01
// Initial release.
//
import java.awt.*;
import java.util.Map;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;
public class ProFisher extends Script implements PaintListener {
RSTile[] toBank = new RSTile[] { new RSTile(3087, 3227),
new RSTile(3085, 3242), new RSTile(3092, 3243) };
RSTile[] toArea = reversePath(toBank);
RSTile[] lostTiles = new RSTile[] { new RSTile(2860, 3428) };
RSTile[] recoverTiles = new RSTile[] { new RSTile(2849, 3430) };
RSTile[] runAway;
RSTile[] runBack;
int[] fishingSpots = new int[] {
// Draynor:
327, 327,
// Barbarian Village:
328, 328, 328,
// Catherby:
320, 320, 321, 321, 322,
// Guild:
312, 312, 313 };
String[] fishingCommands = new String[] {
// Draynor
"Net", "Bait",
// Barbarian Village
"Bait", "Lure", "Lure",
// Catherby:
"Net", "Bait", "Cage", "Harpoon", "Harpoon",
// Guild:
"Cage", "Harpoon", "Harpoon" };
int[] gear = new int[] {
// Draynor:
303, 307,
// Barbarian Village:
307, 309, 309,
// Catherby
303, 307, 301, 311, 311,
// Fishing Guild:
301, 311, 311,
// To prevent deposit of baits.
313, 10087, 314 };
int[] bait = new int[] {
// Draynor:
0, 313,
// Barbarian Village:
313, 314, 314,
// Catherby:
0, 313, 0, 0, 0,
// Guild:
0, 0, 0 };
int[] whirlpools = new int[] { 403, 404, 406, 406 };
int bankBooth = 2213;
boolean powerMode = false;
long catches = 0;
long gainedExp = 0;
long gainedLevels = 0;
final int S_WALKTO_AREA = 1000;
final int S_WALKTO_BANK = 1500;
final int S_FISH = 2000;
final int S_USE_BANK = 2500;
final int S_USE_BANKSHILO = 2550;
final int S_DROP = 3000;
int state = S_FISH;
RSTile lumby = new RSTile(0, 0);
int selectedPath = 0;
int fails = 0;
final int maxFails = 25;
int mode = 0;
int checkTime;
long startTime;
long lastCheck;
int startLevel;
int startExp;
int oldExp;
int avoidedCombat;
int whirlpoolsAvoided;
int randomRun = random(20, 65);
int oldLevels;
int xpPerCatch = 0;
int countToNext = 0;
long oldCatches = 0;
long avgPerHour = 0;
long lastAvgCheck;
public String getAuthor() {
return "Aelin";
}
public String getName() {
return "Pro Fisher";
}
public double getVersion() {
return 0.17;
}
public String getScriptCategory() {
return "Fishing";
}
public String getScriptDescription() {
String html = "";
html += "<html>\n";
html += "<body>\n";
html += "<h2>" + getName() + " v" + getVersion() + "</h2><br>";
html += "<font size=\"2\">";
html += "Author: " + getAuthor() + "<br><br>";
html += "</font>";
html += "<form>";
html += "<font size=\"2\">";
html += "0 - Draynor - Shimp/Anchovies<br>";
html += "1 - Draynor - Herrings/Sardines<br>";
html += "2 - Barbarian Village - Pike<br>";
html += "3 - Barbarian Village - Trout/Salmon<br>";
html += "4 - Barbarian Village - Rainbow Fish<br>";
html += "5 - Catherby - Shimp/Anchovies<br>";
html += "6 - Catherby - Herring/Sardines<br>";
html += "7 - Catherby - Lobsters<br>";
html += "8 - Catherby - Tuna/Swordfish<br>";
html += "9 - Catherby - Sharks<br>";
html += "10 - Fishing Guild - Lobsters<br>";
html += "11 - Fishing Guild - Tuna/Swordfish<br>";
html += "<12 - Fishing Guild - Sharks<br>";
// html += "<13 - Pictoris - Monkfish<br>";
html += "Mode: <input type=\"text\" name=\"mode\" value=\"10\"><br>";
html += "<input type=\"radio\" name=\"power\" value=\"true\">Powerfishing Mode<br>";
html += "</font>";
html += "</form>";
html += "</html>\n";
return html;
}
//
// onStart( )
//
public boolean onStart(Map<String, String> args) {
// Add server listeners.
Bot.getEventManager().addListener(PaintListener.class, this);
// Bot.getEventManager( ).addListener(ServerMessageListener.class,
// this);
// log( args.get("selmode") );
try {
mode = Integer.parseInt(args.get("mode"));
if (args.get("power").equals("true")) {
powerMode = true;
log("Power-fishing mode activated.");
} else {
powerMode = false;
log("Power-mining mode deactivated.");
}
} catch (Exception e) {
}
// Is the selected mode a draynor mode?
if (mode >= 0 && mode <= 1) {
log("Setting paths for draynor.");
toBank = new RSTile[] { new RSTile(3087, 3227),
new RSTile(3085, 3242), new RSTile(3092, 3243) };
toArea = reversePath(toBank);
runAway = toBank;
runBack = toArea;
}
// Is the selected mode a barbarian village mode?
if (mode >= 2 && mode <= 4) {
// Yes, set paths and ids accordingly.
log("Setting paths for barbarian village.");
toBank = new RSTile[] { new RSTile(3103, 3434),
new RSTile(3098, 3437), new RSTile(3091, 3447),
new RSTile(3089, 3459), new RSTile(3100, 3469),
new RSTile(3100, 3484), new RSTile(3094, 3491) };
toArea = reversePath(toBank);
bankBooth = 26972;
}
// Is the selected mode a catherby mode?
if (mode >= 5 && mode <= 9) {
// Yes, set paths and ids accordingly.
log("Setting paths for catherby.");
toBank = new RSTile[] { new RSTile(2848, 3430),
new RSTile(2839, 3435), new RSTile(2822, 3438),
new RSTile(2810, 3440) };
toArea = reversePath(toBank);
bankBooth = 2213;
}
// Is the selected mode a guild mode?
if (mode >= 10 && mode <= 12) {
// Yes, set paths and ids accordingly.
log("Setting paths for the fishing guild.");
toBank = new RSTile[] { new RSTile(2599, 3421),
new RSTile(2594, 3414), new RSTile(2588, 3420) };
toArea = reversePath(toBank);
bankBooth = 2213;
}
// Is the selected mode a pictoris mode?
if (mode == 13) {
// Yes, set paths and IDs accordingly.
log("Setting paths for pictoris.");
}
return true;
}
//
// onFinish( )
//
public void onFinish() {
// Remove listeners.
Bot.getEventManager().removeListener(PaintListener.class, this);
// Bot.getEventManager( ).removeListener(ServerMessageListener.class,
// this);
}
//
// loop( )
//
public int loop() {
// Lost/Recover
// If enough energy and run enable, then enable run.
if (getEnergy() >= randomRun && !isRunning()) {
log("Setting run.");
randomRun = random(20, 65);
setRun(true);
return random(500, 750);
}
// If the player is moving, antiban.
if (getMyPlayer().isMoving()) {
return antiBan();
}
// Stop script if fails is too high.
if (fails >= maxFails) {
// Stop all scripts.
stopAllScripts();
}
// Process script events, based on state.
switch (state) {
// S_WALKTO_AREA - Walk to fishing area.
case S_WALKTO_AREA:
// Is the play missing gear and is the gear laying on the
// ground?
RSItemTile itemTile = getGroundItemByID(gear[mode]);
if (getInventoryCount(gear[mode]) == 0 && itemTile != null) {
if (tileOnScreen(itemTile)) {
log("Recovered gear.");
atTile(itemTile, "Take");
return random(500, 750);
} else {
log("Walking to gear location.");
walkTileMM(itemTile);
return random(500, 750);
}
}
// Does the player have the gear needed for the current mode?
if (getInventoryCount(gear[mode]) <= 0) {
// No, so head to the bank for new gear.
log("No gear for the current fishing mode, heading to bank for more.");
state = S_WALKTO_BANK;
return random(500, 750);
}
// Does the player need bait?
if (bait[mode] != 0) {
// Yes, do we have some?
if (getInventoryCount(bait[mode]) <= 0) {
// No, so head to the bank and withdraw some more.
log("Not enough bait to continue, heading to bank for more.");
state = S_WALKTO_BANK;
return random(500, 750);
}
}
// Is the player currently near the destination?
if (distanceTo(toArea[toArea.length - 1]) <= 2) {
// Yes, so start fishing and select next random path.
log("Ariving at fishing area, switching to fishing mode.");
state = S_FISH;
return random(500, 750);
} else {
// No, so continue to walk path.
if (!getMyPlayer().isMoving()) {
walkPathMM(randomizePath(toArea, 2, 2), 20);
}
return random(500, 750);
}
// S_WALKTO_BANK - Walks to the bank.
case S_WALKTO_BANK:
// Is the player currently near the destination?
if (distanceTo(toBank[toBank.length - 1]) <= 2) {
// Yes, so start banking.
log("Ariving at bank, making deposit.");
state = S_USE_BANK;
return random(500, 750);
} else {
// No, so continue to walk path.
if (!getMyPlayer().isMoving()) {
walkPathMM(randomizePath(toBank, 2, 2), 20);
}
return random(500, 750);
}
// S_FISH - Fishes based on current mode.
case S_FISH:
RSNPC spot = getNearestNPCByID(fishingSpots[mode]);
RSNPC whirl = getNearestNPCByID(whirlpools);
RSTile loc1 = new RSTile(
getMyPlayer().getLocation().getX() + 1, getMyPlayer()
.getLocation().getY());
RSTile loc2 = new RSTile(
getMyPlayer().getLocation().getX() - 1, getMyPlayer()
.getLocation().getY());
RSTile loc3 = new RSTile(getMyPlayer().getLocation().getX(),
getMyPlayer().getLocation().getY() + 1);
// RSTile loc4 = new RSTile(getMyPlayer().getLocation().getX(),
// getMyPlayer().getLocation().getY() - 1);
// Is the play missing gear and is the gear laying on the
// ground?
itemTile = getGroundItemByID(gear[mode]);
if (getInventoryCount(gear[mode]) == 0 && itemTile != null) {
if (tileOnScreen(itemTile)) {
log("Recovered gear.");
atTile(itemTile, "Take");
return random(500, 750);
} else {
log("Walking to gear location.");
walkTileMM(itemTile);
return random(500, 750);
}
}
// Anticombat: Is the player currently in combat?
if (getMyPlayer().isInCombat()) {
// Yes, so run to bank.
log("Running away from combat.");
avoidedCombat++;
state = S_WALKTO_BANK;
return random(500, 750);
}
// Is the player currently busy?
if (getMyPlayer().getAnimation() != -1
|| getMyPlayer().isMoving()) {
if (whirl != null) {
if (whirl.getLocation().equals(loc1)
|| whirl.getLocation().equals(loc2)
|| whirl.getLocation().equals(loc3)
|| whirl.getLocation().equals(loc1)) {
log("Avoiding whirlpool.");
whirlpoolsAvoided++;
}
} else {
return antiBan();
}
}
// Does the player have the gear needed for the current mode?
if (getInventoryCount(gear[mode]) <= 0) {
// No, so head to the bank for new gear.
log("No gear for the current fishing mode, heading to bank for more.");
state = S_WALKTO_BANK;
return random(500, 750);
}
// Does the player need bait?
if (bait[mode] != 0) {
// Yes, do we have some?
if (getInventoryCount(bait[mode]) <= 0) {
// No, so head to the bank and withdraw some more.
log("Not enough bait to continue, heading to bank for more.");
state = S_WALKTO_BANK;
return random(500, 750);
}
}
// Is the inventory full?
if (isInventoryFull()) {
// Yes, so are we power-fishing?
if (powerMode) {
// Yes, so drop.
log("The inventory is full, dropping all the catches.");
state = S_DROP;
return random(500, 750);
} else {
// No, so bank.
log("The inventory is full, heading to the bank.");
state = S_WALKTO_BANK;
return random(500, 750);
}
}
// Was a fishing spot found?
if (spot != null) {
// Yes, so reset fails.
fails = 0;
// Is the spot nearby?
if (tileOnScreen(spot.getLocation())) {
// Yes, so fish.
atNPC(spot, fishingCommands[mode]);
return random(1000, 1500);
} else {
// No, so walk to the fishing spots location.
walkTileRand(spot.getLocation());
return random(500, 750);
}
} else {
for (int i = 0; i < lostTiles.length; i++) {
RSTile lost = lostTiles[i];
if (distanceTo(lost) <= 4) {
log("Currently lost, returning.");
walkTileRand(recoverTiles[i]);
return random(500, 750);
}
}
// No, so increment fails and try again.
log("Couldn't find a fishing spot, trying "
+ (maxFails - fails) + " more times.");
fails++;
return random(1500, 3000);
}
// S_USE_BANK - Makes deposits.
case S_USE_BANK:
RSObject booth = findObject(bankBooth);
if (RSInterface.getInterface(INTERFACE_BANK).isValid()) {
bank.close();
}
// Was the booth found?
if (booth != null) {
// Is the bank on screen?
if (tileOnScreen(booth.getLocation())) {
// Yes, so use it.
atObject(booth, "Use-quickly");
wait(random(500, 750));
// Did the bank open?
if (!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
// No, so retry.
log("Unable to access account, trying "
+ (maxFails - fails) + " more times.");
fails++;
return random(500, 750);
}
// Deposit all except gear.
bank.depositAllExcept(gear);
// Does the current mode require bait?
if (bait[mode] != 0
&& getInventoryCount(bait[mode]) == 0) {
// Yes, so does the bank have bait?
if (bank.getCount(bait[mode]) == 0) {
// No, so stop script.
log("There is no bait in the bank, exiting.");
stopAllScripts();
} else {
// Yes, so withdraw.
bank.atItem(bait[mode], "Withdraw-All");
}
}
// Is the player out of gear and there is none in the
// bank?
if (getInventoryCount(gear[mode]) == 0
&& bank.getCount(gear[mode]) == 0) {
// No, so stop script.
log("No gear in inventory and no gear in the bank, exiting.");
stopAllScripts();
} else {
// Yes, so withdraw.
bank.atItem(gear[mode], "Withdraw 1");
}
// Is the inventory still full?
if (isInventoryFull()) {
// Yes, so rebank.
log("Inventory is still full, rebanking.");
return random(500, 750);
} else {
// No, so head back to the spots.
log("Banked all, heading back to area.");
state = S_WALKTO_AREA;
return random(500, 750);
}
} else {
// No, so walk to the booth.
log("Found bank, but it isn't on screen, walking to location.");
walkTileRand(booth.getLocation());
return random(500, 750);
}
} else {
// No, so increment fails and try again.
log("Unable to find a bank booth, trying "
+ (maxFails - fails) + " more times.");
fails++;
return random(1500, 3000);
}
// S_DROP - Drop inventory, use for power fishing.
case S_DROP:
log("Dropping everything except gear.");
dropAllExcept(gear);
state = S_FISH;
return random(500, 750);
// Default - Unknown state.
default:
log("Unknown state: " + state + " terminating script.");
return -1;
}
}
//
// walkTileRand( )
//
// This method provides a means for the script to walk to a location more
// randomly than RSBot's standard walkTileMM function.
//
public void walkTileRand(RSTile tile) {
// Local objects:
RSTile temp = new RSTile(tile.getX() + random(-2, 2), tile.getY()
+ random(-2, 2));
walkTileMM(temp);
}
//
// antiBan( )
//
// This method provides a psuedo means of antiBan.
// Not sure that this is the greatest method of anti-ban, due
// to it's repetiveness.
//
int antiBan() {
int GambleInt = random(1, 6);
switch (GambleInt) {
case 1:
wait(random(1000, 1500));
break;
case 2:
int x = random(0, 750);
int y = random(0, 500);
moveMouse(0, 0, x, y);
return random(1000, 1500);
case 3:
// Is the current tab the inventory?
if (getCurrentTab() != TAB_INVENTORY) {
// No, so switch to the inventory tab.
openTab(TAB_INVENTORY);
return random(500, 750);
} else {
// No, so return
return random(500, 750);
}
case 4:
// If the player is moving, then abort.
if (getMyPlayer().isMoving()) {
return random(750, 1000);
}
if (System.currentTimeMillis() - lastCheck >= checkTime) {
lastCheck = System.currentTimeMillis();
checkTime = random(60000, 180000);
if (getCurrentTab() != TAB_STATS) {
openTab(TAB_STATS);
}
moveMouse(663, 292, 50, 28);
return random(5000, 8000);
}
case 5:
if (random(1, 8) == 2) {
int angle = getCameraAngle() + random(-90, 90);
if (angle < 0) {
angle = 0;
}
if (angle > 359) {
angle = 0;
}
setCameraRotation(angle);
}
return random(500, 750);
}
return random(500, 1000);
}
//
// onRepaint( )
//
// This method is called every time the graphics is updated.
//
//
// onRepaint( )
//
// This method is called every time the graphics is updated.
//
public void onRepaint(Graphics g) {
/*
* Graphics h = image.getGraphics(); try { ImageIO.write(image, "jpg",
* new File("progressReport.jpg")); } catch (IOException e) {
* e.printStackTrace(); }
*/
// local objects:
int index = Skills.getStatIndex("Fishing");
int exp = 0;
int levels;
long hours = 0, minutes = 0, seconds = 0;
long time;
long untilhour = 0, untilmin = 0, untilsec = 0;
double temptime = 0;
// Has start time been previously set?
if (startTime == 0) {
startTime = System.currentTimeMillis();
}
// Calculate hours, minutes and seconds.
time = System.currentTimeMillis() - startTime;
seconds = time / 1000;
if (seconds >= 60) {
minutes = seconds / 60;
seconds -= minutes * 60;
}
if (minutes >= 60) {
hours = minutes / 60;
minutes -= hours * 60;
}
// Has variables been previously defined?
if (startLevel == 0 || startExp == 0) {
// No, so define them now.
startLevel = skills.getCurrentSkillLevel(index);
startExp = skills.getCurrentSkillExp(index);
oldExp = 0;
}
// Calculate catches based on experience changes.
exp = skills.getCurrentSkillExp(index) - startExp;
if (exp > oldExp) {
xpPerCatch = exp - oldExp;
oldExp = exp;
catches++;
countToNext = skills.getXPToNextLevel(STAT_FISHING) / xpPerCatch
+ 1;
}
// Calculate levels gained.
levels = skills.getCurrentSkillLevel(index) - startLevel;
if (levels > oldLevels) {
oldLevels = levels;
}
//
if (System.currentTimeMillis() - lastAvgCheck >= 60000) {
lastAvgCheck = System.currentTimeMillis();
avgPerHour = (catches - oldCatches) * 60;
oldCatches = catches;
}
if (countToNext == 0) {
untilsec = 0;
untilhour = 0;
untilmin = 0;
} else {
if (avgPerHour == 0) {
untilsec = 0;
untilhour = 0;
untilmin = 0;
} else {
temptime = (double) countToNext / avgPerHour;
untilsec = (int) (temptime * 3600);
untilmin = untilsec / 60;
untilsec -= untilmin * 60;
untilhour = untilmin / 60;
untilmin -= untilhour * 60;
}
}
// Draw information.
g.setColor(Color.WHITE);
g.drawString(getName() + " v" + getVersion(), 9, 171);
g.drawString("XP Gained: " + exp, 9, 187);
g.drawString("Levels Gained: " + levels, 9, 203);
g.drawString("Percent to next level: "
+ skills.getPercentToNextLevel(index), 9, 219);
g.drawString("Catches: " + catches, 9, 235);
g.drawString("Catches to next level: " + countToNext, 9, 251);
g.drawString("Times avoided combat: " + avoidedCombat, 9, 267);
g.drawString("Whirlpools Avoided: " + whirlpoolsAvoided, 9, 283);
g.drawString("Time running: " + hours + "." + minutes + "." + seconds,
9, 299);
g.drawString("Average per hour: " + avgPerHour, 9, 315);
g.drawString("Est time untill next level: " + untilhour + "."
+ untilmin + "." + untilsec, 9, 331);
/*
* h.setColor( Color.WHITE ); h.drawString(getName( ) + " v" +
* getVersion( ), 9, 171); h.drawString("XP Gained: " + exp, 9, 187);
* h.drawString("Levels Gained: " + levels, 9, 203);
* h.drawString("Percent to next level: " +
* skills.getPercentToNextLevel( index ), 9, 219);
* h.drawString("Catches: " + catches, 9, 235); h.drawString("Catches to
* next level: " + countToNext, 9, 251); h.drawString("Times avoided
* combat: " + avoidedCombat, 9, 267); h.drawString("Whirlpools Avoided: " +
* whirlpoolsAvoided, 9, 283); h.drawString("Time running: " + hours +
* "." + minutes + "." + seconds, 9, 299); h.drawString("Average per
* hour: " + avgPerHour, 9, 315); h.drawString("Est time untill next
* level: " + untilhour + "." + untilmin + "." + untilsec , 9, 331);
*/
}
// Modified to drop all except:)
public boolean dropAllExcept(int... items) {
boolean drop = false;
for (int item : getInventoryArray()) {
drop = true;
for (int nodrop : items) {
if (item == nodrop) {
drop = false;
}
}
if (drop && item != -1) {
for (int i = 0; i < getInventoryCount(item); i++) {
atInventoryItem(item, "Drop");
wait(random(500, 750));
}
}
}
return true;
}
}