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 = "Fletching", name = "Conderoga's Stringer", version = 1.4,description = "The fastest stringer, ever.")
- /*UpdateLog:
- v1.0 - Updated for RSBot v2.0
- v1.1 - fixed everything
- v1.2 - fixed not starting after randoms.
- v1.3 - fixed the fix
- v1.4 - Still tinkering
- */
- public class CFletch extends Script implements PaintListener, ServerMessageListener {
- private boolean guiWait = true;
- private boolean guiExit = true;
- private String action = "WAITING";
- CFletchGui gui;
- private int unstrungBowId = 0;
- private int logId = 0;
- private int bowstring = 1777;
- private int startLevel;
- private int startExp;
- private int expGained;
- private int lvlsGained;
- private long startTime;
- private double startTimeDbl;
- private long ExpHr;
- private int safety = 0;
- private String status;
- private Point p;
- private boolean stringing = false;
- private boolean fletching = false;
- private int []bankerIds;
- private RSNPC test;
- private long stringStartTime = 0;
- private int tempNumStrung = 0;
- private int oneTimeOnly = 0;
- private String version = "v1.4";
- private int bowsStrung = 0;
- private int failsafe = 0;
- public boolean onStart() {
- gui = new CFletchGui();
- gui.setVisible(true);
- while(guiWait)
- {
- sleep(100);
- }
- log("Action: "+action);
- 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 void startUpStuff()
- {
- bankerIds = bank.BANKERS;
- test = npcs.getNearest(bankerIds);
- if(action.equals("Normal Short - String"))
- {
- stringing = true;
- unstrungBowId = 50;
- }
- if(action.equals("Normal Long - String"))
- {
- stringing = true;
- unstrungBowId = 48;
- }
- if(action.equals("Oak Short - String"))
- {
- stringing = true;
- unstrungBowId = 54;
- }
- if(action.equals("Oak Long - String"))
- {
- stringing = true;
- unstrungBowId = 52;
- }
- if(action.equals("Willow Short - String"))
- {
- stringing = true;
- unstrungBowId = 60;
- }
- if(action.equals("Willow Long - String"))
- {
- stringing = true;
- unstrungBowId = 58;
- }
- if(action.equals("Maple Short - String"))
- {
- stringing = true;
- unstrungBowId = 64;
- }
- if(action.equals("Maple Long - String"))
- {
- stringing = true;
- unstrungBowId = 62;
- }
- if(action.equals("Yew Short - String"))
- {
- stringing = true;
- unstrungBowId = 68;
- }
- if(action.equals("Yew Long - String"))
- {
- stringing = true;
- unstrungBowId = 66;
- }
- if(action.equals("Magic Short - String"))
- {
- stringing = true;
- unstrungBowId = 72;
- }
- if(action.equals("Magic Long - String"))
- {
- stringing = true;
- unstrungBowId = 70;
- }
- }
- public void serverMessageRecieved(final ServerMessageEvent a){
- final String serverString = a.getMessage();
- if (serverString.toLowerCase().contains("you add a string to the bow"))
- {tempNumStrung++;
- bowsStrung++;
- }
- }
- public boolean string()
- {
- status = "Clicking.";
- tempNumStrung = 0;
- mouse.move(633,335,5,5);
- mouse.click(true);
- mouse.move(663,335,5,5);
- sleep(random(500,600));
- mouse.click(true);
- sleep(random(1200,1300));
- int x = random(253,273);
- int y = random(409,429);
- mouse.move(x,y,0,0);
- String [] actions = menu.getActions();
- if(actions.length>0)
- {
- for(int i = 0; i< actions.length;i++)
- if(actions[i].contains("Make All"))
- {mouse.click(true);
- return true;}
- }
- return false;
- }
- public void bank()
- {
- if(random(1,20)==2)
- camera.setPitch(random(40,99));
- test = npcs.getNearest(bankerIds);
- status = "Finding Banker.";
- if(test!=null)
- {
- do{
- mouse.move(test.getModel().getPoint());
- menu.doAction("Bank Banker");
- sleep(random(1000,1500));
- }while(!bank.isOpen());
- status = "Depositing.";
- mouse.move(395,308,5,5);
- sleep(random(300,400));
- mouse.click(true);
- status = "Withdrawing.";
- if(stringing)
- {
- mouse.move(55,109,5,5);
- mouse.click(false);
- sleep(random(300,400));
- if(oneTimeOnly==0)
- {
- menu.doAction("Withdraw-X");
- sleep(random(1000,2000));
- keyboard.sendText("" + 14, true);
- oneTimeOnly++;
- }
- else
- {
- if(!menu.doAction("Withdraw-14"))
- menu.doAction("Withdraw-14");
- }
- sleep(random(500,800));
- mouse.move(96,107,5,5);
- mouse.click(false);
- sleep(random(300,400));
- if(!menu.doAction("Withdraw-14"))
- menu.doAction("Withdraw-14");
- }
- status = "Closing.";
- mouse.move(491,35,2,2);
- sleep(random(300,400));
- mouse.click(true);
- status = "Clicking.";
- }
- else
- test = npcs.getNearest(bankerIds);
- }
- public boolean stringInventoryHasProper()
- {
- RSItem [] inv = inventory.getItems();
- boolean uBow = false;
- boolean bString = false;
- for(int i = 0; i<inv.length;i++)
- {
- if(inv[i].getID()==unstrungBowId)
- uBow = true;
- if(inv[i].getID()==bowstring)
- bString = true;
- }
- return bString&&uBow;
- }
- public boolean animCheck()
- {
- return getMyPlayer().getAnimation()!=-1;
- }
- public int loop() {
- try{
- if(safety<1)
- {
- startUpStuff();
- camera.setPitch(true);
- safety=1;
- if(stringing)
- {
- bank();
- sleep(random(600,800));
- if(stringInventoryHasProper()&&inventory.getCount()==28)
- {
- string();
- sleep(random(1200,1300));
- }
- }
- failsafe=0;
- }
- antiBan(random(1,80));
- if(failsafe>6)
- log(failsafe+" failed attempts.");
- if(stringing){ //Stuff to do if stringing
- if(inventory.getCount()<28&&stringInventoryHasProper()&&inventory.getCount()!=14&&failsafe<10)
- {
- status = "Stringing.";
- if(!animCheck())
- failsafe++;
- else
- failsafe=0;
- sleep(600,800);
- }
- else if(stringInventoryHasProper()&&inventory.getCount()==28&&failsafe<10)
- {
- if(string())
- failsafe=0;
- sleep(random(600,800));
- }
- else if(failsafe>=10&&failsafe<50)
- {
- bank();
- sleep(random(600,800));
- if(stringInventoryHasProper())
- {string();
- failsafe=0;}
- else
- failsafe+=10;
- sleep(random(600,800));
- }
- else if(failsafe>=50)
- {
- log("Script has failed ~50 times, logging out as a precaution");
- game.logout(true);
- stopScript();
- }
- else
- {
- bank();
- sleep(random(600,800));
- if(stringInventoryHasProper())
- string();
- sleep(random(1200,1500));
- if(animCheck())
- failsafe=0;
- else
- {
- status = "Checking Animation...";
- sleep(random(600,800));
- if(animCheck())
- failsafe=0;
- }
- }
- }
- }
- catch (Exception e){}
- return random(600,800);
- }
- public void antiBan(int rand){
- status += "(AB)";
- if(rand==2)
- if(random(1, 8) == 2)
- mouse.moveRandomly(random(400,800));
- if(rand==3)
- if(random(1, 8) == 2)
- mouse.moveRandomly(random(200,700));
- if(rand==4) //THIS CHECKS THE FLETCHING STAT
- if(random(1, 8) == 2)
- {
- game.openTab(game.TAB_STATS);
- mouse.move(random(614, 667), random(360, 370),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, 18) == 2)
- {
- mouse.move(random(527, 540), random(58, 65),0,0);
- mouse.click(true);
- mouse.moveRandomly(random(20,50));
- sleep(random(900,1000));
- mouse.move(random(527, 540), random(58, 65),0,0);
- mouse.click(true);
- }
- if(rand==6) //THIS CHECKS CURRENT GOAL
- if(random(1, 18) == 2)
- {
- mouse.move(random(527, 543), random(471, 496),0,0);
- mouse.click(true);
- sleep(random(300,1000));
- mouse.move(random(604, 630), random(394, 399),0,0);
- sleep(random(900,1000));
- game.openTab(game.TAB_INVENTORY);
- }
- if(rand==7) //RANDOM SPIN
- if(random(1, 3) == 2)
- {camera.setAngle(random(1,359));
- camera.setPitch(random(1,99));}
- if(rand==8) //THIS CHECKS A RANDOM TAB
- if(random(1, 6) == 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(75,100);
- sleep(random(1600,1800));
- sleep(random(900,1000));
- }
- if(rand==9)
- if(random(1,3)==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("fletching"));
- startLevel = skills.getCurrentLevel(skills.getIndex("fletching"));
- }
- lvlsGained = skills.getCurrentLevel(skills.getIndex("fletching")) - startLevel;
- expGained = skills.getCurrentExp(skills.getIndex("fletching")) - 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("fletching"));
- 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("Conderoga's Stringer "+version,338,192);
- g.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
- g.drawString("Levels Gained: "+lvlsGained,344,207);
- if(action.equals("Normal Short - String"))
- g.drawString("Norm Shorts Strung: "+expGained/5,344,222);
- else if(action.equals("Normal Long - String"))
- g.drawString("Norm Longs Strung: "+expGained/10,344,222);
- else if(action.equals("Oak Short - String"))
- g.drawString("Oak Shorts Strung: "+(int)((expGained+1)/16.5),344,222);
- else if(action.equals("Oak Long - String"))
- g.drawString("Oak Longs Strung: "+expGained/25,344,222);
- else if(action.equals("Willow Short - String"))
- g.drawString("Willow Shorts Strung: "+(int)((expGained+1)/33.3),344,222);
- else if(action.equals("Willow Long - String"))
- g.drawString("Willow Longs Strung: "+(int)((expGained+1)/41.5),344,222);
- else if(action.equals("Maple Short - String"))
- g.drawString("Maple Shorts Strung: "+(expGained/50),344,222);
- else if(action.equals("Maple Long - String"))
- g.drawString("Maple Longs Strung: "+(int)((expGained+1)/58.3),344,222);
- else if(action.equals("Yew Short - String"))
- g.drawString("Yew Shorts Strung: "+(int)((expGained+1)/67.5),344,222);
- else if(action.equals("Yew Long - String"))
- g.drawString("Yew Longs Strung: "+expGained/75,344,222);
- else if(action.equals("Magic Short - String"))
- g.drawString("Magic Shorts Strung: "+(int)((expGained+1)/83.3),344,222);
- else if(action.equals("Magic Long - String"))
- g.drawString("Magic Longs Strung: "+(int)((expGained+1)/91.5),344,222);
- //g.drawString("Failsafe: "+failsafe,357,382);
- 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("fletching"))*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("fletching"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("fletching"))+1)+" ("+expToLvl+")",348,271);
- g.fillRoundRect(345,266,148,10,8,8);
- g.setColor(new Color(0,0,0,255));
- g.drawString(skills.getPercentToNextLevel(skills.getIndex("fletching"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("fletching"))+1)+" ("+expToLvl+")",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(ms2!=0)
- g.drawString("Bows/Hr: "+(int)(bowsStrung/(ms2/3600000)),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,140));
- 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 Fletcher!");
- }
- 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 CFletchGui extends JFrame {
- private static final long serialVersionUID = 1L;
- public CFletchGui()
- {
- initComponents();
- }
- private void button2ActionPerformed(ActionEvent e) {
- guiWait = false;
- guiExit = true;
- dispose();
- }
- private void button1ActionPerformed(ActionEvent e) {
- action = comboBox1.getSelectedItem().toString();
- guiExit = false;
- guiWait = false;
- dispose();
- }
- private void initComponents() {
- //GEN-BEGIN:initComponents
- label1 = new JLabel();
- label2 = new JLabel();
- comboBox1 = new JComboBox();
- label3 = new JLabel();
- button1 = new JButton();
- button2 = new JButton();
- //======== this ========
- setTitle("Conderoga's Speed Stringer");
- setResizable(false);
- setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //---- label1 ----
- label1.setText("Conderoga's Stringer 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 action: ");
- contentPane.add(label2);
- label2.setBounds(new Rectangle(new Point(15, 50), label2.getPreferredSize()));
- //---- comboBox1 ----
- comboBox1.setMaximumRowCount(12);
- comboBox1.setModel(new DefaultComboBoxModel(new String[] {
- "Normal Short - String",
- "Normal Long - String",
- "Oak Short - String",
- "Oak Long - String",
- "Willow Short - String",
- "Willow Long - String",
- "Maple Short - String",
- "Maple Long - String",
- "Yew Short - String",
- "Yew Long - String",
- "Magic Short - String",
- "Magic Long - String"
- }));
- 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());
- //GEN-END:initComponents
- }
- //GEN-BEGIN:variables
- private JLabel label1;
- private JLabel label2;
- private JComboBox comboBox1;
- private JLabel label3;
- private JButton button1;
- private JButton button2;
- //GEN-END:variables
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement