Guest User

Untitled

a guest
Jun 20th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.13 KB | None | 0 0
  1. import com.speljohan.rsbot.script.Random;
  2. import com.speljohan.rsbot.script.wrappers.RSInterfaceChild;
  3. import com.speljohan.rsbot.script.wrappers.RSInterfaceComponent;
  4.  
  5. import java.awt.Point;
  6.  
  7. import java.util.StringTokenizer;
  8. import java.util.ArrayList;
  9.  
  10. public class ImprovedRewardsBox extends Random {
  11.  
  12. private final int boxID = 14664;
  13. private final int boxIF = 202;
  14. private final int boxChoicesIF = 15;
  15. private final int boxExitIF = 14;
  16. private final int boxConfirmIF = 28;
  17. private final int boxScrollIF = 24;
  18.  
  19. private final int XPIF = 134;
  20. private final int XPConfirmIF = 2;
  21.  
  22. private ArrayList<String> yourChoices;
  23. private ArrayList<String> rewards;
  24.  
  25. private String yourChoice;
  26.  
  27. private int wantedSkill;
  28. private int wanted;
  29.  
  30. private final String[] skills = { "Attack", "Strength", "Ranged", "Magic", "Defence", "Crafting", "Hitpoints", "Prayer", "Agility", "Herblore", "Thieving", "Fishing", "Runecrafting", "Slayer", "Farming", "Mining", "Smithing", "Hunter", "Cooking", "Firemaking", "Woodcutting", "Fletching", "Construction", "Summoning" };
  31. private final int lampID = 2528;
  32. private final int bookOfKnowledgeID = 11640;
  33. private final int mysteryBoxID = 6199;
  34.  
  35. public boolean activateCondition() {
  36. if(isLoggedIn() && inventoryContains(boxID)) {
  37. yourChoice = getAccountProperty("reward");
  38. return true;
  39. }
  40. return false;
  41. }
  42.  
  43. public String getAuthor() {
  44. return "Murf";
  45. }
  46.  
  47. public String getName() {
  48. return "Improved Rewards Box";
  49. }
  50.  
  51. public double getVersion() {
  52. return 1.0;
  53. }
  54.  
  55. public int loop() {
  56. if(wantedSkill != -1 && (inventoryContains(lampID) || inventoryContains(bookOfKnowledgeID))) {
  57. if(getInterface(XPIF).isValid()) {
  58. final RSInterfaceChild confFace = getChildInterface(XPIF, XPConfirmIF);
  59. moveMouse(getXPPoint(wantedSkill));
  60. wait(random(600, 800));
  61. clickMouse(true);
  62. moveMouse(confFace.getAbsoluteX() + random(0, confFace.getWidth()), confFace.getAbsoluteY() + random(0, confFace.getHeight()));
  63. wait(random(600, 800));
  64. clickMouse(true);
  65. return random(800, 1000);
  66. } else {
  67. atInventoryItem(inventoryContains(lampID) ? lampID : bookOfKnowledgeID, inventoryContains(lampID) ? "Rub" : "Read");
  68. return random(1000, 1500);
  69. }
  70. }
  71. if(inventoryContains(mysteryBoxID)) {
  72. atInventoryItem(mysteryBoxID, "Open");
  73. return random(1500, 2000);
  74. }
  75. if(yourChoice == null || yourChoice.equals("")) {
  76. log.severe("Please set what kind of reward you would like to get.");
  77. log.severe("Add a new account property called \"reward\" and type the ID of the item you want.");
  78. log.severe("You can choose many different types of rewards by separating the IDs with");
  79. log.severe("dots (.). Here is an example: 1621.447.453");
  80. log.severe("Your first choice is emeralds, if there isn't any, then choose mithril ore,");
  81. log.severe("then coal ore.");
  82. log.severe("If you want to get a XP Item then just type XP instead of a ID and then");
  83. log.severe("what kind of skill you want XP in.");
  84. log.severe("Example: 1621.XP/mining.447.");
  85. log.severe("Again, first choice is emeralds, then XP in mining and then mithril ore.");
  86. log.severe("As you can see, you seperate \"XP\" and what kind of XP you want with a slash(/).");
  87. log.severe("You can also choose emote, costume or mystery box.");
  88. log.severe("emote.xp/mining.custume.1621.mystery");
  89. } else {
  90. yourChoices = new ArrayList<String>();
  91. final StringTokenizer tempST = new StringTokenizer(yourChoice, ".");
  92. while(tempST.hasMoreTokens())
  93. yourChoices.add(tempST.nextToken());
  94. }
  95. if(getInterface(boxIF).isValid()) {
  96. rewards = new ArrayList<String>();
  97. wanted = -1;
  98. wantedSkill = -1;
  99. final RSInterfaceComponent[] tempChoices = getChildInterface(boxIF, boxChoicesIF).getComponents();
  100. for(int i = 0; i < tempChoices.length; i++)
  101. if(tempChoices[i].getComponentID() != -1)
  102. rewards.add(tempChoices[i].getComponentID() + "");
  103. else if(tempChoices[i].getComponentName().toLowerCase().contains("emote"))
  104. rewards.add("emote");
  105. else if(tempChoices[i].getComponentName().toLowerCase().contains("costume"))
  106. rewards.add("costume");
  107. for(int i = 0; i < yourChoices.size(); i++) {
  108. if(yourChoices.get(i).toString().substring(0,3).toLowerCase().equals("xp/")) {
  109. for(int a = 0; a < skills.length; a++) {
  110. if(yourChoices.get(i).toString().substring(3).toLowerCase().equals(skills[a].toLowerCase()))
  111. for(int x = 0; x < rewards.size(); x++)
  112. if(rewards.get(x).equals(bookOfKnowledgeID + "") || rewards.get(x).equals(lampID + "")) {
  113. wantedSkill = a;
  114. wanted = x;
  115. break;
  116. }
  117. if(wanted != -1)
  118. break;
  119. }
  120. } else if(yourChoices.get(i).toString().toLowerCase().equals("mystery")) {
  121. for(int a = 0; a < rewards.size(); a++)
  122. if(rewards.get(a).equals(mysteryBoxID + "")) {
  123. wanted = a;
  124. break;
  125. }
  126. } else
  127. for(int a = 0; a < rewards.size(); a++)
  128. if(yourChoices.get(i).equals(rewards.get(a).toString().toLowerCase())) {
  129. wanted = a;
  130. break;
  131. }
  132. if(wanted != -1)
  133. break;
  134. }
  135. final RSInterfaceChild confFace = getChildInterface(boxIF, boxConfirmIF);
  136. if(wanted != -1) {
  137. if(wanted <= 5) {
  138. moveMouse(getChoicePoint(wanted));
  139. wait(random(600, 800));
  140. clickMouse(true);
  141. } else if(rewards.size() <= 12) {
  142. final RSInterfaceChild tempFace = getChildInterface(boxIF, boxScrollIF);
  143. moveMouse(tempFace.getAbsoluteX() + random(0, tempFace.getWidth()), tempFace.getAbsoluteY() + tempFace.getHeight() - random(0, 10));
  144. wait(random(400, 500));
  145. for(int i = 0; i < 25; i++) {
  146. clickMouse(true);
  147. wait(50);
  148. }
  149. moveMouse(getChoicePoint(wanted - (rewards.size() - 6) - (rewards.size() % 2)));
  150. wait(random(600, 800));
  151. clickMouse(true);
  152. } else {
  153. log.severe("There are more than 12 options, check it out plzz");
  154. stopAllScripts();
  155. }
  156. } else {
  157. log("Couldn't find anything you would like to have, choosing coins.");
  158. moveMouse(getChoicePoint(0));
  159. wait(random(600, 800));
  160. clickMouse(true);
  161. }
  162. moveMouse(confFace.getAbsoluteX() + random(0, confFace.getWidth()), confFace.getAbsoluteY() + random(0, confFace.getHeight()));
  163. wait(random(600, 800));
  164. clickMouse(true);
  165. return random(3000, 3500);
  166. }
  167. if(activateCondition()) {
  168. atInventoryItem(boxID, "Open");
  169. return random(1500, 2000);
  170. }
  171. return -1;
  172. }
  173.  
  174. private Point getChoicePoint(final int index) {
  175. final int col = index % 2;
  176. final int row = index / 2;
  177. final int x = 42 + 15 + col * 164 + random(0, 149 - 30);
  178. final int y = 76 + 15 + row * 78 + random(0, 63 - 30);
  179. return new Point(x, y);
  180. }
  181.  
  182. private Point getXPPoint(final int index) {
  183. if(index >= 21) {
  184. final int col = (index - 21) % 3;
  185. final int x = 167 + col * 60 + random(0, 54);
  186. final int y = 250 + random(0, 53);
  187. return new Point(x, y);
  188. }
  189. final int col = index % 7;
  190. final int row = index / 7;
  191. final int x = 51 + col * 60 + random(0, 54);
  192. final int y = 84 + row * 55 + random(0, 53);
  193. return new Point(x, y);
  194. }
  195.  
  196. }
Add Comment
Please, Sign In to add comment