Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Having some hover problems

Featured Replies

So sometimes the scripts actually hovers the tree which is being cut, which I do not want and it's really inefficient. Can't really seem to fix it.

if (getObjects().getAll().stream().filter(o -> o.getName().equals(gui.getTree())).count() >= 2) {
       if (nextTree == null || !nextTree.exists()) {
             nextTree = getObjects().closest(true, o -> o.getName().equals(gui.getTree()) && o != treeObject &&
                     cuttingArea.contains(o) && o.getPosition() != treeObject.getPosition());
       } else if (!getMouse().isOnCursor(nextTree)) {
           nextTree.hover();
  }
}

Well, if I understand the context right, treeObject is supposed to be the current tree? If the value of nextTree is not assigned anywhere else then the code looks alright but you might be wrongly setting treeObject to the next tree that you want to cut somewhere else in the code and nextTree will be set to the one you are already cutting. Don't forget to treat the exception where your nextTree will be cut by another person before you get to switch trees.

 

So sometimes the scripts actually hovers the tree which is being cut, which I do not want and it's really inefficient. Can't really seem to fix it.

import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "Explv", name = "Example hover", info = "", version = 0.1, logo = "")
public class Example extends Script {

    private enum State { CHOPPING, HOVERING }

    private RS2Object chopTree;

    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()) {
            case CHOPPING:
                chop();
                break;
            case HOVERING:
                hover();
                break;         
        }
        return random(200, 300);
    }

    private State getState() {
        if(chopTree == null || !chopTree.exists() || !myPlayer().isAnimating()) return State.CHOPPING;
        return State.HOVERING;
    }

    private void chop() {
        chopTree = getObjects().closest("Tree");
        if(chopTree != null && chopTree.interact("Chop down")) {
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !chopTree.exists() || myPlayer().isAnimating();
                }
            }.sleep();
        }
    }

    private void hover() {
        RS2Object hoverTree = getObjects().closest(obj -> obj.getName().equals("Tree") && obj != chopTree);
        if(hoverTree != null && !getMouse().isOnCursor(hoverTree)) {         
            hoverTree.hover();
        }
    }
}

The logic is pretty simple:

 

If the player is not woodcutting, find closest tree and chop it

Else find the closest tree, that is not equal to the tree the player is chopping and hover it

Edited by Explv

You make it too complicated..

 

  1. Find the tree you are chopping 
  2. Find the next, closest tree which you are not interacting with (myPlayer().getInteracting() != nextTree) 
  3. Hover if cursor is not on it

You should make the hovering randomized, otherwise it will be an ongoing pattern.

Edited by Woody

You make it too complicated..

  • Find the tree you are chopping
  • Find the next, closest tree which you are not interacting with (myPlayer().getInteracting() != nextTree)
  • Hover if cursor is not on it
You should make the hovering randomized, otherwise it will be a ongoing pattern.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.