Jump to content
JARNQ

Walk to position not working

Recommended Posts

I've been trying to find out whats wrong but i just can't find the mistake.

If i'm on the tile where i'm trying to go, nothing happens. ( this is correct )

But if i'm not on the tile all i see is the "Returning to exact AFK spot." get spammed on log and my character doesn't walk there.

Can someone point me to the right direction?

 

This is on my getState:

if (afk.contains(myPlayer()) && !(myPlayer().getX() == 2704) && !(myPlayer().getY() == 3726))
			return State.AFKSPOT;

Position:

Position afkspot = new Position(2704, 3726, 0);

And this is my AFKSPOT case:

case AFKSPOT:
    		getWalking().walk(afkspot);
    		log("Returning to exact AFK spot.");
    		sleep(random(345, 825));
    		break;

 

Link to comment
Share on other sites

If you want to walk to an exact position you will need to use a custom WalkingEvent  and change the distance threshold to 0. By default the value is 3, which means the player will stop walking when <= 3 tiles away from the destination (getWalking().walk() just uses the default settings)

WalkingEvent walkingEvent = new WalkingEvent(afkspot);
walkingEvent.setMinDistanceThreshold(0);
execute(walkingEvent);

 

Edited by Explv
  • Like 1
Link to comment
Share on other sites

10 minutes ago, JARNQ said:

I've been trying to find out whats wrong but i just can't find the mistake.

If i'm on the tile where i'm trying to go, nothing happens. ( this is correct )

But if i'm not on the tile all i see is the "Returning to exact AFK spot." get spammed on log and my character doesn't walk there.

Can someone point me to the right direction?

 

This is on my getState:


if (afk.contains(myPlayer()) && !(myPlayer().getX() == 2704) && !(myPlayer().getY() == 3726))
			return State.AFKSPOT;

Position:


Position afkspot = new Position(2704, 3726, 0);

And this is my AFKSPOT case:


case AFKSPOT:
    		getWalking().walk(afkspot);
    		log("Returning to exact AFK spot.");
    		sleep(random(345, 825));
    		break;

 

Why are you doing:

!(myPlayer().getX() == 2704)

Wouldn't:

myPlayer().getX() != 2704

Be better?

As for your question you need to do something like so:

WalkingEvent walkToSpot = new WalkingEvent(afkspot);
walkToSpot.setMinDistanceThreshold(0); 
execute(walkToSpot);

 

Edited by harrypotter
Link to comment
Share on other sites

16 minutes ago, Explv said:

If you want to walk to an exact position you will need to use a custom WalkingEvent  and change the distance threshold to 0. By default the value is 3, which means the player will stop walking when <= 3 tiles away from the destination (getWalking().walk() just uses the default settings)


WalkingEvent walkingEvent = new WalkingEvent(afkspot);
walkingEvent.setMinDistanceThreshold(0);
execute(walkingEvent);

 

This^

Link to comment
Share on other sites

1 hour ago, harrypotter said:

Why are you doing:


!(myPlayer().getX() == 2704)

Wouldn't:


myPlayer().getX() != 2704

Be better?

As for your question you need to do something like so:


WalkingEvent walkToSpot = new WalkingEvent(afkspot);
walkToSpot.setMinDistanceThreshold(0); 
execute(walkToSpot);

 

 

Yes sir it would.

I'm pretty new to java so alot of my code is questionable. :P

1 hour ago, Explv said:

If you want to walk to an exact position you will need to use a custom WalkingEvent  and change the distance threshold to 0. By default the value is 3, which means the player will stop walking when <= 3 tiles away from the destination (getWalking().walk() just uses the default settings)


WalkingEvent walkingEvent = new WalkingEvent(afkspot);
walkingEvent.setMinDistanceThreshold(0);
execute(walkingEvent);

 

Oh alright, i see.

 

Thanks alot! :)

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.

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