Guest User

Untitled

a guest
Jul 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.74 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Point;
  5. import java.awt.event.KeyEvent;
  6. import java.util.Map;
  7.  
  8. import org.rsbot.bot.Bot;
  9. import org.rsbot.event.events.ServerMessageEvent;
  10. import org.rsbot.event.listeners.PaintListener;
  11. import org.rsbot.event.listeners.ServerMessageListener;
  12. import org.rsbot.script.Calculations;
  13. import org.rsbot.script.Constants;
  14. import org.rsbot.script.Script;
  15. import org.rsbot.script.ScriptManifest;
  16. import org.rsbot.script.wrappers.RSObject;
  17. import org.rsbot.script.wrappers.RSTile;
  18.  
  19. @ScriptManifest(authors = { "Moran429" }, category = "Woodcutting", name = "MapleChopper", version = 1.0, description = "<html><head>"
  20. + "</head><body>"
  21. + "<center>"
  22. + "<b><font size=\"6\" color=\"Green\">"
  23. + "Moran429's"
  24. + "<br></br>"
  25. + "Maple Chopper"
  26. + "</font></b>"
  27. + "<font size=\"5\">"
  28. + "<br></br>"
  29. + "<br></br>"
  30. + "V1.0"
  31. + "<br></br>"
  32. + "<br></br>"
  33. + "<i><font size=\"4\" color=\"black\">Chops and banks maples behind Seer's Village bank.</font></i>"
  34. + "<br></br>"
  35. + "<br></br>"
  36. + "Start the script wielding or carrying the hatchet you will use anywhere between bank and maples."
  37. + "<br></br>" + "</body></html>"
  38. )
  39.  
  40. public class MapleChopper extends Script implements PaintListener, ServerMessageListener {
  41.  
  42. MapleChopperAntiBan antiban;
  43. Thread t;
  44.  
  45. public int profitPerLog = 34;
  46. public int totalProfit;
  47. public int lastExp;
  48. public int chopped;
  49. public int exp;
  50. public int xpGained;
  51. public int startExp;
  52. public long startTime = System.currentTimeMillis();
  53. public int bankerID [] = {};
  54. public int hatchetID [] = {6739,1359, 1357, 1361, 1351, 1349, 1355, 1353};
  55. public int mapleLogsID = 1517;
  56. RSObject mapleTree;
  57. public RSTile bankerTile = new RSTile(2724, 3493);
  58. public RSTile chopTile = new RSTile (2729, 3500);
  59. RSTile[] bankToMaples = {new RSTile(2724, 3493),
  60. new RSTile(2726, 3489), new RSTile(2726, 3485),
  61. new RSTile(2731, 3489), new RSTile(2731, 3495),
  62. new RSTile(2729, 3500)};
  63. public RSTile maplesToBank [] = reversePath(bankToMaples);
  64.  
  65. public int speed = 16;
  66. public void getMouseSpeed(final int speed) {
  67. this.speed = speed;
  68. getMouseSpeed();
  69. }
  70.  
  71. public boolean onStart(final Map<String, String> args){
  72. startTime = System.currentTimeMillis();
  73. log("Check the thread page for updates.");
  74. antiban = new MapleChopperAntiBan();
  75. t = new Thread(antiban);
  76. return true;
  77. }
  78.  
  79. public void onFinish(){
  80. log("You chopped " + chopped + " maple logs.");
  81. log("That's about " + totalProfit + " gold.");
  82. antiban.stopThread = true;
  83. return;
  84. }
  85.  
  86. public boolean chop(){
  87. mapleTree = getNearestObjectByID(1307);
  88. if(getMyPlayer().isMoving()){
  89. wait(random(500,1000));
  90. }
  91. if(mapleTree == null) {
  92. wait(random(300,500));
  93. }if(mapleTree != null){
  94. atTree(mapleTree, "Chop");
  95. wait(random(5000,10000));
  96. }
  97. return true;
  98. }
  99.  
  100. public boolean deposit(){
  101. if(getMyPlayer().isMoving()){
  102. wait(random(5000,10000));
  103. }if(bank.isOpen()){
  104. bank.depositAllExcept(hatchetID);
  105. bank.close();
  106. }
  107. if(!bank.isOpen()){
  108. bank.open();
  109. }if(bankerID == null){
  110. wait(random(1000,5000));
  111. }
  112. return inventoryEmptyExcept(hatchetID);
  113. }
  114.  
  115. public boolean walkToMaples(){
  116. if (distanceTo(chopTile) > 8) {
  117. if (distanceTo(getDestination()) < random(5, 12)
  118. || distanceTo(getDestination()) > 40) {
  119. if (!walkPathMM(bankToMaples)) {
  120. walkToClosestTile(bankToMaples);
  121. }
  122. }
  123. }
  124. return true;
  125. }
  126.  
  127. public boolean walkToBank(){
  128. if (distanceTo(bankerTile) > 8) {
  129. if (distanceTo(getDestination()) < random(5, 12)
  130. || distanceTo(getDestination()) > 40) {
  131. if (!walkPathMM(maplesToBank)) {
  132. walkToClosestTile(maplesToBank);
  133. }
  134. }
  135. }
  136. return true;
  137. }
  138.  
  139. public boolean atTree(final RSObject tree, final String action) {
  140. final RSTile loc1 = mapleTree.getLocation();
  141. final RSTile loc4 = new RSTile(loc1.getX() + 1, loc1.getY() + 1);
  142. final Point sloc1 = Calculations.tileToScreen(loc1.getX(), loc1.getY(),
  143. 10);
  144. final Point sloc2 = Calculations.tileToScreen(loc4.getX(), loc4.getY(),
  145. 10);
  146. final Point screenLoc = new Point((sloc1.x + sloc2.x) / 2,
  147. (sloc1.y + sloc2.y) / 2);
  148. if (screenLoc.x == -1 || screenLoc.y == -1) {
  149. return false;
  150. }
  151.  
  152. moveMouse(screenLoc, 3, 3);
  153. return atMenu("Chop down");
  154. }
  155.  
  156. @Override
  157. public int loop() {
  158. if (!t.isAlive()) {
  159. t.start();
  160. log("AntiBan initialized!");
  161. }if(!isInventoryFull()){
  162. walkToMaples();
  163. atTree(mapleTree, "Chop down");}
  164. if(isInventoryFull()){
  165. walkToBank();
  166. deposit();
  167. }
  168. return random(100,300);
  169.  
  170. }
  171.  
  172. private class MapleChopperAntiBan implements Runnable {
  173. public boolean stopThread;
  174.  
  175. public void run() {
  176. while (!stopThread) {
  177. try {
  178. if (random(0, 15) == 0) {
  179. final char[] LR = new char[] { KeyEvent.VK_LEFT,
  180. KeyEvent.VK_RIGHT };
  181. final char[] UD = new char[] { KeyEvent.VK_DOWN,
  182. KeyEvent.VK_UP };
  183. final char[] LRUD = new char[] { KeyEvent.VK_LEFT,
  184. KeyEvent.VK_RIGHT, KeyEvent.VK_UP,
  185. KeyEvent.VK_UP };
  186. final int random2 = random(0, 2);
  187. final int random1 = random(0, 2);
  188. final int random4 = random(0, 4);
  189.  
  190. if (random(0, 3) == 0) {
  191. Bot.getInputManager().pressKey(LR[random1]);
  192. Thread.sleep(random(100, 400));
  193. Bot.getInputManager().pressKey(UD[random2]);
  194. Thread.sleep(random(300, 600));
  195. Bot.getInputManager().releaseKey(UD[random2]);
  196. Thread.sleep(random(100, 400));
  197. Bot.getInputManager().releaseKey(LR[random1]);
  198. } else {
  199. Bot.getInputManager().pressKey(LRUD[random4]);
  200. if (random4 > 1) {
  201. Thread.sleep(random(300, 600));
  202. } else {
  203. Thread.sleep(random(500, 900));
  204. }
  205. Bot.getInputManager().releaseKey(LRUD[random4]);
  206. }
  207. } else {
  208. Thread.sleep(random(200, 2000));
  209. }
  210. } catch (final Exception e) {
  211. e.printStackTrace();
  212. }
  213. }
  214. }
  215. }
  216.  
  217. @Override
  218. public void onRepaint(Graphics g) {
  219. if (isLoggedIn()) {
  220. if ( startExp == 0) {
  221. startExp = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING);
  222. }
  223. xpGained = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING) - startExp;
  224. long millis = System.currentTimeMillis() - startTime;
  225. long hours = millis / (1000 * 60 * 60);
  226. millis -= hours * (1000 * 60 * 60);
  227. long minutes = millis / (1000 * 60);
  228. millis -= minutes * (1000 * 60);
  229. long seconds = millis / 1000;
  230. totalProfit = profitPerLog * chopped;
  231. g.setColor(Color.red);
  232. g.drawRect(35, 30, 235, 65);
  233. g.fillRect(35, 30, 235, 65);
  234. g.setFont(new Font("Bradley Hand ITC", Font.BOLD, 18));
  235. g.setColor(Color.green);
  236. g.drawString("Ran for " + hours + ":" + minutes + ":" + seconds + "." , 45, 45);
  237. g.drawString("Cut " + chopped + " maple logs", 45, 60);
  238. g.drawString("Gained " + xpGained + " experience", 45, 75);
  239. g.drawString("Gained about " + totalProfit + " gold", 45, 90);
  240. }
  241. }
  242.  
  243. @Override
  244. public void serverMessageRecieved(ServerMessageEvent e) {
  245. final String message = e.getMessage();
  246. if (message.contains("You get some maple logs.")) {
  247. chopped++;
  248. }
  249. }
  250. }
Add Comment
Please, Sign In to add comment