Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 KB | None | 0 0
  1. package core;
  2.  
  3. import java.awt.Graphics2D;
  4. import java.util.Arrays;
  5.  
  6. import org.osbot.rs07.api.Trade;
  7. import org.osbot.rs07.api.filter.Filter;
  8. import org.osbot.rs07.api.map.Area;
  9. import org.osbot.rs07.api.map.Position;
  10. import org.osbot.rs07.api.model.NPC;
  11. import org.osbot.rs07.api.model.RS2Object;
  12. import org.osbot.rs07.api.ui.RS2Widget;
  13. import org.osbot.rs07.event.WalkingEvent;
  14. import org.osbot.rs07.script.Script;
  15. import org.osbot.rs07.script.ScriptManifest;
  16.  
  17. import utils.Sleep;
  18.  
  19. @ScriptManifest(author = "Fury Shark", info = "Essence Runner ZMI", name = "EssenceRunnerZMI", version = 0, logo = "https://i.imgur.com/3OidXbh.jpg")
  20. public class Main extends Script {
  21.  
  22.  
  23.  
  24. Area tradeArea = new Area(3055, 5585, 3065, 5574);
  25. Area bankArea = new Area(3011, 5626, 3016, 5623);
  26. Area tradeArea2 = new Area(
  27. new int[][]{
  28. { 3057, 5587 },
  29. { 3055, 5585 },
  30. { 3055, 5574 },
  31. { 3065, 5573 },
  32. { 3065, 5582 },
  33. { 3066, 5583 }
  34. }
  35. );
  36. private WalkingEvent myEvent;
  37. Position crackPos = new Position(3055, 5585, 0);
  38. Position[] pathToBank = {
  39. new Position(3052, 5587, 0),
  40. new Position(3042, 5587, 0),
  41. new Position(3041, 5587, 0),
  42. new Position(3037, 5589, 0),
  43. new Position(3028, 5585, 0),
  44. new Position(3024, 5586, 0),
  45. new Position(3023, 5590, 0),
  46. new Position(3028, 5594, 0),
  47. new Position(3033, 5597, 0),
  48. new Position(3043, 5596, 0),
  49. new Position(3043, 5596, 0),
  50. new Position(3053, 5596, 0),
  51. new Position(3054, 5596, 0),
  52. new Position(3062, 5596, 0),
  53. new Position(3063, 5601, 0),
  54. new Position(3054, 5603, 0),
  55. new Position(3048, 5603, 0),
  56. new Position(3042, 5601, 0),
  57. new Position(3035, 5604, 0),
  58. new Position(3029, 5599, 0),
  59. new Position(3022, 5602, 0),
  60. new Position(3022, 5607, 0),
  61. new Position(3026, 5612, 0),
  62. new Position(3022, 5620, 0),
  63. new Position(3019, 5624, 0)
  64. };
  65. Position[] pathToAltar = {
  66. new Position(3019, 5623, 0),
  67. new Position(3023, 5616, 0),
  68. new Position(3026, 5612, 0),
  69. new Position(3021, 5605, 0),
  70. new Position(3025, 5600, 0),
  71. new Position(3031, 5601, 0),
  72. new Position(3038, 5603, 0),
  73. new Position(3044, 5601, 0),
  74. new Position(3051, 5604, 0),
  75. new Position(3060, 5602, 0),
  76. new Position(3064, 5598, 0),
  77. new Position(3054, 5596, 0),
  78. new Position(3052, 5595, 0),
  79. new Position(3042, 5595, 0),
  80. new Position(3039, 5595, 0),
  81. new Position(3034, 5597, 0),
  82. new Position(3025, 5593, 0),
  83. new Position(3023, 5587, 0),
  84. new Position(3026, 5584, 0),
  85. new Position(3033, 5587, 0),
  86. new Position(3038, 5589, 0),
  87. new Position(3047, 5587, 0),
  88. new Position(3052, 5587, 0)
  89. };
  90. Position[] path = {
  91. new Position(3056, 5584, 0),
  92. new Position(3059, 5582, 0)
  93. };
  94. Area bankArea2 = new Area(
  95. new int[][]{
  96. { 3054, 5589 },
  97. { 3052, 5585 },
  98. { 3049, 5586 },
  99. { 3051, 5590 }
  100. }
  101. );
  102.  
  103. @SuppressWarnings("unchecked")
  104. public RS2Widget getWidgetWithAction(int rootId, String... interactions) {
  105. Filter<RS2Widget> filt = arg0 -> {
  106. if (arg0 == null) {
  107. return false;
  108. }
  109. if (arg0.getInteractActions() == null) {
  110. return false;
  111. }
  112. boolean b = false;
  113. for (String s : arg0.getInteractActions()) {
  114. for (String s2 : interactions) {
  115. if (s.equalsIgnoreCase(s2)) {
  116. b = true;
  117. }
  118. }
  119. }
  120. return b;
  121. };
  122.  
  123. return getWidgets().singleFilter(rootId, filt);
  124. }
  125.  
  126. @Override
  127. public void onStart() throws InterruptedException {
  128. log("Started");
  129. }
  130.  
  131. @Override
  132. public int onLoop() throws InterruptedException {
  133. if (getInventory().contains("Pure essence") || getTrade().isCurrentlyTrading()) {
  134. if (tradeArea.contains(myPlayer())) {
  135. tradeMain();
  136. } else {
  137. runToTradeArea();
  138. }
  139. } else {
  140. if (bankArea.contains(myPlayer())) {
  141. bank();
  142. } else {
  143. runToBankArea();
  144. }
  145. }
  146. return random(200, 300);
  147. }
  148.  
  149. private void runToBankArea() throws InterruptedException {
  150. RS2Object crack = getObjects().closest(29627);
  151. int x = random(3014,3016);
  152. int y = random(5624,5626);
  153. Position nearBank = new Position(x, y, 0);
  154. if (tradeArea2.contains(myPlayer())) {
  155. myEvent = new WalkingEvent(crackPos);
  156. myEvent.setMinDistanceThreshold(0);
  157. execute(myEvent);
  158. crack.interact("Squeeze-through");
  159. Sleep.sleepUntil(() -> !myPlayer().isAnimating() && !myPlayer().isMoving(), 25000);
  160. sleep(random(2500,3500));
  161. } else {
  162. getWalking().walkPath(Arrays.asList(pathToBank));
  163. myEvent = new WalkingEvent(nearBank);
  164. myEvent.setMinDistanceThreshold(0);
  165. execute(myEvent);
  166. }
  167.  
  168. }
  169.  
  170. private void bank() {
  171. NPC banker = npcs.closest("Eniola");
  172. if (!getBank().isOpen()) {
  173. banker.interact("Bank");
  174. Sleep.sleepUntil(() -> getBank().isOpen(), 25000);
  175. }
  176. if (!getInventory().onlyContains("Air rune")) {
  177. getBank().depositAllExcept("Air rune");
  178. }
  179. getBank().withdraw("Pure essence", 26);
  180. getBank().close();
  181. Sleep.sleepUntil(!getBank().isOpen(), 25000);
  182.  
  183. }
  184.  
  185. private void runToTradeArea() throws InterruptedException {
  186. RS2Object crack = getObjects().closest(29626);
  187. if (bankArea2.contains(myPlayer())) {
  188. crack.interact("Squeeze-through");
  189. Sleep.sleepUntil(() -> !myPlayer().isAnimating() && !myPlayer().isMoving(), 25000);
  190. sleep(random(2500,3500));
  191. getWalking().walkPath(Arrays.asList(path));
  192. } else {
  193. getWalking().walkPath(Arrays.asList(pathToAltar));
  194. sleep(random(2000,2500));
  195. }
  196.  
  197. }
  198.  
  199. private void tradeMain() {
  200. RS2Widget accept = getWidgetWithAction(334, "Accept");
  201. int k = 0;
  202. if (!getTrade().isCurrentlyTrading()) {
  203. getPlayers().closest("World365").interact("Trade with");
  204. Sleep.sleepUntil(() -> getTrade().isCurrentlyTrading(), 25000);;
  205. }
  206. else if (getTrade().isFirstInterfaceOpen() && !getTrade().getOurOffers().contains("Pure essence")) {
  207. getTrade().offer("Pure essence", 13);
  208. Sleep.sleepUntil(() -> getTrade().getOurOffers().contains("Pure essence"), 25000);
  209. getTrade().acceptTrade();
  210. }
  211. else if (getTrade().isSecondInterfaceOpen()) {
  212. while(accept == null) {
  213. k++;
  214. if(k==10) {
  215. log("cant find accept widget");
  216. return; // or exit if you want
  217. }
  218. accept = getWidgetWithAction(Trade.SECOND_INTERFACE_ID, "Accept");
  219. }
  220. accept.interact();
  221. }
  222. }
  223.  
  224. @Override
  225. public void onExit() {
  226. log(":(");
  227. }
  228.  
  229. @Override
  230. public void onPaint(Graphics2D g) {
  231.  
  232.  
  233. }
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement