import org.rsbot.script.Script; import org.rsbot.script.ScriptManifest; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import org.rsbot.event.events.MessageEvent; import org.rsbot.event.listeners.MessageListener; import org.rsbot.event.listeners.PaintListener; import org.rsbot.script.wrappers.RSComponent; import org.rsbot.script.wrappers.RSNPC; import org.rsbot.script.wrappers.RSTile; //gui import javax.imageio.ImageIO; import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.LayoutStyle; //end gui //idk import java.io.IOException; import java.net.URL; //end IDK import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.awt.BasicStroke; import java.awt.Image; import org.rsbot.util.GlobalConfiguration; @ScriptManifest(authors = "Ryan - Goofy", name = "GoofyScriptsKaramjaFisher", version = 3.6, description = "Fishes in Karamja, uses Stiles") public class GoofyScriptsKaramjaFisher extends Script implements PaintListener, MessageListener, MouseListener{ int[] equipID = {301,311}; int[] spotID = {324}; int[] noDrop = {301,311,995,378,372,371,360}; int tuna = 359; int lob = 377; int sword = 371; int stilesID = 11267; public int f = 0; public int d = 0; public int p = 0; public long startTime = 0; public long millis = 0; public long hours = 0; public long minutes = 0; public long seconds = 0; public long last = 0; public int tunasfished = 0; public int lobstersfished = 0; public int swordfishfished = 0; private int startExp = 0; public int expGained = 0; public int expHour = 0; public int expTNL = 0; public int tunashour = 0; public int lobshour = 0; public int swordshour = 0; public int logsHour = 0; public int fishHour = 0; public int logsTNL; public int currLevel; public int startLevel; public int lvlsGained; private int percentTNL; public int tunaprice = 0; public int lobsterprice = 0; public int swordfishprice = 0; public int profit = 0; String item; String antiban; String status; public int profithour = 0; BufferedImage normal = null; BufferedImage clicked = null; private boolean guiWait = true; gui g = new gui(); //updater private static final String UPDATER_FILE_NAME = "GoofyScriptsKaramjaFisher.java"; private static final String UPDATER_URL = "http://dl.dropbox.com/u/26482180/GoofyScriptsKaramjaFisher.java"; private double currentVer = GoofyScriptsKaramjaFisher.class.getAnnotation(ScriptManifest.class).version(); private static final Pattern UPDATER_VERSION_PATTERN = Pattern.compile("version\\s*=\\s*([0-9.]+)"); //endupdater //hide paint public boolean showPaint; //end RSTile[] FishtoStiles = { new RSTile(2923,3179) , new RSTile(2922,3174) , new RSTile(2916,3174) , new RSTile(2909,3173) , new RSTile(2901,3171) , new RSTile(2899,3166) , new RSTile(2899,3160) , new RSTile(2898,3154) , new RSTile(2898,3149) , new RSTile(2897,3145) , new RSTile(2892,3144) , new RSTile(2888,3142) , new RSTile(2884,3141) , new RSTile(2878,3142) , new RSTile(2872,3144) , new RSTile(2868,3145) , new RSTile(2864,3147) , new RSTile(2861,3145) , new RSTile(2855,3144) , new RSTile(2851,3142) }; RSTile[] StilestoFish = { new RSTile(2851,3142) , new RSTile(2855,3144) , new RSTile(2861,3145) , new RSTile(2864,3147) , new RSTile(2868,3145) , new RSTile(2872,3144) , new RSTile(2878,3142) , new RSTile(2884,3141) , new RSTile(2888,3142) , new RSTile(2892,3144) , new RSTile(2897,3145) , new RSTile(2898,3149) , new RSTile(2898,3154) , new RSTile(2899,3160) , new RSTile(2899,3166) , new RSTile(2901,3171) , new RSTile(2909,3173) , new RSTile(2916,3174) , new RSTile(2922,3174) , new RSTile(2923,3179) }; RSTile[] FishtoStilesF = { new RSTile(2923,3174) , new RSTile(2919,3175) , new RSTile(2914,3175) , new RSTile(2912,3172) , new RSTile(2906,3172) , new RSTile(2904,3171) , new RSTile(2898,3170) , new RSTile(2897,3168) , new RSTile(2893,3167) , new RSTile(2888,3166) , new RSTile(2884,3165) , new RSTile(2881,3162) , new RSTile(2878,3159) , new RSTile(2872,3157) , new RSTile(2867,3154) , new RSTile(2865,3152) , new RSTile(2863,3150) , new RSTile(2859,3147) , new RSTile(2856,3145) , new RSTile(2852,3142) }; RSTile[] StilestoFishF = { new RSTile(2851,3143) , new RSTile(2856,3144) , new RSTile(2861,3148) , new RSTile(2869,3152) , new RSTile(2875,3155) , new RSTile(2880,3158) , new RSTile(2886,3162) , new RSTile(2892,3165) , new RSTile(2901,3169) , new RSTile(2907,3172) , new RSTile(2913,3173) , new RSTile(2918,3175) , new RSTile(2923,3174) , new RSTile(2924,3180) }; public boolean onStart(){ log("Welcome to Goofy's Scripts Karamja Fisher/Stiler -Checking for Updates-"); checkForUpdates(); log("Welcome to Goofy's Scripts Karamja Fisher/Stiler -Loading Price-"); showPaint = true; startTime = System.currentTimeMillis(); startExp = skills.getCurrentExp(skills.FISHING); startLevel = skills.getCurrentLevel(skills.FISHING); tunaprice = grandExchange.lookup(tuna).getGuidePrice(); lobsterprice = grandExchange.lookup(lob).getGuidePrice(); swordfishprice = grandExchange.lookup(sword).getGuidePrice(); log("-Price Loaded- Tuna price is " +tunaprice + " gp."); log("-Price Loaded- SwordFish price is " +swordfishprice + " gp."); log("-Price Loaded- Lobster price is " +lobsterprice + " gp."); g.setVisible(true); while(guiWait) sleep(500); if(d==1){ tunaprice = 0; } return true; } //uploader private boolean checkForUpdates() { try { double newVer = -1; URL url = new URL(UPDATER_URL); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String line, lines = ""; Matcher m; while ((line = in.readLine()) != null) { lines += line + "\n"; if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) { newVer = Double.parseDouble(m.group(1)); break; } } if (newVer < 0) { in.close(); log(Color.red, "Unable to find the new version - update failed"); return false; } if (currentVer == newVer) { in.close(); log(Color.green, "You have the latest script version"); return false; } log(Color.BLUE, "Update found! Downloading version " + newVer); String scriptFilePath = GlobalConfiguration.Paths.getScriptsSourcesDirectory() + "\\" + UPDATER_FILE_NAME; PrintWriter out = new PrintWriter(scriptFilePath); out.print(lines); while ((line = in.readLine()) != null) { out.println(line); } out.close(); in.close(); log("Successfully saved " + UPDATER_FILE_NAME + " to " + GlobalConfiguration.Paths.getScriptsSourcesDirectory()); log.warning("Please compile scripts to run the latest version."); return true; } catch (IOException e) { log(e.toString()); log("Update failed."); } return false; } //end uploader public void MouseSpeed() { int rand = random(1, 5); if (rand == 1) { mouse.setSpeed(random(4, 7)); } if (rand == 2) { mouse.setSpeed(random(5, 10)); } if (rand == 3) { mouse.setSpeed(random(2, 5)); } if (rand == 4) { mouse.setSpeed(random(2, 10)); } } private boolean walkPath(RSTile[] path) { if (calc.distanceTo(path[path.length - 1]) > 4) { RSTile n = getNext(path); if(n!=null){ walking.walkTileMM(n.randomize(2, 2)); if(random(1,6) != 2){ mouse.moveRandomly(20); } } } return false; } private RSTile getNext(RSTile[] path) { boolean found = false; for (int a = 0; a < path.length&&!found; a++) { if(calc.tileOnMap(path[path.length-1-a])){ found = true; return path[path.length-1-a]; } } return null; } public void doFish(){ if (!(getMyPlayer().getAnimation() == 619)) { if(f == 0){ RSNPC spot = npcs.getNearest(spotID); spot.doAction("Cage"); sleep(random(400,600)); if(!spot.isOnScreen()){ int z = random(1, 3); if(z==2){ camera.setAngle(random(-359, 359)); } } } } if (!(getMyPlayer().getAnimation() == 618)) { if(f == 1){ RSNPC spot = npcs.getNearest(spotID); spot.doAction("Harpoon"); sleep(random(400,600)); if(!spot.isOnScreen()){ int z = random(1, 3); if(z==2){ camera.setAngle(random(-359, 359)); } } } } sleep(random(600,800)); } public boolean atFish(){ RSNPC spot = npcs.getNearest(spotID); if (spot !=null) { if(spot.isOnScreen()) { return true; } } return false; } public void doStiles(){ status = ("Talking to Stiles"); RSNPC stiles = npcs.getNearest(stilesID); stiles.doAction("Exchange"); camera.setAngle(random(1, 359)); sleep(random(400,600)); } public boolean atStiles(){ RSNPC stiles = npcs.getNearest(stilesID); if (stiles !=null) { if(stiles.isOnScreen()) { return true; }else { } } return false; } public void wiggle() { int x, y; x = random(500, 650); y = random(300, 420); mouse.move(x, y); sleep(25, 674); x = random(500, 650); y = random(300, 420); mouse.move(x, y); sleep(1, 240); } public void mouseAntiban() { int r = random(1, 20); if (r == 4) { antiban = ("Mouse Wiggle"); wiggle(); } else if (r == 8) { antiban = ("Angle Adjustment"); camera.setAngle(random(1, 359)); } else if (r == 12) { antiban = ("Mouse off screen"); mouse.moveOffScreen(); } else if (r == 16) { int t = random(1, 3); if(t == 2){ antiban = ("Checking Exp"); game.openTab(1); skills.doHover(skills.INTERFACE_FISHING); sleep(random(2100, 3400)); } }else{ antiban = ("Idle"); } } public void dropTuna(){ if(d ==1){ status = ("Dropping Tuna"); inventory.dropAllExcept(noDrop); } } public void onFinish(){ log("Thanks for using Goofy Script's Karamja Fisher"); log("You made a total of " + profit + "gp"); log("You gained a total of " + expGained + " exp and leveled up " +lvlsGained + " times"); env.saveScreenshot(false); } public int loop() { if(inventory.isFull()){ dropTuna(); if(inventory.isFull()){ if(atStiles()){ doStiles(); }else{ status = ("Walking to Stiles"); if(p==1){ walkPath(FishtoStilesF); }else{ walkPath(FishtoStiles); } } }else { doFish(); } }else if(!inventory.isFull()){ if(atFish()){ doFish(); mouseAntiban(); }else{ status = ("Walking to Fish"); if(p==1){ walkPath(StilestoFishF); }else{ walkPath(StilestoFish); } } } if (!walking.isRunEnabled() && walking.getEnergy() > random(60, 90)) { walking.setRun(true); return random(200, 600); } if ((getMyPlayer().getAnimation() == 618 )||(getMyPlayer().getAnimation() == 619 )) { status = ("Fishing"); }else { status = ("Idle"); } MouseSpeed(); return(random(500,750)); } @Override public void mouseClicked(MouseEvent e) { RSComponent inter = interfaces.get(137).getComponent(0); if (inter.getArea().contains(e.getPoint())) { showPaint = !showPaint; } } //START: Code generated using Enfilade's Easel //START: Code generated using Enfilade's Easel private Image getImage(String url) { try { return ImageIO.read(new URL(url)); } catch(IOException e) { return null; } } private final Color color1 = new Color(255, 255, 229); private final Color color2 = new Color(0, 0, 0); private final Color color4 = new Color(255, 0, 0); private final Color color5 = new Color(51, 255, 51); private final BasicStroke stroke1 = new BasicStroke(1); private final BasicStroke stroke2 = new BasicStroke(2); private final Font font1 = new Font("Arial", 1, 19); private final Font font2 = new Font("Arial", 1, 11); private final Font font3 = new Font("Arial", 1, 13); private final Image img1 = getImage(""); private final Image img2 = getImage(""); private final Image img3 = getImage("http://www.rsgoldsell.com/images/gold.gif"); public void onRepaint(Graphics g1) { if (showPaint) { Graphics2D g = (Graphics2D)g1; if(f==1){ item="Harpoon"; } else if(f==0){ item="Cage"; } else { item = "Loading"; } millis = System.currentTimeMillis() - startTime; hours = millis / (1000 * 60 * 60); millis -= hours * (1000 * 60 * 60); minutes = millis / (1000 * 60); millis -= minutes * (1000 * 60); seconds = millis / 1000; expGained = skills.getCurrentExp(skills.FISHING) - startExp; expHour = (int) ((expGained) * 3600000D / (System.currentTimeMillis() - startTime)); expTNL = skills.getExpToNextLevel(skills.FISHING); currLevel = skills.getCurrentLevel(skills.FISHING); lvlsGained = currLevel - startLevel; percentTNL = skills.getPercentToNextLevel(skills.FISHING); tunashour = (int) ((tunasfished) * 3600000D / (System.currentTimeMillis() - startTime)); lobshour = (int) ((lobstersfished) * 3600000D / (System.currentTimeMillis() - startTime)); swordshour = (int) ((swordfishfished) * 3600000D / (System.currentTimeMillis() - startTime)); profit = (swordfishfished * swordfishprice ) + (tunasfished * tunaprice) + (lobstersfished * lobsterprice); profithour = (int) ((profit) * 3600000D / (System.currentTimeMillis() - startTime)); percentTNL = skills.getPercentToNextLevel(skills.FISHING); final int percentBar = (int) (skills.getPercentToNextLevel(skills.FISHING)*1.82); fishHour = (int) ((swordfishfished + tunasfished + lobstersfished)* 3600000D / (System.currentTimeMillis() - startTime)); g.setColor(color2); g.drawLine(0, (int)(mouse.getLocation().getY()), 800, (int)(mouse.getLocation().getY())); g.drawLine((int)(mouse.getLocation().getX()), 0, (int)(mouse.getLocation().getX()), 800); g.setColor(color2); g.drawLine(0, (int)(mouse.getLocation().getY()) +1, 800, (int)(mouse.getLocation().getY())+1); g.drawLine((int)(mouse.getLocation().getX()) +1, 0, (int)(mouse.getLocation().getX())+1, 800); g.setColor(color1); g.fillRect(7, 345, 504, 127); g.setColor(color2); g.setStroke(stroke1); g.drawRect(7, 345, 504, 127); g.drawImage(img1, 9, 347, null); g.drawImage(img2, 324, 348, null); g.setFont(font1); g.drawString("Goofy Script's Karamja Fisher", 43, 373); g.setStroke(stroke2); g.drawLine(9, 380, 511, 380); g.drawLine(175, 380, 175, 472); g.drawLine(359, 380, 359, 472); g.setStroke(stroke1); g.drawLine(409, 395, 471, 395); g.setFont(font2); g.drawString("Experience", 57, 393); g.drawLine(55, 395, 118, 395); g.drawLine(223, 395, 309, 395); g.drawString("Fishies Caught", 226, 393); g.drawString("Total Profit", 410, 435); g.drawLine(409, 437, 471, 437); g.drawString("Profit: " +profit, 362, 450); g.drawString("P/Hr: " +profithour, 362, 465); g.drawImage(img3, 473, 438, null); g.drawString("Status: " +status, 362, 405); g.drawString("Anitban: " +antiban, 362, 421); g.drawString("Updates", 410, 393); g.drawString("Current Level: " + currLevel + " (+" + lvlsGained + ")", 9, 409); g.drawString("Exp Gained: " + expGained, 9, 424); g.drawString("Exp P/Hr: " + expHour, 9, 441); g.drawString("Exp TNL: " + expTNL, 9, 458); g.drawString("Lobsters: " + lobstersfished + "(P/Hr: " + lobshour + ")", 177, 411); g.drawString("Tuna: " + tunasfished + "(P/Hr: " + tunashour + ")", 177, 442); g.drawString("Swordfish: " + swordfishfished + "(P/Hr: " + swordshour + ")", 178, 426); g.setFont(font3); g.drawString("RT: " + hours + ":" + minutes + ":" + seconds, 361, 376); g.drawString("Fishing with: " + item, 361, 361); g.setColor(color4); g.fillRect(176, 455, 182, 16); g.setColor(color2); g.drawRect(176, 455, 182, 16); g.setColor(color5); g.fillRect(176, 455, percentBar, 16); g.setColor(color2); g.drawRect(176, 455, percentBar, 16); g.drawString(percentTNL +"%", 250, 469); } } //END: Code generated using Enfilade's Easel public void messageReceived(MessageEvent e) { if (e.getMessage().contains("You catch a lobster")){ lobstersfished++; } if (e.getMessage().contains("catch a tuna")){ tunasfished++; } if (e.getMessage().contains("catch a swordfish")){ swordfishfished++; } } class gui extends JFrame { public gui() { initComponents(); } private void button1ActionPerformed(ActionEvent e) { if(checkBox1.isSelected()){ f=1; } if(checkBox2.isSelected()){ d=1; } if(checkBox3.isSelected()){ p=1; } guiWait = false; g.dispose(); } private void button2ActionPerformed(ActionEvent e) { if(checkBox1.isSelected()){ f=1; } if(checkBox2.isSelected()){ d=1; } if(checkBox3.isSelected()){ p=1; } guiWait = false; g.dispose(); sleep(5000); stopScript(); } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents label1 = new JLabel(); checkBox1 = new JCheckBox(); label3 = new JLabel(); button1 = new JButton(); checkBox2 = new JCheckBox(); checkBox3 = new JCheckBox(); label2 = new JLabel(); label4 = new JLabel(); button2 = new JButton(); label5 = new JLabel(); //======== this ======== Container contentPane = getContentPane(); //---- label1 ---- label1.setText("Default fishing type is Lobsters (Have a Lobster Pot in Inventory)"); //---- checkBox1 ---- checkBox1.setText("Tuna/Swordfish (Have a harpoon in inventory)"); //---- label3 ---- label3.setText("Start by Stiles or at Fishing Area"); //---- button1 ---- button1.setText("Start"); button1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button1ActionPerformed(e); } }); //---- checkBox2 ---- checkBox2.setText("Drop Tuna (Only for fishing w/ Harpoon)"); //---- checkBox3 ---- checkBox3.setText("Walk Fast Path (For People w/ High Combat Levels) "); //---- label2 ---- label2.setText("Will not drop Noted Fish, Money, and Equipment"); //---- label4 ---- label4.setText("*Note* - Will drop raw lobsters (unnoted)"); //---- button2 ---- button2.setText("Close/Exit/Stop Script"); button2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button2ActionPerformed(e); } }); //---- label5 ---- label5.setText("Thanks for using Goofy Scripts, Please post proggies!!!"); GroupLayout contentPaneLayout = new GroupLayout(contentPane); contentPane.setLayout(contentPaneLayout); contentPaneLayout.setHorizontalGroup( contentPaneLayout.createParallelGroup() .addGroup(contentPaneLayout.createSequentialGroup() .addGroup(contentPaneLayout.createParallelGroup() .addGroup(contentPaneLayout.createSequentialGroup() .addContainerGap() .addComponent(label1)) .addGroup(contentPaneLayout.createSequentialGroup() .addGap(46, 46, 46) .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(checkBox2) .addComponent(checkBox1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(label2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(label4) .addComponent(checkBox3))) .addGroup(contentPaneLayout.createSequentialGroup() .addGap(83, 83, 83) .addComponent(label3)) .addGroup(contentPaneLayout.createSequentialGroup() .addGap(4, 4, 4) .addComponent(button1, GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)) .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup() .addGap(4, 4, 4) .addComponent(button2, GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE))) .addContainerGap()) .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup() .addContainerGap(39, Short.MAX_VALUE) .addComponent(label5) .addGap(30, 30, 30)) ); contentPaneLayout.setVerticalGroup( contentPaneLayout.createParallelGroup() .addGroup(contentPaneLayout.createSequentialGroup() .addContainerGap() .addComponent(label1) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(checkBox1) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(checkBox2) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(label2) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(label4) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(checkBox3) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(label3) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(button1) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(button2) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(label5) .addGap(34, 34, 34)) ); 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 - ryan m private JLabel label1; private JCheckBox checkBox1; private JLabel label3; private JButton button1; private JCheckBox checkBox2; private JCheckBox checkBox3; private JLabel label2; private JLabel label4; private JButton button2; private JLabel label5; // JFormDesigner - End of variables declaration //GEN-END:variables } @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 } }