Advertisement
Guest User

CortadorBasico v1.0.1

a guest
Feb 28th, 2018
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. package CortadorBasico;
  2.  
  3. import java.awt.Graphics;
  4.  
  5. import org.dreambot.api.methods.Calculations;
  6. import org.dreambot.api.methods.container.impl.bank.BankLocation;
  7. import org.dreambot.api.methods.map.Area;
  8. import org.dreambot.api.methods.map.Tile;
  9. import org.dreambot.api.methods.skills.Skill;
  10. import org.dreambot.api.script.AbstractScript;
  11. import org.dreambot.api.script.ScriptManifest;
  12. import org.dreambot.api.script.listener.InventoryListener;
  13. import org.dreambot.api.utilities.Timer;
  14. import org.dreambot.api.script.Category;
  15. import org.dreambot.api.wrappers.interactive.GameObject;
  16. import org.dreambot.api.wrappers.items.Item;
  17.  
  18. @ScriptManifest(author = "henrique190", name = "CortadorBasico", version = 1.0, description = "Corta logs acima de draynor", category = Category.WOODCUTTING)
  19. public class CortadorBasico extends AbstractScript implements InventoryListener {
  20.  
  21. String log = "Iniciando o script";
  22. Timer tempo;
  23. int cont = 0;
  24. Tile tiledraynorbank = new Tile(11055,4782);
  25. Area arvoreArea = new Area(new Tile(3074, 3265), new Tile(3086, 3264), new Tile(3086, 3276), new Tile(3077, 3278),
  26. new Tile(3073, 3274));
  27. Area willowArea = new Area(new Tile(3055, 3251), new Tile(3064, 3251), new Tile(3064, 3258), new Tile(3056, 3257));
  28. GameObject depositbox; // depositbox
  29. Tile depositboxtile = new Tile(3045, 3234); // tile of the depositbox
  30. Skill wc = Skill.WOODCUTTING;
  31. String axes[] = {"Bronze axe","Iron axe", "Steel axe", "Black axe", "Mithril axe", "Adamant axe", "Rune axe", "Dragon axe"};
  32. BankLocation bankLocation;
  33.  
  34.  
  35.  
  36.  
  37. /* private void getAxe(String a) {
  38. if (tiledraynorbank.distance(getLocalPlayer()) <= 4) {
  39. if (getBank().isOpen()) {
  40. log = "Retirando";
  41. getBank().withdraw(a);
  42.  
  43. } else {
  44. getBank().open();
  45. getBank().withdraw(a);
  46. }
  47.  
  48. } else {
  49. log = "indo trocar axe";
  50. getWalking().walk(tiledraynorbank);
  51. sleep(Calculations.random(1827, 2482));
  52. }
  53.  
  54.  
  55. }*/
  56.  
  57. /* private void checkAxes(String a[], int lvl){
  58. if(lvl <= 20 && !getInventory().contains(a[0])) {
  59. getAxe(a[0]);
  60. }else if(lvl >= 20 && lvl <= 30 && !getInventory().contains(a[4])) {
  61. getAxe(a[4]);
  62. }else if(lvl >= 31 && lvl <= 40 && !getInventory().contains(a[5])) {
  63. getAxe(a[5]);
  64. }
  65. else if(lvl >= 41 && !getInventory().contains(a[6])) {
  66. getAxe(a[6]);
  67. }
  68. }*/
  69.  
  70. private int verificalvl() {
  71. int lvl = getSkills().getRealLevel(wc);
  72. return lvl;
  73. }
  74.  
  75. private String verificaTipo(int a) {
  76. String tipo = "";
  77. if (a >= 30) {
  78. tipo = "Willow";
  79. return tipo;
  80. } else {
  81. tipo = "Tree";
  82. return tipo;
  83. }
  84. }
  85.  
  86. private Area verificaArea(String a) {
  87. if (a == "Tree") {
  88. return arvoreArea;
  89.  
  90. } else {
  91. return willowArea;
  92. }
  93.  
  94. }
  95.  
  96. private void chopTree(String nameOfTree) {
  97. GameObject tree = getGameObjects()
  98. .closest(gameObject -> gameObject != null && gameObject.getName().equals(nameOfTree));
  99. if (tree != null && tree.interact("Chop down")) {
  100. int countLog = getInventory().count("Logs");
  101. sleepUntil(() -> getInventory().count("Logs") > countLog, 12000);
  102. }
  103. }
  104.  
  105. public void onStart() {
  106. // TODO Auto-generated method stub
  107. super.onStart();
  108. tempo = new Timer();
  109. }
  110.  
  111. @Override
  112. public int onLoop() {
  113.  
  114. if (!getInventory().isFull()) {
  115. //checkAxes(axes, verificalvl());
  116. if (verificaArea(verificaTipo(verificalvl())).contains(getLocalPlayer())) {
  117.  
  118. chopTree(verificaTipo(verificalvl()));
  119. log = "Cortando Tree";
  120. verificalvl();
  121.  
  122. } else {
  123.  
  124. getWalking().walk(verificaArea(verificaTipo(verificalvl())).getRandomTile());
  125. sleep(Calculations.random(1827, 2482));
  126. log = "Indo para a area";
  127. }
  128.  
  129. } else {
  130. if (depositboxtile.distance(getLocalPlayer()) <= 4) {
  131. if (getDepositBox().isOpen()) {
  132. log = "Depositando";
  133. getDepositBox().depositAllItems();
  134.  
  135. } else {
  136. log = "Abrindo o Depositador";
  137. depositbox = getGameObjects().closest(
  138. d -> d != null && d.getName().equals("Bank deposit box") && d.hasAction("Deposit"));
  139. depositbox.interact("Deposit");
  140. sleepUntil(() -> getDepositBox().isOpen(), Calculations.random(929, 1845));
  141. }
  142. } else {
  143. log = "indo depositar";
  144. getWalking().walk(depositboxtile);
  145. sleep(Calculations.random(1827, 2482));
  146. }
  147.  
  148. }
  149.  
  150. return Calculations.random(500, 600);
  151. }
  152.  
  153. @Override
  154. public void onPaint(Graphics g) {
  155. // TODO Auto-generated method stub
  156. g.drawString("Timer: " + tempo.formatTime(), 20, 200);
  157. g.drawString("action: " + log, 20, 220);
  158. g.drawString("Logs Choped: " + cont , 20, 240);
  159. g.drawString("WC lvl: " + verificalvl() , 20, 260);
  160. g.drawString("Cortando: " + verificaTipo(verificalvl()) , 20, 280);
  161.  
  162. }
  163.  
  164. @Override
  165. public void onItemChange(Item[] items) {
  166. for (Item item : items) {
  167. if(item != null && item.getName().contains("ogs")) {
  168. cont++;
  169. }
  170. }
  171.  
  172. }
  173.  
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement