Jump to content

Walk to a random tile inside an area?


Recommended Posts

Posted (edited)

How can I make the player walk to a random tile inside an area? I've used walking event and webwalk but both seem to randomly every now and again walk 1-2 tiles away from the area.

 

By the way I have put the min distance threshold on walking event to 0 but it doesn't seem to work as intended on the API so possibly a client bug.

 

Thanks

Edited by steve498
Posted (edited)

How can I make the player walk to a random tile inside an area? I've used walking event and webwalk but both seem to randomly every now and again walk 1-2 tiles away from the area.

 

By the way I have put the min distance threshold on walking event to 0 but it doesn't seem to work as intended on the API so possibly a client bug.

 

Thanks

walking.walk(area.getRandomPosition());

or

walking.webWalk(area.getRandomPosition());

?

Edited by Explv
Posted
walking.walk(area.getRandomPosition());

or

walking.webWalk(area.getRandomPosition());

?

 

 

I have tried these and no luck.

 

Basically this is how I'm testing it:

 

I have an area created and a condition that checks whether the area contains the player. If true, great! if false, then log it.

 

Sooo... I then use the methods you mentioned and sometimes it will say that I'm not inside the area. So it is not walking in one of the area's tiles.

 

Hopefully that makes some sense.

Posted (edited)

I have tried these and no luck.

 

Basically this is how I'm testing it:

 

I have an area created and a condition that checks whether the area contains the player. If true, great! if false, then log it.

 

Sooo... I then use the methods you mentioned and sometimes it will say that I'm not inside the area. So it is not walking in one of the area's tiles.

 

Hopefully that makes some sense.

 

You should use WakingEvent, however I feel like the min threshold stuff might not be working right now.

 

You could try:

MainScreenTileDestination destination = new MainScreenTileDestination(getBot(), area.getRandomPosition());
getMouse().click(destination);

or:

MiniMapTileDestination destination = new MiniMapTileDestination(getBot(), area.getRandomPosition());
getMouse().click(destination);
Edited by Explv
Posted (edited)

I have tried these and no luck.

 

Basically this is how I'm testing it:

 

I have an area created and a condition that checks whether the area contains the player. If true, great! if false, then log it.

 

Sooo... I then use the methods you mentioned and sometimes it will say that I'm not inside the area. So it is not walking in one of the area's tiles.

 

Hopefully that makes some sense.

if(AREA.contain(player)){
   walker.walk(AREA.getRandomPosition());
} else {
  log("Area does not contain player");
}
Edited by ni562
Posted (edited)

 

You should use WakingEvent, however I feel like the min threshold stuff might not be working right now.

 

You could try:

MainScreenTileDestination destination = new MainScreenTileDestination(getBot(), area.getRandomPosition());
getMouse().click(destination);

 

Tried and just spams this in the console...

 

ei6m3Tr.jpg

 

This message is logged when the area does not contain the player. When it does not contain the player it executes the code to walk to the area. Unfortunately nothing happens with the solution you just provided sad.png

 

Edit: Trying other solutions just posted bare with... Thanks

Edited by steve498
Posted (edited)

That is incorrect, and also he said walker.walk doesn't work doge.png

 

Well it does but it puts me 1-2 tiles away sometimes. Also that code wouldn't work as it would try to move the player when they are already inside the area?

 

Will edit this post after testing your second solution Explv, thanks.

 

Update:

 

Well the second solution looks like it worked however, inside the bank it cannot run back to the area because it is not on the minimap.

Edited by steve498
Posted (edited)

sad.png Except an 's' what did i miss? 

 

it only walks to a random position in the area, if it's already in the area doge.png

Well it does but it puts me 1-2 tiles away sometimes. 

 

That is because the walker uses default WalkingEvent which walks with a minthreshold of 2 tiles.

 

You should either wait for WalkingEvent to be fixed (if its broken)  or just walk to a position deep in the area rather than a random one?

Edited by Explv
  • Like 1
Posted

it only walks to a random position in the area, if it's already in the area doge.png

 

That is because the walker uses default WalkingEvent which walks with a minthreshold of 2 tiles.

 

You should either wait for WalkingEvent to be fixed (if its broken)  or just walk to a position deep in the area?

 

I thought by setting the minDistance threshold to 0 it would override this but I could be wrong and yes that is what I was just considering. I think I'll stick to WalkingEvent and just make a path and place it inside an area deep so if it's 1-2 tiles out it'll still be in the area.

 

Thanks anyway I appreciate it :)

  • Like 1
Posted (edited)
Position pos = Area.getRandomPosition();
long safeGuard = System.currentTimeMillis();
while(!Area.contains(pos))
{
	pos = Area.getRandomPosition();
	if(System.currentTimeMillis() - safeGuard > 1000)
	{
		log("Something went wrong -_-");
		break;
	}
}

You could try something like that.

Edited by dopenes
Posted
Position pos = Area.getRandomPosition();
long safeGuard = System.currentTimeMillis();
while(!Area.contains(pos))
{
	pos = Area.getRandomPosition();
	if(System.currentTimeMillis() - safeGuard > 1000)
	{
		log("Something went wrong -_-");
		break;
	}
}

You could try something like that.

 

 

This code wont make any difference. Considering his walking code will be inside the onLoop method, the same functionality will occur. The issue lies somewhere else, probably with the walker stopping outside the area due to its minThreshold setting.

Posted

This code wont make any difference. Considering his walking code will be inside the onLoop method, the same functionality will occur. The issue lies somewhere else, probably with the walker stopping outside the area due to its minThreshold setting.

 

 

Ehh, I was assuming that the getRandomPosition() method was returning a position OUTSIDE of the area. If this is the case, then this will fix it, but if not, then yeah, lol.

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