Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1. import java.awt.Graphics2D;
  2. import java.util.concurrent.TimeUnit;
  3.  
  4. import org.osbot.rs07.api.map.Area;
  5. import org.osbot.rs07.api.map.Position;
  6. import org.osbot.rs07.api.model.Entity;
  7. import org.osbot.rs07.api.ui.Message;
  8. import org.osbot.rs07.api.ui.Message.MessageType;
  9. import org.osbot.rs07.api.ui.Skill;
  10. import org.osbot.rs07.script.Script;
  11. import org.osbot.rs07.script.ScriptManifest;
  12.  
  13. @ScriptManifest(author = "You", info = "My first script", name = "cutter", version = 0, logo = "")
  14. public class Yews extends Script {
  15. private long timeBegan;
  16. private long timeRan;
  17. private int beginningXP;
  18. private int currentXp;
  19. private int xpGained;
  20. private int currentLevel;
  21. private int beginningLevel;
  22. private int levelsGained;
  23. private int logsCut = 0;
  24.  
  25.  
  26. /** YOUR VARIABLES */
  27. private static final Area BANK_AREA = new Area(3092, 3245, 3094, 3242);
  28. Area TREE_AREA = new Area(3056,3269,3051,3274);
  29.  
  30. @Override
  31. public void onMessage(Message c) {
  32. if (c.getType() == MessageType.GAME) {
  33. String m = c.getMessage();
  34. try {
  35. if (m.contains("You get some yew logs.")) {
  36. logsCut++;
  37. }
  38. } catch (Exception exception) {
  39. exception.printStackTrace();
  40. }
  41. }
  42. }
  43.  
  44.  
  45. @Override
  46.  
  47. public void onStart() {
  48.  
  49. beginningLevel = skills.getStatic(Skill.WOODCUTTING);
  50. timeBegan = System.currentTimeMillis();
  51. beginningXP = skills.getExperience(Skill.WOODCUTTING);
  52. log("Let's get started!");
  53. log("gl with the ban this anti ban sucks ass");
  54. }
  55.  
  56. private enum State {
  57. CUT, BANKING, BANKING_REAL, WAIT, WALK_TO_TREE
  58. };
  59.  
  60. private State getState() {
  61. Entity tree = objects.closest("Yew");
  62. if(BANK_AREA.contains(myPlayer()) && !inventory.isFull() && !TREE_AREA.contains(myPlayer()))
  63. return State.WALK_TO_TREE;
  64. if (inventory.isFull() && !BANK_AREA.contains(myPlayer()))
  65. return State.BANKING;
  66. if (inventory.isFull() && BANK_AREA.contains(myPlayer()))
  67. return State.BANKING_REAL;
  68. if (tree != null && tree.isVisible() && !inventory.isFull() && !myPlayer().isAnimating()
  69. && !myPlayer().isMoving())
  70. return State.CUT;
  71. return State.WAIT;
  72. }
  73.  
  74. @Override
  75. public int onLoop() throws InterruptedException {
  76. switch (getState()) {
  77. case CUT:
  78. Entity Tree = objects.closest("Yew");
  79. if (Tree != null && Tree.isVisible()) {
  80. Tree.interact("Chop down");
  81. return(random(600, 1200));
  82. }
  83. break;
  84. case WALK_TO_TREE:
  85. getWalking().webWalk(TREE_AREA);
  86. break;
  87. case BANKING:
  88. getWalking().webWalk(BANK_AREA);
  89. break;
  90. case BANKING_REAL:
  91. if (bank.isOpen()) {
  92. getBank().bank.depositAllExcept("Rune Axe");
  93. } else {
  94. getBank().open();
  95. }
  96. case WAIT:
  97. sleep(random(1000, 2000));
  98. break;
  99. }
  100. return random(3000, 4000);
  101. }
  102.  
  103. @Override
  104. public void onExit() {
  105. log("Thanks for running my Wood Cutter!");
  106. }
  107.  
  108.  
  109. @Override
  110. public void onPaint(Graphics2D g) {
  111. g.drawString("Logs cut: " + logsCut , 288, 62);
  112. levelsGained = currentLevel - beginningLevel;
  113. g.drawString("Levels gained " + levelsGained, 266, 327);
  114. currentLevel = skills.getStatic(Skill.WOODCUTTING);
  115. g.drawString("Starting Level " + beginningLevel, 255,273);
  116. g.drawString("Current Level " + currentLevel, 492,309);
  117. currentXp = skills.getExperience(Skill.WOODCUTTING);
  118. xpGained = currentXp - beginningXP;
  119. g.drawString("XP gained " + xpGained, 60, 302);
  120. timeRan = System.currentTimeMillis() - this.timeBegan;
  121. g.drawString(ft(timeRan), 53, 66);
  122. }
  123. private String ft(long duration)
  124. {
  125. String res = "";
  126. long days = TimeUnit.MILLISECONDS.toDays(duration);
  127. long hours = TimeUnit.MILLISECONDS.toHours(duration)
  128. - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  129. long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  130. - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  131. .toHours(duration));
  132. long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  133. - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  134. .toMinutes(duration));
  135. if (days == 0) {
  136. res = (hours + ":" + minutes + ":" + seconds);
  137. } else {
  138. res = (days + ":" + hours + ":" + minutes + ":" + seconds);
  139. }
  140. return res;
  141. }
  142.  
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement