Advertisement
CALEMXS

elder choper

Aug 9th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. package com.calems.bots.elder;
  2.  
  3. import com.runemate.game.api.client.paint.PaintListener;
  4. import com.runemate.game.api.hybrid.RuneScape;
  5. import com.runemate.game.api.hybrid.entities.GameObject;
  6. import com.runemate.game.api.hybrid.entities.Player;
  7. import com.runemate.game.api.hybrid.entities.definitions.ItemDefinition;
  8. import com.runemate.game.api.hybrid.local.Camera;
  9. import com.runemate.game.api.hybrid.local.Skill;
  10. import com.runemate.game.api.hybrid.local.hud.interfaces.Bank;
  11. import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
  12. import com.runemate.game.api.hybrid.location.Area;
  13. import com.runemate.game.api.hybrid.location.Coordinate;
  14. import com.runemate.game.api.hybrid.location.navigation.Path;
  15. import com.runemate.game.api.hybrid.location.navigation.basic.PredefinedPath;
  16. import com.runemate.game.api.hybrid.region.GameObjects;
  17. import com.runemate.game.api.hybrid.region.Players;
  18. import com.runemate.game.api.hybrid.util.StopWatch;
  19. import com.runemate.game.api.rs3.net.GrandExchange;
  20. import com.runemate.game.api.rs3.net.GrandExchange.Item;
  21. import com.runemate.game.api.script.Execution;
  22. import com.runemate.game.api.script.framework.LoopingScript;
  23. import com.runemate.game.api.script.framework.listeners.InventoryListener;
  24. import com.runemate.game.api.script.framework.listeners.SkillListener;
  25. import com.runemate.game.api.script.framework.listeners.events.ItemEvent;
  26. import com.runemate.game.api.script.framework.listeners.events.SkillEvent;
  27.  
  28. import java.awt.*;
  29.  
  30. public class chopper extends LoopingScript implements PaintListener, InventoryListener, SkillListener {
  31.  
  32. private final static Player player = Players.getLocal();
  33. private final static String LOG = "Elder Tree";
  34. private final static Area chopArea = new Area.Rectangular(new Coordinate(cord, cord, c), new Coordinate(cord, cord, c));
  35. private final static Area bankArea = new Area.Rectangular(new Coordinate(cord, cord, c), new Coordinate(cord, cord, c));
  36. private final static StopWatch runtime = new StopWatch();
  37. private static int logCount = 0;
  38. private static int logPrice = 0;
  39. private static int levelsGained = 0;
  40.  
  41. private static boolean isInChop() {
  42. return chopArea.contains(player);
  43. }
  44.  
  45. private static boolean isInBank() {
  46. return bankArea.contains(player);
  47. }
  48.  
  49. @Override
  50. public void onStart(String... args) {
  51. setLoopDelay(250, 700);
  52. getEventDispatcher().addListener(this);
  53. final Item oreGE = GrandExchange.lookup(438);
  54. if (oreGE != null) logPrice = oreGE.getPrice();
  55. runtime.start();
  56. }
  57.  
  58. @Override
  59. public void onLoop() {
  60. GameObject ore = GameObjects.newQuery().names(LOG).within(chopArea).results().nearest();
  61. GameObject minedOre = GameObjects.newQuery().names("Logs").within(chopArea).results().nearest();
  62.  
  63. if (!Inventory.isFull() && ChopisIn()) { // cutting
  64. if (ore != null && isIdle() && ore.isVisible()) {
  65. if (ore.interact("Chop down"))
  66. Execution.delayWhile(player::isMoving, 250, 350);
  67. } else if (ore != null && ore.isVisible() && minedOre != null && player.isFacing(minedOre)) {
  68. if (ore.interact("Chop down"))
  69. Execution.delayWhile(player::isMoving, 250, 350);
  70. } else if (ore != null && !ore.isVisible()) {
  71. Camera.turnTo(ore);
  72. }
  73. } else if (Inventory.isFull() && !isInBank()) { // WalkingToBank to bank
  74. final Path bankPath = PredefinedPath.create(new Coordinate(3285, 3366, 0), new Coordinate(3287, 3371, 0), new Coordinate(3290, 3375, 0), new Coordinate(3293, 3380, 0), new Coordinate(3292, 3385, 0), new Coordinate(3292, 3392, 0), new Coordinate(3292, 3397, 0), new Coordinate(3292, 3404, 0), new Coordinate(3292, 3405, 0), new Coordinate(3288, 3412, 0), new Coordinate(3286, 3417, 0), new Coordinate(3283, 3420, 0), new Coordinate(3280, 3425, 0), new Coordinate(3275, 3428, 0), new Coordinate(3269, 3428, 0), new Coordinate(3264, 3428, 0), new Coordinate(3259, 3428, 0), new Coordinate(3254, 3426, 0), new Coordinate(3254, 3422, 0));
  75.  
  76. bankPath.step();
  77. } else if (Inventory.isFull() && isIdle() && isInBank()) { // Banking.
  78. if (!Bank.isOpen()) {
  79. Bank.open();
  80. Execution.delayUntil(Bank::isOpen, 250, 2000);
  81. } else {
  82. Bank.depositInventory();
  83. Execution.delayUntil(Inventory::isEmpty, 250, 1500);
  84. }
  85. } else if (!Inventory.isFull() && !isInChop()) { // WalkingToBank to tress
  86. final Path minePath = PredefinedPath.create(new Coordinate(3285, 3366, 0), new Coordinate(3287, 3371, 0), new Coordinate(3290, 3375, 0), new Coordinate(3293, 3380, 0), new Coordinate(3292, 3385, 0), new Coordinate(3292, 3392, 0), new Coordinate(3292, 3397, 0), new Coordinate(3292, 3404, 0), new Coordinate(3292, 3405, 0), new Coordinate(3288, 3412, 0), new Coordinate(3286, 3417, 0), new Coordinate(3283, 3420, 0), new Coordinate(3280, 3425, 0), new Coordinate(3275, 3428, 0), new Coordinate(3269, 3428, 0), new Coordinate(3264, 3428, 0), new Coordinate(3259, 3428, 0), new Coordinate(3254, 3426, 0), new Coordinate(3254, 3422, 0)).reverse();
  87.  
  88. minePath.step();
  89. }
  90. }
  91.  
  92. private boolean ChopisIn() {
  93. }
  94.  
  95. private boolean isInCutt() {
  96. }
  97.  
  98.  
  99. @Override
  100. public void onPaint(Graphics2D g) {
  101. Color transBlack = new Color(0, 0, 0, 150);
  102. //Draw trans rect
  103. g.setColor(transBlack);
  104. g.fillRect(0, 0, 200, 100);
  105. //Draw border of rect
  106. g.setColor(Color.blue);
  107. g.drawRect(0, 0, 200, 100);
  108. //Draw green underline under title
  109. g.drawLine(5, 20, 195, 20);
  110. //Draw text
  111. g.setColor(Color.white);
  112. // Text
  113. g.drawString("Calem's_chopperr", 80, 15);
  114. g.drawString("Run time: " + runtime.getRuntimeAsString(), 5, 35);
  115. if (RuneScape.isLoggedIn()) {
  116. g.drawString("Woodcutting level: " + Skill.WOODCUTTING.getCurrentLevel() + " + " + levelsGained, 5, 50);
  117. g.drawString("Experience to level: " + Skill.WOODCUTTING.getExperienceToNextLevel(), 5, 65);
  118. g.drawString("Logs chopped: " + logCount, 5, 80);
  119. g.drawString("Money gained: " + logPrice * logCount, 5, 95);
  120. }
  121. }
  122.  
  123.  
  124. @Override
  125. public void onItemAdded(ItemEvent event) {
  126. ItemDefinition definition = event.getItem().getDefinition();
  127.  
  128. if (definition != null && definition.getName().equals("Elder tree")) {
  129. logCount++;
  130. }
  131. }
  132.  
  133. @Override
  134. public void onLevelUp(SkillEvent event) {
  135. if (event.getSkill().equals(Skill.WOODCUTTING)) {
  136. ++levelsGained;
  137. }
  138. }
  139.  
  140. private boolean isIdle() {
  141. return player.getAnimationId() == -1 && !player.isMoving();
  142. }
  143.  
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement