codemonkey

JizzedCrafter

Apr 14th, 2011
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 20.49 KB | None | 0 0
  1. /**
  2.  * JizzedCrafter AIO
  3.  *
  4.  * by iJizzed
  5.  *
  6.  * Current version 0.01
  7.  */
  8. import java.awt.BasicStroke;
  9. import java.awt.Color;
  10. import java.awt.Font;
  11. import java.awt.Graphics;
  12. import java.awt.Graphics2D;
  13. import java.awt.Point;
  14. import java.awt.Rectangle;
  15. import java.awt.event.MouseEvent;
  16. import java.awt.event.MouseListener;
  17. import org.rsbot.event.listeners.PaintListener;
  18. import org.rsbot.script.Script;
  19. import org.rsbot.script.ScriptManifest;
  20. import org.rsbot.script.methods.Skills;
  21.  
  22. @ScriptManifest(authors = {"iJizzed"}, keywords = "", name = "JizzedCrafter AIO", description = "Crafts all hides.", version = 0.01)
  23.  
  24. public class JizzedCrafter extends Script implements PaintListener, MouseListener {
  25.  
  26.      final ScriptManifest properties = getClass().getAnnotation(
  27.               ScriptManifest.class);
  28.  
  29.  
  30.  
  31.          private int dHide = 0;
  32.          private int armourID = 0;
  33.          private int interfaceID = 0;
  34.          private int componentID = 0;
  35.          private int armourMade = 0;
  36.  
  37.          private final static int leatherID = 1741;
  38.          //private final static int snakeID = 6289;
  39.          private final static int greenhideID = 1745;
  40.          private final static int bluehideID = 2505;
  41.          private final static int redhideID = 2507;
  42.          private final static int blackhideID = 2509;
  43.          
  44.          private final static int leatherBodyID = 1129, leatherChapsID = 1095, leatherVambsID = 1063, blackBodyID = 2503, blackChapsID = 2497, blackVambsID = 2491, greenBodyID = 1135, greenVambsID = 1065, greenChapsID = 1099, blueBodyID = 2499, blueVambsID = 2487, blueChapsID = 2493, redBodyID = 2501, redVambsID = 2489, redChapsID = 2495;
  45.  
  46.          private final static int CChaps = 16, CVambs = 15, CBody = 14, CLeatherBody = 18, CLeatherChaps = 19, CLeatherVambs = 17;
  47.  
  48.          private int needleID = 1733;
  49.          private int threadID = 1734;
  50.          //private int animationID = 1249;
  51.  
  52.          private int Gainedlvls;
  53.      private int xpGained;
  54.      public long startTime = 0;
  55.      private double startTimeDbl;
  56.      public int startXP = 0;
  57.      public int startLevel = 0;
  58.          int wcIndex = Skills.getIndex("Crafting");
  59.          Rectangle closeButton = new Rectangle(493, 226, 15, 18);
  60.          Point p;
  61.          boolean showPaint = true;
  62.  
  63.          private boolean guiWait = true;
  64.          JizzedCrafterGUI g = new JizzedCrafterGUI();
  65.  
  66.          //private final static int[] bankIDs = {11402, 27663, 35647, 4483, 42192, 26972};//Varbank,DuelArena,alkharidBank,Cw,Sw,EdgeBank
  67.  
  68.        @Override
  69.         public boolean onStart() {
  70.             log("Welcome to JizzedCrafter.");
  71.             if (game.isLoggedIn()) {
  72.                 if (startTime == 0 || startXP == 0) {
  73.                     startTime = System.currentTimeMillis();
  74.                     startTimeDbl = System.currentTimeMillis();
  75.                     startXP = skills.getCurrentExp(wcIndex);
  76.                     startLevel = skills.getCurrentLevel(Skills.getIndex("Crafting"));
  77.                 }
  78.             }
  79.                 g.setVisible(true);
  80.                 while (guiWait) sleep(500);
  81.  
  82.             return true;
  83.         }
  84.            
  85.            private void knifeOnHide (){
  86.                if (inventory.containsOneOf(needleID) && inventory.contains(threadID) && inventory.getCount(dHide) == armourMade) {
  87.                    inventory.useItem(needleID, dHide);
  88.                }
  89.            }
  90.            //private void makeAllHide (){
  91.                //if (interfaces.getComponent(interfaceID, componentID).isValid()) {
  92.             //interfaces.getComponent(interfaceID, componentID).doClick();
  93.             //sleep(500,600);
  94.               // }
  95.           // }
  96.  
  97.            private void banking(){
  98.                if(!bank.isOpen()){
  99.                bank.open();
  100.                sleep(500, 650);
  101.                }
  102.                 bank.depositAllExcept(needleID,threadID);
  103.                 sleep(500, 650);
  104.         bank.withdraw(dHide, armourMade);
  105.                 sleep(500, 650);
  106.                 if(bank.isOpen()){
  107.                 bank.close();
  108.                }
  109.            }
  110.  
  111.     @Override
  112.     public void onFinish() {
  113.     }
  114.  
  115.     public int loop() {
  116.         try {
  117.             mouse.setSpeed(random(5, 8));
  118.             switch (getState()) {
  119.                 case 1:
  120.                     if (getMyPlayer().getAnimation() == -1){
  121.                     knifeOnHide();
  122.                     sleep(2150);
  123.             }
  124.                     if (interfaces.getComponent(interfaceID, componentID).isValid()) {
  125.             interfaces.getComponent(interfaceID, componentID).doClick();
  126.             sleep(3150);
  127.                     }
  128.                     return random(50, 100);
  129.  
  130.                 case 2:
  131.                     banking();
  132.                 return random(50, 100);
  133.                 case 3:
  134.                     antiban();
  135.                     return random(50, 100);
  136.  
  137.                 case 4:
  138.                if(!bank.isOpen()){
  139.                bank.open();
  140.                sleep(500, 650);
  141.                }
  142.                 bank.depositAll();
  143.                 sleep(500, 650);
  144.                 if (bank.getCount(needleID) > 0) {
  145.                     bank.withdraw(needleID, 1);
  146.                 } else {
  147.                     stopScript(false);
  148.                     log("No needle script stopped.");
  149.                 }
  150.                 sleep(500, 650);
  151.                 if (bank.getCount(threadID) > 0) {
  152.                     bank.withdraw(threadID, 0);
  153.                 } else {
  154.                     log("No thread script stopped.");
  155.                     stopScript(false);
  156.                 }
  157.                 if(bank.isOpen()){
  158.                 bank.close();
  159.                }
  160.                     return random(50, 100);
  161.             }
  162.         } catch (NullPointerException e) {
  163.         }
  164.         return 5;
  165.     }
  166.  
  167.     public int getState() {
  168.         if (inventory.contains(needleID) && inventory.contains(threadID) && inventory.containsOneOf(dHide)){
  169.             sleep(random(300, 350));
  170.             return 1;
  171.         }
  172.         if (getMyPlayer().getAnimation() != -1) {
  173.             sleep(random(300, 350));
  174.             return 3;
  175.         }
  176.         if (inventory.contains(needleID) && inventory.contains(threadID) && !inventory.containsOneOf(dHide)){
  177.             sleep(random(300, 350));
  178.             return 2;
  179.         }
  180.         if (!inventory.contains(needleID) || !inventory.contains(threadID)){
  181.             sleep(random(300, 350));
  182.             return 4;
  183.         }
  184.         return -1;
  185.     }
  186.     //----------------------------------------antiban------------------------------------
  187.     public void antiban() {
  188.  
  189.         int b = random(0, 10);
  190.              switch (b) {
  191.              case 1:
  192.                  if (random(0, 10) == 5) {
  193.                      mouse.moveSlightly();
  194.                      sleep(200, 600);
  195.                      mouse.moveRandomly(150, 350);
  196.                  }
  197.                  break;
  198.              case 2:
  199.                  if (random(0, 13) == 2) {
  200.                      camera.setAngle(random(30, 70));
  201.                      sleep(400, 1200);
  202.  
  203.                  }
  204.                  break;
  205.              case 3:
  206.                  if (random(0, 24) == 6) {
  207.                      mouse.moveOffScreen();
  208.                      sleep(random(600, random(1200, 2000)));
  209.                  }
  210.                  break;
  211.              case 4:
  212.                  if (random(0, 18) == 3) {
  213.                      game.openTab(1);
  214.                      skills.doHover(Skills.INTERFACE_WOODCUTTING);
  215.                      sleep(random(2100, 3400));
  216.                  }
  217.                  break;
  218.            default:
  219.                  break;
  220.              }
  221.          }
  222.  
  223.  
  224.     private final Color color1 = new Color(0, 0, 0, 103);
  225.     private final Color color2 = new Color(255, 0, 0, 188);
  226.     private final Color color3 = new Color(0, 0, 0);
  227.     private final Color color4 = new Color(255, 0, 0);
  228.     private final Color color5 = new Color(0, 255, 51, 188);
  229.  
  230.     private final BasicStroke stroke1 = new BasicStroke(2);
  231.  
  232.     private final Font font1 = new Font("Mongolian Baiti", 0, 19);
  233.     private final Font font2 = new Font("Comic Sans MS", 0, 11);
  234.     private final Font font3 = new Font("Comic Sans MS", 0, 10);
  235.  
  236.  
  237.     public void onRepaint(Graphics g1) {
  238.         final int percent = skills.getPercentToNextLevel(Skills.CRAFTING);
  239.         long millis = System.currentTimeMillis() - startTime;
  240.     double ms2 = System.currentTimeMillis() - startTimeDbl;
  241.         long hours = millis / (1000 * 60 * 60);
  242.     millis -= hours * (1000 * 60 * 60);
  243.     long minutes = millis / (1000 * 60);
  244.     millis -= minutes * (1000 * 60);
  245.     long seconds = millis / 1000;
  246.     xpGained = skills.getCurrentExp(wcIndex) - startXP;
  247.     Gainedlvls = skills.getCurrentLevel(Skills.getIndex("Crafting")) - startLevel;
  248.         Graphics2D g = (Graphics2D)g1;
  249.         int topRightX = closeButton.x + 25;
  250.         int topRightY = closeButton.y + 25;
  251.         int bottomRightX = closeButton.x + 25;
  252.         int topLeftY = closeButton.y + 25;
  253.         int bottomLeftX5 = closeButton.x + 5;
  254.         int bottomLeftY5 = closeButton.y + 5;
  255.         g.setColor(color3);
  256.         g.fillRect(closeButton.x, closeButton.y, closeButton.width, closeButton.height);//<<Fills a rectangle
  257.         g.setColor(color3);
  258.         g.drawRect(closeButton.x, closeButton.y, closeButton.width, closeButton.height);//<<<Draws a black outline around the close button
  259.         if(showPaint){
  260.         g.setColor(color2);
  261.         g.fillRect(346, 311, 100, 14);
  262.         g.setColor(color5);
  263.         g.fillRect(346, 311, percent, 14);
  264.         g.drawRect(346, 311, 100, 14);
  265.         g.drawRect(346, 311, percent, 14);
  266.         g.setFont(font3);
  267.         g.setColor(Color.black);
  268.         g.drawString("" + percent, 395, 322);
  269.         g.setColor(color1);
  270.         g.fillRect(334, 221, 178, 115);
  271.         //g.setColor(color2);
  272.         //g.fillRect(346, 311, 150, 14);// voor progressbar
  273.         g.setColor(color3);
  274.         g.fillRect(493, 226, 15, 18);//hide button
  275.         g.setColor(color4);
  276.         g.setStroke(stroke1);
  277.         g.drawLine(495, 229, 505, 240);
  278.         g.drawLine(495, 241, 507, 228);
  279.         g.setFont(font1);
  280.         g.setColor(color3);
  281.         g.drawString("JizzedCrafter AIO", 344, 242);
  282.         g.setColor(color4);
  283.         g.drawLine(341, 246, 482, 246);
  284.         g.setFont(font2);
  285.         g.setColor(color3);
  286.         g.drawString("Time running:"  + hours + ":" + minutes + ":" + seconds, 346, 268);
  287.         g.drawString("Xp gained:" + xpGained + "|" + " " +(int)(xpGained/(ms2/3600000)) + "P/H", 346, 283);
  288.         g.drawString("Crafting level:" + skills.getCurrentLevel(Skills.getIndex("Crafting"))+ "|" + " " + Gainedlvls + "lvl(s) Gained", 346, 298);
  289.         g.setFont(font3);
  290.         g.drawString("version:" + properties.version(), 437, 257);
  291.     } else {
  292. g.drawRect(bottomLeftX5, bottomLeftY5, 15, 15);
  293. }
  294.     }
  295.  
  296. public void mouseClicked(MouseEvent e){
  297.     p = e.getPoint();
  298. if(closeButton.contains(p)){
  299. showPaint = !showPaint;
  300.     }
  301. }
  302. public void mouseEntered(MouseEvent e){
  303. }
  304. public void mouseExited(MouseEvent e){
  305. }
  306. public void mousePressed(MouseEvent e){
  307. }
  308. public void mouseReleased(MouseEvent e){
  309. }
  310. /**
  311.  *
  312.  * @author Lorenzo
  313.  */
  314.     class JizzedCrafterGUI extends javax.swing.JFrame {
  315.  
  316.     public JizzedCrafterGUI() {
  317.         initComponents();
  318.     }
  319.  
  320.     @SuppressWarnings("unchecked")
  321.     private void initComponents() {
  322.  
  323.         buttonGroup1 = new javax.swing.ButtonGroup();
  324.         buttonGroup2 = new javax.swing.ButtonGroup();
  325.         jScrollPane1 = new javax.swing.JScrollPane();
  326.         jTextArea1 = new javax.swing.JTextArea();
  327.         startButton = new javax.swing.JButton();
  328.         leatherComboBox = new javax.swing.JComboBox();
  329.         jLabel1 = new javax.swing.JLabel();
  330.         TitleBox = new javax.swing.JLabel();
  331.         jLabel3 = new javax.swing.JLabel();
  332.         jComboBox1 = new javax.swing.JComboBox();
  333.         jLabel2 = new javax.swing.JLabel();
  334.  
  335.         jTextArea1.setColumns(20);
  336.         jTextArea1.setRows(5);
  337.         jScrollPane1.setViewportView(jTextArea1);
  338.  
  339.         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  340.         setTitle("JizzedCrafter");
  341.         setResizable(false);
  342.  
  343.         startButton.setFont(new java.awt.Font("Comic Sans MS", 1, 12));
  344.         startButton.setText("Start the script!");
  345.         startButton.addActionListener(new java.awt.event.ActionListener() {
  346.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  347.                 startButtonActionPerformed(evt);
  348.             }
  349.         });
  350.  
  351.         leatherComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Leather", "Green D'hide", "Blue D'hide", "Red D'hide", "Black D'hide" }));
  352.         leatherComboBox.setEditor(null);
  353.  
  354.         jLabel1.setFont(new java.awt.Font("Comic Sans MS", 0, 12));
  355.         jLabel1.setText("Wich leather will you use:");
  356.  
  357.         TitleBox.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
  358.         TitleBox.setText("Jizzed Crafter AIO");
  359.  
  360.         jLabel3.setFont(new java.awt.Font("Comic Sans MS", 0, 12));
  361.         jLabel3.setText("What will you make:");
  362.  
  363.         jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Vambraces", "Chaps", "Body" }));
  364.  
  365.         jLabel2.setText("Made by iJizzed");
  366.  
  367.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  368.         getContentPane().setLayout(layout);
  369.         layout.setHorizontalGroup(
  370.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  371.             .addGroup(layout.createSequentialGroup()
  372.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  373.                     .addGroup(layout.createSequentialGroup()
  374.                         .addContainerGap()
  375.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  376.                             .addComponent(jLabel1)
  377.                             .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))
  378.                         .addGap(18, 18, 18)
  379.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  380.                             .addComponent(jComboBox1, 0, 105, Short.MAX_VALUE)
  381.                             .addComponent(leatherComboBox, 0, 105, Short.MAX_VALUE)))
  382.                     .addGroup(layout.createSequentialGroup()
  383.                         .addGap(4, 4, 4)
  384.                         .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
  385.                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  386.                         .addContainerGap()
  387.                         .addComponent(startButton, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)))
  388.                 .addContainerGap())
  389.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  390.                 .addContainerGap(58, Short.MAX_VALUE)
  391.                 .addComponent(TitleBox)
  392.                 .addGap(52, 52, 52))
  393.         );
  394.         layout.setVerticalGroup(
  395.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  396.             .addGroup(layout.createSequentialGroup()
  397.                 .addComponent(jLabel2)
  398.                 .addGap(2, 2, 2)
  399.                 .addComponent(TitleBox, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
  400.                 .addGap(18, 18, 18)
  401.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  402.                     .addComponent(jLabel1)
  403.                     .addComponent(leatherComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  404.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  405.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  406.                     .addComponent(jLabel3)
  407.                     .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  408.                 .addGap(18, 18, 18)
  409.                 .addComponent(startButton)
  410.                 .addContainerGap())
  411.         );
  412.  
  413.         startButton.getAccessibleContext().setAccessibleName("S");
  414.  
  415.         pack();
  416.     }
  417.  
  418.     private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {
  419.         String chosen = leatherComboBox.getSelectedItem().toString();
  420.         String chosenArm = jComboBox1.getSelectedItem().toString();
  421.         if (chosen.equals("Leather") && chosenArm.equals("Vambraces")) {
  422.             dHide = leatherID;
  423.             interfaceID = 905;
  424.             componentID = CLeatherVambs;
  425.             armourMade = 26;
  426.             armourID = leatherVambsID;
  427.         } else if (chosen.equals("Leather") && chosenArm.equals("Chaps")) {
  428.             dHide = leatherID;
  429.             interfaceID = 905;
  430.             componentID = CLeatherChaps;
  431.             armourMade = 26;
  432.             armourID = leatherChapsID;
  433.         } else if (chosen.equals("Leather") && chosenArm.equals("Body")) {
  434.             dHide = leatherID;
  435.             interfaceID = 905;
  436.             componentID = CLeatherBody;
  437.             armourMade = 26;
  438.             armourID = leatherBodyID;
  439.         } else if (chosen.equals("Green D'hide") && chosenArm.equals("Vambraces")) {
  440.             dHide = greenhideID;
  441.             interfaceID = 905;
  442.             componentID = CVambs;
  443.             armourMade = 26;
  444.             armourID = greenVambsID;
  445.         } else if (chosen.equals("Green D'hide") && chosenArm.equals("Body")) {
  446.             dHide = greenhideID;
  447.             interfaceID = 905;
  448.             componentID = CBody;
  449.             armourMade = 24;
  450.             armourID = greenBodyID;
  451.         } else if (chosen.equals("Green D'hide") && chosenArm.equals("Chaps")) {
  452.             dHide = greenhideID;
  453.             interfaceID = 905;
  454.             componentID = CChaps;
  455.             armourMade = 26;
  456.             armourID = greenChapsID;
  457.         } else if (chosen.equals("Blue D'hide") && chosenArm.equals("Chaps")) {
  458.             dHide = bluehideID;
  459.             interfaceID = 905;
  460.             componentID = CChaps;
  461.             armourMade = 26;
  462.             armourID = blueChapsID;
  463.         } else if (chosen.equals("Blue D'hide") && chosenArm.equals("Vambraces")) {
  464.             dHide = bluehideID;
  465.             interfaceID = 905;
  466.             componentID = CVambs;
  467.             armourMade = 26;
  468.             armourID = blueVambsID;
  469.         } else if (chosen.equals("Blue D'hide") && chosenArm.equals("Body")) {
  470.             dHide = bluehideID;
  471.             interfaceID = 905;
  472.             componentID = CBody;
  473.             armourMade = 24;
  474.             armourID = blueBodyID;
  475.         }  else if (chosen.equals("Red D'hide") && chosenArm.equals("Chaps")) {
  476.             dHide = redhideID;
  477.             interfaceID = 905;
  478.             componentID = CChaps;
  479.             armourMade = 26;
  480.             armourID = redChapsID;
  481.         }  else if (chosen.equals("Red D'hide") && chosenArm.equals("Vambraces")) {
  482.             dHide = redhideID;
  483.             interfaceID = 905;
  484.             componentID = CVambs;
  485.             armourMade = 26;
  486.             armourID = redVambsID;
  487.         }  else if (chosen.equals("Red D'hide") && chosenArm.equals("Body")) {
  488.             dHide = redhideID;
  489.             interfaceID = 905;
  490.             componentID = CBody;
  491.             armourMade = 24;
  492.             armourID = redBodyID;
  493.         }  else if (chosen.equals("Black D'hide") && chosenArm.equals("Chaps")) {
  494.             dHide = blackhideID;
  495.             interfaceID = 905;
  496.             componentID = CChaps;
  497.             armourMade = 26;
  498.             armourID = blackChapsID;
  499.         }  else if (chosen.equals("Black D'hide") && chosenArm.equals("Body")) {
  500.             dHide = blackhideID;
  501.             interfaceID = 905;
  502.             componentID = CBody;
  503.             armourMade = 24;
  504.             armourID = blackBodyID;
  505.         }  else if (chosen.equals("Black D'hide") && chosenArm.equals("Vambraces")) {
  506.             dHide = blackhideID;
  507.             interfaceID = 905;
  508.             componentID = CVambs;
  509.             armourMade = 26;
  510.             armourID = blackVambsID;
  511.         }
  512.         guiWait = false;
  513.         g.dispose();
  514.     }
  515.     private javax.swing.JLabel TitleBox;
  516.     private javax.swing.ButtonGroup buttonGroup1;
  517.     private javax.swing.ButtonGroup buttonGroup2;
  518.     private javax.swing.JComboBox jComboBox1;
  519.     private javax.swing.JLabel jLabel1;
  520.     private javax.swing.JLabel jLabel2;
  521.     private javax.swing.JLabel jLabel3;
  522.     private javax.swing.JScrollPane jScrollPane1;
  523.     private javax.swing.JTextArea jTextArea1;
  524.     private javax.swing.JComboBox leatherComboBox;
  525.     private javax.swing.JButton startButton;
  526.  
  527. }
  528. }
Add Comment
Please, Sign In to add comment