package scripts;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.util.HashMap;
import java.util.Random;
import org.tribot.api.Banking;
import org.tribot.api.Game;
import org.tribot.api.Inventory;
import org.tribot.api.Minimap;
import org.tribot.api.Player;
import org.tribot.api.ScreenModels;
import org.tribot.api.Timing;
import org.tribot.api.input.Mouse;
import org.tribot.api.types.InventoryItem;
import org.tribot.api.types.MinimapIcon;
import org.tribot.api.types.ScreenModel;
import org.tribot.script.Script;
import org.tribot.script.ScriptManifest;
import org.tribot.script.interfaces.Arguments;
import org.tribot.script.interfaces.Painting;
@ScriptManifest(authors = { "Emu" }, category = "Fishing", name = "Draynor Fisher v0.1",
description =
"<html>"+
"<head>"+
" <title>Emu's Fisher</title>"+
"</head>"+
"<body>"+
" <h1>"+
" Emu's Draynor Fisher V0.1</h1>"+
" <p>"+
" Credits: JJ for Paint and Methods, Mercatres for GUI</p>"+
" <p>"+
" How to use:</p>"+
" <ul>"+
" <li>"+
" Start at Draynor Village willows 2, squares away from other players</li>"+
" <li>"+
" Have a net in your toolbelt (NOT in your inventory), Have your inventory tab open</li>"+
" <li>"+
" Have the camera 'up' as high as possible (Birds' Eye View)</li>"+
" <li>"+
" Fill out the GUI below</li>"+
" <li>"+
" Click Start!</li>"+
" </ul>"+
" <p>"+
" Enter Mouse Speed <input maxlength=\"3\" name=\"MouseSpeed\" type=\"text\" value=\"80\" /></p>"+
" <p>"+
" Number of Trips <input maxlength=\"9\" name=\"runtime\" type=\"text\" value=\"60\" /></p>"+
" <p>"+
" Please report any bugs on the forums - Thanks!</p>"+
" <hr />"+
"</body>"+
"</html>")
public class EmusDraynorFisherAlphaRelease extends Script implements Painting, Arguments {
final Random Randomizer = new Random();
long startTime = 0, animationID = 0, playerID = 0;
final long[] notAnimation = {1417827556L, 4390934L, 2457391002L, 949177853L};
public String status;
final long fishspotID = 2704514198L;
final int fishID = 282419, FishID = 8292, BankID = 30858, bankcounterID = 1189553980;
public long idle = 0;
public int temp = 0;
int stoptime = 60, mspeed = 50, totaltrips = 0;
final Point mmMiddle = new Point(627, 135);
public boolean killswitch = false;
@Override
public void passArguments(HashMap<String, String> m) {
mspeed = Integer.parseInt(m.get("MouseSpeed"));
stoptime = Integer.parseInt(m.get("runtime"));
}
@Override
public void onPaint(Graphics g){
g.setColor(Color.WHITE);
g.drawString("Emu's Draynor Fisher v0.1", 5, 100);
g.drawString("Time Running: " + Timing.msToString(System.currentTimeMillis() - startTime), 5, 120);
g.drawString("Player ID: " + playerID, 5, 140);
g.drawString("Animation ID: " + animationID, 5, 160);
g.drawString("Status: " + status, 5, 180);
g.drawString("Mouse Speed: " + mspeed, 5, 200);
g.drawString("Current Trip: " + totaltrips, 5, 220);
g.drawString("Stopping At: " + stoptime , 5, 240);
g.drawString("Credits: JJ for Paint and Methods", 5, 355);
}
private void grabID(String which){
if (which.equals("animationID") || which.equals("playerID")){
ScreenModel[] ids = ScreenModels.getAll();
for (int i=0; i<ids.length; i++){
if (ids[i].points[0].x > 220 && ids[i].points[0].x < 310){
if (ids[i].points[0].y > 180 && ids[i].points[0].y < 250){
int k=0;
for (int j=0; j<notAnimation.length; j++){
if (ids[i].id != notAnimation[j]){
k++;
}
}
if (k == notAnimation.length){
if (which.equals("animationID")){
if (ids[i].id != playerID)
animationID = ids[i].id;
}else{
playerID = ids[i].id;
}
break;
}
}
}
}
}
}
public long getAnimationID() {
ScreenModel[] ids = ScreenModels.getAll();
for (int i=0; i<ids.length; i++){
if (ids[i].points[0].x > 250 && ids[i].points[0].x < 280){
if (ids[i].points[0].y > 190 && ids[i].points[0].y < 230){
animationID = ids[i].id;
break;
}
}
}
return animationID;
}
public boolean animationcheck(){
if(getAnimationID()==playerID){
return true;
} else {
return false;
}
}
public boolean findfish(){
ScreenModel[] fish = ScreenModels.find(fishspotID);
if(fish.length > 0){
sleep(500, 700);
return true;
} else {
sleep(500, 700);
return false;
}
}
public void EScreenMouse(long fishspotID2){
ScreenModel[] object = ScreenModels.find(fishspotID2);
int x = Randomizer.nextInt(20);
switch(x){
case 1: Point FS = new Point(object[temp].points[temp].x - Randomizer.nextInt(30), object[temp].points[temp].y - Randomizer.nextInt(16)); Mouse.move(FS);
case 2: Point FD = new Point(object[temp].points[temp].x + Randomizer.nextInt(17), object[temp].points[temp].y - Randomizer.nextInt(24)); Mouse.move(FD);
case 3: Point FF = new Point(object[temp].points[temp].x - Randomizer.nextInt(12), object[temp].points[temp].y + Randomizer.nextInt(22)); Mouse.move(FF);
case 4: Point FG = new Point(object[temp].points[temp].x + Randomizer.nextInt(24), object[temp].points[temp].y + Randomizer.nextInt(17)); Mouse.move(FG);
default: sleep(300, 400);
}
}
public boolean fishspot(){
boolean tempwtf = false;
if((findfish()) && (animationcheck())){
EScreenMouse(fishspotID);
ScreenModel[] fish = ScreenModels.find(fishspotID);
// Credits JJ
Point FS = new Point(fish[temp].points[temp].x - Randomizer.nextInt(10), fish[temp].points[temp].y - Randomizer.nextInt(10));
if (FS.y < 160 || FS.y > 430){
status = "Moving to Fish";
}else{
Mouse.move(FS);
if (Timing.waitUptext("Net Fishing Spot", 800)){
sleep(50, 100);
Mouse.click(1);
sleep(1300, 2000);
tempwtf = true;
}else{
Mouse.click(3);
sleep(50, 100);
Timing.waitChooseOption("Net", 800);
sleep(1300, 2000);
tempwtf = true;
}
}
}
while(Player.isMoving()){
sleep(2000, 3000);
}
return tempwtf;
}
public void movetoloc(int ID){
MinimapIcon[] symbol = Minimap.findIcons(ID);
if (symbol.length < 3){
Point SS = new Point(symbol[0].x + Randomizer.nextInt(5), symbol[0].y + Randomizer.nextInt(5));
Mouse.move(SS);
Mouse.click(SS, 1);
sleep(3000, 5000);
}
}
public boolean bankall(){
while(Player.isMoving()){
sleep(1000, 2000);
}
EScreenMouse(bankcounterID);
ScreenModel[] bank = ScreenModels.find(bankcounterID);
// Clicking on the fishing spot, if there are two then randomly picks one
Point FS = new Point(bank[temp].points[temp].x + Randomizer.nextInt(10), bank[temp].points[temp].y + Randomizer.nextInt(10));
Mouse.move(FS);
if (Timing.waitUptext("Bank Counter", 800)){
sleep(50, 100);
Mouse.click(1);
sleep(1300, 2000);
return true;
}else{
Mouse.click(3);
sleep(50, 100);
if ((Timing.waitChooseOption("Bank Counter", 800)) || (Timing.waitChooseOption("Bank Banker", 800))){
sleep(1300, 2000);
return true;
}
}
return false;
}
public void depositfish(){
InventoryItem[] fish =Inventory.find(fishID);
int randtemp = (Randomizer.nextInt(fish.length));
if(randtemp<1){
randtemp = randtemp - 1;
}
Point FS = new Point(fish[randtemp].x - Randomizer.nextInt(2) + 15, fish[randtemp].y - Randomizer.nextInt(2) + 15);
Mouse.move(FS);
if (Timing.waitUptext("Deposit", 800)){
if (fish.length == 1){
Mouse.click(1);
} else {
Mouse.click(3);
sleep(50, 200);
if(Timing.waitChooseOption("All", 800)){
sleep(600, 800);
}
}
}
}
public void antiban(){
int x = Randomizer.nextInt(20);
switch(x){
case 1: mouseoffscreen();
default: sleep(300, 400);
}
}
private void mouseoffscreen() {
Mouse.moveBox(1000, 600, 200, 200);
println("Antiban: Mouse moving");
}
public void mainloop(){
//Credits to JJ for this loop
//Based heavily on http://pastebin.com/CKVCZvmt
if(animationcheck()){
sleep(700, 900);
if(animationcheck()){
status = "Idle";
}
}
if(!findfish()){
status = "Moving to Fish";
}
if((!animationcheck())&&(Inventory.find(fishID).length < 27)){
status = "Fishing";
}
if (Inventory.find(fishID).length > 27){
status = "Banking";
}
if (status == "Fishing"){
sleep(1000, 2000);
antiban();
}
if (status == "Idle"){
if(!fishspot()){
while(Player.isMoving()){
sleep(100, 300);
}
println("Debug: Idle - Moving to fish");
status = "Moving to Fish";
}else{
status = "Fishing";
}
}
if (status == "Moving to Fish"){
movetoloc(FishID);
while(Player.isMoving()){
sleep(700, 1000);
}
}
if (status == "Banking"){
movetoloc(BankID);
while(Player.isMoving()){
sleep(100, 4000);
}
status = "At Bank";
}
if (status == "At Bank"){
if (bankall()){
status = "Deposit Fish";
sleep(600, 900);
} else {
sleep(1000, 2000);
if (bankall()){
sleep(200, 400);
status = "Deposit Fish";
} else {
println("Could not open bank twice - Killing Script");
killswitch = true;
}
}
}
if(status == "Deposit Fish"){
totaltrips ++;
int fail = 0;
while((fail<4) && ((Inventory.find(fishID).length != 0))){
sleep(800, 100);
depositfish();
fail ++;
}
if ((Inventory.find(fishID).length != 0)){
status = "Failed to Deposit... :(";
killswitch = true;
}
}
}
public void onClose(){
println("Script Ending...");
println("Please report any bugs on the forums - Thanks!");
println("Total Runtime: " + Timing.msToString(System.currentTimeMillis() - startTime));
Banking.closeBankScreen();
Mouse.moveBox(750, 56, 759, 64);
Mouse.click(1);
Mouse.moveBox(570, 443, 706, 466);
Mouse.click(1);
}
public boolean onStart(){
println("Emu's Draynor Fisher: Starting...");
status = "Starting...";
Game.setRunMode(true);
Mouse.setSpeed(mspeed);
startTime = System.currentTimeMillis();
grabID("playerID");
getAnimationID();
if (playerID == animationID){
return true;
} else {
println("Animation ID was wrong, please start the bot away from other players");
return false;
}
}
public boolean tripsmet(){
if (totaltrips <= stoptime){
return true;
}else {
return false;
}
}
@Override
public void run() {
startTime = System.currentTimeMillis();
if(onStart()){
while((!killswitch)&&(tripsmet())){
mainloop();
sleep(600, 800);
}
}
onClose();
}
}