brookshirek

RS WoodCutter Revised

Jan 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. import org.dreambot.api.input.Mouse;
  2. import org.dreambot.api.methods.Calculations;
  3. import org.dreambot.api.methods.container.impl.bank.BankLocation;
  4. import org.dreambot.api.methods.MethodProvider;
  5. import org.dreambot.api.methods.filter.Filter;
  6. import org.dreambot.api.methods.map.Area;
  7. import org.dreambot.api.methods.map.Tile;
  8. import org.dreambot.api.methods.widget.Widget;
  9. import org.dreambot.api.script.AbstractScript;
  10. import org.dreambot.api.script.Category;
  11. import org.dreambot.api.script.ScriptManifest;
  12. import org.dreambot.api.utilities.impl.Condition;
  13. import org.dreambot.api.wrappers.interactive.GameObject;
  14. import org.dreambot.api.wrappers.items.Item;
  15. import org.dreambot.api.wrappers.widgets.WidgetChild;
  16.  
  17. @ScriptManifest(category = Category.WOODCUTTING, name = "Cosmic's Woodcutter", author = "Cosmic", version = 3.1)
  18. public class WoodCut extends AbstractScript{
  19. int[] worlds = {301, 326, 393};
  20. public static final String TREE = "Tree";
  21. public static final String AXE = " axe";
  22. Area cutArea = new Area(3280,3442, 3274, 3457);
  23. // TREE cut = TREE.COMMON;
  24.  
  25. /* public GameObject getTrees(){
  26. MethodProvider.log("Looking for trees");
  27. int[] ids;
  28. int count =0;
  29. for(int id: cut.name)
  30. count+=1;
  31.  
  32. ids = new int[count];
  33. count=0;
  34. for(int id: cut.name){
  35. ids[count]=id;
  36. count+=1;
  37. }
  38. return getGameObjects().closest(new Filter<GameObject>(){
  39.  
  40. @Override
  41. public boolean match(GameObject obj) {
  42.  
  43. for(int id: ids)
  44. if(obj.getID()==id)
  45. return true;
  46. return false;
  47. }
  48.  
  49. });
  50. }*/
  51.  
  52. @Override
  53. public void onStart() {
  54. log("Welcome to Cosmic's Wootcutter!");
  55.  
  56.  
  57. }
  58.  
  59. @Override
  60. public int onLoop() {
  61. log("sup");
  62. if(!getLocalPlayer().isAnimating()) {
  63. if(getInventory().isFull()) {
  64. if(getBank().isOpen()) {
  65.  
  66. getBank().depositAllExcept(item -> item != null && item.getName().contains(AXE));
  67. sleep(Calculations.random(10000, 60000));
  68. }else {
  69. getBank().open(BankLocation.VARROCK_EAST);
  70. }
  71. }else if(cutArea.contains(getLocalPlayer())){
  72. log("tup");
  73. chopTree("Tree");//issue right here see method
  74. /* if(tree != null) {
  75. getCamera().mouseRotateToEntity(tree);
  76. sleep(Calculations.random(100, 300));
  77. tree.getClickablePoint();
  78. tree.interact("Chop down"); */
  79. int ran = Calculations.random(0,10);
  80. if (ran == 0) {
  81. getSkills().open();
  82. }else if(ran == 1) {
  83. getWorldHopper().openWorldHopper();
  84. sleep(Calculations.random(1000,5000));
  85. int ranr = Calculations.random(0,25);
  86. if(ranr == 22) {
  87. getWorldHopper().hopWorld(worlds[Calculations.random(0,2)]);
  88. }else {
  89. getWorldHopper().closeWorldHopper();
  90. }
  91. }
  92. sleep(Calculations.random(1500,2000));
  93. }
  94. else {
  95. getWalking().walk(cutArea.getRandomTile());
  96. }
  97. }
  98. return Calculations.random(1000, 5000);
  99. }
  100. private void chopTree(String nameOfTree) {
  101. log("mup");
  102. GameObject tree = getGameObjects().closest(gameObject -> gameObject != null
  103. && gameObject.getName().equals(nameOfTree)); // issue right here!
  104. log("vup");
  105. if (tree != null && tree.interact("Chop down")) {
  106. int countLog = getInventory().count("logs");
  107. sleepUntil(() -> getInventory().count("logs") > countLog, 12000);
  108. }
  109. }
  110. }
  111. // @Override
  112. /* public enum TREE{
  113. COMMON("Tree", 1, new Area());
  114. private String name;
  115. private int level;
  116. private Area area;
  117. TREE(String name, int level, Area area){
  118. this.name = name;
  119. this.level = level;
  120. this.area = area;
  121. }
  122.  
  123. }*/
Advertisement
Add Comment
Please, Sign In to add comment