- /*
- *LICENSE*
- <This is a java script for the PowerBot platform.>
- Copyright (C) 2011 Fuser scripts
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- *LICENSE*
- We encourage every script writer of Fuser scripts to make use of the skeleton code.
- Look at this like suggested methods or recommended ways to write scripts. Don't let this hold back your creativity
- in any way.
- - Ubuntu4life
- - Dew
- - ExoCode
- - Alex
- */
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Point;
- import java.awt.RenderingHints;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.IOException;
- import java.lang.reflect.InvocationTargetException;
- import java.net.URL;
- import java.util.LinkedList;
- import java.util.Random;
- import javax.imageio.ImageIO;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.GroupLayout;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.SwingUtilities;
- import org.rsbot.client.RSNPC;
- import org.rsbot.client.RSObject;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Bank;
- import org.rsbot.script.methods.Calculations;
- import org.rsbot.script.methods.Camera;
- import org.rsbot.script.methods.Environment;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Inventory;
- import org.rsbot.script.methods.Keyboard;
- import org.rsbot.script.methods.Menu;
- import org.rsbot.script.methods.Mouse;
- import org.rsbot.script.methods.NPCs;
- import org.rsbot.script.methods.Objects;
- import org.rsbot.script.methods.Players;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.methods.Walking;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.Area;
- import org.rsbot.script.wrappers.Character;
- import org.rsbot.script.wrappers.GameObject;
- import org.rsbot.script.wrappers.NPC;
- import org.rsbot.script.wrappers.Path;
- import org.rsbot.script.wrappers.Tile;
- import org.rsbot.script.wrappers.TilePath;
- @ScriptManifest(authors = { "Craze" }, name = "Fuser Fishing", keywords = { "Fuser" }, version = 1.01, description = "The new standard of fishing botting.", website = "http://www.powerbot.org/community/topic/LINK/")
- public class FuserFisher extends Script implements PaintListener,
- MessageListener, MouseListener {
- public long experienceGained, currentExperience, startExperience,
- startLevel, experiencePerHour, startTime = 0;
- public MousePaint mousePaint = new MousePaint();
- public Image cursorUnclicked, cursorClicked, fuserScriptsLogo, userLogo,
- paintBackGround, closeButton, openButton, Avatar;
- public String paintType = "null", Status = "Setting up";
- public boolean drop;
- private antiBanThread antibanthread;
- private garbageCollector garbagecollector;
- int npc;
- int bankID;
- Tile bankTile;
- Tile fishTile;
- String interaction;
- int fishesCaught = 0;
- int[] undepositeditems = {314, 307, 309, 305, 311, 303, 13431, 301, 15263, 313};
- public boolean guiIsOpen = true;
- FuserFisherGUI g = new FuserFisherGUI();
- boolean webWalk;
- boolean LRC = false;
- boolean walkBack = false;
- boolean shilo = false;
- int bankerID;
- boolean colony = false;
- int arnoldID = 3824;
- Tile[] tile;
- Path path;
- /**
- * Try to break up the script in as many actions as possible.
- */
- private enum Action {
- DEATHWALK, WALKSPOT4TOSPOT1, WALKTOBANK, USEBANK, FISH, WALKTOFISH, DROP, NOTEFISH, BANKLRC, WALKBANKLRC, WALKSPOT1, WALKSPOT2, WALKSPOT3, WALKSPOT4, AVOIDCOMBAT, FISHLRC, SLEEP, UNKNOWN;
- }
- /**
- * Constants here.
- */
- public static interface Constants {
- //Barb Village
- int barbarianFishID = 328;
- Tile barbfishtile = new Tile(3109, 3433);
- Tile barbbanktile = new Tile(3094, 3490);
- int barbbankid = 42373;
- //Draynor Village
- int draynorFishID = 327;
- Tile draynorFishTile = new Tile(3086, 3230);
- Tile draynorBankTile = new Tile(3092, 3244);
- int draynorBankID = 2015;
- //Lumbridge
- int lumbridgeFishID = 329;
- Tile lumbridgeFishTile = new Tile(3240, 3241);
- Tile lumbridgeBankTile = new Tile(3296, 3168);
- int lumbridgeBankID = 35647;
- //Karamja
- int karamjaFishID = 324;
- Tile karamjaFishTile = new Tile(2925, 3176);
- Tile karamjaStilesTile = new Tile(2852, 3143);
- int karamjaStilesID = 11267;
- //Fishing Guild
- int guildLobsterID = 312;
- int guildSharkID = 313;
- Tile guildBankTile = new Tile(2585, 3422);
- Tile guildFishTile = new Tile(2601, 3421);
- int guildBankID = 49018;
- //Catherby
- int catherbyBankID = 2213;
- Tile catherbyBankTile = new Tile(2809, 3441);
- Tile catherbyFishTile = new Tile(2842, 3432);
- int catherbyLobsterID = 321;
- int catherbySharkID = 322;
- int CathebryNetID = 320;
- //LRC
- int lrcBankID = 45079;
- int lrcCaveFishID = 8841;
- int lrcRocktailID = 8842;
- Tile[] bankToSpot1 = {new Tile(3654, 5114), new Tile(3657, 5105), new Tile(3656, 5094), new Tile(3650, 5084)};
- Tile[] spot1toSpot2 = {new Tile(3647, 5085), new Tile(3634, 5087), new Tile(3625, 5087)};
- Tile[] spot2toSpot3 = {new Tile(3627, 5085), new Tile(3625, 5095), new Tile(3621, 5104), new Tile(3613, 5111)};
- Tile[] spot2toBank = {new Tile(3628, 5087), new Tile(3639, 5092), new Tile(3647, 5095), new Tile(3658, 5102), new Tile(3654, 5114)};
- Tile[] spot3toBank = {new Tile(3613, 5112),new Tile(3620, 5106),new Tile(3628, 5098),new Tile(3639, 5091),new Tile(3653, 5099),new Tile(3657, 5106),new Tile(3654, 5114),};
- Tile spot1 = new Tile(3650, 5084);
- Tile spot2 = new Tile(3645, 5084);
- Tile spot3 = new Tile(3629, 5084);
- Tile spot4 = new Tile(3619, 5089);
- Area spotOne = new Area(new Tile(3647, 5087), new Tile(3656, 5083));
- Area spotTwo = new Area(new Tile(3641, 5086), new Tile(3646, 5079));
- Area spotThree = new Area(new Tile(3625, 5087), new Tile(3638, 5079));
- Area spotFour = new Area(new Tile(3615, 5092), new Tile(3624, 5085));
- Area dead = new Area(new Tile(2960, 3386), new Tile(2971, 3375));
- Tile FaladorBank = new Tile(3013, 3355);
- int bait = 0;
- Tile dwarvenDoor = new Tile(3061, 3374);
- int closedDoor = 11714;
- int openDoor = 11715;
- int stairs = 30944;
- Tile cavernEntrance = new Tile(3014, 9831);
- int entrance = 46204;
- //Shilo
- Tile shilobankTile = new Tile(2852, 2955);
- Tile shilofishTile = new Tile(2857, 2972);
- int shiloFish = 317;
- //Fishing Colony
- Tile colonyBankTile = new Tile(2331, 3689);
- Tile colonyFishTile = new Tile(2343, 3701);
- int colonyFish = 3848;
- }
- /**
- * Try to make as much logic as possible happen here instead of in the loop.
- *
- * @return Action
- */
- public Action getAction() {
- try {
- if (Game.getClientState() != 11) {
- return Action.SLEEP;
- } else {
- if(LRC == true){
- if(Players.getMyPlayer().isInCombat()){
- return Action.WALKBANKLRC;
- } else if(Constants.dead.contains(Players.getMyPlayer().getLocation())){
- return Action.DEATHWALK;
- }else if(atLRCBank() && Inventory.isFull()){
- return Action.BANKLRC;
- } else if(atLRCBank() && !Inventory.isFull()){
- return Action.WALKSPOT1;
- } else if(!atBank() && Inventory.isFull()){
- return Action.WALKBANKLRC;
- } else if(canFish()){
- return Action.FISHLRC;
- } else if(atSpot1()&& !canFish()){
- return Action.WALKSPOT2;
- } else if(atSpot2() && !canFish()){
- return Action.WALKSPOT3;
- } else if(atSpot3() && !canFish()){
- return Action.WALKSPOT4;
- } else if(atSpot4() && !canFish()){
- return Action.WALKSPOT4TOSPOT1;
- }
- } else if(LRC == false){
- if(atBank() && Inventory.isFull()){
- return Action.USEBANK;
- } else if(atBank() && !Inventory.isFull()){
- return Action.WALKTOFISH;
- } else if(!atBank() && Inventory.isFull() && drop == false){
- return Action.WALKTOBANK;
- } else if(atSpot() && !Inventory.isFull()){
- return Action.FISH;
- } else if(drop == true && Inventory.isFull()){
- return Action.DROP;
- } else if(atStiles() && Inventory.isFull()){
- return Action.NOTEFISH;
- } else if(atStiles() && !Inventory.isFull()){
- return Action.WALKTOFISH;
- }
- }
- }
- } catch (final Exception e) {
- return Action.UNKNOWN;
- }
- return Action.UNKNOWN;
- }
- private boolean atSpot4(){
- if(Constants.spotFour.contains(Players.getMyPlayer().getLocation())){
- log("At spot 4");
- return true;
- }
- return false;
- }
- private boolean atSpot3() {
- if(Constants.spotThree.contains(Players.getMyPlayer().getLocation())){
- log("at spot3");
- return true;
- }
- return false;
- }
- private boolean atSpot2(){
- if(Constants.spotTwo.contains(Players.getMyPlayer().getLocation())){
- log("At spot 2");
- return true;
- }
- return false;
- }
- private boolean atSpot1(){
- if(Constants.spotOne.contains(Players.getMyPlayer().getLocation())){
- log("At spot 1");
- return true;
- }
- return false;
- }
- private boolean atLRCBank() {
- if(Calculations.distanceTo(new Tile(3654, 5114)) < 5){
- return true;
- }
- return false;
- }
- private void ToBank(){
- if(!atSpot1()){
- Walking.walkTileMM(Constants.spot1);
- sleep(3000);
- } else if(atSpot1()){
- path = Walking.newTilePath(Constants.bankToSpot1).reverse();
- while(!atBank()){
- path.traverse();
- while(Players.getMyPlayer().isMoving()){
- sleep(200);
- }
- }
- }
- }
- private boolean atStiles() {
- NPC stiles = NPCs.getNearest(Constants.karamjaStilesID);
- if(stiles != null && stiles.isOnScreen()){
- return true;
- }
- return false;
- }
- private boolean atSpot() {
- NPC spot = NPCs.getNearest(npc);
- if(spot != null){
- if(spot.isOnScreen()){
- return true;
- } else {
- Walking.walkTileMM(spot.getLocation());
- sleep(2500);
- }
- }
- return false;
- }
- private boolean atBank() {
- GameObject booth = Objects.getNearest(bankID);
- NPC banker = NPCs.getNearest(bankerID);
- if(booth != null && booth.isOnScreen() || banker != null && banker.isOnScreen()){
- return true;
- }
- return false;
- }
- private boolean canFish() {
- NPC fish = NPCs.getNearest(npc);
- if(fish != null && fish.isOnScreen())
- {
- return true;
- }
- return false;
- }
- @Override
- public int loop() {
- try {
- Mouse.setSpeed(random(4, 7));
- antiBan();
- switch (getAction()) {
- case WALKTOBANK:
- Status = "Walking to bank";
- walkToBank();
- break;
- case WALKTOFISH:
- Status = "Walking to spot";
- walkToSpot();
- break;
- case FISH:
- Status = "Fishing";
- fish();
- break;
- case USEBANK:
- Status = "Banking";
- Bank();
- break;
- case DROP:
- Inventory.dropAllExcept(undepositeditems);
- break;
- case NOTEFISH:
- NPC stiles = NPCs.getNearest(Constants.karamjaStilesID);
- if(stiles != null){
- stiles.interact("Exchange");
- sleep(1000);
- }
- break;
- case BANKLRC:
- Status = "Walking to Bank";
- BankLRC();
- break;
- case WALKBANKLRC:
- Status = "Walking to LRC Bank";
- ToBank();
- break;
- case FISHLRC:
- Status = "Fishing in LRC";
- fishLRC();
- break;
- case WALKSPOT1:
- Status = "Walking to First Spot";
- path = Walking.newTilePath(Constants.bankToSpot1);
- while(!atSpot1()){
- path.traverse();
- while(Calculations.distanceTo(Walking.getDestination()) > 4){
- sleep(500);
- }
- }
- break;
- case WALKSPOT2:
- Status = "Walking to spot 2";
- Walking.walkTileMM(Constants.spot2, 0);
- sleep(1500);
- while(Players.getMyPlayer().isMoving()){
- sleep(500);
- }
- break;
- case WALKSPOT3:
- Status = "Walking to spot 3";
- Walking.walkTileMM(Constants.spot3, 0);
- sleep(1500);
- while(Players.getMyPlayer().isMoving()){
- sleep(500);
- }
- break;
- case WALKSPOT4:
- Status = "Walking to spot 4";
- Walking.walkTileMM(Constants.spot4);
- sleep(1500);
- while(Players.getMyPlayer().isMoving()){
- sleep(500);
- }
- break;
- case WALKSPOT4TOSPOT1:
- Status = "Walking back to spot 1";
- while(!atSpot1()){
- Walking.walkTileMM(Constants.spot1, 0);
- sleep(3000);
- }
- break;
- case DEATHWALK:
- Status = "Died, Walking back!";
- while(Calculations.distanceTo(Constants.FaladorBank) > 2){
- Walking.walkTileMM(Constants.FaladorBank);
- sleep(1500);
- while(Players.getMyPlayer().isMoving()){
- sleep(500);
- }
- }
- sleep(1500);
- GameObject booth = Objects.getNearest(Bank.BANK_BOOTHS);
- if(booth != null && booth.isOnScreen()){
- booth.interact("Use-quickly");
- sleep(2000);
- if(Bank.isOpen()){
- Bank.withdraw(Constants.bait, 0);
- sleep(1000);
- Bank.close();
- } else {
- booth.interact("Use-quickly");
- sleep(2200);
- }
- }
- while(Calculations.distanceTo(Constants.dwarvenDoor) > 2){
- Walking.walkTileMM(Constants.dwarvenDoor);
- sleep(1500);
- while(Players.getMyPlayer().isMoving()){
- sleep(500);
- }
- }
- GameObject closedDoor = Objects.getNearest(Constants.closedDoor);
- if(closedDoor != null && closedDoor.isOnScreen()){
- closedDoor.interact("Open");
- }
- sleep(1200);
- GameObject stairs = Objects.getNearest(Constants.stairs);
- if(stairs != null && stairs.isOnScreen()){
- stairs.click();
- sleep(2500);
- }
- while(Calculations.distanceTo(Constants.cavernEntrance) > 2){
- Walking.walkTileMM(Constants.cavernEntrance);
- while(Calculations.distanceTo(Walking.getDestination()) > 2){
- sleep(500);
- }
- }
- GameObject entrance = Objects.getNearest(Constants.entrance);
- if(entrance != null && entrance.isOnScreen()){
- entrance.click();
- sleep(1500);
- }
- }
- } catch (final Exception e) {
- return 25;
- }
- return random(180, 420);
- }
- private void Bank() {
- if(shilo){
- NPC booth = NPCs.getNearest(bankerID);
- if(booth != null && booth.isOnScreen()){
- booth.interact("Bank Banker");
- sleep(1800);
- if(Bank.isOpen()){
- Bank.depositAllExcept(undepositeditems);
- sleep(1000);
- Bank.close();
- } else {
- booth.interact("Bank Banker");
- sleep(1800);
- }
- }
- }
- if(colony){
- NPC booth = NPCs.getNearest(arnoldID);
- if(booth != null && booth.isOnScreen()){
- booth.interact("Bank");
- sleep(1800);
- if(Bank.isOpen()){
- Bank.depositAllExcept(undepositeditems);
- sleep(1000);
- Bank.close();
- } else {
- booth.interact("Bank");
- sleep(1800);
- }
- }
- }
- GameObject booth = Objects.getNearest(bankID);
- if(booth != null){
- booth.interact("Use-quickly");
- sleep(1800);
- if(Bank.isOpen()){
- Bank.depositAllExcept(undepositeditems);
- sleep(800);
- Bank.close();
- } else {
- booth.interact("Use-quickly");
- sleep(1800);
- }
- }
- }
- private void BankLRC(){
- GameObject booth = Objects.getNearest(bankID);
- if(booth != null){
- booth.interact("Deposit");
- sleep(1800);
- if(Bank.isDepositOpen()){
- Bank.depositAllExcept(undepositeditems);
- sleep(800);
- Bank.close();
- } else {
- booth.click();
- sleep(1800);
- }
- }
- }
- private void fish() {
- NPC fish = NPCs.getNearest(npc);
- if(fish != null){
- if(fish.isOnScreen()){
- fish.interact(interaction);
- Timer t = new Timer(2000);
- while(t.isRunning()){
- if(Players.getMyPlayer().getAnimation() != -1){
- t.reset();
- }
- }
- } else {
- Walking.walkTileMM(fish.getLocation(), 0);
- }
- }
- }
- private void fishLRC() {
- NPC fish = NPCs.getNearest(npc);
- if(fish != null){
- if(fish.isOnScreen()){
- Point p = fish.getPoint();
- Mouse.move(p);
- Mouse.click(true);
- Timer t = new Timer(2000);
- while(t.isRunning()){
- if(Players.getMyPlayer().getAnimation() != -1 && !Players.getMyPlayer().isInCombat()){
- t.reset();
- }
- }
- } else {
- Camera.turnTo(fish.getLocation());
- }
- }
- }
- private void walkToSpot() {
- if(!Walking.isRunEnabled()){
- Walking.setRun(true);
- }
- Path spot = Walking.getPath(fishTile);
- if(webWalk == true){
- if(Calculations.distanceTo(fishTile) > 2){
- while(Calculations.distanceTo(fishTile) > 2){
- spot.traverse();
- sleep(3500);
- while(Players.getMyPlayer().isMoving()){
- sleep(200);
- }
- Walking.walkTileMM(fishTile, 0);
- }
- }
- } else {
- Walking.walkTileMM(fishTile, 0);
- sleep(2500);
- }
- }
- private void walkToBank() {
- if(!Walking.isRunEnabled()){
- Walking.setRun(true);
- }
- Path Bank = Walking.getPath(bankTile);
- if(webWalk == true){
- if(Bank != null){
- while(Calculations.distanceTo(bankTile) > 2){
- Bank.traverse();
- if(Calculations.distanceTo(Walking.getDestination()) > 2){
- sleep(400);
- }
- }
- }
- } else {
- Walking.walkTileMM(bankTile, 0);
- sleep(2500);
- }
- }
- public class FuserFisherGUI extends JFrame {
- public FuserFisherGUI() {
- initComponents();
- }
- private void button1ActionPerformed(ActionEvent e) {
- String loc = comboBox1.getSelectedItem().toString();
- interaction = comboBox3.getSelectedItem().toString();
- String fish = comboBox4.getSelectedItem().toString();
- if(loc.equals("Barbarian Village")){
- webWalk = true;
- bankTile = Constants.barbbanktile;
- fishTile = Constants.barbfishtile;
- npc = Constants.barbarianFishID;
- bankID = Constants.barbbankid;
- LRC = false;
- } else if(loc.equals("Draynor")){
- webWalk = true;
- bankTile = Constants.draynorBankTile;
- fishTile = Constants.draynorFishTile;
- npc = Constants.draynorFishID;
- bankID = Constants.draynorBankID;
- LRC = false;
- } else if(loc.equals("Lumbridge")){
- webWalk = true;
- bankTile = Constants.lumbridgeBankTile;
- fishTile = Constants.lumbridgeFishTile;
- npc = Constants.lumbridgeFishID;
- bankID = Constants.lumbridgeBankID;
- LRC = false;
- } else if(loc.equals("Karamja")){
- webWalk = true;
- bankTile = Constants.karamjaStilesTile;
- fishTile = Constants.karamjaFishTile;
- npc = Constants.karamjaFishID;
- LRC = false;
- } else if(loc.equals("Fishing Guild")){
- LRC = false;
- webWalk = false;
- if(interaction.equals("Cage")){
- npc = Constants.guildLobsterID;
- } else if(interaction.equals("Harpoon")){
- if(fish.equals("Shark")){
- npc = Constants.guildSharkID;
- } else {
- npc = Constants.guildLobsterID;
- }
- } else if(interaction.equals("Net")){
- npc = Constants.guildSharkID;
- }
- bankTile = Constants.guildBankTile;
- fishTile = Constants.guildFishTile;
- bankID = Constants.guildBankID;
- } else if(loc.equals("Catherby")){
- webWalk = true;
- if(interaction.equals("Cage")){
- npc = Constants.catherbyLobsterID;
- } else if(interaction.equals("Harpoon")){
- if(fish.equals("Shark")){
- npc = Constants.catherbySharkID;
- } else {
- npc = Constants.catherbyLobsterID;
- }
- } else if(interaction.equals("Net") || interaction.equals("Bait")){
- npc = Constants.CathebryNetID;
- }
- bankTile = Constants.catherbyBankTile;
- fishTile = Constants.catherbyFishTile;
- bankID = Constants.catherbyBankID;
- LRC = false;
- } else if(loc.equals("Living Rock Cavern")){
- webWalk = false;
- if(fish.equals("Cavefish")){
- npc = Constants.lrcCaveFishID;
- } else if(fish.equals("Rocktail")){
- npc = Constants.lrcRocktailID;
- }
- bankID = Constants.lrcBankID;
- LRC = true;
- } else if(loc.equals("Shilo Village")){
- shilo = true;
- webWalk = false;
- bankerID = 499;
- bankTile = Constants.shilobankTile;
- fishTile = Constants.shilofishTile;
- npc = Constants.shiloFish;
- } else if(loc.equals("Fishing Colony")){
- colony = true;
- bankTile = Constants.colonyBankTile;
- fishTile = Constants.colonyFishTile;
- npc = Constants.colonyFish;
- }
- String method = comboBox2.getSelectedItem().toString();
- if(method.equals("Drop")){
- drop = true;
- } else {
- drop = false;
- }
- setVisible(false);
- guiIsOpen = false;
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- // Generated using JFormDesigner Evaluation license - Alex Martin
- label1 = new JLabel();
- label2 = new JLabel();
- comboBox1 = new JComboBox();
- label3 = new JLabel();
- comboBox2 = new JComboBox();
- label4 = new JLabel();
- comboBox3 = new JComboBox();
- button1 = new JButton();
- label5 = new JLabel();
- comboBox4 = new JComboBox();
- //======== this ========
- Container contentPane = getContentPane();
- //---- label1 ----
- label1.setText("Fuser AIO Fishing");
- label1.setFont(new Font("Tahoma", Font.PLAIN, 24));
- //---- label2 ----
- label2.setText("Location: ");
- label2.setFont(new Font("Tahoma", Font.PLAIN, 18));
- //---- comboBox1 ----
- comboBox1.setModel(new DefaultComboBoxModel(new String[] {
- "Barbarian Village",
- "Draynor",
- "Lumbridge",
- "Karamja",
- "Fishing Guild",
- "Catherby",
- "Living Rock Cavern",
- "Shilo Village",
- "Fishing Colony"
- }));
- //---- label3 ----
- label3.setText("Method: ");
- label3.setFont(new Font("Tahoma", Font.PLAIN, 18));
- //---- comboBox2 ----
- comboBox2.setModel(new DefaultComboBoxModel(new String[] {
- "Drop",
- "Bank"
- }));
- //---- label4 ----
- label4.setText("Action: ");
- label4.setFont(new Font("Tahoma", Font.PLAIN, 18));
- //---- comboBox3 ----
- comboBox3.setModel(new DefaultComboBoxModel(new String[] {
- "Lure",
- "Bait",
- "Net",
- "Cage",
- "Harpoon"
- }));
- //---- button1 ----
- button1.setText("Start");
- button1.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- button1ActionPerformed(e);
- }
- });
- //---- label5 ----
- label5.setText("Fish: ");
- label5.setFont(new Font("Tahoma", Font.PLAIN, 18));
- //---- comboBox4 ----
- comboBox4.setModel(new DefaultComboBoxModel(new String[] {
- "Shrimp",
- "Anchovie",
- "Trout",
- "Salmon",
- "Tuna",
- "Lobster",
- "Swordfish",
- "Shark",
- "Cavefish",
- "Rocktail"
- }));
- GroupLayout contentPaneLayout = new GroupLayout(contentPane);
- contentPane.setLayout(contentPaneLayout);
- contentPaneLayout.setHorizontalGroup(
- contentPaneLayout.createParallelGroup()
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGroup(contentPaneLayout.createParallelGroup()
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(100, 100, 100)
- .addComponent(label1))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(82, 82, 82)
- .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
- .addComponent(label2)
- .addComponent(label3)
- .addComponent(label4)
- .addComponent(label5))
- .addGap(18, 18, 18)
- .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
- .addComponent(comboBox4, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(comboBox3, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(comboBox2, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(comboBox1, 0, 121, Short.MAX_VALUE)))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(141, 141, 141)
- .addComponent(button1, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(93, Short.MAX_VALUE))
- );
- contentPaneLayout.setVerticalGroup(
- contentPaneLayout.createParallelGroup()
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(label1)
- .addGap(18, 18, 18)
- .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(comboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addComponent(label2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGap(18, 18, 18)
- .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(comboBox2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addComponent(label3))
- .addGap(18, 18, 18)
- .addGroup(contentPaneLayout.createParallelGroup()
- .addComponent(label4)
- .addComponent(comboBox3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(18, 18, 18)
- .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(label5)
- .addComponent(comboBox4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(26, 26, 26)
- .addComponent(button1, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
- .addGap(39, 39, 39))
- );
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Evaluation license - Alex Martin
- private JLabel label1;
- private JLabel label2;
- private JComboBox comboBox1;
- private JLabel label3;
- private JComboBox comboBox2;
- private JLabel label4;
- private JComboBox comboBox3;
- private JButton button1;
- private JLabel label5;
- private JComboBox comboBox4;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- public boolean onStart() {
- if (!Game.isLoggedIn()) {
- log.severe("Start this script logged in please.");
- return false;
- }
- if (!Game.isFixed()) {
- log.severe("It's highly recommended to bot with fixed screen mode.");
- return false;
- }
- try {
- SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- new FuserFisherGUI().setVisible(true);
- }
- });
- } catch (InterruptedException ignored) {
- } catch (InvocationTargetException ignored) {
- }
- // Load files from external server here.
- new Thread(new Runnable() {
- public void run() {
- }
- }).start();
- while (guiIsOpen) {
- sleep(25);
- Camera.setPitch(true);
- }
- log.info("Loading version "
- + getClass().getAnnotation(ScriptManifest.class).version());
- startTime = System.currentTimeMillis();
- startExperience = Skills.getExperience(Skills.FISHING);
- antibanthread = new antiBanThread();
- antibanthread.start();
- garbagecollector = new garbageCollector();
- garbagecollector.start();
- return true;
- }
- public void onFinish() {
- for (int Tries = 0; antibanthread.isAlive(); Tries++) {
- if (Tries > 2400) {
- antibanthread.interrupt();
- sleep(25);
- if (antibanthread.isInterrupted()) {
- break;
- } else if (Tries > 4800) {
- break;
- }
- } else {
- antibanthread.stopThread = true;
- sleep(25);
- if (antibanthread.isInterrupted()) {
- break;
- }
- }
- }
- Environment.saveScreenshot(true);
- for (int Tries = 0; garbagecollector.isAlive(); Tries++) {
- if (Tries > 2400) {
- garbagecollector.interrupt();
- sleep(25);
- if (garbagecollector.isInterrupted()) {
- break;
- } else if (Tries > 4800) {
- break;
- }
- } else {
- garbagecollector.stopThread = true;
- sleep(25);
- if (garbagecollector.isInterrupted()) {
- break;
- }
- }
- }
- log("Thank you for using a Fuser script.");
- }
- @Override
- public void messageReceived(final MessageEvent serverTraffic) {
- final String serverMessage = serverTraffic.getMessage().toLowerCase();
- if (serverMessage.contains("advanced")) {
- log("Congratulations on level up !");
- }
- if (serverMessage.contains("the next runescape")) {
- log("There will be a system update soon, logged out.");
- }
- if(serverMessage.contains("you catch")){
- fishesCaught++;
- }
- }
- /**
- * Looped antiBan version 1.00
- *
- * @Author Ubuntu4life
- */
- private void antiBan() {
- // CHANGE randomInteger to tune the frequency of the antiBan.
- final int randomInteger = random(1, 11);
- switch (randomInteger) {
- case 1:
- // CHANGE this random integer generator to tune the relative
- // distribution of antiBan actions.
- if (random(1, 17) != 1) {
- break;
- } else {
- Mouse.move(random(10, 750), random(10, 495));
- if (random(1, 7) == 1) {
- Mouse.move(random(10, 750), random(10, 495));
- }
- }
- break;
- case 2:
- if (random(1, 12) != 1) {
- break;
- } else {
- Mouse.moveSlightly();
- }
- break;
- case 3:
- if (random(1, 18) != 1) {
- break;
- } else {
- if (random(1, 11) == 1) {
- Camera.setPitch(true);
- }
- int angle = Camera.getAngle() + random(-45, 45);
- if (angle < 0) {
- angle = random(0, 10);
- }
- if (angle > 359) {
- angle = random(0, 10);
- }
- char Direction = 37;
- if (random(0, 100) < 50) {
- Direction = 39;
- }
- Keyboard.pressKey(Direction);
- sleep(random(100, 700));
- Keyboard.releaseKey(Direction);
- }
- break;
- default:
- return;
- }
- }
- /**
- * Multi-threaded antiBan version 1.00
- *
- * @Author Ubuntu4life
- */
- class antiBanThread extends Thread {
- private volatile boolean stopThread = false;
- Random javaUtilRandom = new Random();
- @Override
- public void run() {
- try {
- while (!stopThread && !isPaused()
- && Game.isLoggedIn()) {
- // CHANGE this integer to tune the frequency of the antiBan
- if (javaUtilRandom.nextInt(Math.abs(0 - 21)) == 1) {
- final char[] leftRight = new char[] { KeyEvent.VK_LEFT,
- KeyEvent.VK_RIGHT };
- final char[] upDown = new char[] { KeyEvent.VK_DOWN,
- KeyEvent.VK_UP };
- final char[] leftRightUpDown = new char[] {
- KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
- KeyEvent.VK_UP, KeyEvent.VK_UP };
- final int random1 = javaUtilRandom.nextInt(Math
- .abs(2 - 0));
- final int random2 = javaUtilRandom.nextInt(Math
- .abs(2 - 0));
- final int random3 = javaUtilRandom.nextInt(Math
- .abs(4 - 0));
- boolean didLeftRight = false;
- if (javaUtilRandom.nextInt(Math.abs(3 - 0)) == 1) {
- if (random(0, 5) != 1) {
- Keyboard.pressKey(leftRight[random1]);
- Thread.sleep(javaUtilRandom.nextInt(Math
- .abs(101 - 402)));
- didLeftRight = true;
- }
- Keyboard.pressKey(upDown[random2]);
- Thread.sleep(javaUtilRandom.nextInt(Math
- .abs(301 - 601)));
- Keyboard.releaseKey(upDown[random2]);
- Thread.sleep(javaUtilRandom.nextInt(Math
- .abs(99 - 399)));
- if (didLeftRight) {
- Keyboard.releaseKey(leftRight[random1]);
- }
- } else {
- Keyboard.pressKey(leftRightUpDown[random3]);
- if (random3 > 1) {
- Thread.sleep(javaUtilRandom.nextInt(Math
- .abs(601 - 298)));
- } else {
- Thread.sleep(javaUtilRandom.nextInt(Math
- .abs(903 - 501)));
- }
- Keyboard.releaseKey(leftRightUpDown[random3]);
- }
- } else {
- Thread.sleep(javaUtilRandom.nextInt(Math
- .abs(2004 - 198)));
- }
- }
- } catch (final Exception e) {
- }
- }
- }
- /**
- * Multi-threaded Java garbage collector. Removes un-used GameObjects loaded in
- * the RAM. version 1.00
- *
- * @Author Ubuntu4life
- */
- class garbageCollector extends Thread {
- private volatile boolean stopThread = false;
- @Override
- public void run() {
- while (!stopThread && Game.isLoggedIn()) {
- try {
- if (random(0, 450) == 1) {
- final Runtime runtime = Runtime.getRuntime();
- runtime.gc();
- }
- Thread.sleep(random(1000, 1500));
- } catch (final InterruptedException e) {
- }
- }
- }
- }
- private final RenderingHints renderHints = new RenderingHints(
- RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- private final Color color1 = new Color(0, 0, 0, 205);
- private final Color color2 = new Color(0, 255, 255);
- private final Color color3 = new Color(0, 255, 255, 230);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 20);
- private final Font font2 = new Font("Arial", 0, 14);
- @Override
- public void onRepaint(Graphics g) {
- 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;
- experienceGained = Skills.getExperience(Skills.FISHING) - startExperience;
- float xpsec = 0;
- if (minutes > 0 || hours > 0 || seconds > 0 && experienceGained > 0){
- xpsec = ((float) experienceGained /(float)(seconds + (minutes * 60) + (hours * 60 * 60)));
- }
- float xpmin = xpsec * 60;
- float xphour = xpmin * 60;
- float timeTNLhour = 0;
- timeTNLhour = (float) Skills.getExperienceToLevel(Skills.FISHING + 1)/(float)xphour;
- float timeTNLmin = timeTNLhour*60;
- float timeTNLsec = timeTNLmin*60;
- float estimatedHour = timeTNLsec/3600;
- float tempminutes = timeTNLsec%3600;
- float estimatedMinutes = tempminutes/60;
- float estimatedSeconds = tempminutes%60;
- Graphics2D g2 = (Graphics2D) g;
- g2.setRenderingHints(renderHints);
- g.setColor(color1);
- g.fillRoundRect(6, 344, 509, 129, 16, 16);
- g.setColor(color2);
- ((Graphics2D) g).setStroke(stroke1);
- g.drawRoundRect(6, 344, 509, 129, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("Fuser AIO Fisher", 175, 371);
- g.setFont(font2);
- g.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 18, 391);
- g.drawString("Time To Level: " + (int) estimatedHour + ":" + (int) estimatedMinutes + " :" + (int) estimatedSeconds, 18, 417);
- g.drawString("Status: " + Status, 18, 442);
- g.drawString("Experience Gained: " + (int) experienceGained, 267, 391);
- g.drawString("Experience Per/Hr: " + (int) xphour, 267, 417);
- g.drawString("Fish Caught: " + fishesCaught, 267, 442);
- MousePaint.Draw(g2);
- }
- public void MouseClicked(MouseEvent MouseEvent) {
- }
- public void sendToURL(String url) {
- try {
- java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
- } catch (Exception exception) {
- log("Error:" + exception.getLocalizedMessage());
- }
- }
- public void MouseEntered(MouseEvent e) {
- }
- public void MouseExited(MouseEvent e) {
- }
- public void MousePressed(MouseEvent e) {
- }
- public void MouseReleased(MouseEvent e) {
- }
- /**
- * Official Mouse paint. Version 1.00
- *
- * @author ExoCode
- *
- */
- public class MousePaint {
- public int waveSize = 0;
- @SuppressWarnings({ "serial" })
- public class MousePathPoint extends Point {
- private long finishTime;
- private double lastingTime;
- public MousePathPoint(int x, int y, int lastingTime) {
- super(x, y);
- this.lastingTime = lastingTime;
- finishTime = System.currentTimeMillis() + lastingTime;
- }
- public boolean isUp() {
- return System.currentTimeMillis() > finishTime;
- }
- }
- public double getRot(int ticks) {
- return (System.currentTimeMillis() % (360 * ticks)) / ticks;
- }
- public LinkedList<MousePathPoint> MousePath = new LinkedList<MousePathPoint>();
- public void drawTrail(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g2.setStroke(new BasicStroke(1));
- while (!MousePath.isEmpty() && MousePath.peek().isUp()) {
- MousePath.remove();
- }
- Point clientCursor = Mouse.getLocation();
- MousePathPoint mpp = new MousePathPoint(clientCursor.x,
- clientCursor.y, 250);
- if (MousePath.isEmpty() || !MousePath.getLast().equals(mpp)) {
- MousePath.add(mpp);
- }
- MousePathPoint lastPoint = null;
- for (MousePathPoint a : MousePath) {
- if (lastPoint != null) {
- long mpt = System.currentTimeMillis()
- - Mouse.getPressTime();
- if (Mouse.getPressTime() == -1 || mpt >= 250) {
- g2.setColor(Color.GREEN);
- }
- if (mpt < 250) {
- g2.setColor(Color.RED);
- }
- g2.drawLine(a.x, a.y, lastPoint.x, lastPoint.y);
- }
- lastPoint = a;
- }
- }
- public void drawMouse(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g2.setRenderingHints(new RenderingHints(
- RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON));
- g2.setStroke(new BasicStroke(3));
- g2.setColor(Color.BLACK);
- g2.drawOval(Mouse.getLocation().x - 13, Mouse.getLocation().y - 13,
- 25, 25);
- g2.setStroke(new BasicStroke(1));
- g2.setColor(new Color(0, 0, 0, 114));
- g2.fillOval(Mouse.getLocation().x - 13, Mouse.getLocation().y - 13,
- 25, 25);
- Point MouseLocation = Mouse.getLocation();
- long mpt = System.currentTimeMillis() - Mouse.getPressTime();
- g2.rotate(Math.toRadians(getRot(5)), Mouse.getLocation().x,
- Mouse.getLocation().y);
- if (Mouse.getPressTime() == -1 || mpt >= 250) {
- g2.setColor(Color.GREEN);
- g2.drawLine(MouseLocation.x - 5, MouseLocation.y,
- MouseLocation.x + 5, MouseLocation.y);
- g2.drawLine(MouseLocation.x, MouseLocation.y - 5,
- MouseLocation.x, MouseLocation.y + 5);
- }
- if (mpt < 250) {
- g2.setColor(Color.RED);
- g2.drawLine(MouseLocation.x - 5, MouseLocation.y,
- MouseLocation.x + 5, MouseLocation.y);
- g2.drawLine(MouseLocation.x, MouseLocation.y - 5,
- MouseLocation.x, MouseLocation.y + 5);
- }
- }
- public void drawWave(Graphics g, Color color) {
- Graphics2D g2 = (Graphics2D) g;
- Point MouseLoc = Mouse.getPressLocation();
- long mpt = System.currentTimeMillis() - Mouse.getPressTime();
- g2.setRenderingHints(new RenderingHints(
- RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON));
- g2.setColor(color);
- if (mpt < 1000) {
- waveSize = (int) (mpt / 7.5);
- } else {
- waveSize = 0;
- }
- g2.setStroke(new BasicStroke(3));
- g2.drawOval(MouseLoc.x - (waveSize / 2), MouseLoc.y
- - (waveSize / 2), waveSize, waveSize);
- g2.drawOval(MouseLoc.x - ((waveSize / 2) / 2), MouseLoc.y
- - ((waveSize / 2) / 2), waveSize / 2, waveSize / 2);
- }
- public void Draw(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g2.setRenderingHints(new RenderingHints(
- RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON));
- drawWave(g2, Color.BLACK);
- drawTrail(g2);
- drawMouse(g2);
- }
- }
- public interface Condition {
- public boolean isTrue();
- }
- /**
- * Advanced sleeping method with no Walking involved.
- *
- * @Author Ubuntu4life
- *
- * @param condition
- * The condition under which the script has to sleep.
- * @param Threshold
- * The maximum amount of milliseconds to wait /while/ something
- * is not going the way it's supposed to.
- * @return True when everything went fine.
- */
- private boolean sleepWhile(final Condition condition, final int Threshold) {
- final int Irritations = Threshold / 25;
- for (int i = 0; i < Irritations && condition.isTrue(); i++) {
- if (Game.getClientState() != 11) {
- i = 0;
- }
- sleep(random(20, 30));
- }
- return condition.isTrue();
- }
- /**
- * Advanced sleeping method with NPC interaction.
- *
- * @Author Ubuntu4life
- *
- * @param condition
- * The condition under which the script has to sleep. Walking has
- * already been included.
- * @param targetNPC
- * The NPC to interact with.
- * @param Threshold
- * The maximum amount of milliseconds to wait /while/ something
- * is not going the way it's supposed to.
- * @return True when everything went fine.
- */
- private boolean sleepWhile(final Condition condition,
- final NPC targetNPC, final int Threshold) {
- final int Irritations = Threshold / 25;
- if (!Players.getMyPlayer().isMoving()
- && Calculations.distanceTo(targetNPC) >= 2) {
- final long endTime = System.currentTimeMillis()
- + random(1500, 2000);
- while (System.currentTimeMillis() < endTime) {
- if (Players.getMyPlayer().isMoving()) {
- break;
- }
- sleep(random(20, 30));
- }
- if (!Players.getMyPlayer().isMoving()) {
- return false;
- }
- }
- for (int i = 0; i < Irritations && condition.isTrue(); i++) {
- if (Players.getMyPlayer().isMoving() || Game.getClientState() != 11) {
- i = 0;
- }
- sleep(random(20, 30));
- }
- return condition.isTrue();
- }
- /**
- * Advanced sleeping method with NPC interaction.
- *
- * @Author Ubuntu4life
- *
- * @param condition
- * The condition under which the script has to sleep. Walking has
- * already been included.
- * @param targetGameObject
- * The GameObject to interact with.
- * @param Threshold
- * The maximum amount of milliseconds to wait /while/ something
- * is not going the way it's supposed to.
- * @return True when everything went fine.
- */
- private boolean sleepWhile(final Condition condition,
- final GameObject targetGameObject, final int Threshold) {
- final int Irritations = Threshold / 25;
- final int minimalSleepTillMove = 1500;
- final int MaximalSleepTillMove = 2000;
- if (!Players.getMyPlayer().isMoving()
- && Threshold < (minimalSleepTillMove + MaximalSleepTillMove) / 2) {
- if (targetGameObject != null) {
- if (Calculations.distanceTo(targetGameObject) >= Calculations
- .distanceTo(targetGameObject) + 1) {
- final long endTime = System.currentTimeMillis()
- + random(minimalSleepTillMove, MaximalSleepTillMove);
- while (System.currentTimeMillis() < endTime) {
- if (Players.getMyPlayer().isMoving()) {
- break;
- }
- sleep(random(20, 30));
- }
- if (!Players.getMyPlayer().isMoving()) {
- return false;
- }
- }
- } else {
- return false;
- }
- }
- for (int i = 0; i < Irritations && condition.isTrue(); i++) {
- if (Players.getMyPlayer().isMoving() || Game.getClientState() != 11) {
- i = 0;
- }
- sleep(random(20, 30));
- }
- return condition.isTrue();
- }
- /**
- * Walks to the given tile using the minimap with given randomness. Version
- * 1.00
- *
- * @param Tile
- * The tile to walk to.
- * @param xDeviation
- * The maximum deviation in the X dimension from Tile to allow.
- * @param yDeviation
- * The maximum deviation in the Y dimension from Tile to allow.
- * @return <tt>true</tt> if the tile was clicked; otherwise <tt>false</tt>.
- *
- * @Author Ubuntu4life
- */
- private boolean walkTile(final Tile Tile, final int xDeviation,
- final int yDeviation) {
- final Tile destinationTile = new Tile(Tile.getX()
- + random(0, xDeviation), Tile.getY() + random(0, yDeviation));
- Point targetPoint = Calculations.tileToMinimap(destinationTile);
- while (!Mouse.getLocation().equals(targetPoint)) {
- targetPoint = Calculations.tileToMinimap(destinationTile);
- if (targetPoint.x == -1 || targetPoint.y == -1) {
- return false;
- }
- moveMouse(20, targetPoint);
- }
- Mouse.click(true);
- return true;
- }
- /**
- * Performs the specified action on a given NPC. Version 1.00
- *
- * @param NPC
- * The NPC to perform an action on.
- * @param Action
- * the menu item to search and click.
- * @return returns true if clicked.
- *
- * @Author Ubuntu4life
- */
- private boolean clickNPC(final NPC NPC, final String Action) {
- try {
- Point targetPoint;
- for (int i = 0; i < 25; i++) {
- while (!Menu.contains(Action)) {
- if (Players.getMyPlayer().isMoving()) {
- targetPoint = NPC.getModel().getCentralPoint();
- } else {
- targetPoint = NPC.getModel().getPoint();
- }
- if (!NPC.isOnScreen() || Bank.isOpen()) {
- return false;
- }
- moveMouse(getDelay(targetPoint), targetPoint);
- }
- if (Menu.contains(Action)) {
- Mouse.setSpeed(random(5, 8));
- Mouse.click(false);
- for (int x = 0; x < 4; x++) {
- if (Menu.doAction(Action)) {
- return true;
- }
- }
- }
- if (Menu.isOpen() && !Menu.contains(Action)) {
- do {
- Mouse.moveRandomly(random(180, 310));
- } while (Menu.isOpen());
- i = 0;
- }
- }
- } catch (final Exception e) {
- }
- return false;
- }
- /**
- * Performs the specified action on a given GameObject. Version 1.00
- *
- * @param GameObject
- * The GameObject to perform an action on.
- * @param Action
- * the menu item to search and click.
- * @return returns true if clicked.
- *
- * @Author Ubuntu4life
- */
- private boolean clickGameObject(final GameObject GameObject, final String action) {
- try {
- Point targetPoint;
- for (int i = 0; i < 25; i++) {
- while (!Menu.contains(action)) {
- if (Players.getMyPlayer().isMoving()) {
- targetPoint = GameObject.getModel().getCentralPoint();
- } else {
- targetPoint = GameObject.getModel().getPoint();
- }
- if (!GameObject.isOnScreen() || Bank.isOpen()) {
- return false;
- }
- moveMouse(getDelay(targetPoint), targetPoint);
- }
- final String[] MenuItems = Menu.getItems();
- if (MenuItems.length > 0
- && MenuItems[0].toLowerCase().startsWith(
- action.toLowerCase())) {
- Mouse.click(true);
- return true;
- } else if (Menu.contains(action)) {
- Mouse.setSpeed(random(5, 8));
- Mouse.click(false);
- for (int x = 0; x < 4; x++) {
- if (Menu.doAction(action)) {
- return true;
- }
- }
- }
- if (!Menu.contains(action) && Menu.isOpen()) {
- do {
- Mouse.moveRandomly(random(180, 310));
- } while (Menu.isOpen());
- i = 0;
- }
- }
- } catch (final Exception e) {
- }
- return false;
- }
- private double getDelay(final Point p) {
- final double Distance = Calculations.distanceBetween(Mouse.getLocation(), p);
- if (Distance > 150) {
- return 60;
- } else {
- if (Distance >= 40) {
- return Distance / 4;
- } else {
- return 20;
- }
- }
- }
- private void moveMouse(final double time, final Point p) {
- final double endTime = System.currentTimeMillis() + time;
- while (System.currentTimeMillis() < endTime) {
- Mouse.move(p, 0, 0);
- }
- }
- /**
- * @author Alex
- *
- * Attacks an npc with the ID you input, will walk if npc isnt in combat and will only attack
- * if npc isn't already in combat.
- *
- * @param npc
- * The ID of the npc you wish to attack.
- */
- private void attack(int npc){
- NPC i = NPCs.getNearest(npc);
- if(i != null){
- if(i.isOnScreen()){
- if(!i.isInCombat()){
- i.interact("Attack");
- sleep(1200);
- while(Players.getMyPlayer().isInCombat() || Players.getMyPlayer().isMoving()){
- sleep(500);
- }
- }
- } else {
- Walking.walkTileMM(i.getLocation());
- }
- }
- }
- /**
- * Extracts images from an external server.
- *
- * @return The image.
- */
- private Image getImage(final String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (final IOException e) {
- return null;
- }
- }
- @Override
- public void mouseClicked(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- }