Codydude56

Draynor Chop'n'Bank

Mar 25th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. import java.awt.*;
  2.  
  3. import org.vinsert.bot.script.*;
  4. import org.vinsert.bot.script.api.GameObject;
  5. import org.vinsert.bot.script.api.tools.Navigation.NavigationPolicy;
  6. import org.vinsert.bot.script.api.tools.Skills;
  7. import org.vinsert.bot.util.Filter;
  8.  
  9. @ScriptManifest(authors = { "Coordinates" }, name = "Draynor Chop'n'Bank", description = "Chops logs at Draynor and banks them.", version = 1.0)
  10. public class DraynorChopper extends Script {
  11.  
  12. @Override
  13. public void render(Graphics2D arg0) {
  14. runtime = System.currentTimeMillis() - startTime;
  15. xpGained = (skills.getExperience(Skills.WOODCUTTING) - xpStart);
  16. lvlCurrent = skills.getLevel(Skills.WOODCUTTING);
  17. int lvlGain = (lvlCurrent - lvlStart);
  18. int xpHour = (int) ((double) xpGained / runtime * 3600000);
  19. int stealsHour = (int) ((double) totalLogs / runtime * 3600000);
  20.  
  21. Graphics2D g = (Graphics2D) arg0;
  22. g.setColor(color1);
  23. g.fillRect(237, 258, 271, 69);
  24. g.setColor(color3);
  25. g.setStroke(stroke1);
  26. g.drawRect(237, 258, 271, 69);
  27. g.setFont(font1);
  28. g.drawString("Draynor C'n'B by Coordinates", 241, 271);
  29. g.drawLine(237, 273, 508, 273);
  30. g.drawString("Logs: " + totalLogs, 241, 291);
  31. g.drawString("XP Gained: " + xpGained, 241, 308);
  32. g.drawString("Current Level: " + lvlCurrent + "(+" + lvlGain + ")",
  33. 241, 323);
  34. g.drawString("XP/Hour: " + xpHour, 374, 308);
  35. g.drawString("Logs/HR: " + stealsHour, 374, 291);
  36. g.drawString("Run time:" + timeToString((int) runtime), 374, 323);
  37. g.drawString("Version 1.00", 435, 271);
  38. }
  39.  
  40. @Override
  41. public void close() {
  42. log("Thank you for using Draynor Chop'n'Bank by Coordinates.");
  43. }
  44.  
  45. @Override
  46. public boolean init() {
  47. startTime = System.currentTimeMillis();
  48. startLogs = inventory.getCount(false, 1520);
  49. lvlStart = skills.getLevel(Skills.WOODCUTTING);
  50. xpStart = skills.getExperience(Skills.WOODCUTTING);
  51. return true;
  52. }
  53.  
  54. @Override
  55. public int pulse() {
  56. tempLogs = inventory.getCount(false, 1520) - startLogs;
  57. totalLogs = currentLogs + tempLogs;
  58. if (!inventory.isFull()) {
  59. doChop();
  60. }
  61. if (inventory.isFull()) {
  62. doBank();
  63. }
  64. return 1;
  65. }
  66.  
  67. public void doBank() {
  68. Filter<GameObject> booth = new Filter<GameObject>() {
  69. int booth = 16937;
  70.  
  71. public boolean accept(GameObject o) {
  72. return o.getId() == this.booth;
  73. }
  74. };
  75. GameObject bankbooth = objects.getNearest(booth);
  76. if (players.getLocalPlayer().getLocation()
  77. .distanceTo(bankbooth.getLocation()) < 6) {
  78. if (bank.isOpen()) {
  79. currentLogs += inventory.getCount(false, 1520) - startLogs;
  80. startLogs = 0;
  81. bank.depositAll();
  82. sleep(1250);
  83. } else {
  84. bankbooth.interact("Bank");
  85. sleep(1250);
  86. }
  87. }
  88. if (players.getLocalPlayer().getLocation()
  89. .distanceTo(bankbooth.getLocation()) > 6
  90. && !players.getLocalPlayer().isMoving()) {
  91. navigation.navigate(bankbooth.getLocation(),
  92. NavigationPolicy.MINIMAP);
  93. }
  94. }
  95.  
  96. public void doChop() {
  97. final int tree1 = 17771;
  98. final int tree2 = 17772;
  99. final int tree3 = 16711;
  100. Filter<GameObject> tree = new Filter<GameObject>() {
  101. public boolean accept(GameObject o) {
  102. if (o.getId() == tree1) {
  103. return true;
  104. } else {
  105. return false;
  106. }
  107. }
  108. };
  109. GameObject trees = objects.getNearest(tree);
  110. if (players.getLocalPlayer().getLocation()
  111. .distanceTo(trees.getLocation()) > 7
  112. && !players.getLocalPlayer().isMoving()) {
  113. navigation.navigate(trees.getLocation(), NavigationPolicy.MINIMAP);
  114. sleep(2500);
  115. }
  116. if (players.getLocalPlayer().getLocation()
  117. .distanceTo(trees.getLocation()) < 7) {
  118. if (players.getLocalPlayer().getAnimation() == 867) {
  119. sleep(500);
  120. } else {
  121. trees.interact("Chop down");
  122. sleep(1000);
  123. }
  124. }
  125. }
  126.  
  127. public static String timeToString(int time) {
  128. int seconds = (int) (time / 1000) % 60;
  129. int minutes = (int) ((time / (1000 * 60)) % 60);
  130. int hours = (int) ((time / (1000 * 60 * 60)) % 24);
  131. return (hours < 10 ? "0" + hours : hours) + ":"
  132. + (minutes < 10 ? "0" + minutes : minutes) + ":"
  133. + (seconds < 10 ? "0" + seconds : seconds);
  134. }
  135.  
  136. int tempLogs;
  137. int startLogs;
  138. int currentLogs = 0;
  139. int totalLogs;
  140. long runtime;
  141. int xpGained;
  142. int lvlCurrent;
  143. int xpStart;
  144. int lvlStart;
  145. long startTime;
  146. private final Color color1 = new Color(34, 139, 34, 151);
  147. private final Color color3 = new Color(255, 255, 255);
  148. private final BasicStroke stroke1 = new BasicStroke(1);
  149. private final Font font1 = new Font("Arial", 0, 13);
  150.  
  151. }
Add Comment
Please, Sign In to add comment