Guest User

Toxic/ToxicHerb

a guest
Sep 5th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.31 KB | None | 0 0
  1.  
  2. import java.awt.BasicStroke;
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.*;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10. import javax.swing.*;
  11.  
  12.  
  13. import xobot.client.callback.listeners.PaintListener;
  14. import xobot.script.ActiveScript;
  15. import xobot.script.Manifest;
  16. import xobot.script.methods.Bank;
  17. import xobot.script.methods.GameObjects;
  18. import xobot.script.methods.Packets;
  19. import xobot.script.methods.Players;
  20. import xobot.script.methods.Widgets;
  21. import xobot.script.methods.tabs.Inventory;
  22. import xobot.script.util.Time;
  23. import xobot.script.util.Timer;
  24. import xobot.script.wrappers.interactive.GameObject;
  25. import xobot.script.wrappers.interactive.Item;
  26.  
  27. @Manifest(authors = { "Toxic" }, name = "Toxic Herb")
  28. public class ToxicHerb extends ActiveScript implements PaintListener{
  29.  
  30.     private Timer t;
  31.     private int pot = 0;
  32.     private int herbId = 0;
  33.     private int productId = 0;
  34.     private int secondaryId = 0;
  35.     String[] supportedPots = {"Toadflax potion (unf)", "SaraBrew (3)", "Extreme Magic (3)", "Extreme Defence (3)", "Extreme Strength (3)", "Extreme Attack (3)", "Dwarf Weed Potion (unf)", "Ranging Potion (3)", "Lantadyme Potion (unf)", "Magic Potion (3)", "Cadantine Potion (unf)", "Super Defence (3)", "Kwuarm Potion (unf)", "Super strength (3)", "Irit Potion (unf)", "Super Attack (3)", "Guam potion (unf)", "Attack potion (3)", "Ranarr potion (unf)", "Prayer potion (3)", "Harralander potion (unf)", "Combat potion (3)", "Snapdragon potion (unf)", "Super restore (3)"};
  36.     JComboBox combo = new JComboBox(supportedPots);
  37.  
  38.     public boolean onStart() {
  39.  
  40.         JDialog frame = new JDialog();
  41.         frame.setPreferredSize(new Dimension(300,150));
  42.         frame.setLocationRelativeTo(null);
  43.         frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  44.         FlowLayout layout = new FlowLayout();
  45.         layout.setHgap(5);
  46.         layout.setVgap(5);
  47.         frame.setLayout(layout);
  48.  
  49.         combo.setPreferredSize(new Dimension(200,30));
  50.         combo.setFocusable(false);
  51.  
  52.         JButton button = new JButton("Start");
  53.         button.setFocusable(false);
  54.         button.setPreferredSize(new Dimension(60,32));
  55.         button.addActionListener(new ActionListener() {
  56.  
  57.             @Override
  58.             public void actionPerformed(ActionEvent arg0) {
  59.                 switch(combo.getSelectedItem().toString()) {
  60.                     case "Toadflax potion (unf)":
  61.                         herbId = 2998;
  62.                         secondaryId = 227;
  63.                         productId = 3002;
  64.                         break;
  65.                     case "SaraBrew (3)":
  66.                         herbId = 6693;
  67.                         secondaryId = 3002;
  68.                         productId = 6687;
  69.                         break;
  70.                     case "Extreme Magic (3)":
  71.                         herbId = 9594;
  72.                         secondaryId = 3042;
  73.                         break;
  74.                     case "Extreme Defence (3)":
  75.                         herbId = 2481;
  76.                         secondaryId = 163;
  77.                         break;
  78.                     case "Extreme Strength (3)":
  79.                         herbId = 267;
  80.                         secondaryId = 157;
  81.                         break;
  82.                     case "Extreme Attack (3)":
  83.                         herbId = 261;
  84.                         secondaryId = 145;
  85.                         break;
  86.                     case "Dwarf Weed Potion (unf)":
  87.                         herbId = 227;
  88.                         secondaryId = 267;
  89.                         break;
  90.                     case "Ranging Potion (3)":
  91.                         herbId = 245;
  92.                         secondaryId = 109;
  93.                         break;
  94.                     case "Lantadyme Potion (unf)":
  95.                         herbId = 227;
  96.                         secondaryId = 2481;
  97.                         break;
  98.                     case "Magic Potion (3)":
  99.                         herbId = 3138;
  100.                         secondaryId = 2483;
  101.                         break;
  102.                     case "Cadantine Potion (unf)":
  103.                         herbId = 227;
  104.                         secondaryId = 265;
  105.                         break;
  106.                     case "Super Defence (3)":
  107.                         herbId = 239;
  108.                         secondaryId = 107;
  109.                         break;
  110.                     case "Kwuarm Potion (unf)":
  111.                         herbId = 227;
  112.                         secondaryId = 263;
  113.                         break;
  114.                     case "Super strength (3)":
  115.                         herbId = 225;
  116.                         secondaryId = 105;
  117.                         break;
  118.                     case "Irit Potion (unf)":
  119.                         herbId = 227;
  120.                         secondaryId = 259;
  121.                         break;
  122.                     case "Super Attack (3)":
  123.                         herbId = 221;
  124.                         secondaryId = 101;
  125.                         break;
  126.                     case "Guam potion (unf)":
  127.                         herbId = 227;
  128.                         secondaryId = 249;
  129.                         break;
  130.                     case "Attack potion (3)":
  131.                         herbId = 221;
  132.                         secondaryId = 91;
  133.                         break;
  134.                     case "Ranarr potion (unf)":
  135.                         herbId = 227;
  136.                         secondaryId = 257;
  137.                         break;
  138.                     case "Prayer potion (3)":
  139.                         herbId = 231;
  140.                         secondaryId = 99;
  141.                         break;
  142.                     case "Harralander potion (unf)":
  143.                         herbId = 227;
  144.                         secondaryId = 255;
  145.                         break;
  146.                     case "Combat potion (3)":
  147.                         herbId = 9736;
  148.                         secondaryId = 97;
  149.                         productId = 9741;
  150.                         break;
  151.                     case "Snapdragon potion (unf)":
  152.                         herbId = 227;
  153.                         secondaryId = 3000;
  154.                         break;
  155.                     case "Super restore (3)":
  156.                         herbId = 3004;
  157.                         secondaryId = 223;
  158.                         break;
  159.                     case "default":
  160.                         onStop();
  161.                         break;
  162.                 }
  163.                 frame.dispose();
  164.  
  165.             }
  166.  
  167.         });
  168.  
  169.         frame.add(combo);
  170.         frame.add(button);
  171.         frame.setTitle("Select your job");
  172.  
  173.  
  174.         frame.pack();
  175.         frame.setVisible(true);
  176.         while(frame.isVisible()) {
  177.             Time.sleep(500);
  178.         }
  179.  
  180.         t = new Timer(System.currentTimeMillis());
  181.         return true;
  182.  
  183.     }
  184.  
  185.     @Override
  186.     public int loop() {
  187.         if(Widgets.getBackDialogId() == 4429) {
  188.             Packets.sendAction(315, -1, -1, 1747);
  189.             return 16000;
  190.         }
  191.         if(Players.getMyPlayer().getAnimation() == 363) {
  192.             return 1000;
  193.         }
  194.         Time.sleep(400);
  195.         if(Players.getMyPlayer().getAnimation() == 363) {
  196.             return 1000;
  197.         }
  198.             if(Inventory.Contains(secondaryId) && Inventory.Contains(herbId)) {
  199.                 Item i = Inventory.getItem(herbId);
  200.                 Item u = Inventory.getItem(secondaryId);
  201.                 if(i != null) {
  202.                     Packets.sendAction(447, i.getID(), i.getSlot(), 3214);
  203.                     Time.sleep(190, 250);
  204.                     Packets.sendAction(870, u.getID(), u.getSlot(), 3214);
  205.                     Time.sleep(190, 250);
  206.                 }
  207.         }else {
  208.             if(Bank.isOpen()) {
  209.                 if(Inventory.Contains(productId)) {
  210.                     Bank.depositAll();
  211.                     if (secondaryId == 440) {
  212.                         pot += 14;
  213.                         Time.sleep(190, 250);
  214.                     } else {
  215.                         pot += 14;
  216.                         Time.sleep(190, 250);
  217.                     }
  218.                 }
  219.  
  220.                 Item herb = Bank.getItem(herbId);
  221.                 Item secondaryIng = Bank.getItem(secondaryId);
  222.                 if(secondaryIng != null && herb != null) {
  223.                     Bank.depositAll();
  224.                     Time.sleep(190, 250);
  225.                     Bank.withdraw(herbId, 14);
  226.                     Time.sleep(190, 250);
  227.                     Bank.withdraw(secondaryId, 14);
  228.                     Time.sleep(190, 250);
  229.                     return 500;
  230.                 }else{
  231.                     return -1;
  232.                 }
  233.  
  234.             }else {
  235.                 GameObject o = GameObjects.getNearest(26972);
  236.                 o.interact(4);
  237.                 Time.sleep(1200);
  238.             }
  239.  
  240.         }
  241.         return 2000;
  242.     }
  243.  
  244.     private final Color color1 = new Color(255, 255, 255, 84);
  245.     private final Color color2 = new Color(0, 0, 0);
  246.     private final Color colour3 = new Color(255, 0, 0);
  247.  
  248.  
  249.     private final BasicStroke stroke1 = new BasicStroke(1);
  250.  
  251.     private final Font font1 = new Font("Arial", 0, 23);
  252.     private final Font font2 = new Font("Arial", 0, 16);
  253.  
  254.  
  255.     @Override
  256.     public void repaint(Graphics g1) {
  257.         try {
  258.  
  259.             int ph = (int) ((pot) * 3600000D / (t.getElapsed()));
  260.             Item b = Bank.getItem(453);
  261.             int item = 0;
  262.             if(b != null) {
  263.                 item = b.getStack();
  264.             }
  265.             Graphics2D g = (Graphics2D)g1;
  266.             g.setColor(color1);
  267.             g.fillRect(343, 155, 171, 183);
  268.             g.setColor(color2);
  269.             g.setStroke(stroke1);
  270.             g.drawRect(343, 155, 171, 183);
  271.             g.setFont(font1);
  272.             g.drawString("Smelting", 367, 184);
  273.             g.setFont(font2);
  274.             g.drawString("Time: " + t.toElapsedString(), 352, 219);
  275.             g.drawString("pot: " + pot, 352, 249);
  276.             g.drawString("Herbs: " + item, 352, 305);
  277.             g.drawString("pot(h): " + ph, 352, 277);
  278.             g.setColor(colour3);
  279.             g.drawString("Rumple/Toxic", 360, 334);
  280.         }catch(Exception e) {
  281.             e.printStackTrace();
  282.         }
  283.     }
  284.  
  285. }
Add Comment
Please, Sign In to add comment