Advertisement
Guest User

Main.java

a guest
Sep 21st, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.87 KB | None | 0 0
  1. import org.osbot.rs07.api.filter.Filter;
  2. import org.osbot.rs07.api.map.Area;
  3. import org.osbot.rs07.api.model.Entity;
  4. import org.osbot.rs07.api.model.Item;
  5. import org.osbot.rs07.script.Script;
  6. import org.osbot.rs07.script.ScriptManifest;
  7. import org.osbot.rs07.utility.ConditionalSleep;
  8.  
  9. import java.awt.*;
  10.  
  11.  
  12. @ScriptManifest(name = "Woodcutter", author = "Venetox", version = 1.0, info = "Woodcutter", logo = "IMGURLINKTOLOGO(NOTNEEDED)")
  13. public class Main extends Script {
  14.  
  15.     private Area edgeVilleTrees = new Area(3084, 3467, 3089, 3483);
  16.     private Area edgeVilleBank = new Area(3092, 3498, 3094, 3488);
  17.    
  18.     private Area selectedBank;
  19.     private Area selectedTrees;
  20.    
  21.     private boolean powerchop = false;
  22.    
  23.     private Filter<Item> axeFilter = new Filter<Item>(){
  24.  
  25.         @Override
  26.         public boolean match(Item i) {
  27.                 if(i.getName().contains(" axe"))
  28.                     return true;
  29.             return false;
  30.         }};
  31.  
  32.  
  33.     @Override
  34.     public void onStart() {
  35.  
  36.         selectedBank = edgeVilleBank;
  37.         selectedTrees = edgeVilleTrees;
  38.        
  39.     }
  40.    
  41.     @Override
  42.     public void onExit() {
  43.     }
  44.  
  45.  
  46.     @SuppressWarnings("unchecked")
  47.     @Override
  48.     public int onLoop() throws InterruptedException {
  49.        
  50.         Action currentAction = getAction();
  51.         log("onLoop: " + currentAction);
  52.        
  53.         switch(currentAction)
  54.         {
  55.        
  56.         case BANK_ITEMS: // GetAction has determined that we can bank items, so we do it.
  57.            
  58.             if(!getBank().isOpen()) // If bank is not open, open it
  59.                 getBank().open();
  60.             else // Else, bank everything except an axe.
  61.             {
  62.                 bank.depositAllExcept(axeFilter);
  63.                 new ConditionalSleep(5000){
  64.  
  65.                     @Override
  66.                     public boolean condition() throws InterruptedException {
  67.                             if(!getInventory().isFull())
  68.                                 return true;
  69.                         return false;
  70.                     }
  71.                    
  72.                 }.sleep();
  73.             }
  74.             break;
  75.            
  76.         case CHOP_TREES: // GetAction has determined we are in the tree area and should chop trees, so we do it.
  77.            
  78.             Entity nearestTree = getObjects().closest(selectedTrees, "Yew");
  79.            
  80.             if(nearestTree != null)
  81.                 nearestTree.interact("Chop");
  82.            
  83.             break;
  84.            
  85.         case DROP_ITEMS: // Get action has determined that we should drop out items, so we do it.
  86.             getInventory().dropAllExcept(axeFilter);
  87.             break;
  88.                
  89.         case WALK_TO_BANK: // Get action has determined we should be inside the bank but arent, so walk there.
  90.             getWalking().webWalk(selectedBank);
  91.             break;
  92.            
  93.         case WALK_TO_TREES: // Get action has determined we should be at the trees so walk to them.
  94.             getWalking().webWalk(selectedTrees);
  95.             break;
  96.            
  97.         case PERFORMING_ACTION: // Get action has determined that we are performing an action,
  98.             // we currently don't need to do anything when performing an action
  99.             // So we do nothing.
  100.             break;
  101.         }
  102.        
  103.         return 700;
  104.     }
  105.    
  106.     public Action getAction()
  107.     {
  108.         // If we are not currently doing something then do stuff
  109.         if(myPlayer().isMoving() || myPlayer().isAnimating())
  110.             return Action.PERFORMING_ACTION;
  111.        
  112.         // Check our inventory
  113.         if(getInventory().isFull() && powerchop) // If its full and we powerchop, drop items.
  114.             return Action.DROP_ITEMS;
  115.         else if (getInventory().isFull() && !powerchop) // If it is full and we shouldnt powerchop, we should bank
  116.         {
  117.             if(!selectedBank.contains(myPlayer())) // If we are not in the bank, walk to it
  118.                 return Action.WALK_TO_BANK;
  119.             else
  120.                 return Action.BANK_ITEMS; // If we are in the bank, do the banking
  121.         }
  122.        
  123.         // We now know that our inventory is not full and we should try and cut some trees now
  124.         if(!selectedTrees.contains(myPlayer())) // If we are not inside the area where the trees are, walk to it
  125.             return Action.WALK_TO_TREES;
  126.         else
  127.             return Action.CHOP_TREES; // If we are, chop trees
  128.  
  129.     }
  130.  
  131.  
  132.     @Override
  133.     public void onPaint(Graphics2D g) {
  134.  
  135.  
  136.    
  137.  
  138.  
  139.     }
  140.  
  141.  
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement