Jump to content

Walk to a random tile inside an area?


steve498

Recommended Posts

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

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

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.

Link to comment
Share on other sites

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

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

 

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

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

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

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

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

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.

Link to comment
Share on other sites

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.

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