Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.osbot.rs07.api.filter.Filter;
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.model.Entity;
- import org.osbot.rs07.api.model.Item;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.ConditionalSleep;
- import java.awt.*;
- @ScriptManifest(name = "Woodcutter", author = "Venetox", version = 1.0, info = "Woodcutter", logo = "IMGURLINKTOLOGO(NOTNEEDED)")
- public class Main extends Script {
- private Area edgeVilleTrees = new Area(3084, 3467, 3089, 3483);
- private Area edgeVilleBank = new Area(3092, 3498, 3094, 3488);
- private Area selectedBank;
- private Area selectedTrees;
- private boolean powerchop = false;
- private Filter<Item> axeFilter = new Filter<Item>(){
- @Override
- public boolean match(Item i) {
- if(i.getName().contains(" axe"))
- return true;
- return false;
- }};
- @Override
- public void onStart() {
- selectedBank = edgeVilleBank;
- selectedTrees = edgeVilleTrees;
- }
- @Override
- public void onExit() {
- }
- @SuppressWarnings("unchecked")
- @Override
- public int onLoop() throws InterruptedException {
- Action currentAction = getAction();
- log("onLoop: " + currentAction);
- switch(currentAction)
- {
- case BANK_ITEMS: // GetAction has determined that we can bank items, so we do it.
- if(!getBank().isOpen()) // If bank is not open, open it
- getBank().open();
- else // Else, bank everything except an axe.
- {
- bank.depositAllExcept(axeFilter);
- new ConditionalSleep(5000){
- @Override
- public boolean condition() throws InterruptedException {
- if(!getInventory().isFull())
- return true;
- return false;
- }
- }.sleep();
- }
- break;
- case CHOP_TREES: // GetAction has determined we are in the tree area and should chop trees, so we do it.
- Entity nearestTree = getObjects().closest(selectedTrees, "Yew");
- if(nearestTree != null)
- nearestTree.interact("Chop");
- break;
- case DROP_ITEMS: // Get action has determined that we should drop out items, so we do it.
- getInventory().dropAllExcept(axeFilter);
- break;
- case WALK_TO_BANK: // Get action has determined we should be inside the bank but arent, so walk there.
- getWalking().webWalk(selectedBank);
- break;
- case WALK_TO_TREES: // Get action has determined we should be at the trees so walk to them.
- getWalking().webWalk(selectedTrees);
- break;
- case PERFORMING_ACTION: // Get action has determined that we are performing an action,
- // we currently don't need to do anything when performing an action
- // So we do nothing.
- break;
- }
- return 700;
- }
- public Action getAction()
- {
- // If we are not currently doing something then do stuff
- if(myPlayer().isMoving() || myPlayer().isAnimating())
- return Action.PERFORMING_ACTION;
- // Check our inventory
- if(getInventory().isFull() && powerchop) // If its full and we powerchop, drop items.
- return Action.DROP_ITEMS;
- else if (getInventory().isFull() && !powerchop) // If it is full and we shouldnt powerchop, we should bank
- {
- if(!selectedBank.contains(myPlayer())) // If we are not in the bank, walk to it
- return Action.WALK_TO_BANK;
- else
- return Action.BANK_ITEMS; // If we are in the bank, do the banking
- }
- // We now know that our inventory is not full and we should try and cut some trees now
- if(!selectedTrees.contains(myPlayer())) // If we are not inside the area where the trees are, walk to it
- return Action.WALK_TO_TREES;
- else
- return Action.CHOP_TREES; // If we are, chop trees
- }
- @Override
- public void onPaint(Graphics2D g) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement