Advertisement
Guest User

scriptLoop.java

a guest
Jun 25th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.91 KB | None | 0 0
  1. package core;
  2.  
  3. import org.osbot.rs07.api.GrandExchange;
  4. import org.osbot.rs07.api.map.Area;
  5. import org.osbot.rs07.api.map.constants.Banks;
  6. import org.osbot.rs07.api.model.NPC;
  7. import org.osbot.rs07.api.ui.RS2Widget;
  8. import org.osbot.rs07.api.ui.Skill;
  9. import org.osbot.rs07.api.ui.Spells;
  10. import org.osbot.rs07.api.ui.Tab;
  11. import org.osbot.rs07.script.MethodProvider;
  12. import org.osbot.rs07.script.Script;
  13. import org.osbot.rs07.api.ui.Spells.NormalSpells;
  14. import org.osbot.rs07.utility.ConditionalSleep;
  15.  
  16. import core.Main;
  17. import utils.Sleep;
  18. import core.Starting;
  19.  
  20. @SuppressWarnings("unused")
  21. public final class scriptLoop extends MethodProvider{
  22.  
  23. public int beginningXP;
  24. public int currentXp;
  25. public int xpGained;
  26. public int bracelets;
  27. public int magicOld;
  28. long timeBegan;
  29. public long timeRan;
  30. public int mageLvl;
  31. public int attLvl;
  32. public String hiAlch;
  33. public String warn;
  34. public int numCharged;
  35. public int numBraces;
  36. public long costBraces;
  37. public String started;
  38. public static String braceletPrice;
  39. Area geArea = Banks.GRAND_EXCHANGE;
  40.  
  41. public void addEther() throws InterruptedException {
  42. while (getInventory().contains("Nature rune") && getInventory().contains("Bracelet of ethereum (uncharged)")) {
  43. bracelets = (int) getInventory().getAmount("Bracelet of ethereum (uncharged)");
  44. if (getInventory().contains("Revenant ether")) {
  45. inventory.interact("Use", "Revenant ether");
  46. Sleep.sleepUntil(() -> getInventory().isItemSelected(), 5000);
  47. inventory.interact("Use", "Bracelet of ethereum (uncharged)");
  48. new ConditionalSleep(5000) {
  49. @Override
  50. public boolean condition() throws InterruptedException {
  51. long braceletsNew = getInventory().getAmount("Bracelet of ethereum (uncharged)");
  52. if (bracelets != braceletsNew) {
  53. return true;
  54. }
  55. return false;
  56. }
  57. }.sleep();
  58. }
  59. else if (!getInventory().contains("Revenant ether")) {
  60. getBank().open();
  61. Sleep.sleepUntil(() -> getBank().isOpen(), 5000);
  62. if (!getInventory().isFull()) {
  63. if (getBank().contains("Revenant ether")) {
  64. getBank().withdraw("Revenant ether", 1);
  65. getBank().close();
  66. Sleep.sleepUntil(() -> !getBank().isOpen(), 5000);
  67. }
  68. else {
  69. buyEther();
  70. }
  71. }
  72. else {
  73. getBank().depositAll();
  74. if (getBank().contains("Revenant ether")) {
  75. getBank().withdrawAll("Nature rune");
  76. getBank().withdraw("Revenant ether", 1);
  77. getBank().withdrawAll("Bracelet of ethereum (uncharged)");
  78. getBank().close();
  79. Sleep.sleepUntil(() -> (!getBank().isOpen()), 5000);
  80. }
  81. else {
  82. buyNats();
  83. }
  84. }
  85. }
  86. }
  87. }
  88.  
  89.  
  90. public void bank() throws InterruptedException {
  91. NPC geClerk = npcs.closest("Grand Exchange Clerk");
  92. getBank().open();
  93. Sleep.sleepUntil(() -> (getBank().isOpen()), 5000);
  94. getBank().depositAllExcept("Nature rune");
  95. if (getBank().contains("Bracelet of ethereum") || getBank().contains("Bracelet of ethereum (uncharged)")) {
  96. getBank().depositAllExcept("Nature rune");
  97. if (getBank().contains("Bracelet of ethereum")) {
  98. getBank().withdrawAll("Bracelet of ethereum");
  99. getBank().close();
  100. Sleep.sleepUntil(() -> (!getBank().isOpen()), 5000);
  101. }
  102. else if (getBank().contains("Revenant ether") && getBank().contains("Bracelet of ethereum (uncharged)")) {
  103. getBank().withdraw("Revenant ether", 1);
  104. getBank().withdrawAll("Bracelet of ethereum (uncharged)");
  105. getBank().close();
  106. Sleep.sleepUntil(() -> (!getBank().isOpen()), 5000);
  107. }
  108. }
  109. else {
  110. if(getBank().contains("Coins") && Main.braceletPrice != 0) {
  111. getBank().withdrawAll("Coins");
  112. getBank().close();
  113. Sleep.sleepUntil(() -> (!getBank().isOpen()), 5000);
  114. buyBracelets();
  115. } else {
  116. getBot().getScriptExecutor().stop(false);
  117. }
  118. }
  119. }
  120.  
  121. public void buyBracelets() throws InterruptedException {
  122. NPC geClerk = npcs.closest("Grand Exchange Clerk");
  123. if(getBank().isOpen()) {
  124. getBank().close();
  125. Sleep.sleepUntil(() -> (!getBank().isOpen()), 5000);
  126. }
  127. if (geClerk != null) {
  128. geClerk.interact("Exchange");
  129. Sleep.sleepUntil(() -> (grandExchange.isOpen()), 5000);
  130. long numBracelet = getInventory().getAmount("Coins") / Main.braceletPrice;
  131. int numBracelets = (int) numBracelet;
  132. /* if(getGrandExchange().getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.EMPTY){
  133. log("Opening ge slot 1");
  134. getGrandExchange().buyItems(GrandExchange.Box.BOX_1);
  135. sleep(random(2000,3000));
  136. }
  137. else if(getGrandExchange().getStatus(GrandExchange.Box.BOX_2) == GrandExchange.Status.EMPTY){
  138. getGrandExchange().buyItems(GrandExchange.Box.BOX_2);
  139. sleep(random(2000,3000));
  140. }
  141. else if(getGrandExchange().getStatus(GrandExchange.Box.BOX_3) == GrandExchange.Status.EMPTY){
  142. getGrandExchange().buyItems(GrandExchange.Box.BOX_3);
  143. sleep(random(2000,3000));
  144. }
  145. else if(getGrandExchange().getStatus(GrandExchange.Box.BOX_4) == GrandExchange.Status.EMPTY){
  146. getGrandExchange().buyItems(GrandExchange.Box.BOX_4);
  147. sleep(random(2000,3000));
  148. }
  149. else if(getGrandExchange().getStatus(GrandExchange.Box.BOX_5) == GrandExchange.Status.EMPTY){
  150. getGrandExchange().buyItems(GrandExchange.Box.BOX_5);
  151. sleep(random(2000,3000));
  152. }
  153. else if(getGrandExchange().getStatus(GrandExchange.Box.BOX_6) == GrandExchange.Status.EMPTY){
  154. getGrandExchange().buyItems(GrandExchange.Box.BOX_6);
  155. sleep(random(2000,3000));
  156. }
  157. else if(getGrandExchange().getStatus(GrandExchange.Box.BOX_7) == GrandExchange.Status.EMPTY){
  158. getGrandExchange().buyItems(GrandExchange.Box.BOX_7);
  159. sleep(random(2000,3000));
  160. }
  161. else if(getGrandExchange().getStatus(GrandExchange.Box.BOX_8) == GrandExchange.Status.EMPTY){
  162. getGrandExchange().buyItems(GrandExchange.Box.BOX_8);
  163. sleep(random(2000,3000));
  164. }
  165. else {
  166. log("GE is full. Stopping script.");
  167. getBot().getScriptExecutor().stop(false);
  168. } */
  169. log("Buying bracelets");
  170. grandExchange.buyItem(21817, "Bracelet of ethereum (uncharged)", Main.braceletPrice, numBracelets);
  171. sleep(random(3000,4000));
  172. grandExchange.collect();
  173. grandExchange.close();
  174. Sleep.sleepUntil(() -> (!grandExchange.isOpen()), 5000);
  175. getInventory();
  176. getBank().open();
  177. Sleep.sleepUntil(() -> (getBank().isOpen()), 5000);
  178. getBank().depositAllExcept("Nature rune");
  179. if (getBank().contains("Bracelet of ethereum (uncharged)")) {
  180. getBank().withdraw("Revenant ether", 1);
  181. getBank().withdrawAll("Nature rune");
  182. getBank().withdrawAll("Bracelet of ethereum (uncharged)");
  183. getBank().close();
  184. Sleep.sleepUntil(() -> !getBank().isOpen(), 5000);
  185. }
  186. else {
  187. getBank().close();
  188. getBot().getScriptExecutor().stop(false);
  189. }
  190. }
  191. }
  192.  
  193. private void buyEther() throws InterruptedException {
  194.  
  195. }
  196.  
  197. private void buyNats() throws InterruptedException {
  198.  
  199. }
  200.  
  201. public void alch() throws InterruptedException {
  202. RS2Widget alchWarn = getWidgets().getWidgetContainingText("Click here to continue");
  203. getTabs().open(Tab.MAGIC);
  204. while (getInventory().contains("Nature rune") && getInventory().contains("Bracelet of ethereum")) {
  205. magicOld = skills.getExperience(Skill.MAGIC);
  206. if (getTabs().getOpen().equals(Tab.MAGIC)) {
  207. magic.castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY);
  208. }
  209. inventory.interact("Cast", "Bracelet of ethereum");
  210. new ConditionalSleep(5000) {
  211. @Override
  212. public boolean condition() throws InterruptedException {
  213. long magicNew = skills.getExperience(Skill.MAGIC);
  214. if ((magicNew != magicOld) || (alchWarn != null && alchWarn.isVisible()) && getTabs().getOpen().equals(Tab.MAGIC)) {
  215. return true;
  216. }
  217. return false;
  218. }
  219. }.sleep();
  220. new ConditionalSleep(5000) {
  221. @Override
  222. public boolean condition() throws InterruptedException {
  223. if (getTabs().getOpen().equals(Tab.MAGIC)) {
  224. return true;
  225. }
  226. return false;
  227. }
  228. }.sleep();
  229. if (alchWarn != null && alchWarn.isVisible()) {
  230. warn = "Y";
  231. break;
  232. }
  233. if(getInventory().contains("Bracelet of ethereum") && getInventory().contains("Nature rune")) {
  234. magic.castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY);
  235. }
  236. else {
  237. break;
  238. }
  239. }
  240. }
  241.  
  242.  
  243. public void warn() throws InterruptedException {
  244. sleep(10000);
  245. getBot().getScriptExecutor().stop(false);
  246. }
  247.  
  248. public void logout() throws InterruptedException {
  249. getBank().open();
  250. Sleep.sleepUntil(() -> getBank().isOpen(), 5000);
  251. if (!getBank().contains("Nature rune")) {
  252. getBank().close();
  253. Sleep.sleepUntil(() -> !getBank().isOpen(), 5000);
  254. getBot().getScriptExecutor().stop(false);
  255. }
  256. else {
  257. getBank().depositAll();
  258. getBank().withdrawAll("Nature rune");
  259. getBank().withdraw("Revenant ether", 1);
  260. getBank().withdrawAll("Bracelet of ethereum (uncharged)");
  261. }
  262. }
  263.  
  264. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement