Advertisement
Guest User

Untitled

a guest
May 14th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. package org.peter.aiowcx2.user.methods;
  2.  
  3. import org.osbot.script.rs2.map.Position;
  4.  
  5. public class Walking extends MethodProvider {
  6.  
  7. public Walking(MethodWrapper wrapper) {
  8. super(wrapper);
  9. }
  10.  
  11. public boolean walkPathMM(Position[] path) {
  12. try {
  13. Position next = nextTile(path, 17);
  14. return next != null && wrapper.script.walkMiniMap(next);
  15. } catch (Exception e) {
  16. return false;
  17. }
  18. }
  19.  
  20. public Position nextTile(Position path[], int skipDist) {
  21. int dist = 99;
  22. int closest = -1;
  23. for (int i = path.length - 1; i >= 0; i--) {
  24. Position tile = path[i];
  25. int d = wrapper.script.distance(tile);
  26. if (d < dist) {
  27. dist = d;
  28. closest = i;
  29. }
  30. }
  31.  
  32. int feasibleTileIndex = -1;
  33.  
  34. for (int i = closest; i < path.length; i++) {
  35.  
  36. if (wrapper.script.distance(path[i]) <= skipDist) {
  37. feasibleTileIndex = i;
  38. } else {
  39. break;
  40. }
  41. }
  42.  
  43. if (feasibleTileIndex == -1) {
  44. return null;
  45. } else {
  46. return path[feasibleTileIndex];
  47. }
  48. }
  49.  
  50. public Position[] reversePath(Position[] path) {
  51. Position[] t = new Position[path.length];
  52. for (int i = 0; i < t.length; i++) {
  53. t[i] = path[path.length - i - 1];
  54. }
  55. return t;
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement