Advertisement
Guest User

Untitled

a guest
Jun 5th, 2014
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. import org.tribot.api.DynamicClicking;
  2. import org.tribot.api.General;
  3. import org.tribot.api.Timing;
  4. import org.tribot.api.types.generic.Condition;
  5. import org.tribot.api2007.Banking;
  6. import org.tribot.api2007.Inventory;
  7. import org.tribot.api2007.NPCs;
  8. import org.tribot.api2007.Objects;
  9. import org.tribot.api2007.Player;
  10. import org.tribot.api2007.Walking;
  11. import org.tribot.api2007.WebWalking;
  12. import org.tribot.api2007.types.RSNPC;
  13. import org.tribot.api2007.types.RSObject;
  14. import org.tribot.api2007.types.RSTile;
  15. import org.tribot.script.Script;
  16. import org.tribot.script.ScriptManifest;
  17.  
  18. @ScriptManifest(authors = { "Podgorsek" }, category = "Woodcutting", name = "podChopper")
  19. public class PodChopp extends Script {
  20.  
  21. private RSTile last_tree_tile = null;
  22.  
  23. private boolean isAtTrees() {
  24.  
  25. final RSObject[] trees = Objects.findNearest(20, "Tree");
  26. if (trees.length < 1)
  27. return false;
  28. return trees[0].isOnScreen();
  29. }
  30.  
  31. private boolean isInBank() {
  32. final RSObject[] booths = Objects.findNearest(20, "Bank booth");
  33. if (booths.length > 1) {
  34. if (booths[0].isOnScreen())
  35. return true;
  36. }
  37. final RSNPC[] bankers = NPCs.findNearest("Banker");
  38. if (bankers.length < 1)
  39. return false;
  40. return bankers[0].isOnScreen();
  41. }
  42.  
  43. private boolean cut() {
  44. if (isCutting()) {
  45. final long timeout = System.currentTimeMillis()
  46. + General.random(60000, 90000);
  47. while (isCutting() && System.currentTimeMillis() < timeout) {
  48. sleep(100, 150);
  49. if (this.last_tree_tile != null) {
  50. if (!Objects.isAt(this.last_tree_tile, "Tree")) {
  51. break;
  52.  
  53. }
  54. }
  55. }
  56. }
  57.  
  58. final RSObject[] tree = Objects.findNearest(50, "Tree");
  59.  
  60. if (tree.length < 1)
  61. return false;
  62.  
  63. if (!tree[0].isOnScreen()) {
  64.  
  65. if (!Walking.walkPath(Walking.generateStraightPath(tree[0])))
  66. return false;
  67.  
  68. if (!Timing.waitCondition(new Condition() {
  69.  
  70. @Override
  71. public boolean active() {
  72. General.sleep(100);
  73.  
  74. return tree[0].isOnScreen();
  75. }
  76. }, General.random(8000, 9300)))
  77. return false;
  78. }
  79.  
  80. if (!DynamicClicking.clickRSObject(tree[0], "Chop down"))
  81. return false;
  82.  
  83. Timing.waitCondition(new Condition() {
  84.  
  85. @Override
  86. public boolean active() {
  87. return !isCutting();
  88. }
  89.  
  90. }, General.random(1000, 1200));
  91.  
  92. if (Timing.waitCondition(new Condition() {
  93.  
  94. @Override
  95. public boolean active() {
  96. return isCutting();
  97.  
  98. }
  99.  
  100. }, General.random(8000, 9000))) {
  101.  
  102. this.last_tree_tile = tree[0].getPosition().clone();
  103.  
  104. return true;
  105. }
  106. return false;
  107. }
  108.  
  109. private boolean isCutting() {
  110. return Player.getAnimation() > 0;
  111. }
  112.  
  113. private boolean walkToBank() {
  114. if (!WebWalking.walkToBank()) {
  115.  
  116. return false;
  117.  
  118. }
  119.  
  120. return Timing.waitCondition(new Condition() {
  121.  
  122. @Override
  123. public boolean active() {
  124. General.sleep(200, 300);
  125.  
  126. return isInBank();
  127. }
  128.  
  129. }, General.random(8000, 9000));
  130.  
  131. }
  132.  
  133. private boolean walkToTrees() {
  134. final RSObject[] trees = Objects.findNearest(50, "Tree");
  135. if (trees.length < 1)
  136.  
  137. return false;
  138.  
  139. if (!WebWalking.walkTo(trees[0]))
  140.  
  141. return false;
  142.  
  143. return Timing.waitCondition(new Condition() {
  144.  
  145. @Override
  146. public boolean active() {
  147. General.sleep(200, 300);
  148.  
  149. return isAtTrees();
  150.  
  151. }
  152.  
  153. }, General.random(8000, 9000));
  154.  
  155. }
  156.  
  157. private boolean bank() {
  158. if (!Banking.isBankScreenOpen()) {
  159.  
  160. if (!Banking.openBank())
  161.  
  162. return false;
  163.  
  164. }
  165.  
  166. final String[] axe_names = { "Bronze axe", "Iron axe", "Black axe",
  167. "Steel axe", "Mithril axe", "Adamant axe", "Rune axe",
  168. "Dragon axe" };
  169.  
  170. if (Inventory.find(axe_names).length > 0) {
  171.  
  172. if (Banking.depositAllExcept(axe_names) < 1)
  173.  
  174. return false;
  175.  
  176. } else {
  177. if (Banking.depositAll() < 1)
  178.  
  179. return false;
  180. }
  181.  
  182. return Timing.waitCondition(new Condition() {
  183.  
  184. @Override
  185. public boolean active() {
  186. return !Inventory.isFull();
  187.  
  188. }
  189.  
  190. }, General.random(3000, 4000));
  191.  
  192. }
  193.  
  194. @Override
  195. public void run() {
  196. while (true) {
  197. sleep(50);
  198.  
  199. if (isAtTrees()) {
  200. if (Inventory.isFull()) {
  201. walkToBank();
  202.  
  203. } else
  204. cut();
  205.  
  206. } else if (isInBank()) {
  207. if (Inventory.isFull())
  208. bank();
  209.  
  210. else {
  211. walkToTrees();
  212. }
  213.  
  214. } else {
  215.  
  216. if (Inventory.isFull())
  217. walkToBank();
  218. else
  219. walkToTrees();
  220.  
  221. }
  222. }
  223.  
  224. }
  225. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement