Jump to content

Path Walking Error


PwneRL33T

Recommended Posts

this is my loop

 

http://pastebin.com/JcAAhMb7

 

and this is what happens

 

d73520520bf3f22dda0b3e50e0a9edd1.gif

 

i i just don't know what to do now I'm completely stuck..

 

"go learn basic java" they say, 

trust me iv'e learnt it and studied it over and over, but no basic java tuts show me about paths for a runescape bot :L

 

pathwalking method

 

public void walkPath(Position[] path)
   throws InterruptedException
 {
   for (Position p : path) {
     if ((myPosition().distance(p) <= 16) && 
       (myPosition().distance(p) >= 3))
     {
       boolean success;
       do
       {
         success = walkTile(p);
       } while (!success);
     }
   }
 }
 
 public boolean walkTile(Position p)
   throws InterruptedException
 {
   if (myPosition().distance(p) > 13)
   {
     Position pos = new Position(
       (p.getX() + myPosition().getX()) / 2 + 
       MethodProvider.random(-3, 3), (p.getY() + myPosition().getY()) / 2 + 
       MethodProvider.random(-3, 3), myPosition()
       .getZ());
     walkTile(pos);
   }
   for (int i = 0; i < 2; i++)
   {
mouse.click(new MiniMapTileDestination(bot, p), false);
   }
   mouse.click(new MiniMapTileDestination(bot, p), false);
   int fail = 0;
   while ((myPosition().distance(p) > 2) && (fail < 10))
   {
     MethodProvider.sleep(500L);
     if (!myPlayer().isMoving()) {
       fail++;
     }
   }
   return fail != 10;
 } 
Edited by PwneRL33T
Link to comment
Share on other sites

(p.getX() + myPosition().getX()) / 2 + 
       MethodProvider.random(-3, 3)
1) Parentheses!
 
((p.getX() + myPosition().getX()) / 2)
       MethodProvider.random(-3, 3)
 
Same applies to what you do for the Y coordinate.
 
2) Redundant action repetition
 
   for (int i = 0; i < 2; i++)
   {
mouse.click(new MiniMapTileDestination(bot, p), false); // YOU CLICK TWICE HERE
   }
   mouse.click(new MiniMapTileDestination(bot, p), false); // AND A THIRD TIME HERE
 
3) Awkward sleeping
 

The idea of having a fail counter isn't bad at all, this while loop makes no sense whatsoever though.

The fail int doesn't represent actual fails, just you not moving. After each fail you should probably retry the walkTile method instead of just sleeping again.

while ((myPosition().distance(p) > 2) && (fail < 10))
   {
     MethodProvider.sleep(500L);
     if (!myPlayer().isMoving()) {
       fail++;
     }
   }
^not very effective
 
 
 
Edited by Botrepreneur
Link to comment
Share on other sites

http://osbot.org/forum/topic/55480-walker-with-basic-obstacle-handling/

The reason why it walks to the second position then walks back to the first is because you have only one loop, you loop though the position, since your looping from the beginning to the end. Your near the first position it will walk to the second, and once your walking it's still looping through the positions from the beginning so while your conditions are correct it will go back to the first. Why it's a never ending loop.

In swizz method he has two loop, regular loop, and a loop in reverse. He uses the reverse path to find the next furthest available position.

Rather then looping and finding the closest tile from the beginning of the loop.

If you don't understand me look at his method, get next tile and read it

Edited by josedpay
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...