Advertisement
Guest User

Untitled

a guest
Sep 17th, 2015
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. package scripts.runecrafting.abysscrafter;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.Timing;
  5. import org.tribot.api2007.Camera;
  6. import org.tribot.api2007.Game;
  7. import org.tribot.api2007.NPCChat;
  8. import org.tribot.api2007.Objects;
  9. import org.tribot.api2007.Player;
  10. import org.tribot.api2007.Walking;
  11. import org.tribot.api2007.WebWalking;
  12. import org.tribot.api2007.types.RSObject;
  13. import org.tribot.api2007.types.RSTile;
  14.  
  15. import scripts.methods.Methods;
  16.  
  17. public class House {
  18.  
  19. private Main main;
  20.  
  21. public static final int PORTAL = 2835;
  22. public static final int OUTSIDE_PORTAL = 2100;
  23.  
  24. public House(Main main) {
  25. setMain(main);
  26. }
  27.  
  28. public void setMain(Main main) {
  29. this.main = main;
  30. }
  31.  
  32. public Main getMain() {
  33. return main;
  34. }
  35.  
  36. public boolean isInside() {
  37. RSObject[] glory = Objects.find(64, "Amulet of Glory");
  38. if(glory != null && glory.length > 0) {
  39. return true;
  40. }
  41. RSObject portal = Methods.findObjectByModelPoints(new int[] { PORTAL });
  42. if(portal != null) {
  43. return true;
  44. }
  45. return false;
  46. }
  47.  
  48. private RSObject getOutsidePortal() {
  49. if(Locations.isOutsideHouse()) {
  50. RSObject[] portal = Objects.find(64, "Portal");
  51. if(portal != null && portal.length > 0) {
  52. return portal[0];
  53. }
  54. }
  55. return null;
  56. }
  57.  
  58. public boolean isOutside() {
  59. if(Locations.isOutsideHouse()) {
  60. return true;
  61. }
  62. return false;
  63. }
  64.  
  65. public boolean enterHouse() {
  66. if(isInside()) {
  67. return true;
  68. }
  69. RSObject portal = getOutsidePortal();
  70. if(portal != null) {
  71. if(!portal.isOnScreen()) {
  72. WebWalking.walkTo(portal);
  73. Camera.turnToTile(portal);
  74. }
  75. portal.click("Enter");
  76. if(clickedPortal(2000)) {
  77. if(NPCChat.getOptions() != null) {
  78. if(NPCChat.selectOption("Go to your house", true)) {
  79. return true;
  80. }
  81. }
  82. }
  83. }
  84. return false;
  85. }
  86.  
  87. private long last_non_idle = 0L;
  88.  
  89. public void turnCamera() {
  90. switch(getMain().getOrientation()) {
  91. case SOUTH:
  92. Methods.turnCameraSouth();
  93. break;
  94. case NORTH:
  95. Methods.turnCameraNorth();
  96. break;
  97. case EAST:
  98. Methods.turnCameraEast();
  99. break;
  100. case WEST:
  101. Methods.turnCameraWest();
  102. break;
  103. }
  104. }
  105.  
  106. private int cameraTries = 0;
  107.  
  108. public boolean rubGlory() {
  109. if(Locations.isAtEdgeville()) {
  110. getMain().setState(State.BANKING);
  111. return true;
  112. }
  113. if(isOutside()) {
  114. enterHouse();
  115. return false;
  116. }
  117. getMain().sleep(250, 500);
  118. RSObject glory = Methods.findObjectByModelPoints(new int[] { Constants.MOUNTED_GLORY });
  119. if(glory != null) {
  120. if(!glory.isOnScreen() || Methods.distanceTo(getMain(), glory.getPosition()) > 3) {
  121. RSTile gloryTile = new RSTile(glory.getPosition().getX(), glory.getPosition().getY() + 1);
  122. if(!Player.getPosition().equals(gloryTile) && Game.getDestination() == null) {
  123.  
  124. if(!glory.isOnScreen()) {
  125. if(cameraTries > 3) {
  126. Walking.walkTo(gloryTile);
  127. cameraTries = 0;
  128. } else
  129. Camera.turnToTile(glory);
  130. cameraTries++;
  131. }
  132. }
  133. last_non_idle = System.currentTimeMillis();
  134. while(Methods.distanceTo(getMain(), glory.getPosition()) > 3 && Player.isMoving() && !isTimedOut(5000, 7000)) {
  135. if(Locations.isAtEdgeville()) {
  136. getMain().setState(State.BANKING);
  137. return true;
  138. }
  139. getMain().sleep(50, 150);
  140. }
  141. }
  142. int tries = 0;
  143. last_non_idle = System.currentTimeMillis();
  144. while(glory.isOnScreen() && isInside() && !isTimedOut(8000, 10000)) {
  145. if(Locations.isAtEdgeville()) {
  146. getMain().setState(State.BANKING);
  147. return true;
  148. }
  149. if(tries >= 5) {
  150. Walking.walkTo(glory);
  151. turnCamera();
  152. tries = 0;
  153. }
  154. tries++;
  155.  
  156. if(glory.click("Edgeville")) {
  157. if(teleported(10000)) {
  158. getMain().setState(State.BANKING);
  159. return true;
  160. }
  161. } else {
  162. if(Locations.isAtEdgeville()) {
  163. getMain().setState(State.BANKING);
  164. return true;
  165. }
  166. getMain().println("Failed to click mounted glory.");
  167. }
  168. getMain().sleep(50, 150);
  169. }
  170. }
  171. return false;
  172. }
  173.  
  174. private boolean isTimedOut(int i, int j) {
  175. if(Timing.timeFromMark(last_non_idle) > General.random(i, j)) {
  176. return true;
  177. }
  178. return false;
  179. }
  180.  
  181. private boolean clickedPortal(int i) {
  182. long t = System.currentTimeMillis();
  183. while (Timing.timeFromMark(t) < i) {
  184. if (NPCChat.getOptions() != null) {
  185. return true;
  186. }
  187. getMain().sleep(50, 150);
  188. }
  189. return false;
  190. }
  191. private boolean teleported(int i) {
  192. long t = System.currentTimeMillis();
  193. while (Timing.timeFromMark(t) < i) {
  194. //Methods.performAntiBan();
  195. if (Player.getPosition().equals(Locations.EDGEVILLE_TELEPORT_TILE)) {
  196. return true;
  197. }
  198. getMain().sleep(50, 150);
  199. }
  200. return false;
  201. }
  202.  
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement