Advertisement
iant06

Untitled

Sep 17th, 2015
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. package scripts.moneymaking.iplankfarmer.woodcutting;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.Timing;
  5. import org.tribot.api2007.GroundItems;
  6. import org.tribot.api2007.Inventory;
  7. import org.tribot.api2007.Player;
  8. import org.tribot.api2007.WebWalking;
  9. import org.tribot.api2007.types.RSGroundItem;
  10. import org.tribot.api2007.types.RSItem;
  11.  
  12. import scripts.moneymaking.iplankfarmer.utils.Constants;
  13.  
  14. public class BirdsNest {
  15.  
  16. private Woodcutting woodcutting;
  17.  
  18. private int[] nestRewards = new int[10];
  19. private int nestRewardIndex = 0;
  20.  
  21. public BirdsNest(Woodcutting woodcutting) {
  22. setWoodcutting(woodcutting);
  23. }
  24.  
  25. public void pickUp() {
  26. RSGroundItem[] nest = getNest();
  27. if(nest != null && nest.length > 0) {
  28. WebWalking.walkTo(nest[0]);
  29. nest[0].click("Take");
  30. if(isNestPickedUp(nest[0].getID(), 3000)) {
  31. int nests = getWoodcutting().getScript().getData().getNestsFound();
  32. getWoodcutting().getScript().getData().setNestsFound(nests + 1);
  33. emptyNest();
  34. }
  35. }
  36. }
  37.  
  38. private boolean isOldReward(int id) {
  39. for(int i = 0; i < nestRewards.length; i++) {
  40. if(nestRewards[i] == id) {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46.  
  47. private void emptyNest() {
  48. RSItem[] nest = Inventory.find(Constants.BIRD_NEST);
  49. if(nest != null && nest.length > 0) {
  50. while(Inventory.isFull()) {
  51. RSItem[] logs = Inventory.find(getWoodcutting().getScript().getPlank().getLogId());
  52. if(logs != null && logs.length > 0) {
  53. logs[0].click("Drop");
  54. } else {
  55. break;
  56. }
  57. }
  58. nest[0].click("Search");
  59. getWoodcutting().getScript().sleep(1000, 1500);
  60. double nestPrice = getWoodcutting().getScript().getCrushedNestPrice();
  61. getWoodcutting().getScript().println("Found Birds Nest worth " + moneyFormat(nestPrice));
  62. double moneyMade = getWoodcutting().getScript().getData().getMoneyMade();
  63. getWoodcutting().getScript().getData().setMoneyMade(moneyMade + nestPrice);
  64. /*@SuppressWarnings("unchecked")
  65. RSItem[] seed = Inventory.find(Inventory.generateFilterGroup(new Filter<RSItem>() {
  66.  
  67. @Override
  68. public boolean accept(RSItem item) {
  69. for(int i = 0; i < Constants.SEED_REWARD.length; i++) {
  70. if(item.getID() == Constants.SEED_REWARD[i] && !isOldReward(item.getID())) {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76.  
  77. }));
  78. if(seed != null && seed.length > 0) {
  79. moneyMade = getWoodcutting().getScript().getData().getMoneyMade();
  80. String seedName = seed[0].getDefinition().getName();
  81. int seedPrice = Zybez.getPrice(seedName.toLowerCase());
  82. getWoodcutting().getScript().getData().setMoneyMade(moneyMade + seedPrice);
  83. getWoodcutting().getScript().println("Found " + seedName + " worth "
  84. + getWoodcutting().getScript().setInMoneyFormat(seedPrice));
  85. getNestRewards()[nestRewardIndex++] = seed[0].getID();
  86. return;
  87. }
  88. @SuppressWarnings("unchecked")
  89. RSItem[] ring = Inventory.find(Inventory.generateFilterGroup(new Filter<RSItem>() {
  90.  
  91. @Override
  92. public boolean accept(RSItem item) {
  93. for(int i = 0; i < Constants.RING_REWARD.length; i++) {
  94. if(item.getID() == Constants.RING_REWARD[i] && !isOldReward(item.getID())) {
  95. return true;
  96. }
  97. }
  98. return false;
  99. }
  100.  
  101. }));
  102. if(ring != null && ring.length > 0) {
  103. moneyMade = getWoodcutting().getScript().getData().getMoneyMade();
  104. String ringName = ring[0].getDefinition().getName();
  105. int ringPrice = Zybez.getPrice(ringName.toLowerCase());
  106. getWoodcutting().getScript().getData().setMoneyMade(moneyMade + ringPrice);
  107. getWoodcutting().getScript().println("Found " + ringName + " worth "
  108. + getWoodcutting().getScript().setInMoneyFormat(ringPrice));
  109. getNestRewards()[nestRewardIndex++] = ring[0].getID();
  110. }*/ // UNSUPPORTED CODE
  111. }
  112. }
  113.  
  114. private String moneyFormat(double amount) {
  115. return getWoodcutting().getScript().setInMoneyFormat(amount);
  116. }
  117.  
  118. private RSGroundItem[] getNest() {
  119. return GroundItems.findNearest(Constants.BIRD_NEST);
  120. }
  121.  
  122. public boolean isOnGround() {
  123. if(getNest() != null && getNest().length > 0) {
  124. return true;
  125. }
  126. return false;
  127. }
  128.  
  129. private boolean isNestPickedUp(int id, int i) {
  130. while(Player.isMoving()) {
  131. getWoodcutting().getScript().sleep(40, 80);
  132. }
  133. long t = System.currentTimeMillis();
  134. while (Timing.timeFromMark(t) < i + General.random(100, 200)) {
  135. if (Inventory.getCount(id) > 0) {
  136. return true;
  137. }
  138. getWoodcutting().getScript().sleep(40, 80);
  139. }
  140. return false;
  141. }
  142.  
  143. public void setNestRewards(int[] nestRewards) {
  144. this.nestRewards = nestRewards;
  145. }
  146.  
  147. public int[] getNestRewards() {
  148. return nestRewards;
  149. }
  150.  
  151. public void setWoodcutting(Woodcutting woodcutting) {
  152. this.woodcutting = woodcutting;
  153. }
  154.  
  155. public Woodcutting getWoodcutting() {
  156. return woodcutting;
  157. }
  158.  
  159. public int getNestRewardIndex() {
  160. return nestRewardIndex;
  161. }
  162.  
  163. public void setNestRewardIndex(int nestRewardIndex) {
  164. this.nestRewardIndex = nestRewardIndex;
  165. }
  166.  
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement