Guest User

Untitled

a guest
Jul 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.90 KB | None | 0 0
  1.  
  2.  
  3. import org.powerbot.game.api.util.Random;
  4. import org.powerbot.concurrent.Task;
  5. import org.powerbot.game.api.Manifest;
  6. import org.powerbot.concurrent.action.Action;
  7. import org.powerbot.game.api.ActiveScript;
  8. import org.powerbot.game.api.methods.Tabs;
  9. import org.powerbot.game.api.methods.Widgets;
  10. import org.powerbot.game.api.methods.interactive.Npcs;
  11. import org.powerbot.game.api.methods.tab.Inventory;
  12. import org.powerbot.game.api.methods.widget.Camera;
  13. import org.powerbot.game.api.util.Filter;
  14. import org.powerbot.game.api.util.Time;
  15. import org.powerbot.game.api.wrappers.interactive.Npc;
  16. import org.powerbot.game.api.wrappers.widget.WidgetChild;
  17. import org.powerbot.lang.Activatable;
  18.  
  19.  
  20. @Manifest(
  21.         name = "xScott's Lunar Plank Maker!",
  22.         version = 1.0,
  23.         description = "Makes planks using the Lunar spell Plank Make.",
  24.         authors = { "xScott"}
  25. )
  26.  
  27. public class LunarPlanker extends ActiveScript
  28. {
  29.     //Banker ID - Dungeoneering bank
  30.     private final static int banker = 9710;
  31.     //Widgets
  32.     private static WidgetChild[] InventoryItems;
  33.     private static WidgetChild PlankMakeSpell;
  34.     private static WidgetChild Logs;
  35.     private static WidgetChild CloseBank;
  36.    
  37.    
  38.     @Override
  39.     public void setup()
  40.     {
  41.         InventoryItems = Widgets.get(679,0).getChildren();
  42.         PlankMakeSpell = Widgets.get(430, 33);
  43.         Logs = Widgets.get(762,99);
  44.         CloseBank = Widgets.get(762, 45);
  45.        
  46.         MakePlank makePlanks = new MakePlank();
  47.         Bank bank = new Bank();
  48.         AntiBan anti = new AntiBan();
  49.        
  50.         Action doBank = new Action(bank, bank);
  51.         Action myAction = new Action(makePlanks, makePlanks);
  52.         Action DoAnti = new Action(anti,anti);
  53.        
  54.         provide(doBank);
  55.         provide(myAction);
  56.         provide(DoAnti);
  57.        
  58.  
  59.     }
  60.    
  61.    
  62.     public class MakePlank implements Task, Activatable
  63.     {
  64.         //checks if magic tab is open, if not open it.
  65.         private void CheckMagicTabIsOpen()
  66.         {
  67.             if(!Tabs.MAGIC.open())
  68.                 Tabs.MAGIC.open();
  69.         }
  70.          
  71.  
  72.         @Override
  73.         public void run()
  74.         {
  75.             CheckMagicTabIsOpen();//checks
  76.            
  77.             for(int x = 2; x < 28; x++)//Loops through all the inventory slots.
  78.             {
  79.                 PlankMakeSpell.click(true);
  80.                 InventoryItems[x].click(true);
  81.                 Time.sleep(1100);
  82.                 CheckMagicTabIsOpen();
  83.             }
  84.         }
  85.  
  86.         @Override
  87.         public boolean applicable()
  88.         {
  89.             return true;
  90.         }
  91.     }  
  92.    
  93.     //Banking is temporary atm, extremely dogdy from the looks of it.
  94.     public class Bank implements Task, Activatable
  95.     {
  96.    
  97.         private void WithdrawLogs()
  98.         {
  99.             Logs.interact("Withdraw-All"); 
  100.             Time.sleep(900);
  101.             if(Inventory.getCount() == 2) { WithdrawLogs(); }
  102.                
  103.         }
  104.         @Override
  105.         public void run()
  106.         {
  107.                
  108.             Npc bank = Npcs.getNearest(new Filter<Npc>()  
  109.                     {
  110.                 @Override  
  111.                 public boolean accept(Npc npc) { return npc.getId() == banker; }});
  112.  
  113.                  if(bank !=null && bank.isOnScreen())
  114.                  {
  115.                      bank.interact("Bank");  
  116.                      Time.sleep(500);
  117.                      
  118.                      InventoryItems[4].interact("Deposit-All");
  119.                      Time.sleep(500);
  120.                      
  121.                      WithdrawLogs();
  122.                      
  123.                      CloseBank.click(true);
  124.                      
  125.                  }
  126.         }
  127.  
  128.         @Override
  129.         public boolean applicable()
  130.         {
  131.             return true;
  132.         }
  133.        
  134.     }
  135.     public class AntiBan implements Task, Activatable
  136.     {
  137.  
  138.         @Override
  139.         public void run()
  140.         {
  141.             Antiban(Random.nextInt(0, 20));
  142.            
  143.         }
  144.  
  145.         @Override
  146.         public boolean applicable() {
  147.             return true;
  148.         }
  149.        
  150.         private void Antiban(int randomNumber)
  151.         {
  152.             if(randomNumber % 2 == 0)
  153.             {
  154.                 switch(randomNumber)
  155.                 {
  156.                     case 2:
  157.                     case 4:
  158.                     case 6:
  159.                     case 8:
  160.                     case 10:
  161.                         Camera.setAngle(Random.nextInt(43, 311));
  162.                    
  163.                 }
  164.             }
  165.            
  166.         }
  167.        
  168.     }
  169. }
Add Comment
Please, Sign In to add comment