Jump to content

Move mouse while waiting for tasks to complete


Recommended Posts

Posted (edited)

You can use the .hover(); method on any Entity, something like this, you'll still have to check which tree you're interacting with...

RS2Object tree = getObjects().closest("Oak");
if(!myPlayer().isAnimating()){
    tree.interact("Chop down");
} else {
    tree.hover();
}
Edited by GaetanoH
Posted (edited)

Hey there,

I was wondering if it was possible to move the mouse while doing a task and waiting for it to complete.

Fx while Woodcutting, it hovers the mouse on the next nearby tree, while chopping another one.

Any help / tips appreciated! smile.png

 

Maybe something like this?

 

Pseudo Code:

 

If we are chopping a tree:

    If we have not found another tree:

        Find another tree

    Else if we are not hovering over the other tree:

        Hover over the other tree

Else:

  Chop a tree

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 = "", name = "", info = "", version = 0.1, logo = "")
public class WoodCutter extends Script {

    private enum State{ CHOPPING, HOVERING }

    private RS2Object currentTree;
    private RS2Object hoverTree;

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

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

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

    private void hoverNextTree(){
        if(hoverTree == null || !hoverTree.exists()) {
            hoverTree = getObjects().closest(obj -> obj.getName().equals("Tree") && obj != currentTree);
        } else if(!getMouse().isOnCursor(hoverTree)) {
            hoverTree.hover();
        }
    }
}

 

You can use the .hover(); method on any Entity, something like this, you'll still have to check which tree you're interacting with...

RS2Object tree = getObjects().closest("Oak");
if(!myPlayer().isAnimating()){
    tree.interact("Chop down");
} else {
    tree.hover();
}

 

That would only hover over the same tree that you are cutting (the closest one)

Edited by Explv
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...