Advertisement
Guest User

>C< Prayer potion Drinker

a guest
Feb 15th, 2018
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.42 KB | None | 0 0
  1. @ScriptManifest(author = "Castro_", info = "", logo = "https://i.imgur.com/4EG1pKu.png", name = ">C< Prayer Potion Drinker", version = 0.1)
  2. public class Main extends Script {
  3.  
  4.     public int drink_at = 0;
  5.  
  6.     public String[] prayer_potions = { "Prayer potion(1)", "Prayer potion(2)", "Prayer potion(3)", "Prayer potion(4)" };
  7.  
  8.     public boolean gui_COMPLETE = false;
  9.  
  10.     public void onStart() {
  11.  
  12.         log("Waiting on GUI...");
  13.  
  14.         GUI gui = new GUI();
  15.  
  16.         Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
  17.         int screenW = screensize.width / 2;
  18.         int screenH = screensize.height / 2;
  19.  
  20.         gui.frmc.setVisible(true);
  21.         gui.frmc.setLocation(screenW / 2, screenH / 2);
  22.  
  23.         while (!this.gui_COMPLETE) {
  24.             try {
  25.                 sleep(300L);
  26.             } catch (InterruptedException e) {
  27.                 e.printStackTrace();
  28.             }
  29.         }
  30.         gui.frmc.setVisible(false);
  31.  
  32.         log("GUI completed.");
  33.  
  34.     }
  35.  
  36.     @Override
  37.     public int onLoop() throws InterruptedException {
  38.  
  39.         if (getSkills().getDynamic(Skill.PRAYER) <= drink_at) {
  40.  
  41.             drink_prayer_potions();
  42.         }
  43.  
  44.         return random(20, 40);
  45.     }
  46.  
  47.     public void drink_prayer_potions() {
  48.  
  49.         if (getInventory().contains(prayer_potions)) {
  50.  
  51.             if (getInventory().contains("Prayer potion(1)")) {
  52.  
  53.                 getInventory().interact("Drink", "Prayer potion(1)");
  54.  
  55.             } else {
  56.                
  57.                 if (getInventory().contains("Prayer potion(2)")) {
  58.  
  59.                     getInventory().interact("Drink", "Prayer potion(2)");
  60.  
  61.                 } else {
  62.                    
  63.                     if (getInventory().contains("Prayer potion(3)")) {
  64.  
  65.                         getInventory().interact("Drink", "Prayer potion(3)");
  66.  
  67.                     } else {
  68.                        
  69.                         if (getInventory().contains("Prayer potion(4)")) {
  70.  
  71.                             getInventory().interact("Drink", "Prayer potion(4)");
  72.  
  73.                         }
  74.  
  75.                         new ConditionalSleep(random(3000, 4000)) {
  76.  
  77.                             @Override
  78.                             public boolean condition() {
  79.                                 return myPlayer().getAnimation() != 829;
  80.                             }
  81.  
  82.                         }.sleep();
  83.                     }
  84.                 }
  85.             }
  86.            
  87.         }else {
  88.            
  89.             if(!getInventory().contains(prayer_potions)) {
  90.                
  91.                 log("Out of prayer potions.");
  92.                 stop(false);
  93.                
  94.             }
  95.         }
  96.     }
  97.  
  98.     public class GUI {
  99.  
  100.         private JFrame frmc;
  101.         private JTextField textField;
  102.  
  103.         public GUI() {
  104.             initialize();
  105.         }
  106.  
  107.         /**
  108.          * Initialize the contents of the frame.
  109.          */
  110.         private void initialize() {
  111.             frmc = new JFrame();
  112.             frmc.setResizable(false);
  113.             frmc.setTitle(">C< PPD");
  114.             frmc.setBounds(100, 100, 227, 120);
  115.             frmc.getContentPane().setLayout(null);
  116.  
  117.             textField = new JTextField();
  118.             textField.setBounds(55, 11, 46, 20);
  119.             frmc.getContentPane().add(textField);
  120.             textField.setColumns(10);
  121.  
  122.             JLabel lblDrinkAt = new JLabel("Drink at");
  123.             lblDrinkAt.setBounds(10, 14, 46, 14);
  124.             frmc.getContentPane().add(lblDrinkAt);
  125.  
  126.             JLabel lblPrayerPoints = new JLabel("prayer points.");
  127.             lblPrayerPoints.setBounds(111, 14, 77, 14);
  128.             frmc.getContentPane().add(lblPrayerPoints);
  129.  
  130.             JButton btnStart = new JButton("Start");
  131.             btnStart.addActionListener(new ActionListener() {
  132.                 public void actionPerformed(ActionEvent arg0) {
  133.  
  134.                     drink_at = Integer.parseInt(textField.getText());
  135.  
  136.                     gui_COMPLETE = true;
  137.  
  138.                 }
  139.             });
  140.             btnStart.setBounds(10, 57, 201, 23);
  141.             frmc.getContentPane().add(btnStart);
  142.  
  143.             JLabel lblRandomizedBy = new JLabel("Prioritises lower doses first.");
  144.             lblRandomizedBy.setForeground(Color.GRAY);
  145.             lblRandomizedBy.setBounds(10, 32, 201, 23);
  146.             frmc.getContentPane().add(lblRandomizedBy);
  147.         }
  148.     }
  149.  
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement