Advertisement
Guest User

Untitled

a guest
Sep 17th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.33 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.WebWalking;
  6. import org.tribot.api.util.ABCUtil;
  7. import org.tribot.api2007.Camera;
  8. import org.tribot.api2007.Game;
  9. import org.tribot.api2007.Inventory;
  10. import org.tribot.api2007.Objects;
  11. import org.tribot.api2007.Player;
  12. import org.tribot.api2007.Walking;
  13. import org.tribot.api2007.types.RSItem;
  14. import org.tribot.api2007.types.RSObject;
  15. import org.tribot.api2007.types.RSTile;
  16.  
  17. import scripts.methods.Methods;
  18.  
  19. public class Runecrafting {
  20.  
  21. private Main main;
  22.  
  23. public Runecrafting(Main main) {
  24. setMain(main);
  25. }
  26.  
  27. public void setMain(Main main) {
  28. this.main = main;
  29. }
  30.  
  31. public Main getMain() {
  32. return main;
  33. }
  34.  
  35. public RSTile[] getRiftPath() {
  36.  
  37. return getMain().getPathNavigator().findPath(getMain().getRune().getRiftLocation());
  38. }
  39.  
  40. public boolean enterRift() {
  41. if(Locations.isInsideAltar()) {
  42. return true;
  43. }
  44. if(getMain().getHouse().isInside()) {
  45. getMain().setState(State.TELEPORTING_TO_EDGEVILLE);
  46. return false;
  47. }
  48. if(!Player.getPosition().equals(getMain().getRune().getRiftLocation()) && !Player.isMoving()) {
  49. if(Game.getDestination() == null) {
  50. Walking.walkPath(getRiftPath());
  51. }
  52. if(Game.getDestination() != null && !Game.getDestination().isOnScreen() || !Player.isMoving())
  53. Walking.walkPath(getRiftPath());
  54. //Methods.performAntiBan();
  55. getMain().sleep(50, 150);
  56. }
  57. getMain().getObstacles().setObstacle(null);
  58. RSObject[] rift = Objects.findNearest(64, getMain().getRune().getRiftName());
  59. if(rift != null && rift.length > 0) {
  60. int distance = Methods.distanceTo(getMain(), rift[0].getPosition());
  61. int tries = 0;
  62. if(!rift[0].isOnScreen()
  63. && distance < 6) {
  64. Camera.turnToTile(rift[0]);
  65. }
  66. while(!Locations.isInsideAltar() && Methods.distanceTo(getMain(), rift[0].getPosition()) < 2) {
  67. if(tries == 0) {
  68. Camera.turnToTile(rift[0]);
  69. } else if(tries >= 10) {
  70. Camera.turnToTile(rift[0]);
  71. tries = 0;
  72. }
  73. tries++;
  74. if(rift[0].click("Exit-through")) {
  75. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  76. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  77. }
  78. getMain().sleep(50, 150);
  79. }
  80. }
  81. getMain().sleep(100, 200);
  82. return false;
  83. }
  84.  
  85. public boolean craftRunes() {
  86. if(Locations.isInsideAltar()) {
  87. RSObject[] altar = Objects.findNearest(24, "Altar");
  88. if(altar != null && altar.length > 0) {
  89.  
  90. if(!altar[0].isOnScreen()) {
  91. Camera.turnToTile(altar[0]);
  92. if(!altar[0].isOnScreen())
  93. WebWalking.walkTo(altar[0]);
  94. }
  95. while(Inventory.getCount(Constants.ESSENCE) > 0) {
  96. if(altar[0].click("Craft-rune")) {
  97. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  98. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  99. craftedRunes(6000);
  100. }
  101. getMain().sleep(50, 150);
  102. }
  103. RSItem[] giantPouch = Inventory.find(Constants.POUCHES[3]);
  104. RSItem[] largePouch = Inventory.find(Constants.POUCHES[2]);
  105. RSItem[] medPouch = Inventory.find(Constants.POUCHES[1]);
  106. RSItem[] smallPouch = Inventory.find(Constants.POUCHES[0]);
  107. int essCount = 0;
  108. boolean hasGiantPouch = false;
  109. if(giantPouch != null && giantPouch.length > 0) {
  110. hasGiantPouch = true;
  111. essCount = Inventory.getCount(Constants.ESSENCE);
  112. if(giantPouch[0].click("Empty")) {
  113. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  114. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  115. emptiedPouch(essCount, 2000);
  116. }
  117.  
  118. }
  119. if(largePouch != null && largePouch.length > 0) {
  120. essCount = Inventory.getCount(Constants.ESSENCE);
  121. if(largePouch[0].click("Empty")) {
  122. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  123. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  124. emptiedPouch(essCount, 2000);
  125. }
  126. }
  127. if(hasGiantPouch) {
  128. while(Inventory.getCount(Constants.ESSENCE) > 0) {
  129. if(altar[0].click("Craft-rune")) {
  130. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  131. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  132. craftedRunes(6000);
  133. }
  134. getMain().sleep(50, 150);
  135. }
  136. }
  137. if(medPouch != null && medPouch.length > 0) {
  138. essCount = Inventory.getCount(Constants.ESSENCE);
  139. if(medPouch[0].click("Empty")) {
  140. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  141. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  142. emptiedPouch(essCount, 2000);
  143. }
  144. }
  145. if(smallPouch != null && smallPouch.length > 0) {
  146. essCount = Inventory.getCount(Constants.ESSENCE);
  147. if(smallPouch[0].click("Empty")) {
  148. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  149. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  150. emptiedPouch(essCount, 2000);
  151. }
  152. }
  153. while(Inventory.getCount(Constants.ESSENCE) > 0) {
  154. if(altar[0].click("Craft-rune")) {
  155. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  156. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  157. craftedRunes(6000);
  158. }
  159. getMain().sleep(50, 150);
  160. }
  161. while(Player.getAnimation() != -1) {
  162. getMain().sleep(50, 150);
  163. }
  164. if(Inventory.getCount(Constants.ESSENCE) <= 0) {
  165. int natsCrafted = getMain().getNatsCrafted();
  166. getMain().setNatsCrafted(natsCrafted + Inventory.getCount(getMain().getRune().getItemId()));
  167. return true;
  168. }
  169. return false;
  170. }
  171. }
  172. return false;
  173. }
  174.  
  175. private ABCUtil abc = new ABCUtil();
  176.  
  177. private boolean craftedRunes(int i) {
  178. long t = System.currentTimeMillis();
  179. while (Timing.timeFromMark(t) < i) {
  180. if (Inventory.getCount(Constants.ESSENCE) <= 0) {
  181. if(Player.getAnimation() == -1) {
  182. return true;
  183. }
  184. }
  185. getMain().sleep(50, 150);
  186. }
  187. return false;
  188. }
  189.  
  190. private boolean emptiedPouch(int essAmt, int i) {
  191. long t = System.currentTimeMillis();
  192. while (Timing.timeFromMark(t) < i) {
  193. if (Inventory.getCount(Constants.ESSENCE) > essAmt) {
  194. return true;
  195. }
  196. getMain().sleep(50, 150);
  197. }
  198. return false;
  199. }
  200.  
  201. public boolean isAtRift() {
  202. RSObject[] rift = Objects.findNearest(64, getMain().getRune().getRiftName());
  203. if(rift != null && rift.length > 0) {
  204. if(Methods.distanceTo(getMain(), rift[0].getPosition()) <= 5) {
  205. return true;
  206. }
  207. }
  208. return false;
  209. }
  210.  
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement