Advertisement
Guest User

Untitled

a guest
Feb 27th, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.29 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package scripts;
  6.  
  7. import java.awt.Color;
  8. import java.awt.Container;
  9. import java.awt.FlowLayout;
  10. import java.awt.Graphics;
  11. import java.awt.Graphics2D;
  12. import java.awt.event.ActionEvent;
  13. import java.awt.event.ActionListener;
  14. import org.tribot.api.DynamicClicking;
  15. import org.tribot.api.General;
  16. import org.tribot.api.Timing;
  17. import org.tribot.api.types.generic.Condition;
  18. import org.tribot.api2007.Banking;
  19. import org.tribot.api2007.Camera;
  20. import org.tribot.api2007.Interfaces;
  21. import org.tribot.api2007.Inventory;
  22. import org.tribot.api2007.NPCs;
  23. import org.tribot.api2007.Objects;
  24. import org.tribot.api2007.Player;
  25. import org.tribot.api2007.Skills;
  26. import org.tribot.api2007.Walking;
  27. import org.tribot.api2007.WebWalking;
  28. import org.tribot.api2007.types.RSInterfaceChild;
  29. import org.tribot.api2007.types.RSInterfaceMaster;
  30. import org.tribot.api2007.types.RSNPC;
  31. import org.tribot.api2007.types.RSObject;
  32. import org.tribot.api2007.types.RSTile;
  33. import org.tribot.script.Script;
  34. import org.tribot.script.ScriptManifest;
  35. import org.tribot.script.interfaces.Painting;
  36. import javax.swing.*;
  37.  
  38. /**
  39.  *
  40.  * @author Spencer
  41.  */
  42. @ScriptManifest(authors = { "Deluxes" }, category = "Money Making", name = "DeluxesTANNER")
  43. public class DeluxesTANNER extends Script implements Painting {
  44.  
  45.     RSTile tanner = new RSTile(3275, 3191);
  46.     State state = State.TO_BANK;
  47.     RSArea tanArea = new RSArea(new RSTile(3274, 3192), 3);
  48.     RSArea bankArea = new RSArea(new RSTile(3270, 3167), 3);
  49.    
  50.     DeluxesGUI gui;
  51.     JFrame f;
  52.     JComboBox list;
  53.     boolean inGUI = true;
  54.    
  55.     //int leatherID = 1741;
  56.     ZybezRSItem hide;
  57.     ZybezRSItem tanned;
  58.     int cowhideID = 1739;
  59.     int moneyID = 995;
  60.     int cowhidePrice;
  61.     int leatherPrice;
  62.    
  63.     int[] hideID = new int[] { 1739, 1739, 2861, 2861, 1753, 1751, 1749, 1747};
  64.     int[] leatherID = new int[] {1741, 1743, 6289, 6289, 1745, 2505, 2507, 2509};
  65.     int[] payment = new int[] {1, 3, 20, 15, 20, 20, 20, 20};
  66.     String[] hideName = new String[] {"Cowhide", "Cowhide", "Snake hide", "Snake hide", "Green dragonhide", "Blue dragonhide", "Red dragonhide", "Black dragonhide" };
  67.     String[] tannedName = new String[] {"Leather", "Hard Leather", "Snakeskin", "Snakeskin", "Green d-leather", "Blue d-leather", "Red d-leather", "Black d-leather" };
  68.     int tanType = 108;
  69.     int selectedHide = 0;
  70.     int tanOffset = 108;
  71.     String typeToTan = "";
  72.    
  73.     int hidesTanned = 0;
  74.    
  75.     long failSafeTimeoutLow = 3250;
  76.     long failSafeTimeoutHigh = 4000;
  77.     long startTime = System.currentTimeMillis();
  78.    
  79.     public enum State
  80.     {
  81.         TO_BANK, BANK, TO_TANNER, TAN
  82.     }
  83.     public static void main(String[] args) {
  84.         // TODO code application logic here
  85.     }
  86.    
  87.     @Override
  88.     public void onPaint(Graphics g)
  89.     {
  90.         int profit = ((hidesTanned * leatherPrice) - (hidesTanned * cowhidePrice) - (hidesTanned * payment[selectedHide]));
  91.         Graphics2D g1 = (Graphics2D)g;
  92.         g1.drawString("STATE: " + state, 236, 225);
  93.         g1.drawString("HIDES TANNED: " + hidesTanned, 236, 245);
  94.         g1.drawString("TANNING: " + typeToTan, 236, 265);
  95.         g1.drawString("PROFIT: " + profit, 236, 285);
  96.         g1.drawString("TIME RAN: " + Timing.msToString(System.currentTimeMillis() - startTime), 236, 305);
  97.         g1.drawString("HIDES PER HOUR: " +  (hidesTanned * (3600000 / Timing.timeFromMark(startTime))), 236, 325);
  98.         g1.drawString("GOLD PER HOUR: " + (profit * (3600000 / Timing.timeFromMark(startTime))), 236, 345);
  99.     }
  100.    
  101.     boolean atBank()
  102.     {
  103.         return bankArea.contains(Player.getPosition());
  104.     }
  105.    
  106.     boolean atTanner()
  107.     {
  108.         return tanArea.contains(Player.getPosition());
  109.     }
  110.    
  111.     State getState()
  112.     {
  113.         if (atBank() && Inventory.getCount(hideID[selectedHide]) != 0)
  114.             return State.TO_TANNER;
  115.         else if (atTanner() && Inventory.getCount(hideID[selectedHide]) != 0)
  116.             return State.TAN;
  117.         else if (atBank())
  118.             return State.BANK;
  119.         else if (Inventory.getCount(hideID[selectedHide]) != 0)
  120.             return State.TO_TANNER;
  121.         else
  122.             return State.TO_BANK;
  123.     }
  124.    
  125.     @Override
  126.     public void run()
  127.     {
  128.        
  129.         try
  130.         {
  131.             SwingUtilities.invokeAndWait(new Runnable() {
  132.                                 public void run()
  133.                                 {
  134.                                     System.out.print("MAKE GUI");
  135.                                     gui = new DeluxesGUI();
  136.                                     f.setVisible(true);
  137.                                 }});
  138.         } catch(Exception e)
  139.         {
  140.            
  141.         }
  142.        
  143.         while (inGUI)
  144.             sleep(100, 150);
  145.        
  146.         hide = new ZybezRSItem(hideName[selectedHide]);
  147.         tanned = new ZybezRSItem(tannedName[selectedHide]);
  148.         cowhidePrice = hide.getAveragePrice();
  149.         leatherPrice = tanned.getAveragePrice();
  150.        
  151.         Walking.control_click = true;
  152.         WebWalking.setUseRun(true);
  153.         while (true)
  154.         {
  155.            state = getState();
  156.            switch (state)
  157.            {
  158.                case TAN:
  159.                    tan();
  160.                    break;
  161.                case BANK:
  162.                    bank();
  163.                    break;
  164.                case TO_BANK:
  165.                    walkToBank();
  166.                    break;
  167.                case TO_TANNER:
  168.                    walkToTanner();
  169.                    break;
  170.            }
  171.         }
  172.     }
  173.    
  174.     void walkToBank()
  175.     {
  176.         WebWalking.walkToBank();
  177.         while (!bankArea.contains(Player.getPosition()) && Player.isMoving())
  178.             sleep(50, 150);
  179.     }
  180.    
  181.     void walkToTanner()
  182.     {
  183.         WebWalking.setUseRun(true);
  184.         WebWalking.walkTo(tanner);
  185.         while (!tanArea.contains(Player.getPosition()) && Player.isMoving())
  186.             sleep(50, 150);
  187.     }
  188.    
  189.     void tan()
  190.     {
  191.         RSNPC[] tanner = NPCs.find("Ellis");
  192.         if (tanner.length > 0)
  193.         {
  194.             if (Interfaces.get(324) == null)
  195.             {
  196.                 if (DynamicClicking.clickRSNPC(tanner[0], "Trade"))
  197.                 {
  198.                     Timing.waitCondition(new Condition()
  199.                             {
  200.                                 public boolean active()
  201.                                 {
  202.                                     return Interfaces.get(324) != null;
  203.                                 }
  204.                             }, General.random((int)failSafeTimeoutLow, (int)failSafeTimeoutHigh));
  205.                 }
  206.             }
  207.             if (Interfaces.get(324) != null)
  208.             {
  209.                 RSInterfaceMaster master = Interfaces.get(324);
  210.                 while (Inventory.getCount(leatherID[selectedHide]) == 0)
  211.                 {
  212.                     master.getChild(tanType).click("All");
  213.                     Timing.waitCondition(new Condition()
  214.                             {
  215.                                 public boolean active()
  216.                                 {
  217.                                     return Inventory.getCount(leatherID[selectedHide]) != 0;
  218.                                 }
  219.                             }, General.random((int)failSafeTimeoutLow, (int)failSafeTimeoutHigh));
  220.                     hidesTanned += Inventory.getCount(leatherID);
  221.                 }
  222.             }
  223.         }
  224.        
  225.     }
  226.    
  227.     void bank()
  228.     {
  229.         RSObject[] bankBooths = Objects.findNearest(10, "Bank Booth");
  230.         if(bankBooths.length > 0)
  231.         {
  232.             if (!bankBooths[0].isOnScreen())
  233.             {
  234.                 Camera.turnToTile(bankArea.getRandomTile());
  235.                 sleep(200, 300);
  236.             }
  237.             if (DynamicClicking.clickRSObject(bankBooths[0], "Bank"))
  238.             {
  239.                 Timing.waitCondition(new Condition()
  240.                 {
  241.                     public boolean active()
  242.                     {
  243.                         return Banking.isBankScreenOpen();
  244.                     }
  245.                 }, General.random((int)failSafeTimeoutLow, (int)failSafeTimeoutHigh));
  246.             }
  247.             if (Banking.isBankScreenOpen())
  248.             {
  249.                 Banking.depositAllExcept(moneyID);
  250.                 Banking.withdraw(0, hideID[selectedHide]);
  251.                 Timing.waitCondition(new Condition()
  252.                     {
  253.                         public boolean active()
  254.                         {
  255.                             return Inventory.getCount(cowhideID) > 0;
  256.                         }
  257.                     }, General.random((int)failSafeTimeoutLow, (int)failSafeTimeoutHigh));
  258.             }
  259.         }
  260.     }
  261.    
  262.     class DeluxesGUI
  263.     {
  264.         public DeluxesGUI()
  265.         {
  266.             f = new JFrame("This is a test");
  267.             f.setSize(250, 100);
  268.             f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
  269.             Container content = f.getContentPane();
  270.             content.setBackground(Color.white);
  271.             content.setLayout(new FlowLayout());
  272.             String[] petStrings = { "Soft Leather", "Hard Leather", "Snakeskin Light", "Snakeskin Dark", "Green d'hide", "Blue d'hide", "Red d'hide", "Black d'hide" };
  273.             list = new JComboBox(petStrings);
  274.             JButton start = new JButton("Start");
  275.             list.setSelectedIndex(0);
  276.             list.addActionListener(new ActionListener() {
  277.                 public void actionPerformed(ActionEvent e) {
  278.                     JComboBox combo = (JComboBox) e.getSource();
  279.                     tanType = tanOffset + combo.getSelectedIndex();
  280.                     selectedHide = combo.getSelectedIndex();
  281.                     typeToTan = (String)combo.getSelectedItem();
  282.                 }});
  283.             start.addActionListener(new ActionListener() {
  284.                 public void actionPerformed(ActionEvent e) {
  285.                     tanType = tanOffset + list.getSelectedIndex();
  286.                     selectedHide = list.getSelectedIndex();
  287.                     typeToTan = (String)list.getSelectedItem();
  288.                     inGUI = false;
  289.                     f.dispose();
  290.                 }});
  291.             f.add(list);
  292.             f.add(start);
  293.         }
  294.     }
  295. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement