Jump to content

Walk to position not working


Recommended Posts

Posted

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;

 

Posted (edited)

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
Posted (edited)
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
Posted
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^

Posted
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! :)

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