joedezzy1

AutoAlcher

Mar 4th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.50 KB | None | 0 0
  1. package scripts.AutoAlcher;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Dimension;
  5. import java.awt.Font;
  6. import java.awt.Graphics;
  7. import java.awt.Toolkit;
  8.  
  9. import org.tribot.api.General;
  10. import org.tribot.api.Timing;
  11. import org.tribot.api.input.Mouse;
  12. import org.tribot.api2007.Camera;
  13. import org.tribot.api2007.Game;
  14. import org.tribot.api2007.Magic;
  15. import org.tribot.api2007.GameTab;
  16. import org.tribot.api2007.Player;
  17. import org.tribot.api2007.Skills;
  18. import org.tribot.api2007.Walking;
  19. import org.tribot.api2007.GameTab.TABS;
  20. import org.tribot.api2007.Skills.SKILLS;
  21. import org.tribot.api2007.Inventory;
  22. import org.tribot.api2007.types.RSItem;
  23. import org.tribot.api2007.types.RSTile;
  24. import org.tribot.script.Script;
  25. import org.tribot.script.ScriptManifest;
  26. import org.tribot.script.interfaces.Painting;
  27.  
  28. @ScriptManifest(authors = { "JDezzy" }, category = "Magic", name = "AutoAlchemy")
  29.  
  30. public class AutoAlchemyPRO extends Script implements Painting{
  31.  
  32.     public int ItemID;
  33.     public int delayFrom;
  34.     public int delayTo;
  35.    
  36.     //paint
  37.     public int numberofalchs;
  38.     public int alchsperhour;
  39.     public int startXP;
  40.     public int startLvl;
  41.     public long startTime;
  42.     //paint
  43.    
  44.     public static RSTile OriginalTile;
  45.     public RSItem[] ItemToAlch;
  46.    
  47.     public TABS mage = TABS.MAGIC;
  48.     public TABS inv = TABS.INVENTORY;
  49.    
  50.     public boolean GUI_COMPLETE = false;
  51.     public boolean Running = true;
  52.     //public static int Price = 1340; get price to buy from users
  53.    
  54.     private final Font font1 = new Font("Arial", 0, 11);
  55.    
  56.     @Override
  57.     public void run() {
  58.        
  59.         SetUpGUI(); //get item to alch ID
  60.        
  61.         println("Welcome!");
  62.         println("Alching item: " +ItemID);
  63.                 OriginalTile = Player.getRSPlayer().getPosition();
  64.                
  65.         GetPaintValues();
  66.        
  67.        
  68.         while(Running){
  69.             StartAlching();
  70.         }
  71.     }
  72.  
  73.     private void GetPaintValues() {
  74.         startXP = Skills.getXP(SKILLS.MAGIC);
  75.         startTime = System.currentTimeMillis();
  76.         startLvl = Skills.getCurrentLevel(SKILLS.MAGIC);
  77.         OriginalTile = Player.getRSPlayer().getPosition();
  78.     }
  79.  
  80.     private void StartAlching() {
  81.  
  82.         ChecksAndSafes();
  83.            
  84.         Alch();
  85.     }
  86.  
  87.     private void Alch() {
  88.        
  89.         if(!IsOpen(mage) && !UpTextContains("Cast"))
  90.             OpenTab();
  91.    
  92.    
  93.              if(IsOpen(mage))
  94.                 ClickAlch();
  95.        
  96.        
  97.                  if(IsOpen(inv) && UpTextContains("Cast"))
  98.                         ClickItem();
  99.     }
  100.  
  101.     private void ChecksAndSafes() {
  102.         AntiBan1();
  103.            
  104.                 //CheckIfOut();
  105.                
  106.                         OriginalTileCheck();
  107.     }
  108.  
  109.     private boolean UpTextContains(String UpText) {
  110.         if(Game.getUptext().contains(UpText))
  111.             return true;
  112.                 else return false;
  113.     }
  114.  
  115.     private void CheckIfOut() {
  116.        
  117.         if(Inventory.find(ItemID).length == 0)
  118.            
  119.             { BowBuyer.WeNeedBows = true;
  120.                 println("BuyingBows();");
  121.                             BowBuyer.run(); }
  122.        
  123.     }
  124.  
  125.     private void AntiBan1() {
  126.         int x;
  127.        
  128.         x = General.random(1, 1500);
  129.        
  130.         if(x == 6 || x == 9|| x == 546)
  131.             AntiBan(x);
  132.     }
  133.  
  134.     private void ClickItem() {
  135.        
  136.         ItemToAlch = Inventory.find(ItemID);
  137.        
  138.         if(WeCanAlch())
  139.            
  140.         { ItemToAlch[0].hover();
  141.            
  142.                 if(!UpTextContains("Cast"))
  143.                     StartAlching();
  144.  
  145.                     else if(UpTextContains("Cast"))
  146.                             ItemToAlch[0].click();
  147.                    
  148.                                 sleep(delayFrom, delayTo); }
  149.        
  150.         else if(IsOpen(mage))
  151.             StartAlching();
  152.        
  153.     }
  154.  
  155.     private boolean WeCanAlch() {
  156.         if(Inventory.open() && ItemToAlch.length > 0)
  157.            
  158.             return true;
  159.        
  160.         else return false;
  161.     }
  162.  
  163.     private void ClickAlch() {
  164.        
  165.         if(IsOpen(mage))
  166.              ClickSpell();
  167.                
  168.                 while(IsOpen(mage))
  169.                 { sleep(2000, 2100);
  170.                     OpenTab(); } //might not need this
  171.        
  172.     }
  173.  
  174.     private void ClickSpell() {
  175.          Magic.selectSpell("High Level Alchemy");
  176.             sleep(497, 1868);
  177.                 numberofalchs = numberofalchs +1;
  178.     }
  179.  
  180.     private boolean IsOpen(TABS tab) {
  181.  
  182.         if(GameTab.getOpen().equals(tab))
  183.             return true;
  184.                 else return false;
  185.     }
  186.  
  187.     private void OpenTab() {
  188.        
  189.         if(!IsOpen(mage))      
  190.              if(Game.getUptext().contains("Cast"))
  191.                     Mouse.click(1);
  192.                    
  193.        
  194.             GameTab.open(TABS.MAGIC);
  195.            
  196.             while(!IsOpen(mage))
  197.                 { OpenTab(); sleep(2000,2100); }
  198.  
  199.     }
  200.  
  201.     private void AntiBan(int x) {
  202.         if(x == 6)
  203.             Camera.setCameraAngle(General.random(0,100));
  204.        
  205.        
  206.         if (x == 9)
  207.         { Camera.setCameraRotation(General.random(1, 364));
  208.             int y = General.random(1,10);
  209.                 if(y == 7)
  210.                 { GameTab.open(TABS.STATS);
  211.                     Mouse.move(General.random(556,597), General.random(365,382));
  212.                         sleep(1350, 2406); } }
  213.     }
  214.    
  215.     private void OriginalTileCheck() {
  216.  
  217.         if (!Player.getRSPlayer().getPosition().equals(OriginalTile))
  218.          { println("We've changed positions, moving back!");
  219.                 Walking.walkTo(OriginalTile);
  220.                     sleep(General.random(1403,3064)); }
  221.        
  222.     }
  223.  
  224.     private void SetUpGUI() {
  225.         GUI GUI = new GUI();
  226.        
  227.        
  228.         Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
  229.         int screenW = (screensize.width) / 2;
  230.         int screenH = (screensize.height) / 2;
  231.  
  232.         GUI.setVisible(true);
  233.  
  234.         GUI.setLocation((screenW / 2), (screenH / 2));
  235.  
  236.         while (!GUI_COMPLETE) {
  237.             sleep(300);
  238.         }
  239.  
  240.         GUI.setVisible(false);
  241.     }
  242.  
  243.    
  244.     public class GUI extends javax.swing.JFrame {
  245.  
  246.         /**
  247.          *
  248.          */
  249.         private static final long serialVersionUID = 1L;
  250.         /**
  251.          * Creates new form GUI
  252.          */
  253.         public GUI() {
  254.             initComponents();
  255.         }
  256.  
  257.         /**
  258.          * This method is called from within the constructor to initialize the form.
  259.          * WARNING: Do NOT modify this code. The content of this method is always
  260.          * regenerated by the Form Editor.
  261.          */
  262.        
  263.         // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  264.         private void initComponents() {
  265.  
  266.             jLabel1 = new javax.swing.JLabel();
  267.             jLabel2 = new javax.swing.JLabel();
  268.             itemID = new javax.swing.JTextField();
  269.             start = new javax.swing.JButton();
  270.             jLabel3 = new javax.swing.JLabel();
  271.             DelayFrom = new javax.swing.JTextField();
  272.             DelayTo = new javax.swing.JTextField();
  273.             jLabel4 = new javax.swing.JLabel();
  274.             jLabel5 = new javax.swing.JLabel();
  275.  
  276.             jLabel1.setFont(new java.awt.Font("Tempus Sans ITC", 1, 18)); // NOI18N
  277.             jLabel1.setText("JDezzy's AutoAlchemy");
  278.            
  279.  
  280.             jLabel2.setText("to");
  281.  
  282.             start.setText("Start Alching");
  283.             start.addActionListener(new java.awt.event.ActionListener() {
  284.                 public void actionPerformed(java.awt.event.ActionEvent evt) {
  285.                     startActionPerformed(evt);
  286.                 }
  287.             });
  288.  
  289.             jLabel3.setText("Delay between alchs:");
  290.  
  291.             jLabel4.setText("Item ID:");
  292.  
  293.             jLabel5.setText("milliseconds");
  294.  
  295.             javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  296.             getContentPane().setLayout(layout);
  297.             layout.setHorizontalGroup(
  298.                 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  299.                 .addGroup(layout.createSequentialGroup()
  300.                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  301.                         .addGroup(layout.createSequentialGroup()
  302.                             .addGap(68, 68, 68)
  303.                             .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE))
  304.                         .addGroup(layout.createSequentialGroup()
  305.                             .addContainerGap()
  306.                             .addComponent(jLabel3)
  307.                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  308.                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  309.                                 .addComponent(start)
  310.                                 .addGroup(layout.createSequentialGroup()
  311.                                     .addComponent(DelayFrom, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
  312.                                     .addGap(6, 6, 6)
  313.                                     .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
  314.                                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  315.                                     .addComponent(DelayTo, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
  316.                                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  317.                                     .addComponent(jLabel5))))
  318.                         .addGroup(layout.createSequentialGroup()
  319.                             .addGap(102, 102, 102)
  320.                             .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
  321.                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  322.                             .addComponent(itemID, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)))
  323.                     .addContainerGap(20, Short.MAX_VALUE))
  324.             );
  325.             layout.setVerticalGroup(
  326.                 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  327.                 .addGroup(layout.createSequentialGroup()
  328.                     .addContainerGap()
  329.                     .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  330.                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  331.                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  332.                         .addComponent(itemID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  333.                         .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
  334.                     .addGap(11, 11, 11)
  335.                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  336.                         .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
  337.                         .addComponent(DelayFrom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  338.                         .addComponent(DelayTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  339.                         .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
  340.                         .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
  341.                     .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  342.                     .addComponent(start)
  343.                     .addContainerGap(16, Short.MAX_VALUE))
  344.             );
  345.  
  346.             pack();
  347.         }// </editor-fold>                        
  348.  
  349.         private void startActionPerformed(java.awt.event.ActionEvent evt) {                                      
  350.             // TODO add your handling code here:
  351.             delayFrom = Integer.parseInt(DelayFrom.getText().toString());
  352.             delayTo = Integer.parseInt(DelayTo.getText().toString());
  353.             ItemID = Integer.parseInt(itemID.getText().toString());
  354.             GUI_COMPLETE = true;
  355.         }                                    
  356.  
  357.         // Variables declaration - do not modify                    
  358.         private javax.swing.JTextField DelayFrom;
  359.         private javax.swing.JTextField DelayTo;
  360.         private javax.swing.JTextField itemID;
  361.         private javax.swing.JLabel jLabel1;
  362.         private javax.swing.JLabel jLabel2;
  363.         private javax.swing.JLabel jLabel3;
  364.         private javax.swing.JLabel jLabel4;
  365.         private javax.swing.JLabel jLabel5;
  366.         private javax.swing.JButton start;
  367.         // End of variables declaration                  
  368.     }
  369.    
  370.     @Override
  371.     public void onPaint(Graphics g) {
  372.          
  373.  
  374.          
  375.         long timeRan = System.currentTimeMillis() - startTime;
  376.         int currentLvl = Skills.getActualLevel(SKILLS.MAGIC);
  377.         int gainedLvl = currentLvl - startLvl;
  378.         int gainedXP = Skills.getXP(SKILLS.MAGIC) - startXP;
  379.         int xpToLevel = Skills.getXPToNextLevel(SKILLS.MAGIC);
  380.         int xpPerHour = (int)(gainedXP * 3600000d / timeRan);
  381.  
  382.         g.setFont(font1);
  383.  
  384.         g.setColor(new Color(44, 44, 44));
  385.         g.drawString("Runtime: " + Timing.msToString(timeRan), 300, 370);
  386.         g.drawString("Current lvl: " + currentLvl + " (+" + gainedLvl + ")", 300, 390);
  387.         g.drawString("XP Gained: " + gainedXP, 300, 410);
  388.         g.drawString("XP TNL: " + xpToLevel, 300, 430);
  389.         g.drawString("XP/H: " + xpPerHour, 300, 450);
  390.        
  391.     }
  392. }
Advertisement
Add Comment
Please, Sign In to add comment