Advertisement
iant06

Untitled

Sep 17th, 2015
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. package scripts.firemaker;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.Timing;
  5. import org.tribot.api.util.ABCUtil;
  6. import org.tribot.api2007.Banking;
  7. import org.tribot.api2007.Inventory;
  8. import org.tribot.api2007.Objects;
  9. import org.tribot.api2007.types.RSItem;
  10. import org.tribot.api2007.types.RSObject;
  11.  
  12. public class Bank {
  13.  
  14. private Main main;
  15.  
  16. private ABCUtil abc = new ABCUtil();
  17.  
  18. public Bank(Main main) {
  19. setMain(main);
  20. }
  21.  
  22. public boolean performedBankTask() {
  23. int logId = getMain().getLogType().getLogId();
  24. boolean tinderbox = Inventory.getCount(Constants.TINDERBOX) > 0;;
  25. boolean logs = Inventory.getCount(logId) > 0;
  26.  
  27. if(Banking.isBankScreenOpen())
  28. Banking.depositAllExcept(Constants.TINDERBOX, getMain().getLogId());
  29.  
  30. if(!tinderbox) {
  31. if(Inventory.getCount(Constants.TINDERBOX) <= 0) {
  32. if(withdrawItem(Constants.TINDERBOX, 1)) {
  33. tinderbox = Inventory.getCount(Constants.TINDERBOX) > 0;
  34. }
  35. }
  36. }
  37.  
  38. if(!logs) {
  39. if(withdrawItem(logId, 28 - Inventory.getAll().length)) {
  40. logs = Inventory.getCount(logId) > 0;
  41. }
  42. }
  43.  
  44. if(tinderbox && logs) {
  45. return true;
  46. }
  47.  
  48. return false;
  49. }
  50.  
  51. public boolean openBank() {
  52. if(Banking.isBankScreenOpen()) {
  53. return true;
  54. }
  55. if(getMain().usingGrandExchange()) {
  56. RSObject[] geBank = Objects.findNearest(64, "Grand Exchange booth");
  57. if(geBank != null && geBank.length > 0) {
  58. for(int i = 0; i < geBank.length; i++) {
  59. String[] actions = geBank[i].getDefinition().getActions();
  60. for(String a : actions) {
  61. if(a.equals("Bank")) {
  62. if(geBank[i].click("Bank")) {
  63. General.sleep(abc.DELAY_TRACKER.NEW_OBJECT.next());
  64. abc.DELAY_TRACKER.NEW_OBJECT.reset();
  65. return isBankScreenOpen(2000);
  66. }
  67. }
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. Banking.openBank();
  74. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  75. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  76. return isBankScreenOpen(2000);
  77. }
  78.  
  79. public boolean withdrawItem(int itemId, int withdrawAmount) {
  80. if(openBank()) {
  81. getMain().sleep(250, 500);
  82. RSItem[] item = Banking.find(itemId);
  83. if(item != null && item.length > 0) {
  84. Banking.withdraw(withdrawAmount, itemId);
  85. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  86. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  87. if(isItemWithdrawn(2000, itemId, Inventory.getCount(itemId))) {
  88. return true;
  89. }
  90. } else {
  91. getMain().println("Can't find: " + itemId);
  92. getMain().setEndScript(true);
  93. return false;
  94. }
  95. }
  96. return false;
  97. }
  98.  
  99. public boolean isBankScreenOpen(int i) {
  100. long t = System.currentTimeMillis();
  101. while (Timing.timeFromMark(t) < i) {
  102. if (Banking.isBankScreenOpen()) {
  103. return true;
  104. }
  105. getMain().sleep(50, 150);
  106. }
  107. return false;
  108. }
  109.  
  110. private boolean isItemWithdrawn(int i, int id, int amt) {
  111. long t = System.currentTimeMillis();
  112. while (Timing.timeFromMark(t) < i) {
  113. if (Inventory.getCount(id) > amt) {
  114. return true;
  115. }
  116. getMain().sleep(50, 150);
  117. }
  118. return false;
  119. }
  120. public Main getMain() {
  121. return main;
  122. }
  123.  
  124. public void setMain(Main main) {
  125. this.main = main;
  126. }
  127.  
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement