Jump to content

Move mouse while waiting for tasks to complete


Flexeren

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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