Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.awt.*;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Condition;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Game;
- import org.powerbot.game.api.methods.Tabs;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.GroundItems;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.util.Filter;
- import org.powerbot.game.api.util.Random;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.api.util.Timer;
- import org.powerbot.game.api.wrappers.Area;
- import org.powerbot.game.api.wrappers.Tile;
- import org.powerbot.game.api.wrappers.interactive.NPC;
- import org.powerbot.game.api.wrappers.map.TilePath;
- import org.powerbot.game.api.wrappers.node.Item;
- import org.powerbot.game.api.wrappers.widget.WidgetChild;
- import org.powerbot.game.bot.event.listener.PaintListener;
- @Manifest(name = "TEST FISHER", description = "TEST THIS ONE", version = 0.1, authors = {"brandon"})
- public class TEST extends ActiveScript implements PaintListener {
- //PAINT VARRIABLES
- String status;
- String Location;
- public Timer TIME;
- public Timer ERROR_TIMES;
- long runtime;
- int runningFishCount = -1;
- int startCount = -1;
- int bankedfishCount = 0;
- int animation;
- int client_state;
- int fish = 0;
- int before;
- int after;
- int FISH;
- private final boolean fishing = true;
- private final boolean fly = true;
- private final boolean bank = true;
- private final boolean pickup = true;
- private final boolean GP_priority = true;
- private final boolean XP_priotiy = false;
- private final int fishies[] = {335,331,349};
- private final int fishA1 = 335;// trout
- private final int fishA2 = 331;//salmon
- private final int fishA3 = 349;//pike
- private final int pools[] = {328};
- private final int items[] = {314,313};
- //private final int fishA[] = {623};
- private final int banks = 553;
- //barbarian outpost
- private final Area lebank = new Area(new Tile(3091, 3488, 0) , new Tile(3097, 3498, 0));
- private final Area lefish = new Area(new Tile(3099, 3423, 0) , new Tile(3112, 3440, 0));
- public final Tile[] Bankpath = {
- new Tile(3105, 3431, 0), new Tile(3100, 3440, 0),
- new Tile(3097, 3450, 0), new Tile(3096, 3460, 0),
- new Tile(3098, 3470, 0), new Tile(3101, 3481, 0),
- new Tile(3093, 3491, 0)
- };
- private final TilePath pathToBank = new TilePath(Bankpath);
- public final Tile[] Fishpath = {
- new Tile(3093, 3491, 0) , new Tile(3101, 3481, 0),
- new Tile(3098, 3470, 0), new Tile(3096, 3460, 0),
- new Tile(3097, 3450, 0), new Tile(3100, 3440, 0),
- new Tile(3105, 3431, 0)
- };
- public final TilePath pathToFish = new TilePath(Fishpath);
- public void setup(){
- provide(new Strategy(new Fish_1(), new Fish_1()));
- provide(new Strategy(new Fish_2(), new Fish_2()));
- provide(new Strategy(new Pick_up_1(), new Pick_up_1()));
- provide(new Strategy(new Pick_up_2(), new Pick_up_2()));
- provide(new Strategy(new Drop(),new Drop()));
- provide(new Strategy(new Walk_to_bank(), new Walk_to_bank()));
- provide(new Strategy(new Bank(), new Bank()));
- provide(new Strategy(new Walk_to_fish(), new Walk_to_fish()));
- provide(new Strategy(new Record_error(), new Record_error()));
- provide(new Strategy(new Anti_Ban(), new Anti_Ban()));
- }
- public class Fish_1 implements Task, Condition{
- public void run(){
- status = "fishing";
- NPC pool = NPCs.getNearest(pools);
- if(lefish.contains(Players.getLocal().getLocation()))
- pool.interact("lure");
- Time.sleep(Random.nextInt(6000, 12000));
- }
- public boolean validate() {
- return fishing == true
- && GP_priority == true
- && pickup == true
- && fly == true
- && Players.getLocal().getAnimation() == -1
- && !Inventory.isFull()
- && GroundItems.getLoaded(fishA1) == null
- && GroundItems.getLoaded(fishA2) == null
- && GroundItems.getLoaded(fishA3) == null;
- }
- }
- public class Fish_2 implements Task, Condition{
- public void run(){
- status = "fishing";
- NPC pool = NPCs.getNearest(pools);
- if(lefish.contains(Players.getLocal().getLocation()))
- pool.interact("lure");
- Time.sleep(Random.nextInt(6000, 12000));
- }
- public boolean validate(){
- return XP_priotiy == true
- && fishing == true
- && pickup == true
- && fly == true
- && Players.getLocal().getAnimation() == -1
- && !Inventory.isFull();
- }
- }
- public class Pick_up_1 implements Task, Condition{
- public void run(){
- status = "picking up fish";
- before = Inventory.getCount(fishies);
- if(lefish.contains(Players.getLocal().getLocation())){
- Mouse.click(GroundItems.getNearest(fishies).getLocation().getCentralPoint(), true);
- Time.sleep(Random.nextInt(300, 500));
- after = Inventory.getCount(fishies);
- if(after - before == 1){
- ++fish;
- }
- }
- }
- public boolean validate(){
- return pickup == true
- && fly == true
- && Players.getLocal().getAnimation() == -1
- && !Inventory.isFull()
- && GP_priority == true;
- }
- }
- public class Pick_up_2 implements Task, Condition{
- public void run(){
- status = "picking up fish";
- before = Inventory.getCount(fishies);
- if(lefish.contains(Players.getLocal().getLocation())){
- Mouse.click(GroundItems.getNearest(fishies).getLocation().getCentralPoint(), true);
- Time.sleep(Random.nextInt(300, 500));
- after = Inventory.getCount(fishies);
- if(after - before == 1){
- ++fish;
- }
- }
- }
- public boolean validate(){
- return XP_priotiy == true
- && NPCs.getLoaded(pools) == null;
- }
- }
- public class Drop implements Task, Condition{
- public void run(){
- status = "droping";
- dropAllExcept(items);
- Time.sleep(Random.nextInt(300, 500));
- }
- public boolean validate(){
- return Inventory.isFull()
- && Players.getLocal().getAnimation() == -1
- && bank == false
- && pickup == false;
- }
- }
- public class Walk_to_bank implements Task, Condition{
- public void run(){
- status = "walking to bank";
- traverse(pathToBank);
- }
- public boolean validate(){
- return Players.getLocal().getAnimation() == -1
- && Inventory.isFull()
- && bank == true;
- }
- }
- public class Bank implements Task, Condition{
- public void run(){
- status = "banking";
- NPC bank = NPCs.getNearest(new Filter<NPC>(){
- public boolean accept(NPC npc){
- return npc.getId() == banks;
- }
- });
- if( lebank.contains(Players.getLocal().getLocation())){
- status = "selecting bank";
- if (bank != null){
- if (bank.isOnScreen()){
- bank.interact("bank");
- Time.sleep(Random.nextInt(300, 500));
- status = "interacting";
- }}
- status = "storing";
- Time.sleep(Random.nextInt(100,150 ));
- depositAllExcept(items);
- Time.sleep(Random.nextInt(250,300));
- Widgets.get(11, 15).interact("Close");
- }
- }
- public boolean validate(){
- return bank == true
- && Inventory.isFull()
- && Players.getLocal().getAnimation() == -1;
- }
- }
- public class Walk_to_fish implements Task, Condition{
- public void run(){
- status = "walking to fish";
- if(!lefish.contains(Players.getLocal().getLocation()))
- {traverse(pathToFish);
- Time.sleep(Random.nextInt(400, 600));
- }
- }
- public boolean validate(){
- return !Inventory.isFull()
- && Players.getLocal().getAnimation() == -1;
- }
- }
- public class Record_error implements Task, Condition{
- public void run(){
- if(Game.getClientState() == 3){
- runtime = TIME.getElapsed();
- log.info("what was it doing ?"+status);
- log.info("how long did it run?"+ runtime);
- log.info("Start again?");
- }
- }
- public boolean validate(){
- return true;
- }
- }
- public class Get_paint_info implements Task, Condition{
- public void run(){
- animation = Players.getLocal().getAnimation();
- client_state = Game.getClientState();
- }
- public boolean validate(){
- return true;
- }
- }
- public class Anti_Ban implements Task, Condition{
- public void run(){
- }
- public boolean validate(){
- return true;
- }
- }
- public void traverse(TilePath path) {
- if (Tabs.INVENTORY.isOpen()) {
- if (Players.getLocal().getSpeed() == 0) {
- for (int i=0; i<10 && (Players.getLocal().getSpeed() == 0); i++) {
- path.getNext().clickOnMap();
- Time.sleep(500);
- }
- if (Players.getLocal().getSpeed() == 0) { //used as a failsafe when mouse keeps trying to traverse but just clicks edge of minimap
- Mouse.click(Random.nextInt(627-30, 627 + 30), Random.nextInt(85-30, 85+30), true); // x:627 & y:85 = exact center of minimap
- }
- } else {
- path.traverse();
- }
- } else {
- Tabs.INVENTORY.open();
- }
- }
- public void depositAllExcept(int... item) {
- ArrayList<Integer> ids = new ArrayList<Integer>();
- int ninvCount = -1;
- int invCount = Inventory.getCount();
- for (int id : item) {
- ids.add(id);
- }
- for (int i = 0; i < 28; i++) {
- WidgetChild slot = Widgets.get(679, 0).getChild(i);
- int slotId = slot.getChildId();
- if (slot.validate() && Inventory.getCount(slotId) > 0) {
- if (!ids.contains(slotId)) {
- for (int tries = 0; tries < 5; tries++) {
- if (Inventory.getCount(slotId) > 1) {
- if (slot.interact("Deposit-All"));
- else
- tries = 5;
- } else {
- if (slot.interact("Deposit"));
- else
- tries = 5;
- }
- Time.sleep(625, 902);
- ninvCount = Inventory.getCount();
- if (invCount > ninvCount) {
- invCount = ninvCount;
- tries = 5;
- }
- }
- }
- }
- }
- }
- public void dropAllExcept(final int... nodrop) {
- for(Item item : Inventory.getItems(new Filter<Item>() {
- @Override
- public boolean accept(Item arg0) {
- for(int i : nodrop) {
- if(arg0.getId() == i)
- return false;
- }
- return true;
- }
- })) {
- item.getWidgetChild().interact("Drop");
- Time.sleep(150, 300);
- }
- }
- private final Color color1 = new Color(255, 255, 255);
- private final Color color2 = new Color(0, 0, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 20);
- private final Font font2 = new Font("Arial", 0, 10);
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.fillRect(22, 357, 468, 87);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(22, 357, 468, 87);
- g.setFont(font1);
- g.drawString("FISHER", 223, 378);
- g.setFont(font2);
- g.drawString("status" + status, 26, 395);
- g.drawString("client state" + client_state, 27, 414);
- g.drawString("time:" + TIME, 29, 434);
- g.drawString("fish cought:" + fish, 295, 393);
- }
- //END: Code generated using Enfilade's Easel
- }
Add Comment
Please, Sign In to add comment