Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.50 KB | None | 0 0
  1. import java.awt.Point;
  2.  
  3. import org.powerbot.core.script.ActiveScript;
  4. import org.powerbot.game.api.Manifest;
  5. import org.powerbot.game.api.methods.Widgets;
  6. import org.powerbot.game.api.methods.input.Mouse;
  7. import org.powerbot.game.api.methods.tab.Inventory;
  8. import org.powerbot.game.api.methods.widget.Bank;
  9. import org.powerbot.game.api.util.Random;
  10. import org.powerbot.game.api.wrappers.node.Item;
  11.  
  12.  
  13. @Manifest(authors = { "Metamorphed" }, name = "Pots2Flasks", version = 0.1, description = "Converts the 2 or 3 dose potions into potion flasks")
  14. public class Pots2Flasks extends ActiveScript {
  15.  
  16.     public int potions;
  17.     public int flasks = 23191;
  18.     public long startTime;
  19.    
  20.     final Point[] p = {new Point(250,430), new Point(304,457), new Point(214,457), new Point(257,479), new Point(294,459)};
  21.     int x = Random.nextInt(0, 5);
  22.  
  23.  
  24.     public boolean twoDose = false;
  25.     public boolean threeDose = false;
  26.  
  27.     public void onStart() {
  28.         for (Item  i: Inventory.getItems()) {
  29.             if (i.getName().contains("(3)")) {
  30.                 potions = i.getId();
  31.                 threeDose = true;
  32.             }
  33.             if(i.getName().contains("(2)")){
  34.                 potions = i.getId();
  35.                 twoDose = true;
  36.             }
  37.         }
  38.     }
  39.  
  40.     @Override
  41.     public int loop() {
  42.         if(Widgets.get(905).validate()){
  43.             int x = Random.nextInt(0, 4);
  44.             Mouse.click(p[x], true);
  45.             sleep(7500,9000);
  46.         }
  47.        
  48.         if(Inventory.getItem(potions) != null){
  49.             if(Inventory.getItem(flasks) != null){
  50.                 Inventory.getItem(flasks).getWidgetChild().interact("Use");
  51.                 sleep(600);
  52.                 Inventory.getItem(potions).getWidgetChild().interact("Use");
  53.                 sleep(1500,2000);
  54.                
  55.             }else  if(Inventory.getItem(flasks) == null){bankMethod();}
  56.         }else if(Inventory.getItem(potions) == null){bankMethod();}
  57.         return 0;
  58.     }
  59.    
  60.     private void bankMethod(){
  61.         if(Inventory.getItem(potions) != null && Inventory.getItem(flasks) != null){
  62.             if(Bank.isOpen()){
  63.                 Bank.close();
  64.                 sleep(1550);
  65.             }
  66.         }
  67.        
  68.         if(Bank.isOpen()){
  69.             Bank.depositInventory();
  70.             sleep(1000);
  71.             if(Bank.getItem(potions) != null){
  72.                 if(twoDose){
  73.                     Bank.withdraw(potions, 21);
  74.                     sleep(1500);
  75.                 }
  76.                 if(threeDose){
  77.                     Bank.withdraw(potions, 18);
  78.                     sleep(1500);
  79.                 }
  80.             }else{
  81.                 Bank.close();
  82.                 stop();
  83.             }
  84.            
  85.            
  86.             if(Bank.getItem(flasks) != null){
  87.                 Bank.getItem(flasks).getWidgetChild().interact("Withdraw-All");
  88.                 sleep(1500);
  89.             }else{
  90.                 Bank.close();
  91.                 stop();
  92.             }
  93.             Bank.close();
  94.             sleep(1500);
  95.         }
  96.        
  97.         else if(!Bank.isOpen()){
  98.             Bank.open();
  99.             sleep(1500);
  100.         }
  101.     }
  102.  
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement