Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Point;
- import java.io.IOException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.util.Timer;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.border.*;
- @ScriptManifest(
- authors = ("Fag3xx"),
- version = 2.3,
- keywords = {},
- description = "Fletches for you, start at bankbooth with materials in a bank tab (including knife)",
- name = "Fag3xx Fletcher"
- )
- public class FletcherFag3xx extends Script implements PaintListener{
- int knifeID = 946;
- int logID;
- int unstrungID;
- int bowID;
- int stringID = 1777;
- int left =1;
- int leftstring =1;
- int exp = 0;
- int expu = 0;
- int exphour = 0;
- int unstrung = 0;
- int unstrunghour = 0;
- int bows = 0;
- int bowshour = 0;
- int child = 0;
- int stringexp = 0;
- int fletchexp = 0;
- int method;
- int a=0;
- String display;
- public String status = "start";
- Timer runTime = new Timer(0);
- public boolean guiwait = true;
- gui gu = new gui();
- public boolean onStart() {
- gu.setVisible(true);
- while(guiwait == true){
- sleep(500);
- }
- log("Script made by Fag3xx");
- log("Checking bank for materials and loading paint");
- while(!bank.isOpen()){
- bank.open();
- sleep(random(600,800));
- }
- left = bank.getCount(logID);
- sleep(random(600,800));
- return true;
- }
- public int loop (){
- mouse.setSpeed(random(8,9));
- if(left == 0){
- if(!(leftstring == 0)){
- status = ("string");
- if (players.getMyPlayer().getAnimation() == 6689) {
- antiBan();
- }
- if(!inventory.contains(unstrungID) || !inventory.contains(stringID)){
- bank2();
- }
- if(inventory.contains(unstrungID) && inventory.contains(stringID) && players.getMyPlayer().getAnimation() == -1){
- sleep(random(1500,1600));
- if(inventory.contains(unstrungID) && inventory.contains(stringID) && players.getMyPlayer().getAnimation() == -1){
- if(bank.isOpen()){
- bank.close();
- bows = bows +14;
- sleep(random(600,800));
- }
- stringbow();
- }
- }
- }else{
- kill();
- }
- }else{
- if (inventory.contains(knifeID)) {
- status = ("unstrung");
- if (players.getMyPlayer().getAnimation() == 7211) {
- antiBan();
- }
- if(inventory.contains(logID) && players.getMyPlayer().getAnimation() == -1){
- if(bank.isOpen()){
- bank.close();
- unstrung = unstrung +27;
- sleep(random(600,800));
- }
- fletchlog();
- }
- if(!inventory.contains(logID)){
- bank();
- }
- }else{
- takeknife();
- }
- }
- return random(100,200);
- }
- private void fletchlog(){
- display = ("Fletching logs");
- if(!inventory.isItemSelected()){
- if(inventory.contains(knifeID)){
- inventory.getItem(knifeID).doClick(true);
- sleep(random(500, 600));
- }else{
- takeknife();
- }
- }
- if(inventory.isItemSelected()){
- if(inventory.contains(logID)){
- inventory.getItem(logID).doClick(true);
- sleep(random(1400, 1600));
- interfaces.getComponent(905, child).doHover();
- interfaces.getComponent(905, child).isValid();
- interfaces.getComponent(905, child).doClick();
- sleep(random(1400, 1600));
- }
- }
- }
- private void stringbow(){
- display = ("Stringing bows");
- if(!inventory.isItemSelected()){
- inventory.getItem(unstrungID).doClick(true);
- sleep(random(200, 300));
- }
- if(inventory.isItemSelected()){
- if(inventory.contains(unstrungID)){
- inventory.getItem(stringID).doClick(true);
- sleep(random(1800, 2000));
- interfaces.getComponent(905, 14).isValid();
- interfaces.getComponent(905, 14).doClick();
- interfaces.getComponent(905, 14).doClick();
- sleep(random(1400, 1600));
- }
- }
- }
- private void takeknife(){
- display = ("Taking knife");
- if(bank.isOpen()){
- bank.depositAll();
- sleep(random(300,400));
- bank.withdraw(knifeID, 1);
- sleep(random(2000,2200));
- }else{
- if (bank.open()) {
- bank.depositAllExcept(Inventory.getItemID("knife"));
- return 0;
- sleep(random(400,600));
- }
- }
- private void bank2(){
- display = ("Banking");
- if(bank.isOpen()){
- if(inventory.contains(bowID)){
- bank.depositAll();
- sleep(random(600,800));
- }
- if(inventory.contains(knifeID)){
- bank.deposit(knifeID, 0);
- }
- if(bank.getCount(unstrungID) < 15){
- kill();
- }else{
- if(!inventory.contains(unstrungID)){
- bank.withdraw(unstrungID, 14);
- }
- if(inventory.getCount(unstrungID) > 14){
- bank.depositAll();
- }
- if(0 == bank.getCount(stringID)){
- kill();
- }
- if(!inventory.contains(stringID)){
- bank.withdraw(stringID, 14);
- }
- }
- }else{
- if (bank.open()) {
- bank.depositAllExcept(inventory.getItemID("knife"));
- return 0;
- }
- }
- }
- }
- private void bank(){
- display = ("Banking");
- if(bank.isOpen()){
- if(inventory.contains(unstrungID)){
- if(inventory.contains(knifeID)){
- bank.depositAllExcept(knifeID);
- leftstring = bank.getCount(unstrungID);
- sleep(random(400,600));
- }
- }
- left = bank.getCount(logID);
- bank.withdraw(logID, 0);
- sleep(random(100,200));
- }else{
- if (bank.open()) {
- bank.depositAllExcept(Inventory.getItemID("knife"));
- return 0;
- }
- }
- }
- private void kill(){
- env.saveScreenshot(true);
- log("out of materials to make bows");
- log("Please leave feedback on my forum post");
- stopScript();
- }
- private final void antiBan() {
- int r = random(0, 40);
- switch(r) {
- case 1:
- mouse.setSpeed(random(4, 8));
- mouse.moveSlightly();
- mouse.moveSlightly();
- mouse.moveSlightly();
- break;
- case 8:
- mouse.moveSlightly();
- sleep(500, 800);
- break;
- case 11:
- mouse.moveRandomly(300, 500);
- break;
- case 15:
- camera.moveRandomly(random(400, 600));
- break;
- case 20:
- camera.setAngle(random(0, 360));
- sleep(random(300, 500));
- break;
- case 26:
- mouse.moveRandomly(300, 500);
- sleep(random(300, 500));
- break;
- case 28:
- mouse.moveOffScreen();
- sleep(2000, 3000);
- break;
- case 36:
- camera.setAngle(random(1,360));
- break;
- case 39:
- skills.doHover(Skills.INTERFACE_FLETCHING);
- sleep(random(2000, 3000));
- break;
- }
- }
- /*
- * --------------- Paint --------------
- */
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (IOException e) {
- return null;
- }
- }
- private final Image img = getImage("http://i1138.photobucket.com/albums/n528/fag3xx/fletcher-1.png");
- public void onRepaint(Graphics render) {
- Graphics2D g = (Graphics2D) render;
- Point m = mouse.getLocation();
- unstrunghour= (int) (unstrung * (3600000D / runTime.getElapsed()));
- bowshour= (int) (bows * (3600000D / runTime.getElapsed()));
- g.drawOval(m.x,m.y,8,8);
- g.drawImage(img, 0, 208, null);
- g.setColor(new Color(85, 48, 26));
- g.drawString("Status: " + display, 10, 260);
- if (status.equals("unstrung")) {
- expu = (fletchexp * unstrung) ;
- exphour= (int) (expu * (3600000D / runTime.getElapsed()));
- g.drawString("Unstrung made: " + unstrung, 40, 290);
- g.drawString("Unstrung/h: " + (int)unstrunghour, 40, 308);
- g.drawString("Exp gained: " + expu, 190, 290);
- g.drawString("Exp/h: " + (int)exphour, 190, 308);
- g.drawString("Exp to LvL: "+ skills.getExpToNextLevel(Skills.FLETCHING), 190, 324);
- }
- if (status.equals("string")){
- exp = (stringexp * bows);
- exphour= (int) ((expu+exp) * (3600000D / runTime.getElapsed()));
- g.drawString("Bows made: " + bows, 40, 290);
- g.drawString("Unstrung made "+ unstrung, 40, 308);
- g.drawString("Exp gained: " + (expu + exp), 190, 290);
- g.drawString("Exp/h: " + (int)exphour, 190, 308);
- g.drawString("Exp to LvL: "+ skills.getExpToNextLevel(Skills.FLETCHING), 190, 324);
- }
- g.drawString("Time Running: "+ runTime.toElapsedString(), 360, 290);
- g.drawString("Current LvL: "+ skills.getRealLevel(Skills.FLETCHING), 360, 308);
- g.drawString("% to LvL: "+ skills.getPercentToNextLevel(Skills.FLETCHING) + "%", 360, 324);
- }
- class gui extends JFrame {
- public gui() {
- initComponents();
- }
- private void button1ActionPerformed(ActionEvent e) {
- String type = comboBox2.getSelectedItem().toString();
- if(type.equals("longbow")){
- method = 0;
- }
- if(type.equals("shortbow")){
- method = 1;
- }
- String chosen = comboBox1.getSelectedItem().toString();
- if(chosen.equals("oak log")){
- logID = 1521;
- if(method == 0){
- unstrungID = 56;
- bowID = 845;
- child = 15;
- stringexp = 58;
- fletchexp = 58;
- }else{
- unstrungID = 54;
- bowID = 843;
- child = 14;
- stringexp = 50;
- fletchexp = 50;
- }
- }
- if(chosen.equals("willow log")){
- logID = 1519;
- if(method == 0){
- unstrungID =58;
- bowID = 847;
- child = 15;
- stringexp = 58;
- fletchexp = 58;
- }else{
- unstrungID = 60;
- bowID = 849;
- child = 14;
- stringexp = 50;
- fletchexp = 50;
- }
- }
- if(chosen.equals("maple log")){
- logID = 1517;
- if(method == 0){
- unstrungID = 62;
- bowID = 851;
- child = 15;
- stringexp = 58;
- fletchexp = 58;
- }else{
- unstrungID = 64;
- bowID = 853;
- child = 14;
- stringexp = 50;
- fletchexp = 50;
- }
- }
- if(chosen.equals("yew log")){
- logID = 1515;
- if(method == 0){
- unstrungID = 66;
- bowID = 855;
- child = 15;
- stringexp = 75;
- fletchexp = 75;
- }else{
- unstrungID = 68;
- bowID = 857;
- child = 14;
- stringexp = 67;
- fletchexp = 67;
- }
- }
- if(chosen.equals("magic log")){
- logID = 1513;
- if(method == 0){
- unstrungID = 70;
- bowID = 859;
- child = 15;
- stringexp = 91;
- fletchexp = 91;
- }else{
- unstrungID = 72;
- bowID = 861;
- child = 14;
- stringexp = 83;
- fletchexp = 83;
- }
- }
- guiwait = false;
- gu.dispose();
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- // Generated using JFormDesigner Open Source Project license - unknown
- dialogPane = new JPanel();
- contentPanel = new JPanel();
- label2 = new JLabel();
- label3 = new JLabel();
- comboBox1 = new JComboBox();
- comboBox2 = new JComboBox();
- button1 = new JButton();
- label1 = new JLabel();
- //======== this ========
- Container contentPane = getContentPane();
- contentPane.setLayout(new BorderLayout());
- //======== dialogPane ========
- {
- dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
- dialogPane.setLayout(new BorderLayout());
- //======== contentPanel ========
- {
- contentPanel.setLayout(null);
- //---- label2 ----
- label2.setText("Log type:");
- label2.setFont(new Font("Tahoma", Font.PLAIN, 14));
- contentPanel.add(label2);
- label2.setBounds(new Rectangle(new Point(5, 15), label2.getPreferredSize()));
- //---- label3 ----
- label3.setText("Long/Short:");
- label3.setFont(new Font("Tahoma", Font.PLAIN, 14));
- contentPanel.add(label3);
- label3.setBounds(new Rectangle(new Point(5, 45), label3.getPreferredSize()));
- //---- comboBox1 ----
- comboBox1.setModel(new DefaultComboBoxModel(new String[] {
- "oak log",
- "willow log",
- "maple log",
- "yew log",
- "magic log"
- }));
- contentPanel.add(comboBox1);
- comboBox1.setBounds(105, 15, 95, comboBox1.getPreferredSize().height);
- //---- comboBox2 ----
- comboBox2.setModel(new DefaultComboBoxModel(new String[] {
- "longbow",
- "shortbow"
- }));
- contentPanel.add(comboBox2);
- comboBox2.setBounds(105, 45, 95, comboBox2.getPreferredSize().height);
- //---- button1 ----
- button1.setText("Start");
- button1.setFont(new Font("Tahoma", Font.PLAIN, 14));
- button1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- button1ActionPerformed(e);
- }
- });
- contentPanel.add(button1);
- button1.setBounds(45, 75, 130, 35);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPanel.getComponentCount(); i++) {
- Rectangle bounds = contentPanel.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 = contentPanel.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- contentPanel.setMinimumSize(preferredSize);
- contentPanel.setPreferredSize(preferredSize);
- }
- }
- dialogPane.add(contentPanel, BorderLayout.CENTER);
- //---- label1 ----
- label1.setText("Fletcher by Fag3xx");
- label1.setFont(new Font("Tahoma", Font.PLAIN, 18));
- label1.setHorizontalAlignment(SwingConstants.CENTER);
- dialogPane.add(label1, BorderLayout.NORTH);
- }
- contentPane.add(dialogPane, BorderLayout.CENTER);
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Open Source Project license - unknown
- private JPanel dialogPane;
- private JPanel contentPanel;
- private JLabel label2;
- private JLabel label3;
- private JComboBox comboBox1;
- private JComboBox comboBox2;
- private JButton button1;
- private JLabel label1;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment