import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import com.speljohan.rsbot.event.events.*;
import com.speljohan.rsbot.event.listeners.*;
import com.speljohan.rsbot.accessors.*;
import com.speljohan.rsbot.account.*;
import com.speljohan.rsbot.bot.*;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.script.*;
public class TehGuildFisher extends Script {
public String getAuthor( ) {
return "Mike_";
}
public String getName( ) {
return "Teh Guild Fisher";
}
public boolean isInGuild() {
int[] nameX = {2617,2616,2616,2595,2592,2592,2589,2589,2588,2588,2586,2585,2585,2582,2580,2579,2579,2580,2590,2592,2606,2613};
int[] nameY = {3401,3398,3394,3394,3396,3398,3401,3405,3406,3408,3409,3410,3413,3415,3415,3416,3423,3425,3425,3424,3427,3417};
Polygon name=new Polygon(nameX, nameY, 22);
if(name.contains(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY()))
return true;
return false;
}
public double getVersion( ) {
return 1.0;
}
public String getScriptCategory() {
return "Mike's Scripts";
}
public String getScriptDescription( ) {
String html="";
html += "
";
html += "";
html += "";
html += "";
html += "Teh Guild Fisher! Fish n shet.
";
html += "Fish Sharks";
html += "";
html += "";
return html;
}
long nextAnti = 0;
boolean combat = false;
int swordsBanked = 0;
int sharksBanked = 0;
int tunasBanked = 0;
int spot=312;
long startTime;
long nextLog;
public boolean onStart( Map args ) {
startTime=System.currentTimeMillis();
spot=312;
nextAnti = 0;
combat = false;
swordsBanked = 0;
sharksBanked = 0;
tunasBanked = 0;
if(args.get("sharks") != null)
spot=313;
return true;
}
public void onFinish( ) {
}
public int loop( ) {
RSCharacter temp = getMyPlayer().getInteracting();
RSNPC interacting=null;
if(temp!=null)
interacting=getNPCAt(temp.getLocation());
if(interacting != null) {
if(interacting.getID() == 403 || interacting.getID() == 404 || interacting.getID() == 406) {
atTile(getMyPlayer().getLocation(), "alk here");
return fish();
}
if(interacting.getID() == 312 && spot!= 312 || interacting.getID() == 313 && spot!= 313) {
return fish();
}
}
RSItemTile itemTile = getGroundItemByID(10129);
if (!isCarryingItem(10129) && itemTile != null) {
if (tileOnScreen(itemTile)) {
log("Recovered gear.");
atTile(itemTile, "Take");
return random(500, 750);
}
}
if(getMyPlayer().isInCombat())
return bank();
if(inventoryContains(10129) && !equipmentContains(10129)) {
atInventoryItem(10129, "ield");
return random(50,100);
}
if(getMyPlayer().getAnimation() != -1 || getMyPlayer().isMoving()) {
if(System.currentTimeMillis() > nextAnti) {
moveMouse(random(10,510),random(10,330));
nextAnti=System.currentTimeMillis()+1000*random(random(random(10,30),40),59);
}
return random(50,100);
}
nextAnti=System.currentTimeMillis()+1000*59*random(4,5);
if(isInventoryFull())
return bank();
if(bank.getInterface().isValid())
bank.close();
if(isCarryingItem(10129) && isInGuild())
return fish();
if(random(0,30)==9) //im a lazy fuck...and this should do the trick. will logout in around a minute if theres a problem.
return -1;
return random(1000,1500);
}
public void prog() {
long millis = System.currentTimeMillis() - startTime;
long seconds2 = millis / 1000;
long hours = millis / (1000 * 60 * 60);
millis -= hours * 1000 * 60 * 60;
long minutes = millis / (1000 * 60);
millis -= minutes * 1000 * 60;
long seconds = millis / 1000;
String hoursString = "";
String minutesString = "";
String secondsString = seconds + "";
String type = "seconds";
if (minutes > 0) {
minutesString = minutes + ":";
type = "minutes";
}
if (hours > 0) {
hoursString = hours + ":";
type = "hours";
}
if (minutesString.length() == 1) {
minutesString = "0" + minutesString;
}
if (hoursString.length() == 1) {
hoursString = "0" + hoursString;
}
if (secondsString.length() == 1) {
secondsString = "0" + secondsString;
}
long time = System.currentTimeMillis()-startTime;
log("---------------------------------------------");
log("----------TehGuildFisher by Mike_------------");
log("Running for " + hoursString + minutesString + secondsString + " " + type + ".");
log("Sharks Banked: "+sharksBanked);
log("Swords Banked: "+swordsBanked);
log("Tunas Banked: "+tunasBanked);
log("Averaging " + ((tunasBanked+swordsBanked+sharksBanked) * 3600 / seconds2) + " fish per hour.");
log("---------- Have a nice day ------------");
log("---------------------------------------------");
}
public int fish() {
if(bank.getInterface().isValid()) {
bank.close();
return random(50,100);
}
RSNPC fish = getNearestNPCByID(spot);
RSTile fishingSpot;
if(fish == null)
if(random(0,30)==15)
return -1;
else
fishingSpot = new RSTile(2599,3422);
else
fishingSpot = fish.getLocation();
if(atTile(fishingSpot, "harpoon"))
return random(250,1000);
if(distanceTo(fish) > 4) {
walkPathMM(randomizePath(fixPath2(fishingSpot),2,2),17);
} else {
turnToTile(fishingSpot);
}
if(atTile(fishingSpot, "harpoon"))
return random(250,1000);
return random(50,100);
}
public int bank() {
if(distanceTo(new RSTile(2587,3420)) > 6) {
walkPathMM(randomizePath(fixPath2(new RSTile(2587,3420)),2,2),17);
return random(250,500);
}
if(bank.getInterface().isValid()) {
int sharksTemp = getInventoryCount(383);
int swordsTemp = getInventoryCount(371);
int tunasTemp = getInventoryCount(359);
depositAllExcept(10129);
wait(random(2000,3000));
if(getInventoryCount(383) != sharksTemp)
sharksBanked+=sharksTemp;
if(getInventoryCount(371) != swordsTemp)
swordsBanked+=swordsTemp;
if(getInventoryCount(359) != tunasTemp)
tunasBanked+=tunasTemp;
prog();
return random(50,100);
}
RSObject banker = findObject(2213);
if(banker == null)
return random(50,500);
if(atObject(banker, "Use-quickly"))
return random(500,1000);
turnToObject(banker);
return random(250,500);
}
public RSTile[] fixPath2(RSTile tile) {
return fixPath2(getMyPlayer().getLocation().getX(),getMyPlayer().getLocation().getY(), tile.getX(), tile.getY());
}
public RSTile[] fixPath2(RSTile tile, RSTile tile2) {
return fixPath2(tile.getX(), tile.getY(), tile2.getX(), tile2.getY());
}
public RSTile[] fixPath2(int startX, int startY, int destinationX, int destinationY) { //most credits to aftermath
double dx, dy;
ArrayList list = new ArrayList();
list.add(new RSTile(startX, startY));
while(Math.hypot(destinationY - startY, destinationX - startX) > 8) {
dx = destinationX - startX;
dy = destinationY - startY;
int gamble = random(14,17);
while(Math.hypot(dx, dy) > gamble) {
dx *= .95;
dy *= .95;
}
startX += (int) dx;
startY += (int) dy;
list.add(new RSTile(startX, startY));
}
list.add(new RSTile(destinationX, destinationY));
return list.toArray(new RSTile[list.size()]);
}
public RSNPC getNPCAt(RSTile t) {
int Dist = 20;
RSNPC closest = null;
int[] validNPCs = Bot.getClient().getNPCIndexArray();
NPC[] npcs = Bot.getClient().getNPCArray();
for (int element : validNPCs) {
if (npcs[element] == null) {
continue;
}
RSNPC Monster = new RSNPC(npcs[element]);
try {
if(Monster.getLocation().equals(t))
return Monster;
} catch (Exception e) {
e.printStackTrace();
}
}
log("NpcAt: None");
return null;
}
}