Walking

Discussion in 'Developer Support' started by Exile, Aug 25, 2014.

  1. Exile

    Joined:
    Jul 24, 2014
    Messages:
    188
    Likes Received:
    23
    I'm stuck on this for already a week or 2 now, I've tried RegionPath, WebPath, BresenhamPath, PredefinedPath, everything.

    What happens is the following: the path is correctly generated, but the bot only clicks once on the minimap and when my player has reached that position, it doesn't move to the next position, it just sits there somewhere halfway the path.

    I use this code:
    Code (Text):
    1.  
    2. Coordinate coord = new Coordinate(3189, 3241, 0); //A point somewhere in Lumbridge that I used for testing purposes
    3. final WebPath path = Traversal.getDefaultWeb().getPathBuilder().buildTo(coord);
    4. path.step();
    5.  
    The same happens when I replace the WebPath line by RegionPath.buildTo(coord);, or by BresenhamPath, or when I use a PredefinedPath.

    Do I need to add a loop somewhere?
     
  2. Qosmiof2

    Qosmiof2 Qosidog3 - I write bots not tragedies.

    Joined:
    Aug 5, 2014
    Messages:
    2,415
    Likes Received:
    681
    maybe make an area (if there is one) and then while(!area.contains(Players.getLocal().getPosition()))

    cheers
     
  3. Exile

    Joined:
    Jul 24, 2014
    Messages:
    188
    Likes Received:
    23
    I'll try looping it, thanks
     
  4. Mmaaikel

    Joined:
    Mar 11, 2014
    Messages:
    319
    Likes Received:
    85
    Path.step takes a single step. So I guess you need another method.
     
  5. Exile

    Joined:
    Jul 24, 2014
    Messages:
    188
    Likes Received:
    23
    Well that explains alot :p

    I tried putting it in a loop and this seems to have worked :) Might want to include that in those walking tutorials
     
  6. Mmaaikel

    Joined:
    Mar 11, 2014
    Messages:
    319
    Likes Received:
    85
    I'm not sure.. i just looked at the docs. I've not yet experimented with the api just yet.
     
  7. Qosmiof2

    Qosmiof2 Qosidog3 - I write bots not tragedies.

    Joined:
    Aug 5, 2014
    Messages:
    2,415
    Likes Received:
    681
    Great :)
     
  8. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,480
    Likes Received:
    717
    If you're using a looping script bot it shouldnt need an extra loop.

    If you're using the Execution framework or whatever it's called, you've probably set the conditions in a way that it only calls it once and because it never reached the end just sits there. You'll want to fix that because it's best to not use extra loops if they're not needed.
     
    #8 Aidden, Aug 25, 2014
    Last edited: Aug 25, 2014
  9. Qosmiof2

    Qosmiof2 Qosidog3 - I write bots not tragedies.

    Joined:
    Aug 5, 2014
    Messages:
    2,415
    Likes Received:
    681
    But, it would need to check every Activate or whatever its called (boolean) to run this method again. So waste of RAM imo
     
  10. Aidden

    Aidden The better executive

    Joined:
    Dec 3, 2013
    Messages:
    3,480
    Likes Received:
    717
    It's better practice to have each loop only perform one action rather than contain a nested loop performing actions over and over until the end condition, so it's best to sterr clear of extra loops where they're not absolutely necessary. It's also the best way to make the script bot stop as soon as the stop button is clicked as we don't force scripts bots to stop.
     
  11. Exile

    Joined:
    Jul 24, 2014
    Messages:
    188
    Likes Received:
    23
    I'm using Executor + my own framework :p but it's pretty complicated, anyways it's fixed :)
     
  12. Cloud

    Joined:
    Jul 28, 2013
    Messages:
    2,556
    Likes Received:
    922
    This is spot on.
     

Share This Page

Loading...