Jump to content

Accurate Position Clicks


Ragnar Lothbrok

Recommended Posts

Is there a way I can verify that the mouse is in fact on the specified position?

I need to walk to specific tiles however I'm having troubles with the bot missclicking. Have tried walking events with mini-map threshold and distance threshold set as well as position.hover then click but this still has problems.

Current code for walking to a position:

if (!position.isVisible(api.getBot())) {
    api.getCamera().toPosition(position);
} else {
    if (position.hover(api.getBot())) {
        if (api.getMouse().click(false)) {
            Sleep.sleepUntil(() -> inPosition(position) && !api.myPlayer().isMoving(), 5000);
        }
    }
}

Have also tried:

WalkingEvent walkingEvent = new WalkingEvent(position);
walkingEvent.setMinDistanceThreshold(0);
walkingEvent.setMiniMapDistanceThreshold(10);
api.execute(walkingEvent);
Sleep.sleepUntil(() -> inPosition(position) && !api.myPlayer().isMoving(), 5000);

 

Appreciate any help!

Link to comment
Share on other sites

I had the same problem, position.hover then click seemed to work for me, the thing is if you are moving and it's already hovered over a position it wont keep on hovering, the players movement will offset the hover, so I had to re-hover before I clicked to make sure, that worked good enough for me. I wouldn't be surprised if there's a better solution though.

Edited by ScummyBotter
Link to comment
Share on other sites

Just now, ScummyBotter said:

I had the same problem, position.hover then click seemed to work for me, the thing is if you are moving and it's already hovered over a position it wont keep on hovering, the players movement will offset the hover, so I had to re-hover before I clicked to make sure, that worked good enough for me

I've tried checking to make sure my player isn't moving before clicking however I'm still having troubles with the wrong tiles being clicked

Link to comment
Share on other sites

Just now, FrostBug said:

What results are you getting with WalkingEvent? From what I understand it should retry until at the desired location or reach an attempt threshold. Also it's a blocking event, so sleeping after the fact probably won't do anything

With the walking event sometimes the correct tile is clicked - other times the tiles next to the correct tile is clicked.

Link to comment
Share on other sites

11 minutes ago, Ragnar Lothbrok said:

Did you even read the thread?

I meant just with that, I have the following on my sandcrabs script and it works everytime. 

(Credit not to me, don't remember where I got it it was a long time ago)

private static boolean walkExact(Script script, Position position) {
        WalkingEvent event = new WalkingEvent(position);
        event.setMinDistanceThreshold(0);
        return script.execute(event).hasFinished();
    }

Sorry for no codeblock, don't know how to do it on mobile.

EDIT:

To be clear, I call that function over and over again until the player reached the position.

Edited by HunterRS
Link to comment
Share on other sites

1 minute ago, HunterRS said:

I meant just with that, I have the following on my sandcrabs script and it works everytime. 

(Credit not to me, don't remember where I got it it was a long time ago)

private static boolean walkExact(Script script, Position position) {
        WalkingEvent event = new WalkingEvent(position);
        event.setMinDistanceThreshold(0);
        return script.execute(event).hasFinished();
    }

Sorry for no codeblock, don't know how to do it on mobile.

Eventually that will walk to the exact tile yes - but I can't afford miss-clicks in this script.

Link to comment
Share on other sites

You can't control misclicks. Every script will evntually misclick due to ping, lag and the client isn't 100% efficient. No matter what the click could misclick. But the next click will fix it. Same as a human. A human will misclick every once in a while 

Edited by Juggles
  • Heart 1
Link to comment
Share on other sites

16 hours ago, Juggles said:

You can't control misclicks. Every script will evntually misclick due to ping, lag and the client isn't 100% efficient. No matter what the click could misclick. But the next click will fix it. Same as a human. A human will misclick every once in a while 

A method to verify the mouse hover position could work - just have the bot pause until true then we know for sure we're clicking on the correct position? 

Link to comment
Share on other sites

6 hours ago, Ragnar Lothbrok said:

A method to verify the mouse hover position could work - just have the bot pause until true then we know for sure we're clicking on the correct position? 

Sure do 

if (mouse.isHovering) {

mouse.click(false);

} else {

mouse.hover 
}

But the mouse could still spaz out randomly sometimes. 

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...