Advertisement
iant06

Untitled

Oct 21st, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.68 KB | None | 0 0
  1. package scripts.clues;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.tribot.api.General;
  6. import org.tribot.api.Timing;
  7. import org.tribot.api.util.ABCUtil;
  8. import org.tribot.api2007.Banking;
  9. import org.tribot.api2007.Equipment;
  10. import org.tribot.api2007.Interfaces;
  11. import org.tribot.api2007.Equipment.SLOTS;
  12. import org.tribot.api2007.Inventory;
  13. import org.tribot.api2007.Skills.SKILLS;
  14. import org.tribot.api2007.types.RSItem;
  15. import org.tribot.api2007.types.RSItemDefinition;
  16.  
  17. import scripts.methods.Methods;
  18.  
  19. public class Equipped {
  20.  
  21. private final ABCUtil abc = new ABCUtil();
  22.  
  23. private ArrayList<String> playerEquipment = new ArrayList<String>();
  24.  
  25. private Main main;
  26.  
  27. public Equipped(Main main) {
  28. setMain(main);
  29. }
  30.  
  31. public boolean wearOriginalEquipment() {
  32. getMain().setStatus("Equipping Original Equipment");
  33.  
  34. Interfaces.closeAll();
  35.  
  36. for(String itemName : playerEquipment) {
  37.  
  38. if(Equipment.isEquipped(itemName)) {
  39. continue;
  40. }
  41.  
  42. RSItem[] item = Inventory.find(itemName);
  43. if(item != null && item.length > 0) {
  44.  
  45. RSItemDefinition def = item[0].getDefinition();
  46.  
  47. if(def != null) {
  48.  
  49. if(item[0].click(def.getActions()[0])) {
  50. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT_COMBAT.next());
  51. abc.DELAY_TRACKER.SWITCH_OBJECT_COMBAT.reset();
  52. }
  53.  
  54. }
  55. }
  56. }
  57. return wearingOriginalEquipment();
  58. }
  59.  
  60. public boolean wearingOriginalEquipment() {
  61. boolean allEquipped = true;
  62.  
  63. for(String s : playerEquipment) {
  64. if(!Equipment.isEquipped(s)) {
  65. allEquipped = false;
  66. break;
  67. }
  68. }
  69. return allEquipped;
  70. }
  71.  
  72. public boolean hasOriginalEquipment() {
  73. boolean hasAll = true;
  74.  
  75. for(String s : playerEquipment) {
  76. if(!Equipment.isEquipped(s) && Inventory.getCount(s) <= 0) {
  77. hasAll = false;
  78. break;
  79. }
  80. }
  81. return hasAll;
  82. }
  83.  
  84. public Object[][] getItemRequirements(String[] items) {
  85. getMain().println("Searching for item requirements...");
  86. Object[][] req = new Object[4][2];
  87. int index = 0;
  88. for(Object[] r : req) {
  89. r[0] = null;
  90. r[1] = 0;
  91. }
  92. for(String s : items) {
  93. if(s.equals("Coif")) {
  94. getMain().println("Found " + s + " Requirements.");
  95. req[index][0] = SKILLS.RANGED;
  96. req[index][1] = 20;
  97. }
  98. if(s.equals("Steel full helm")) {
  99. getMain().println("Found " + s + " Requirements.");
  100. req[index][0] = SKILLS.DEFENCE;
  101. req[index][1] = 5;
  102. }
  103. if(s.equals("Steel platebody")) {
  104. getMain().println("Found " + s + " Requirements.");
  105. req[index][0] = SKILLS.DEFENCE;
  106. req[index][1] = 5;
  107. }
  108. if(s.equals("Steel plateskirt")) {
  109. getMain().println("Found " + s + " Requirements.");
  110. req[index][0] = SKILLS.DEFENCE;
  111. req[index][1] = 5;
  112. }
  113. if(s.equals("Steel axe")) {
  114. getMain().println("Found " + s + " Requirements.");
  115. req[index][0] = SKILLS.ATTACK;
  116. req[index][1] = 5;
  117. }
  118. if(s.equals("Steel pickaxe")) {
  119. getMain().println("Found " + s + " Requirements.");
  120. req[index][0] = SKILLS.ATTACK;
  121. req[index][1] = 5;
  122. }
  123. if(s.equals("Steel med helm")) {
  124. getMain().println("Found " + s + " Requirements.");
  125. req[index][0] = SKILLS.DEFENCE;
  126. req[index][1] = 5;
  127. }
  128. if(s.equals("Studded body")) {
  129. getMain().println("Found " + s + " Requirements.");
  130. req[index][0] = SKILLS.RANGED;
  131. req[index][1] = 20;
  132. index++;
  133. req[index][0] = SKILLS.DEFENCE;
  134. req[index][1] = 20;
  135. }
  136. if(s.equals("Studded chaps")) {
  137. getMain().println("Found " + s + " Requirements.");
  138. req[index][0] = SKILLS.RANGED;
  139. req[index][1] = 20;
  140. }
  141. if(s.equals("Black axe")) {
  142. getMain().println("Found " + s + " Requirements.");
  143. req[index][0] = SKILLS.ATTACK;
  144. req[index][1] = 10;
  145. }
  146. if(s.equals("Oak shortbow")) {
  147. getMain().println("Found " + s + " Requirements.");
  148. req[index][0] = SKILLS.RANGED;
  149. req[index][1] = 5;
  150. }
  151. if(s.equals("Hardleather body")) {
  152. getMain().println("Found " + s + " Requirements.");
  153. req[index][0] = SKILLS.DEFENCE;
  154. req[index][1] = 10;
  155. }
  156. if(s.equals("Mithril pickaxe")) {
  157. getMain().println("Found " + s + " Requirements.");
  158. req[index][0] = SKILLS.ATTACK;
  159. req[index][1] = 20;
  160. }
  161. if(s.equals("Black platebody")) {
  162. getMain().println("Found " + s + " Requirements.");
  163. req[index][0] = SKILLS.DEFENCE;
  164. req[index][1] = 10;
  165. }
  166. if(s.equals("Steel mace")) {
  167. getMain().println("Found " + s + " Requirements.");
  168. req[index][0] = SKILLS.ATTACK;
  169. req[index][1] = 5;
  170. }
  171. if(s.equals("Steel longsword")) {
  172. getMain().println("Found " + s + " Requirements.");
  173. req[index][0] = SKILLS.ATTACK;
  174. req[index][1] = 5;
  175. }
  176. if(s.equals("Oak longbow")) {
  177. getMain().println("Found " + s + " Requirements.");
  178. req[index][0] = SKILLS.RANGED;
  179. req[index][1] = 5;
  180. }
  181. SKILLS skill = (SKILLS) req[index][0];
  182. if(skill != null) {
  183. int lvl = (Integer) req[index][1];
  184. getMain().println("Level " + lvl + " " + Methods.correctCapitalization(skill.toString()) + " Required!");
  185. }
  186. index++;
  187. }
  188. return req;
  189. }
  190.  
  191. public boolean setEquipment() {
  192. for(SLOTS s : SLOTS.values()) {
  193. if(s.equals(SLOTS.AMULET)
  194. || s.equals(SLOTS.RING))
  195. continue;
  196. RSItem i = Equipment.getItem(s);
  197. if(i != null) {
  198. RSItemDefinition def = i.getDefinition();
  199. if(def != null) {
  200. playerEquipment.add(def.getName());
  201. }
  202. }
  203. }
  204. String s = "Setting Equipment: ";
  205. for(String item : playerEquipment) {
  206. s = s + " " + item + ", ";
  207. }
  208. getMain().println(s);
  209. return true;
  210. }
  211.  
  212. public boolean unequipAllItems() {
  213. getMain().setStatus("Removing All Equipment");
  214. for(SLOTS s : SLOTS.values()) {
  215. if(Inventory.isFull()) {
  216. if(Inventory.isFull())
  217. getMain().getHamDungeon().eatFood();
  218. }
  219. Equipment.remove(s);
  220. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT_COMBAT.next());
  221. abc.DELAY_TRACKER.SWITCH_OBJECT_COMBAT.reset();
  222. }
  223. boolean unequipped = true;
  224. for(SLOTS s : SLOTS.values()) {
  225. if(Equipment.getItem(s) != null) {
  226. unequipped = false;
  227. }
  228. }
  229. return unequipped;
  230. }
  231.  
  232. public boolean wearingRequiredEquipment(ClueTask task) {
  233. if(task.getEmoteClue() != null) {
  234. String[] items = task.getEmoteClue().getItems();
  235. if(items[0].equals("")) {
  236. boolean unequipped = true;
  237. for(SLOTS s : SLOTS.values()) {
  238. if(Equipment.getItem(s) != null) {
  239. unequipped = false;
  240. }
  241. }
  242. return unequipped;
  243. }
  244. boolean hasItems = true;
  245.  
  246. for(int i = 0; i < items.length; i++) {
  247. if(items[i].length() > 0) {
  248. if(!Equipment.isEquipped(items[i])) {
  249. hasItems = false;
  250. }
  251. }
  252. }
  253. return hasItems;
  254. }
  255. return false;
  256. }
  257.  
  258. public boolean wearRequiredEquipment(String[] required) {
  259. getMain().setStatus("Wearing Required Equipment");
  260.  
  261. if(Banking.isBankScreenOpen())
  262. Banking.close();
  263.  
  264. boolean wearingAll = true;
  265.  
  266. for(int i = 0; i < required.length; i++) {
  267. if(required[i].length() > 0) {
  268. RSItem[] item = Inventory.find(required[i]);
  269. if(item != null && item.length > 0) {
  270. RSItemDefinition def = item[0].getDefinition();
  271. if(def != null) {
  272. if(item[0].click(def.getActions()[0])) {
  273. if(isWearingItem(required[i], getMain().getProfile().getRandomGeneralSleep())) {
  274. continue;
  275. }
  276. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT_COMBAT.next());
  277. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  278. }
  279. }
  280. }
  281. }
  282. }
  283.  
  284. for(String s : required) {
  285. if(!Equipment.isEquipped(s)) {
  286. wearingAll = false;
  287. }
  288. }
  289.  
  290. return wearingAll;
  291. }
  292.  
  293. public boolean isWearingItem(int item, int i) {
  294. long l = System.currentTimeMillis();
  295. while(Timing.timeFromMark(l) <= i) {
  296. if(Equipment.isEquipped(item)) {
  297. return true;
  298. }
  299. General.sleep(50, 150);
  300. }
  301. return false;
  302. }
  303.  
  304. public boolean isWearingItem(String item, int i) {
  305. long l = System.currentTimeMillis();
  306. while(Timing.timeFromMark(l) <= i) {
  307. if(Equipment.isEquipped(item)) {
  308. return true;
  309. }
  310. General.sleep(50, 150);
  311. }
  312. return false;
  313. }
  314.  
  315. public boolean hasRing() {
  316. return Inventory.getCount(Constants.DUEL_RING_ID) > 0
  317. || Equipment.isEquipped(Constants.DUEL_RING_ID);
  318. }
  319.  
  320. public boolean hasNecklace() {
  321. return Inventory.getCount(Constants.GAMES_NECKLACE_ID) > 0
  322. || Equipment.isEquipped(Constants.GAMES_NECKLACE_ID);
  323. }
  324.  
  325. public Main getMain() {
  326. return main;
  327. }
  328.  
  329. public void setMain(Main main) {
  330. this.main = main;
  331. }
  332.  
  333. public ArrayList<String> getPlayerEquipment() {
  334. return playerEquipment;
  335. }
  336.  
  337. public void setPlayerEquipment(ArrayList<String> playerEquipment) {
  338. this.playerEquipment = playerEquipment;
  339. }
  340.  
  341. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement