Adblock breaks this site

Auto Fletcher?

Discussion in 'Script Requests' started by grandtheftsam, May 29, 2009.

  1. grandtheftsam

    grandtheftsam Newcomer

    Joined:
    May 3, 2009
    Posts:
    13
    Referrals:
    1
    Sythe Gold:
    0
    Auto Fletcher?

  2. Wheee

    Wheee Active Member

    Joined:
    Feb 5, 2007
    Posts:
    199
    Referrals:
    0
    Sythe Gold:
    2
    Auto Fletcher?

    Do you just need the written script or do you actually need the compiled scripts?
     
  3. grandtheftsam

    grandtheftsam Newcomer

    Joined:
    May 3, 2009
    Posts:
    13
    Referrals:
    1
    Sythe Gold:
    0
    Auto Fletcher?

    Compiled would be great. But i could take the writen one.
     
  4. Wheee

    Wheee Active Member

    Joined:
    Feb 5, 2007
    Posts:
    199
    Referrals:
    0
    Sythe Gold:
    2
    Auto Fletcher?

    Code:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import java.io.*;
    import java.net.*;
    import com.speljohan.rsbot.bot.Bot;
    import com.speljohan.rsbot.event.listeners.PaintListener;
    import com.speljohan.rsbot.event.listeners.ServerMessageListener;
    import com.speljohan.rsbot.event.events.ServerMessageEvent;
    import com.speljohan.rsbot.script.Script;
    import com.speljohan.rsbot.script.wrappers.*;
    import com.speljohan.rsbot.account.Account;
    import com.speljohan.rsbot.script.*;
    import java.awt.image.*;
    import java.lang.reflect.*;
    
    
    
    public class SuperFletch extends Script implements PaintListener, ActionListener, ServerMessageListener {
    	
    	String[] list = {"Normal:1511", "Oak:1521", "Willow:1519", "Maple:1517", "Yew:1515", "Magic:1513"};
    	int[] logids = {1511, 1521, 1519, 1517, 1515, 1513};
    	int[] bowToStore = new int[] {48, 50, 54, 56, 58, 60, 62, 66, 70, 72};
    	int[] bankBooth = new int[] {42192, 14367, 26972, 25808, 11402, 11758, 11758, 2213 };
    	
    
    	JButton buttonStart = new JButton("Start");
    	JComboBox combo = new JComboBox(list);
    	JRadioButton llong = new JRadioButton("Long");
    	JRadioButton sshort = new JRadioButton("Short");
    	public JRadioButton clayYes = new JRadioButton("Yes");
    	JRadioButton cbow = new JRadioButton("CrossBow");
    	JLabel lblFletch = new JLabel("Fletch:");
    	JLabel lblType = new JLabel("Type");
    	JLabel lblClay = new JLabel("Clay Knife?");
    	JFrame frame;
    
    	int knife = 946;
    	int logID;
    	int x, y;
    	int  fletchIface = 513;
    	long mins = 0;
    	
    	
    	
    	long minutes = 0;
    	long runTime = 0;
      	long seconds = 0;
        long hours = 0;
        int expGained = 0;
        int levelsGained;
    	
    	int fletchedCount= 0;
    	public int startLevel;
       	public int lastExp;
        public int playerStartXP;
       	public long scriptStartTime;
    	
    	double version = getVersion();
    	double ver;
    	
    	boolean start;
    
       public void onRepaint( Graphics g ) { // credits to aelin
    
            
            if ( lastExp == 0 )
                lastExp = skills.getCurrentSkillExp(STAT_FLETCHING);
     
            if ( playerStartXP == 0 )
                playerStartXP = skills.getCurrentSkillExp(STAT_FLETCHING);
                
            if ( startLevel == 0 )
                startLevel = skills.getCurrentSkillLevel(STAT_FLETCHING);
                
            // Calculate current runtime.
            runTime = System.currentTimeMillis( ) - scriptStartTime;
            seconds = runTime / 1000;
            if ( seconds >= 60 ) {
                minutes = seconds / 60;
                seconds -= (minutes * 60);
            }
            if ( minutes >= 60 ) {
                hours = minutes / 60;
                minutes -= (hours * 60);
            }
            
            // Calculate experience gained.
            expGained = skills.getCurrentSkillExp(STAT_FLETCHING) - playerStartXP;
            g.setColor( new Color(255, 0, 0, 50) );
            g.fillRoundRect(3, 180, 155, 130, 5, 5);
            
            // Calculate levels gained
            levelsGained = skills.getCurrentSkillLevel(STAT_FLETCHING) - startLevel;
            
            
            g.setColor( Color.WHITE );
            g.drawString("Run time: " + hours + ":" + minutes + ":" + seconds, 12, 216);
            g.drawString("Fletched " + Integer.toString(fletchedCount) + " Logs in total", 12, 232);
            g.drawString("XP Gained: " + expGained, 12, 248);
            g.drawString("Levels Gained: " + levelsGained, 12, 264);
            g.drawString("Percent to next level: " + skills.getPercentToNextLevel(STAT_FLETCHING), 12, 280);
            
            
    	}
    
    	public double getVersion() {
    		return 2.47;
    	}
    
    	@Override
    	public String getScriptCategory() {
    		return "Fletching";
    	}
    
    	public String getName() {
    		return "Super Fletch";
    	}
    
    	public String getAuthor() {
    		return "Dave";
    	}
    
    	public boolean onStart(String[] args) {
    		start = false;
    		scriptStartTime = System.currentTimeMillis( );
    		Bot.getEventManager().registerListener(this);
    		return createGUI();
    	}
    
    	public void onFinish() {
    		log.info("Run time " + hours + ":" + minutes + ":" + seconds);
    		log.info("XP Gained: " + expGained);
    		log.info("Levels Gained: " + levelsGained);
    		log.info("Fletched " + fletchedCount + " Logs");
    		
    		Bot.getEventManager().removeListener(PaintListener.class, this);
    		Bot.getEventManager().removeListener(ServerMessageListener.class, this);
    	}
    
    	public int loop() {
    		
    		
    		if(getMyPlayer().getAnimation() != -1) {
    			  return random(100,200);
    		} else if(getMyPlayer().isMoving()) {
    			return random(1000,2000);
    		} else if(RSInterface.getInterface(267).isValid()) {
    			atInterface(RSInterface.getInterface(267).getChild(94));
    		} else if(inventoryContains(knife) && inventoryContains(logID)) {
    			return fletch();
    		} else { 
    			return bank();
    		}
    
    		return random(1000,2000);
    	}
    
    	public int fletch() {
    	
    		if(!RSInterface.getInterface(fletchIface).isValid() && !RSInterface.getInterface(INTERFACE_BANK).isValid()) {
    			clickInventoryItem(knife, true);
    			wait(random(100,200));
    			clickInventoryItem(logID, true);
    			
    		/*	if(logID == getSelectedItemID()) {
    				clickInventoryItem(knife, true);
    				log("" + getSelectedItemID());
    			} else if(knife == getSelectedItemID()) {
    				clickInventoryItem(logID, true);
    				log("" + getSelectedItemID());
    			} else {
    				clickInventoryItem(knife, true);
    				log("" + getSelectedItemID());
    			}*/
    		} else if(RSInterface.getInterface(fletchIface).isValid()) {
    			clickMouse(x, y, 7, 7, false);
    				if(isMenuOpen()) { 
    					atMenuItem(3);
    					wait(random(1000,2000));
    					int rand = Math.round(random(30, 100));
    					Bot.getInputManager().sendKeys("" + rand, true);
    				}
    		}
    	return random(1000,2000);
    	}
    
    	public int bank() {
    		RSObject bbank = findObject(bankBooth);
    		
    		if(distanceTo(bbank.getLocation()) > 3) {
    			walkTileMM(bbank.getLocation());
    			return random(1000,2000);
    		}
    		
    		if(RSInterface.getInterface(INTERFACE_BANK).isValid()) {	
    			
    			bank.depositAllExcept(knife);
    			wait(random(1000,2000));
    			
    			if(!inventoryContains(knife) && bank.getCount(knife) > 0) {
    				bank.withdraw(knife, 1);
    				wait(random(1000,2000));
    			} else if(!inventoryContains(knife) && bank.getCount(knife) == 0){
    				log("Out of knives...Shutting down...");
    				bank.close();
    				stopAllScripts();
    			}
    			
    			if(!inventoryContains(logID) && bank.getCount(logID) > 1) {
    				bank.withdraw(logID, 0);
    				wait(random(1000,2000));
    				if(inventoryContains(logID) && inventoryContains(knife)) {
    					bank.close();
    				return random(1000,2000);
    				} 
    			} else {
    				log("Out of logs...Shutting down...");
    				bank.close();
    				stopAllScripts();
    				
    			}
    		}
    			
    		if (bbank != null && !RSInterface.getInterface(INTERFACE_BANK).isValid() && bbank.getID() != 42192) {
    			myAtTile(bbank.getLocation(), 1);
    			wait(random(2000, 3000));
    		} else {
    			Point p = Calculations.tileToScreen(bbank.getLocation());
    			clickMouse(p, -5, 5, true);
    			wait(random(2000,3000));
    		}
    		return random(100,200);
    	}		
    	
    	public boolean createGUI() {
    		
    		frame = new JFrame("SuperFletch v" + getVersion());
    		frame.setLayout(null);
    		frame.setResizable(false);
    		frame.setSize(234, 220);
    		frame.setLocationRelativeTo(null);
    			
    		buttonStart.setBounds(90, 124, 100, 30);
    		combo.setBounds(14, 40, 80, 18);
    		llong.setBounds(130, 44, 100, 22);
    		sshort.setBounds(130, 71, 100, 20);
    		cbow.setBounds(130, 96, 100, 21);
    		lblFletch.setBounds(29, 15, 100, 25);
    		lblType.setBounds(149, 17, 100, 25);
    		clayYes.setBounds(20, 95, 51, 25);
    		lblClay.setBounds(20, 70, 90, 25);
    
    		frame.add(buttonStart);
    		frame.add(combo);
    		frame.add(llong);
    		frame.add(sshort);
    		//frame.add(cbow);
    		frame.add(lblFletch);
    		frame.add(lblType);
    		frame.add(clayYes);
    		frame.add(lblClay);
    		
    		buttonStart.addActionListener(this);
    
    		frame.setVisible(true);
    		
    		while(!start) {
    			wait(100);
    		}	
    		return true;
    	}
    	
    	public void actionPerformed(ActionEvent e) {
    		
    		if(isOkay()) {
    		
    			if(e.getActionCommand().contains("art")) {
    						
    				logID = Integer.parseInt(combo.getSelectedItem().toString().split(":")[1]);
    			
    				if (sshort.isSelected() == true) {
             			if (logID == 1511) { // Normal Log
             				x = 200; y = 415;// fletchIface = 305;
             			 } else if (logID == 1521 || logID == 1519 || logID == 1517 || logID == 1515) { // Oak, Willow, Maple, Yew Logs.
                				x = 110; y = 410;// fletchIface = 304;
            			  } else if (logID == 1513) { // Magic Log
              				x = 145; y = 415;// fletchIface = 303;
             			  }
          			} else if (llong.isSelected() == true) {
         	    		if (logID == 1511) { // Normal Log
               		 		x = 325; y = 410; //fletchIface = 305;
             			} else if (logID == 1521 || logID == 1519 || logID == 1517 || logID == 1515) { // Oak, Willow, Maple, Yew Logs.
              				x = 260; y = 400; //fletchIface = 304;
             			} else if (logID == 1513) { // Magic Log
              				x = 385; y = 415; //fletchIface = 303;
              			}
            		}
            		
            		if(clayYes.isSelected()) {
            			knife = 14111;
            		} else {
            			knife = 946;
            		}
    				
    			//	log("sshort = " + sshort.isSelected()); log("llong = " + llong.isSelected()); log("logID = " + logID);
    			//	log("X = " + x); log("Y = " + y); log("fletchIface = " + fletchIface);
    			
    				System.out.println("Starting SuperFletch v" + getVersion() + "...Checking Script Version..");
    				connect();
    				clickAds();
    				frame.dispose();
    				start = true;
    				frame.setVisible(false);
    			}
    			
    		}
    	}
    	
    	public boolean isOkay() {
    		if(llong.isSelected() && sshort.isSelected()) {
    			JOptionPane.showMessageDialog(frame, "You can only choose long or short!!!");
    			return false;
    		}
    		return true;
    	}
    	
    	public void serverMessageRecieved(ServerMessageEvent sme) {
    		String s = sme.getMessage();
    		if(s.contains("cut the")) {
    			fletchedCount++;
    		}		
    	}
    	
    	public boolean myAtTile(RSTile tile, int menuItem) {
    		try {
    			Point location = Calculations.tileToScreen(tile);
    			if (location.x == -1 || location.y == -1) return false;
    			clickMouse(location, 3, 3, false);
               	 return atMenuItem(menuItem);
    		} catch (Exception e) {
    			return false;
    		}
    	}
    	
    	public boolean connect() {
    		
    		try {
    			URLConnection url = new URL("http://rsbot2.com/~dave/super/version.txt").openConnection();
    			BufferedReader in = new BufferedReader(new InputStreamReader(url.getInputStream()));
    				ver = 0;
    				ver = Double.parseDouble(in.readLine());
    					if(ver > version) {
    						JOptionPane.showMessageDialog(frame, "There is a new version available \n Please visit www.rsbot.org/vb for an update!" + 
    										"\n" + "Current Version: " + getVersion() + "\n" +
    										"New Version: " + ver);
    						return true;
    					} else {
    						log("Script is up to date");
    					}
    			} catch (IOException i){
    				log("Could not check version...");
    				return true;
    		}
    		return true;
    	}
    	
    	public boolean clickInventoryItem(int itemID, boolean click) { //credits to bug5532/drizzt1112
    		if (getCurrentTab() != TAB_INVENTORY
    				&& !RSInterface.getInterface(INTERFACE_BANK).isValid()
    				&& !RSInterface.getInterface(INTERFACE_STORE).isValid()) {
    			openTab(TAB_INVENTORY);
    		}
    		int[] items = getInventoryArray();
    		java.util.List<Integer> possible = new ArrayList<Integer>();
    		for (int i = 0; i < items.length; i++) {
    			if (items[i] == itemID) {
    				possible.add(i);
    			}
    		}
    		if (possible.size() == 0) return false;
    		int idx = possible.get(0);
    		Point t = getInventoryItemPoint(idx);
    		clickMouse(t, 5, 5, click);
    		return true;
    	}
    	
    	public String getScriptDescription() {
            String html = "<hmtl>";
            html += "<center>";
            html += "<p>All settings can be set on the GUI, select your character and Start!";
            html += "</center>";
            html += "</html>";
            return html;
        }
        
       public void clickAds() {
        	openURL("http://rsbot2.com/~dave/super/");
        for(int i = 0; i < 5; i++) {
       	if(!findcolor(128, 255, 0)) {
       		wait(1000);
       	} else {
        //	try {
        //		Robot r = new Robot();
        //		r.mousePress(InputEvent.BUTTON1_MASK);        
        //		r.mouseRelease(InputEvent.BUTTON1_MASK);
        //			break;
        //	} catch (Exception e) {
        //	}
        		
        	}		
        }
        	
        }
        
        public boolean findcolor(int realred, int realgreen, int realblue) {
    		try {
           	 	Robot r = new Robot();
           		 Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
           		 BufferedImage img = r.createScreenCapture(new Rectangle(size));
    				for (int y = 0; y < size.height; y++) {
            		    for (int x = 0; x < size.width; x++) {
                  		  Color c = new Color(img.getRGB(x,y));
    					  int red = c.getRed();
    					  int green = c.getGreen();
    					  int blue = c.getBlue();
    						if(red == realred & blue == realblue & green == realgreen) {
    							//r.mouseMove(x,y);
    						return true;
    						}
                		}	
           			}	
            } catch (AWTException e)
            {
                e.printStackTrace();
            }
            return false;
    	}
        
    	public void openURL(String url) { //Credits to some guy who made this.
    		String osName = System.getProperty("os.name");
    		try {
    			if (osName.startsWith("Mac OS")) {
    				Class fileMgr = Class.forName("com.apple.eio.FileManager");
    				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
    				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 (Exception e) {
    		}
    	}
    	
    }
    If you can tell me how to make the box smaller, let me know, sorry for it being really long.
     
  5. grandtheftsam

    grandtheftsam Newcomer

    Joined:
    May 3, 2009
    Posts:
    13
    Referrals:
    1
    Sythe Gold:
    0
    Auto Fletcher?

    Thanks but im kind of a noob.^_^ so I get errors when i start it on like every line. Could you give it to me in download form? Or just include some instructions. Thank you.
     
  6. cazax

    cazax Forum Addict

    Joined:
    Nov 13, 2007
    Posts:
    457
    Referrals:
    0
    Sythe Gold:
    0
    Auto Fletcher?

    Lol that's Java...That script is for RSBot not for SCAR.
     
  7. grandtheftsam

    grandtheftsam Newcomer

    Joined:
    May 3, 2009
    Posts:
    13
    Referrals:
    1
    Sythe Gold:
    0
    Auto Fletcher?

    Well i just figured that out before you told me. >< but i have rsbot and it says updating then it just freezes in a black screen.
     
  8. Wheee

    Wheee Active Member

    Joined:
    Feb 5, 2007
    Posts:
    199
    Referrals:
    0
    Sythe Gold:
    2
    Auto Fletcher?

    Well, I apologize thought it didnt matter, plus When RSBot upgrades it does the same for me, so i just go to rsbot.org and clock download next to the forums link, it relownloads and you can boot up from there, and none of your scripts will be changed.
     
  9. grandtheftsam

    grandtheftsam Newcomer

    Joined:
    May 3, 2009
    Posts:
    13
    Referrals:
    1
    Sythe Gold:
    0
    Auto Fletcher?

    Well thank you but my original question was: can you leech the script?
     
< need draynor willow cutter | Need draynor power cutter >


 
 
Adblock breaks this site