Alek Posted September 20, 2014 Share Posted September 20, 2014 private Position[] path = { new Position(3254, 3421, 0), new Position(3256, 3428, 0), new Position(3264, 3428, 0), new Position(3273, 3428, 0), new Position(3277, 3426, 0), new Position(3281, 3422, 0) }; getWalking().walkPath(path); Explanation: The position array listed above will be defined at the top of your script (with the other variables) and getWalking().walkPath(path) will be defined wherever you want to call it (such as in a method, in your onLoop, etc.). Getting positions: Click on the settings gear icon in the client and scroll over "Entity debugs" and then toggle "Entity hover debug". Hover your mouse over a tile and it will show the position of the tile. The third number in the position constructor is the "Z" coordinate, meaning the current plane which you are on. Order: The position array has a list of positions with the first position being where your character will start walking and the last position being where your character will end walking. Add positions in a manner where once your character reaches one position, it can find the next position on the minimap. Additional: If your character starts in the middle of the path, it will not walk to the beginning, it will resume until it reaches the final position. If for some reason your character gets off the path, the walkPath() method will attempt to get back onto your path. 4 1 Link to comment Share on other sites More sharing options...
Joseph Posted September 20, 2014 Share Posted September 20, 2014 I'll see if I could tweak up my path collector so it be easier for people to collect position. Link to comment Share on other sites More sharing options...
BotRS123 Posted September 20, 2014 Share Posted September 20, 2014 Additional: If your character starts in the middle of the path, it will not walk to the beginning, it will resume until it reaches the final position. If for some reason your character gets off the path, the walkPath() method will attempt to get back onto your path. Based on what you said, does that mean we don't have to implement checks to determine where to start? Ex. The path contains 5 positions and my char is between 3 and 4, it will just start walking to 4? Link to comment Share on other sites More sharing options...
Joseph Posted September 20, 2014 Share Posted September 20, 2014 Based on what you said, does that mean we don't have to implement checks to determine where to start? Ex. The path contains 5 positions and my char is between 3 and 4, it will just start walking to 4? that exactly what hes talking about. Hes mostly likely using this method ive see on OSB public Position nextTile(int skipDist, Position...path) { int dist = -1, closest = -1; for (int i = path.length - 1; i >= 0; i--) { Position tile = path[i]; int d = s.map.distance(tile); if (d < dist || dist == -1) { dist = d; closest = i; } } int feasibleTileIndex = -1; for (int i = closest; i < path.length; i++) { if (s.map.distance(path[i]) <= skipDist) { feasibleTileIndex = i; } else { break; } } return (feasibleTileIndex == -1) ? null : path[feasibleTileIndex]; } Link to comment Share on other sites More sharing options...
Alek Posted September 20, 2014 Author Share Posted September 20, 2014 It iterates to the positions closest to you, then continues to walk the path. @BotRS123 - It does everything except handle obstacles. @josedpay - I never use other people's code, defeats the purpose of learning 1 Link to comment Share on other sites More sharing options...
Joseph Posted September 20, 2014 Share Posted September 20, 2014 It iterates to the positions closest to you, then continues to walk the path. @BotRS123 - It does everything except handle obstacles. @josedpay - I never use other people's code, defeats the purpose of learning I feel you, well if anybody is just curious of how it could be done they have a method above (if you really read the code, you'll understand it and be like wow that was easy). If not they could create their own algo like you did. Thanks for the walking method btw. Link to comment Share on other sites More sharing options...
thepecher Posted September 20, 2014 Share Posted September 20, 2014 Let it handle obstacles Shouldn't be that hard to implement. Let people add Entities or a custom obstacle class to an ArrayList and iterate through that 1 Link to comment Share on other sites More sharing options...
Joseph Posted September 25, 2014 Share Posted September 25, 2014 You could use my script to help you collect positions LINK 1 Link to comment Share on other sites More sharing options...
Gold Scripts Posted November 3, 2014 Share Posted November 3, 2014 Is there a way to reverse a path using local walker? Link to comment Share on other sites More sharing options...
Alek Posted November 4, 2014 Author Share Posted November 4, 2014 Is there a way to reverse a path using local walker? Look into: Collections.reverse() Link to comment Share on other sites More sharing options...
pjrunescape Posted February 9, 2015 Share Posted February 9, 2015 Does this stuff works? I'm trying to use it, but I just keep clicking at my foot when it reach the 1st position Link to comment Share on other sites More sharing options...
Eliot Posted February 9, 2015 Share Posted February 9, 2015 (edited) This is what I've been doing since the beginning. Unless my memory is incorrect. Edited February 9, 2015 by Eliot Link to comment Share on other sites More sharing options...
CallMeDominic Posted February 9, 2015 Share Posted February 9, 2015 (edited) Is there a way to reverse a path using local walker? private Position[] reverse(Position[] p) { Position[] r = new Position[p.length]; for (int i=0;i<p.length;i++) r[(p.length-1)-i] = p[i]; return r; } Edited February 9, 2015 by CallMeDominic Link to comment Share on other sites More sharing options...
Mysteryy Posted February 9, 2015 Share Posted February 9, 2015 (edited) private Position[] reverse(Position[] p) { Position[] r = new Position[p.length]; for (int i=p.length;i>0;i--) r[i] = p[i]; return r; }That's a pretty inefficient way to reverse an array.Not only that, but all you are doing is copying the array. Edited February 9, 2015 by Mysteryy 1 Link to comment Share on other sites More sharing options...
Botre Posted February 9, 2015 Share Posted February 9, 2015 private Position[] reverse(Position[] p) { Position[] r = new Position[p.length]; for (int i=p.length;i>0;i--) r[i] = p[i]; return r; } For an array A where: Position A[0] = x Position A[1] = y Position A[2] = z And an empty array B with size 3. Array B after your method: Position B[2] = A[2] Position B[1] = A[1] Position B[0] = A[0] -> B[0] = A[0] = x B[1] = A[1] = y B[2] = B[2] = z A = B Link to comment Share on other sites More sharing options...