Advertisement
Guest User

wizy

a guest
Aug 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.82 KB | None | 0 0
  1. package Main;
  2.  
  3. import org.dreambot.api.methods.Calculations;
  4. import org.dreambot.api.methods.container.impl.bank.Bank;
  5. import org.dreambot.api.methods.map.Area;
  6. import org.dreambot.api.methods.map.Tile;
  7. import org.dreambot.api.methods.skills.Skill;
  8. import org.dreambot.api.script.AbstractScript;
  9. import org.dreambot.api.script.Category;
  10. import org.dreambot.api.script.ScriptManifest;
  11. import org.dreambot.api.wrappers.interactive.GameObject;
  12. import org.dreambot.api.wrappers.interactive.NPC;
  13. import org.dreambot.api.methods.skills.Skills;
  14. import sun.reflect.generics.tree.Tree;
  15. import java.awt.*;
  16.  
  17. import static org.dreambot.api.script.Category.WOODCUTTING;
  18.  
  19. @ScriptManifest(category = WOODCUTTING, name = "my first script", author = "Mjwizy", version = 1.3)
  20. public class Main extends AbstractScript{
  21.  
  22. //banking & tree areas
  23. //bank areas
  24. Area bankAreadraynor = new Area(3092, 3240, 3097, 3246, 0);
  25. // Area bankAreaLumbridge = new Area(3209, 3220, 3208, 3220, 2);
  26. //tree areas
  27. Area yewtreeArea = new Area(3145, 3256, 3164, 3219, 0);
  28. Area treetooaktreeArea = new Area(3167, 3243, 3198, 3207, 0);
  29. Area WillowtreeArea = new Area(3087, 3230, 3090, 3226, 0);
  30. // int for wc lvl
  31. public int wcLevel;
  32. //timer for checking wc lvl set to 20 to check in the beginnign
  33. int timepassed = 20;
  34.  
  35. //log hi for start of program
  36. @Override
  37. public void onStart (){
  38. log("Hi");
  39. }
  40. //start of bot
  41. @Override public int onLoop() {
  42.  
  43. if (timepassed == 20) {
  44. // Grab wc lvl
  45. wcLevel = getSkills().getRealLevel(Skill.WOODCUTTING);
  46. log("wc time pass reset");
  47. log(wcLevel);
  48. timepassed = 0;
  49. }
  50. // add one to the timepass
  51. timepassed ++;
  52. // walk to bank
  53. if (getInventory().isFull() && !bankAreadraynor.contains(getLocalPlayer())) {
  54. log("walk to bank in lumbridge");
  55. while (!bankAreadraynor.contains(getLocalPlayer())) {
  56. if (getWalking().shouldWalk(Calculations.random(10, 12))) {
  57. getWalking().walk(bankAreadraynor.getRandomTile());
  58. }
  59. }
  60. }
  61. // walk for normal and oak trees
  62. if(!getInventory().isFull() && !treetooaktreeArea.contains(getLocalPlayer()) && wcLevel >= 1 && wcLevel <= 29) {
  63. log("walk behind lumbridge");
  64. while (!treetooaktreeArea.contains(getLocalPlayer())) {
  65. if (getWalking().shouldWalk(Calculations.random(10, 12))) {
  66. getWalking().walk(treetooaktreeArea.getRandomTile());
  67. }
  68. }
  69. }
  70. // chop normal tree
  71. if (!getInventory().isFull() && treetooaktreeArea.contains(getLocalPlayer())&& wcLevel >= 1 && wcLevel <= 14) {
  72. log("prepare to cut normal tree");
  73. if (!getLocalPlayer().isAnimating() && (!getLocalPlayer().isMoving())) {
  74. chopTree("Tree");
  75. sleep(Calculations.random(1000,3000));
  76. }
  77. }
  78. // chop oak tree
  79. if (!getInventory().isFull() && treetooaktreeArea.contains(getLocalPlayer())&& wcLevel >= 15 && wcLevel <= 29) {
  80. log("prepare to cut oak tree");
  81. if (!getLocalPlayer().isAnimating() && (!getLocalPlayer().isMoving())) {
  82. chopoakTree("Oak");
  83. sleep(Calculations.random(3000,4000));
  84. }
  85. }
  86. // walk to willows
  87. if(!getInventory().isFull() && !WillowtreeArea.contains(getLocalPlayer()) && wcLevel >= 30 && wcLevel <= 59) {
  88. log("walk to willows in draynor");
  89. while (!WillowtreeArea.contains(getLocalPlayer())) {
  90. if (getWalking().shouldWalk(Calculations.random(10, 12))) {
  91. getWalking().walk(WillowtreeArea.getRandomTile());
  92. }
  93. }
  94. }
  95. // chop willow tree
  96. if (!getInventory().isFull() && WillowtreeArea.contains(getLocalPlayer())&& wcLevel >= 30 && wcLevel <= 59) {
  97. log("prepare to cut willow tree");
  98. if (!getLocalPlayer().isAnimating() && (!getLocalPlayer().isMoving())) {
  99. chopwillowTree("Willow");
  100. sleep(Calculations.random(3000,4000));
  101. }
  102. }
  103. // walk to yew tree area
  104. if(!getInventory().isFull() && !yewtreeArea.contains(getLocalPlayer()) && wcLevel >= 60) {
  105. log("walk to yews in draynor");
  106. while (!yewtreeArea.contains(getLocalPlayer())) {
  107. if (getWalking().shouldWalk(Calculations.random(10, 12))) {
  108. getWalking().walk(yewtreeArea.getRandomTile());
  109. }
  110. }
  111. }
  112. // chop yew tree
  113. if (!getInventory().isFull() && yewtreeArea.contains(getLocalPlayer())&& wcLevel >= 60) {
  114. log("prepare to cut yew tree");
  115. if (!getLocalPlayer().isAnimating() && (!getLocalPlayer().isMoving())) {
  116. chopyewTree("Yew");
  117. sleep(Calculations.random(3000,4000));
  118. }
  119. }
  120. //Bank at Lumbridge or draynor
  121. if(getInventory().isFull() && bankAreadraynor.contains(getLocalPlayer())){
  122. log("Banking");
  123. bank();
  124. }
  125. return 5000;
  126. }
  127. //allows to log wclvl
  128. private void log(int wcLevel) {
  129. }
  130. @Override
  131. public void onExit(){
  132. }
  133. //chop normal tree
  134. private void chopTree(String Tree) {
  135. log("chop tree");
  136. GameObject treenormal = getGameObjects().closest(gameObject -> gameObject.getName().equals("Tree"));
  137. if(treenormal != null && treenormal.interact("Chop down")) {
  138. }else{
  139. sleep(1000,1500);
  140. }
  141. }
  142. //chop oak tree
  143. private void chopoakTree(String Oak) {
  144. log("chop oak tree");
  145. GameObject treeoak = getGameObjects().closest(gameObject -> gameObject.getName().equals("Oak"));
  146. if(treeoak != null && treeoak.interact("Chop down")) {
  147. }else{
  148. sleep(1000,1500);
  149. }
  150. }
  151. //Choop willow tree
  152. private void chopwillowTree(String Willow) {
  153. log("willow tree");
  154. GameObject treewillow = getGameObjects().closest(gameObject -> gameObject.getName().equals("Willow")
  155. && gameObject.isOnScreen()) ;
  156. if(treewillow != null && treewillow.interact("Chop down")) {
  157. }else{
  158. sleep(1000,1500);
  159. }
  160. }
  161. //chop yew tree
  162. private void chopyewTree(String Yew) {
  163. log("chop yew tree");
  164. GameObject treeyew = getGameObjects().closest(tree -> (tree != null) && tree.getName().equals("Yew") && tree.hasAction("Chop Down"));
  165. if (treeyew.interact("Chop Down")){
  166. treeyew.interact("Chop down");
  167. while(getLocalPlayer().isAnimating()){
  168. // Pretty much just wait here while you're chopping it down
  169. }
  170. sleep(1000,1500); // Realism break after tree is chopped down
  171. }
  172. }
  173. //bank
  174. private void bank() {
  175. NPC banker = getNpcs().closest(npc -> npc != null && npc.hasAction("Bank"));
  176. log("clicked on banker");
  177. if(banker.interact("Bank")) {
  178. if (sleepUntil(() -> getBank().isOpen(), 7000)) {
  179. log("bank menu opened");
  180. if (getBank().depositAllExcept(item -> item != null && item.getName().contains("axe"))) {
  181. log("banked all items");
  182. if (sleepUntil(() -> !getInventory().isFull(), 5000)) {
  183. if (getBank().close()) {
  184. log("close bank");
  185. sleepUntil(() -> !getBank().isOpen(), 8000);
  186. log("banking completed");
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement