Advertisement
Guest User

Untitled

a guest
Sep 17th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. package scripts.runecrafting.abysscrafter;
  2.  
  3. import org.tribot.api.Timing;
  4. import org.tribot.api2007.Camera;
  5. import org.tribot.api2007.Game;
  6. import org.tribot.api2007.NPCChat;
  7. import org.tribot.api2007.Player;
  8. import org.tribot.api2007.WebWalking;
  9. import org.tribot.api2007.types.RSObject;
  10.  
  11. import scripts.methods.Methods;
  12.  
  13. public class Ditch {
  14.  
  15. private Main main;
  16.  
  17. public Ditch(Main main) {
  18. setMain(main);
  19. }
  20.  
  21. public void setMain(Main main) {
  22. this.main = main;
  23. }
  24.  
  25. public Main getMain() {
  26. return main;
  27. }
  28.  
  29. public boolean clickedDitch = false;
  30.  
  31. public boolean cross() {
  32. if(clickedDitch
  33. //|| Player.getPosition().getY() >= Locations.CROSSED_DITCH_TILE.getY()
  34. || (Player.getAnimation() == 6132)) {
  35. //clickedDitch = true;
  36. return false;
  37. }
  38. RSObject ditch = Methods.findObjectByModelPoints(new int[] { Constants.DITCH });
  39. if(ditch != null) {
  40. if(!ditch.isOnScreen() && Methods.distanceTo(getMain(), ditch.getPosition()) > 6) {
  41. WebWalking.walkTo(ditch);
  42. Camera.turnToTile(ditch);
  43. }
  44. int y = Player.getPosition().getY();
  45. if(ditch.isOnScreen()) {
  46. if(ditch.click("Cross")) {
  47. //clickedDitch = true;
  48. int distance = Methods.distanceTo(getMain(), ditch.getPosition());
  49. if(crossedDitch(y, distance * 1000)) {
  50. clickedDitch = true;
  51. return true;
  52. }
  53. }
  54. } else {
  55. WebWalking.walkTo(ditch);
  56. Camera.turnToTile(ditch);
  57. }
  58. }
  59. return false;
  60. }
  61.  
  62. private boolean crossedDitch(int y, int i) {
  63. long t = System.currentTimeMillis();
  64. while (Timing.timeFromMark(t) < i) {
  65.  
  66. if (NPCChat.getMessage() != null) {
  67. clickedDitch = false;
  68. return false;
  69. }
  70. if (Player.getAnimation() == 6132) {
  71. //clickedDitch = true;
  72. return true;
  73. }
  74. if (Player.getPosition().getY() > Locations.DITCH_TILE.getY()) {
  75. return true;
  76. }
  77. getMain().sleep(50, 150);
  78. }
  79. return false;
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement