Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.Insets;
- import java.awt.Paint;
- import java.awt.Rectangle;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.*;
- import java.util.*;
- import java.net.*;
- import java.util.List;
- import java.util.logging.Level;
- import java.lang.reflect.Method;
- import javax.accessibility.*;
- import javax.swing.*;
- import org.rsbot.*;
- import org.rsbot.bot.Bot;
- import org.rsbot.script.*;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.event.listeners.*;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.util.ScreenshotUtil;
- @ScriptManifest(authors = { "Conderoga" }, keywords = "Fishing", name = "C's Power Flyfisher", version = 1.03,description = "Fishes trout, salmon & leaping fish.")
- /*UpdateLog:
- v1.000 - GUI, Antiban, Should work anywhere?
- v1.001 - Fixed double click problem, added failsafe mechanism
- v1.002 - Fixed antiban, fixed failsafe
- v1.01 - Added Shilo Village
- v1.02 - Added Barbarian Leaping Fishing, and more failsafes
- v1.03 - New Dropping Method
- */
- public class CPowerFish extends Script implements PaintListener, ServerMessageListener {
- //Paint stuff
- private int startLevel;
- private int startExp;
- private int expGained;
- private int lvlsGained;
- private long startTime;
- private double startTimeDbl;
- private long ExpHr;
- //Script stuff
- private int [] equipment;
- private int animId;
- private int spawnID;
- private String action;
- private String status;
- private int failSafe;
- private int amntTrout;
- private int amntSalmon;
- private int amntLTrout;
- private int amntLSalmon;
- private int amntLSturgeon;
- private RSTile [] toBank;
- private RSTile [] toFish;
- private int bankerID;
- private double [] columns= {563,605,647,689};
- private double [] rows = {213,249,285,321,357,393,429};
- //Other stuff
- private int safety = 0;
- private String version = "v1.03";
- CPowerFishGUI gui;
- private boolean guiWait = true;
- private boolean guiExit = true;
- private String type = "";
- private RSTile loc;
- public boolean onStart() {
- gui = new CPowerFishGUI();
- gui.setVisible(true);
- while(guiWait)
- {
- sleep(100);
- }
- startTime = System.currentTimeMillis();
- startTimeDbl = System.currentTimeMillis();
- //Credits to Zombieknight for this:-----------------
- final int welcome = JOptionPane.showConfirmDialog(null,"Before using my script, would you like to thank me\nby clicking some adverts?","Welcome", JOptionPane.YES_NO_OPTION);
- if (welcome == 0) {
- final String message = "<html>Thank you for your support!<br />"+"You will now be redirected to an advert loop.<br />"+"Just keep pressing skip ad as long as you wish.</html>";
- JOptionPane.showMessageDialog(null, message);
- openURL("http://adf.ly/317631/agsn");
- }
- //--------------------------------------------------
- return !guiExit;
- }
- public boolean checkAnim()
- {
- for(int i = 0; i<4;i++){
- if(getMyPlayer().getAnimation()==animId||getMyPlayer().getAnimation()==animId-1||getMyPlayer().getAnimation()==animId+1)
- { status = "Fishing.";
- return true;
- }
- sleep(300);
- }
- failSafe++;
- status = "Not fishing.";
- return false;
- }
- public void fish()
- {
- RSNPC test = npcs.getNearest(spawnID);
- if(test!=null)
- {
- status = "Clicking.";
- if(test.doAction(action))
- {failSafe = 0;
- status = "Clicked";
- }
- else
- failSafe++;
- sleep(random(600,800));
- while(players.getMyPlayer().isMoving())
- sleep(random(100,200));
- }
- else
- failSafe++;
- }
- public void setUp()
- {
- if(type.equals("Barbarian Village")){
- animId = 623;
- equipment = new int[2];
- equipment[0] = 309;
- equipment[1] = 314;
- spawnID = 328;
- action = "Lure";
- amntTrout = 0;
- amntSalmon = 0;
- }
- if(type.equals("Barbarian Leaping")){
- animId=623;
- equipment = new int[2];
- equipment[0] = 11323;
- equipment[1] = 314;
- spawnID = 2722;
- action = "Use-rod";
- amntLTrout = 0;
- amntLSalmon = 0;
- amntLSturgeon = 0;
- }
- if(type.equals("Shilo Village")){
- animId = 623;
- equipment = new int[2];
- equipment[0] = 309;
- equipment[1] = 314;
- toBank = new RSTile [3];
- toBank[0] = new RSTile(2859,2971);
- toBank[1] = new RSTile(2849,2965);
- toBank[2] = new RSTile(2852,2954);
- toFish = new RSTile[3];
- toFish[0] = new RSTile(2852,2954);
- toFish[1] = new RSTile(2849,2965);
- toFish[2] = new RSTile(2859,2971);
- bankerID = 499;
- spawnID = 317;
- action = "Lure";
- amntTrout = 0;
- amntSalmon = 0;
- }
- }
- public void serverMessageRecieved(final ServerMessageEvent a){
- final String serverString = a.getMessage();
- if (serverString.toLowerCase().contains("you catch a trout"))
- amntTrout++;
- else if(serverString.toLowerCase().contains("you catch a salmon"))
- amntSalmon++;
- else if(serverString.toLowerCase().contains("you catch a leaping trout"))
- amntLTrout++;
- else if(serverString.toLowerCase().contains("you catch a leaping salmon"))
- amntLSalmon++;
- else if(serverString.toLowerCase().contains("you catch a leaping sturgeon"))
- amntLSturgeon++;
- }
- public void bank(){
- if(type.equals("Shilo Village"))
- {
- mouse.setSpeed(random(7,8));
- RSNPC banker = npcs.getNearest(bankerID);
- if(banker!=null)
- {
- do{
- while(!bank.isOpen()) {
- status = "Opening bank.";
- if(banker.doAction("Bank banker"))
- sleep(random(1000,2000));
- else
- camera.setAngle(random(1,359));
- bank.open();
- sleep(random(1000,2000));}
- status = "Depositing.";
- bank.depositAllExcept(equipment);
- sleep(random(1000,2000));
- } while(inventory.isFull());
- }
- else
- log("Can't find banker.");
- }
- }
- public void walkToBank()
- {
- status = "Walking to bank.";
- camera.setPitch(true);
- while(!atBank())
- {
- if(walking.getEnergy()> 40)
- walking.setRun(true);
- status = "Walking to bank..";
- walkPath(toBank);
- sleep(random(1500,2000));
- }
- }
- public void walkToFish()
- {
- status = "Walking to fish.";
- camera.setPitch(true);
- while(!atFish())
- {
- if(walking.getEnergy()> 40)
- walking.setRun(true);
- status = "Walking to fish..";
- walkPath(toFish);
- sleep(random(1500,2000));
- }
- }
- public boolean atBank(){
- if(type.equals("Shilo Village"))
- {
- return players.getMyPlayer().getLocation().getX()<2855&&players.getMyPlayer().getLocation().getX()>2849&&players.getMyPlayer().getLocation().getY()<2958&&players.getMyPlayer().getLocation().getY()>2951;
- }
- return false;
- }
- public boolean atFish(){
- if(type.equals("Shilo Village"))
- {
- return players.getMyPlayer().getLocation().getX()<2865&&players.getMyPlayer().getLocation().getX()>2854&&players.getMyPlayer().getLocation().getY()<2980&&players.getMyPlayer().getLocation().getY()>2968;
- }
- return false;
- }
- public void walkPath(RSTile [] path)
- {
- if(playerIsNear(path[path.length-2]))
- walking.walkTileMM(path[path.length-1],1,1);
- else{
- int temp = 0;
- boolean nearSomething = false;
- for(int i = 0; i<path.length;i++)
- {
- if(playerIsNear(path[i]))
- {
- nearSomething = true;
- temp = i+1;
- antiBan(random(1,200));
- for(int j = i; j<path.length; j++)
- {
- if(calc.tileToMinimap(path[j]).x==-1)
- {
- temp=j-1;
- break;
- }
- if(j==path.length-1&&calc.tileToMinimap(path[j]).x!=-1)
- {
- temp=j;
- break;
- }
- }
- walking.walkTileMM(path[temp],1,1);
- }
- }
- if(!nearSomething)
- walking.walkTileMM(walking.nextTile(path),1,1);
- }
- }
- public boolean playerIsNear(RSTile tile)
- {
- return (Math.abs(getMyPlayer().getLocation().getX()-tile.getX())<6&&Math.abs(getMyPlayer().getLocation().getY()-tile.getY())<6);
- }
- public int loop() {
- try{
- if(safety<1)
- {
- setUp();
- camera.setPitch(true);
- safety=1;
- }
- antiBan(random(1,50));
- if(!inventory.isFull()&&!checkAnim())
- fish();
- if(!inventory.contains(equipment[1]))
- {
- log("Out of feathers, stopping script.");
- game.logout(true);
- stopScript();
- }
- while(failSafe>3&&!checkAnim())
- {
- camera.setPitch(false);
- int angle = camera.getAngle();
- if(angle<259)
- camera.setAngle(camera.getAngle()+random(80,100));
- else
- camera.setAngle(random(0,10));
- fish();
- if(!status.equals("Clicked"))
- {
- if(failSafe>6&&type.equals("Barbarian Leaping"))
- walking.walkTo(new RSTile(2500,3515));
- while(players.getMyPlayer().isMoving())
- sleep(random(100,200));
- fish();
- }
- else
- failSafe = 0;
- }
- if(inventory.isFull()){
- sleep(random(600,800));
- dropAll(equipment);
- }
- }
- catch (Exception e){}
- return random(300,500);
- }
- public void dropAll(int [] ids)
- {
- status = "Dropping";
- if(ids.length==2){
- int count = 0;
- RSItem [] inv = inventory.getItems();
- for(int i =0; i<inv.length;i++)
- if(inv[i].getID()!=ids[0]&&inv[i].getID()!=ids[1])
- count++;
- RSItem [] toDrop = new RSItem [(count/2)-1];
- count = 0;
- for(int i =0; i<inv.length;i++){
- if(count==toDrop.length)
- break;
- if(inv[i].getID()!=ids[0]&&inv[i].getID()!=ids[1])
- {toDrop[count] = inv[i];
- count++;
- }
- }
- int [] dropOrder = new int[toDrop.length];
- int index = 0;
- for(int j = 0; j<columns.length;j++)
- for(int i =0; i<toDrop.length;i++)
- {
- if(toDrop[i].getComponent().getLocation().getX()==columns[j])
- {
- dropOrder[index]=i;
- index++;
- }
- }
- for(int i =0; i<toDrop.length;i++)
- {
- if(!toDrop[dropOrder[i]].doAction("Drop"))
- {status = "Attempting to Destroy";
- if(toDrop[dropOrder[i]].doAction("Destroy")){
- sleep(random(1000,1500));
- mouse.move(random(304,338),random(380,392),0,0);
- sleep(random(600,800));
- mouse.click(true);
- sleep(random(600,800));
- }}
- }
- }
- }
- public void antiBan(int rand){
- status += "(AB)";
- mouse.setSpeed(random(7,8));
- if(rand==1)
- if(random(1, 8) == 2)
- mouse.moveRandomly(900,1200);
- if(rand==2)
- if(random(1, 8) == 2)
- mouse.moveRandomly(400,800);
- if(rand==3)
- if(random(1, 8) == 2)
- mouse.moveRandomly(200,700);
- if(rand==4) //THIS CHECKS THE FISHING STAT
- if(random(1, 12) == 2)
- {
- game.openTab(game.TAB_STATS);
- sleep(random(600,800));
- mouse.move(random(681, 690), random(269, 291),0,0);
- sleep(random(900,1000));
- game.openTab(game.TAB_INVENTORY);
- }
- if(rand==5) //THIS CLICKS THE XP BUTTON UNDER THE COMPASS
- if(random(1, 12) == 2)
- {
- mouse.move(random(527, 540), random(58, 65),0,0);
- sleep(random(800,1000));
- mouse.click(true);
- mouse.moveRandomly(20,50);
- sleep(random(3000,4000));
- }
- if(rand==6) //THIS CHECKS CURRENT GOAL
- if(random(1, 12) == 2)
- {
- game.openTab(8);
- sleep(random(300,1000));
- mouse.move(random(604, 630), random(394, 399),0,0);
- sleep(random(3000,4000));
- }
- if(rand==7) //RANDOM SPIN
- if(random(1, 3) == 2)
- {int r = random(1,2);
- camera.setAngle(random(1,359));
- if(r!=1)
- camera.setPitch(random(1,99));}
- if(rand==8) //THIS CHECKS A RANDOM TAB
- if(random(1, 4) == 2)
- {
- int[] tabs = {0,2,3,5,6,7,9,10,11,12,13,14,15};
- game.openTab(tabs[random(0,tabs.length-1)]);
- mouse.moveRandomly(150,200);
- sleep(random(1600,1800));
- sleep(random(900,1000));
- }
- if(rand==9)
- if(random(1,10)==2)
- mouse.moveOffScreen();
- status=status.substring(0,status.indexOf('('));
- }
- public void onRepaint(Graphics g)
- {
- if(game.isLoggedIn())
- {
- try{
- if(startExp==0)
- {
- startExp = skills.getCurrentExp(skills.getIndex("fishing"));
- startLevel = skills.getCurrentLevel(skills.getIndex("fishing"));
- }
- lvlsGained = skills.getCurrentLevel(skills.getIndex("fishing")) - startLevel;
- expGained = skills.getCurrentExp(skills.getIndex("fishing")) - startExp;
- //setting up the time
- long ms = System.currentTimeMillis() - startTime;
- double ms2 = System.currentTimeMillis() - startTimeDbl;
- long hours = ms/3600000;
- ms = ms-(hours*3600000);
- long minutes = ms/60000;
- ms = ms-(minutes*60000);
- long seconds = ms/1000;
- // |
- //Background v transparency!
- g.setColor(new Color(0, 0, 0, 205));
- g.fillRoundRect(333, 175, 181, 164, 6, 6); //Background
- long expToLvl = skills.getExpToNextLevel(skills.getIndex("fishing"));
- long time2Lvl = 0;
- long time2LvlHrs = 0;
- long time2LvlMins = 0;
- long time2LvlSec = 0;
- if(ms2!=0&&expGained!=0){
- time2Lvl = (long)(expToLvl/(expGained/(ms2/3600000))*3600000);
- time2LvlHrs = time2Lvl/3600000;
- time2Lvl -= time2LvlHrs*3600000;
- time2LvlMins = time2Lvl/60000;
- time2Lvl -= time2LvlMins*60000;
- time2LvlSec = time2Lvl/1000;
- }
- //Text Color and Output
- g.setColor(new Color(255,0,0,255));
- g.setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
- g.drawString("C's Power Flyfisher "+version,338,192);
- g.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
- g.drawString("Levels Gained: "+lvlsGained,344,207);
- if(type.equals("Barbarian Leaping"))
- g.drawString("Fish Caught: "+(amntLTrout+amntLSalmon+amntLSturgeon),344,222);
- else
- g.drawString("Fish Caught: "+(amntTrout+amntSalmon),344,222);
- g.drawString("Exp Gained: "+expGained,344,237);
- g.drawString("Time Running: "+hours+":"+minutes+":"+seconds,344, 252);
- //Progress Bar
- g.fillRoundRect(344,256,150,20,8,8); //Bar background
- g.setColor(new Color(0,255,0,255)); //GREEN
- g.fillRoundRect(344,256,(int)(skills.getPercentToNextLevel(skills.getIndex("fishing"))*1.5),20,8,8);
- g.setColor(new Color(0,0,0,255));
- g.setColor(new Color(255,255,255,100));
- g.drawString(skills.getPercentToNextLevel(skills.getIndex("fishing"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("fishing"))+1)+" ("+expToLvl+" exp)",348,271);
- g.fillRoundRect(345,266,148,10,8,8);
- g.setColor(new Color(0,0,0,255));
- g.drawString(skills.getPercentToNextLevel(skills.getIndex("fishing"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("fishing"))+1)+" ("+expToLvl+" exp)",347,270);
- g.setColor(new Color(255,0,0,255));
- if(ms2!=0)
- g.drawString("Exp/Hr: "+(int)(expGained/(ms2/3600000)),344,289);
- g.drawString("Status: "+status,344,304);
- if(type.equals("Barbarian Leaping")){
- if(expGained!=0&&amntLTrout+amntLSalmon+amntLSturgeon!=0)
- g.drawString("Fish to Lvl: "+(int)(expToLvl/(expGained/(amntLTrout+amntLSalmon+amntLSturgeon))),344,319);
- }
- else if(expGained!=0&&amntTrout+amntSalmon!=0)
- g.drawString("Fish to Lvl: "+(int)(expToLvl/(expGained/(amntTrout+amntSalmon))),344,319);
- g.drawString("Est. Time to Lvl: "+time2LvlHrs+":"+time2LvlMins+":"+time2LvlSec,344,334);
- //Mouse Stuff
- Point tempPoint = mouse.getLocation();
- int tempXCoordinate = (int)tempPoint.getX();
- int tempYCoordinate = (int)tempPoint.getY();
- g.setColor(new Color(0,255,0,100));
- g.drawLine(tempXCoordinate,0,tempXCoordinate,501);
- g.drawLine(0,tempYCoordinate,764,tempYCoordinate);
- }catch(Exception E){}
- }
- }
- public void onFinish() {
- log("Exp gained: "+expGained);
- log("Levels gained: "+lvlsGained);
- log("Thanks for using Conderoga's Power Flyfisher!");
- }
- public void openURL(final String url) { // Credits ZombieKnight
- //who gave credits to Dave who gave credits
- // to
- // some guy who made this.
- final String osName = System.getProperty("os.name");
- try {
- if (osName.startsWith("Mac OS")) {
- final Class<?> fileMgr = Class
- .forName("com.apple.eio.FileManager");
- final Method openURL = fileMgr.getDeclaredMethod("openURL",new Class[]{String.class});
- openURL.invoke(null, new Object[]{url});
- } else if (osName.startsWith("Windows")) {
- Runtime.getRuntime().exec(
- "rundll32 url.dll,FileProtocolHandler " + url);
- } else { // assume Unix or Linux
- final String[] browsers = {"firefox", "opera", "konqueror",
- "epiphany", "mozilla", "netscape"};
- String browser = null;
- for (int count = 0; count < browsers.length && browser == null; count++) {
- if (Runtime.getRuntime().exec(
- new String[]{"which", browsers[count]})
- .waitFor() == 0) {
- browser = browsers[count];
- }
- }
- if (browser == null) {
- throw new Exception("Could not find web browser");
- } else {
- Runtime.getRuntime().exec(new String[]{browser, url});
- }
- }
- } catch (final Exception e) {
- }
- }
- public class CPowerFishGUI extends JFrame {
- private static final long serialVersionUID = 1L;
- public CPowerFishGUI()
- {
- initComponents();
- }
- private void button2ActionPerformed(ActionEvent e)
- {
- guiWait = false;
- guiExit = true;
- dispose();
- }
- private void button1ActionPerformed(ActionEvent e)
- {
- type = comboBox1.getSelectedItem().toString();
- guiExit = false;
- guiWait = false;
- dispose();
- }
- private void initComponents() {
- label1 = new JLabel();
- label2 = new JLabel();
- comboBox1 = new JComboBox();
- label3 = new JLabel();
- button1 = new JButton();
- button2 = new JButton();
- setTitle("Conderoga's Power Flyfisher");
- setResizable(false);
- setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //---- label1 ----
- label1.setText("Conderoga's Power Flyfisher Settings");
- label1.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
- contentPane.add(label1);
- label1.setBounds(10, -10, 380, 70);
- //---- label2 ----
- label2.setText("Select the location: ");
- contentPane.add(label2);
- label2.setBounds(new Rectangle(new Point(15, 50), label2.getPreferredSize()));
- //---- comboBox1 ----
- comboBox1.setMaximumRowCount(3);
- comboBox1.setModel(new DefaultComboBoxModel(new String[] {
- "Barbarian Village",
- "Shilo Village",
- "Barbarian Leaping"
- }));
- contentPane.add(comboBox1);
- comboBox1.setBounds(175, 45, 125, 25);
- //---- label3 ----
- label3.setText(version);
- contentPane.add(label3);
- label3.setBounds(15, 80, 124, label3.getPreferredSize().height);
- //---- button1 ----
- button1.setText("Start!");
- button1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- button1ActionPerformed(e);
- }
- });
- contentPane.add(button1);
- button1.setBounds(40, 115, 75, 30);
- //---- button2 ----
- button2.setText("Exit");
- button2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- button2ActionPerformed(e);
- }
- });
- contentPane.add(button2);
- button2.setBounds(200, 115, 75, 30);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPane.getComponentCount(); i++)
- {
- Rectangle bounds = contentPane.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = contentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- contentPane.setMinimumSize(preferredSize);
- contentPane.setPreferredSize(preferredSize);
- }
- setSize(325, 190);
- setLocationRelativeTo(getOwner());
- }
- private JLabel label1;
- private JLabel label2;
- private JComboBox comboBox1;
- private JLabel label3;
- private JButton button1;
- private JButton button2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement