Advertisement
Guest User

Untitled

a guest
May 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.28 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Graphics2D;
  5. import java.awt.RenderingHints;
  6. import java.util.Map;
  7.  
  8. import org.rsbot.bot.Bot;
  9. import org.rsbot.bot.input.Mouse;
  10. import org.rsbot.event.events.ServerMessageEvent;
  11. import org.rsbot.event.listeners.PaintListener;
  12. import org.rsbot.event.listeners.ServerMessageListener;
  13. import org.rsbot.script.Constants;
  14. import org.rsbot.script.Script;
  15. import org.rsbot.script.ScriptManifest;
  16. import org.rsbot.script.wrappers.RSNPC;
  17. import org.rsbot.script.wrappers.RSObject;
  18. import org.rsbot.script.wrappers.RSTile;
  19. import org.rsbot.util.ScreenshotUtil;
  20.  
  21. @ScriptManifest(authors = { "Script Dude" }, category = "Woodcutting", name = "SrcYews", version = 1.00, description = "<html>"
  22. + "<center><h2>Script Dude's Yew Chopper</h2></center>"
  23. + "<centerStart this scipr near yew trees, bank or anywhere between them<center"
  24. + "<center>Location: "
  25. + "<select name='location'>"
  26. + "<option>Grand Exchange"
  27. + "<option>Rimmington"
  28. + "<option>Seers village"
  29. + "</select>"
  30. + "</center>"
  31. + "<center>Show Paint: "
  32. + "<select name='showpaint'>"
  33. + "<option>Yes"
  34. + "<option>No" + "</select>" + "</center>" + "</html>")
  35. public class SrcYews extends Script implements PaintListener,
  36. ServerMessageListener {
  37. public String status = "";
  38. public String location = "";
  39. public int treeID = 1309;
  40. public int[] hatchetID = { 1351, 1349, 1353, 1361, 1355, 1357, 1359, 4031,
  41. 6739, 13470, 14108 };
  42. public int[] bankBoothID = { 11758, 11402, 34752, 35647, 2213, 25808, 2213,
  43. 26972, 27663, 4483, 14367, 19230, 29085, 12759, 6084, 24914 };
  44. public int logs = 0;
  45. public int levels = 0;
  46. public int yewID = 1515;
  47. public int bankerID = 6533;
  48. public int profit;
  49. public int startexp;
  50. public int yewCost = grandExchange.loadItemInfo(yewID).getMarketPrice();
  51. public long startTime;
  52. public boolean showPaint, showAveraging, showGained, end = false;
  53. public RSTile midTree1 = new RSTile(2935, 3226);
  54. public RSTile midTree2 = new RSTile(2936, 3230);
  55. public RSTile midTree3 = new RSTile(2934, 3234);
  56. public RSTile midTree4 = new RSTile(2941, 3233);
  57. public RSTile midTree5 = new RSTile(3205, 3504);
  58. public RSTile midTree6 = new RSTile(3210, 3504);
  59. public RSTile midTree7 = new RSTile(3222, 3503);
  60. public RSTile midTree8 = new RSTile(2715, 3460);
  61. public RSTile midTree9 = new RSTile(2706, 3460);
  62. public RSTile midTree10 = new RSTile(2706, 3465);
  63. public RSTile banktileR = new RSTile(3014, 3355);
  64. public RSTile treetileR = new RSTile(2938, 3231);
  65. public RSTile banktileGE = new RSTile(3168, 3489);
  66. public RSTile treetileGE = new RSTile(3215, 3500);
  67. public RSTile banktileS = new RSTile(2726, 3491);
  68. public RSTile treetileS = new RSTile(2710, 3462);
  69. public RSTile[] bankToYewsR = { new RSTile(3013, 3358),
  70. new RSTile(3008, 3349), new RSTile(3006, 3334),
  71. new RSTile(3005, 3319), new RSTile(2996, 3308),
  72. new RSTile(2986, 3296), new RSTile(2977, 3284),
  73. new RSTile(2972, 3270), new RSTile(2964, 3260),
  74. new RSTile(2958, 3247), new RSTile(2945, 3238),
  75. new RSTile(2938, 3232) };
  76. public RSTile[] yewsToBankR = reversePath(bankToYewsR);
  77. public RSTile[] bankToYewsGE = { new RSTile(3167, 3489),
  78. new RSTile(3174, 3489), new RSTile(3185, 3489),
  79. new RSTile(3195, 3491), new RSTile(3197, 3501),
  80. new RSTile(3206, 3502) };
  81. public RSTile[] yewsToBankGE = reversePath(bankToYewsGE);
  82. public RSTile[] yewsToBankS = { new RSTile(2715, 3463),
  83. new RSTile(2722, 3474), new RSTile(2724, 3485),
  84. new RSTile(2726, 3491) };
  85. public RSTile[] bankToYewsS = reversePath(yewsToBankS);
  86.  
  87. @Override
  88. protected int getMouseSpeed() {
  89. return random(4, 6);
  90. }
  91.  
  92. public boolean onStart(Map<String, String> args) {
  93. startTime = System.currentTimeMillis();
  94. final String paint = args.get("showpaint");
  95. if (paint.equals("Yes")) {
  96. showPaint = true;
  97. } else if (paint.equals("No")) {
  98. showPaint = false;
  99. }
  100. final String place = args.get("location");
  101. if (place.equals("Grand Exchange")) {
  102. location = "GE";
  103. } else if (place.equals("Rimmington")) {
  104. location = "R";
  105. } else if (place.equals("Seers village")) {
  106. location = "S";
  107. }
  108. return true;
  109. }
  110.  
  111. public void onFinish() {
  112. end = true;
  113. showGained = true;
  114. ScreenshotUtil.takeScreenshot(true);
  115. long millis = System.currentTimeMillis() - startTime;
  116. long hours = millis / (1000 * 60 * 60);
  117. millis -= hours * (1000 * 60 * 60);
  118. long minutes = millis / (1000 * 60);
  119. millis -= minutes * (1000 * 60);
  120. long seconds = millis / 1000;
  121. log("Thank You for using Script Dude's Yew Chopper!");
  122. log("Time ran " + hours + ":" +minutes + ":" + seconds);
  123. log("Logs cut: " + logs);
  124. log("Levels Gained: " + levels);
  125. log("Profit got: " + profit);
  126. }
  127.  
  128. @Override
  129. public int loop() {
  130. setCameraAltitude(true);
  131. antiBan();
  132. if (isInventoryFull()) {
  133. if (atBank()) {
  134. bank();
  135. } else {
  136. toBank();
  137. }
  138. }
  139. if (!isInventoryFull()) {
  140. if (atTrees()) {
  141. chop();
  142. } else {
  143. toTrees();
  144. }
  145. }
  146. return random(100, 250);
  147. }
  148.  
  149. // METHODS
  150. public boolean atBank() {
  151. if (location == "R") {
  152. return distanceTo(banktileR) <= 7;
  153. }
  154. if (location == "GE") {
  155. return distanceTo(banktileGE) <= 7;
  156. }
  157. if (location == "S") {
  158. return distanceTo(banktileS) <= 7;
  159. }
  160. return false;
  161. }
  162.  
  163. public boolean atTrees() {
  164. if (location == "R") {
  165. return distanceTo(treetileR) <= 10;
  166. }
  167. if (location == "GE") {
  168. return distanceTo(treetileGE) <= 15;
  169. }
  170. if (location == "S") {
  171. return distanceTo(treetileS) <= 10;
  172. }
  173. return false;
  174. }
  175.  
  176. public void antiBan() {
  177. int randomNumber = random(1, 50);
  178. if (randomNumber <= 4) {
  179. status = "Antiban";
  180. if (randomNumber == 1) {
  181. setCameraRotation(random(1, 360));
  182. }
  183. if (randomNumber == 2) {
  184. moveMouse(random(50, 700), random(50, 450), 2, 2);
  185. }
  186. if (randomNumber == 3) {
  187. setCameraRotation(random(1, 360));
  188. moveMouse(random(50, 700), random(50, 450), 2, 2);
  189. }
  190. if (randomNumber == 4) {
  191. moveMouse(random(50, 700), random(50, 450), 2, 2);
  192. setCameraRotation(random(1, 360));
  193. moveMouse(random(50, 700), random(50, 450), 2, 2);
  194. }
  195. }
  196. int randomnumber2 = random(1, 500);
  197. if (randomnumber2 == 1) {
  198. if (getCurrentTab() != TAB_STATS) {
  199. openTab(TAB_STATS);
  200. wait(random(100, 200));
  201. moveMouse(random(664, 713), random(392, 419), 2, 2);
  202. wait(random(750, 1000));
  203. openTab(TAB_INVENTORY);
  204. }
  205. }
  206. }
  207.  
  208. public boolean atTree(final String action) {
  209. try {
  210. final RSObject yew = getNearestObjectByID(treeID);
  211. if (location == "R") {
  212. if (distanceBetween(yew.getLocation(), midTree1) <= 1) {
  213. if (distanceTo(midTree1) >= 6) {
  214. setRun(true);
  215. walkTo(midTree1);
  216. }
  217. atTile(midTree1, action);
  218. return false;
  219. }
  220. if (distanceBetween(yew.getLocation(), midTree2) <= 1) {
  221. if (distanceTo(midTree2) >= 6) {
  222. setRun(true);
  223. walkTo(midTree2);
  224. }
  225. atTile(midTree2, action);
  226. return false;
  227. }
  228. if (distanceBetween(yew.getLocation(), midTree3) <= 1) {
  229. if (distanceTo(midTree3) >= 6) {
  230. setRun(true);
  231. walkTo(midTree3);
  232. }
  233. atTile(midTree3, action);
  234. return false;
  235. }
  236. if (distanceBetween(yew.getLocation(), midTree4) <= 1) {
  237. if (distanceTo(midTree4) >= 6) {
  238. setRun(true);
  239. walkTo(midTree4);
  240. }
  241. atTile(midTree4, action);
  242. return false;
  243. }
  244. }
  245. if (location == "GE") {
  246. if (distanceBetween(yew.getLocation(), midTree5) <= 1) {
  247. if (distanceTo(midTree5) >= 6) {
  248. setRun(true);
  249. walkTo(midTree5);
  250. }
  251. atTile(midTree5, action);
  252. return false;
  253. }
  254. if (distanceBetween(yew.getLocation(), midTree6) <= 1) {
  255. if (distanceTo(midTree6) >= 6) {
  256. setRun(true);
  257. walkTo(midTree6);
  258. }
  259. atTile(midTree6, action);
  260. return false;
  261. }
  262. if (distanceBetween(yew.getLocation(), midTree7) <= 1) {
  263. if (distanceTo(midTree7) >= 6) {
  264. setRun(true);
  265. walkTo(midTree7);
  266. }
  267. atTile(midTree7, action);
  268. return false;
  269. }
  270. }
  271. if (location == "S") {
  272. if (distanceBetween(yew.getLocation(), midTree8) <= 1) {
  273. if (distanceTo(midTree8) >= 6) {
  274. setRun(true);
  275. walkTo(midTree8);
  276. }
  277. atTile(midTree8, action);
  278. return false;
  279. }
  280. if (distanceBetween(yew.getLocation(), midTree9) <= 1) {
  281. if (distanceTo(midTree9) >= 6) {
  282. setRun(true);
  283. walkTo(midTree9);
  284. }
  285. atTile(midTree9, action);
  286. return false;
  287. }
  288. if (distanceBetween(yew.getLocation(), midTree10) <= 1) {
  289. if (distanceTo(midTree10) >= 6) {
  290. setRun(true);
  291. walkTo(midTree10);
  292. }
  293. atTile(midTree10, action);
  294. return false;
  295. }
  296. }
  297. } catch (Exception e) {
  298. log("Something went wrong, but it didn't stop the script");
  299. }
  300. return true;
  301. }
  302.  
  303. public boolean chop() {
  304. if (getMyPlayer().getAnimation() == 867) {
  305. status = "Chopping";
  306. wait(random(500, 1000));
  307. }
  308. if (getMyPlayer().getAnimation() != 867) {
  309. status = "Waiting";
  310. if (location == "GE") {
  311. final RSObject yew = getNearestObjectByID(treeID);
  312. if (yew == null) {
  313. if (distanceTo(new RSTile(3213, 3501)) > 2) {
  314. walkTo(new RSTile(3213, 3501));
  315. }
  316. }
  317. }
  318. wait(random(500, 1000));
  319. }
  320. if (!(getMyPlayer().getAnimation() == 867)) {
  321. final RSObject yew = getNearestObjectByID(treeID);
  322. if (yew != null) {
  323. atTree("Chop down Yew");
  324. wait(random(300, 700));
  325. }
  326. }
  327. return true;
  328. }
  329.  
  330. public int toBank() {
  331. status = ("Walking to bank");
  332. if (getEnergy() >= 65) {
  333. setRun(true);
  334. }
  335. if (location == "R") {
  336. if (distanceTo(getDestination()) < random(5, 12)
  337. || distanceTo(getDestination()) > 40) {
  338. if (!walkPathMM(yewsToBankR)) {
  339. walkToClosestTile(randomizePath(yewsToBankR, 2, 2));
  340. return random(400, 600);
  341. }
  342. }
  343. }
  344. if (location == "GE") {
  345. if (distanceTo(getDestination()) < random(5, 12)
  346. || distanceTo(getDestination()) > 40) {
  347. if (!walkPathMM(yewsToBankGE)) {
  348. walkToClosestTile(randomizePath(yewsToBankGE, 2, 2));
  349. return random(400, 600);
  350. }
  351. }
  352. }
  353. if (location == "S") {
  354. if (distanceTo(getDestination()) < random(5, 12)
  355. || distanceTo(getDestination()) > 40) {
  356. if (!walkPathMM(yewsToBankS)) {
  357. walkToClosestTile(randomizePath(yewsToBankS, 2, 2));
  358. return random(400, 600);
  359. }
  360. }
  361. }
  362. return random(100, 250);
  363. }
  364.  
  365. public int toTrees() {
  366. status = ("Walking to yews");
  367. if (getEnergy() >= 65) {
  368. setRun(true);
  369. }
  370. if (location == "R") {
  371. if (distanceTo(getDestination()) < random(5, 12)
  372. || distanceTo(getDestination()) > 40) {
  373. if (!walkPathMM(randomizePath(bankToYewsR, 2, 2))) {
  374. walkToClosestTile(randomizePath(bankToYewsR, 2, 2));
  375. return random(400, 600);
  376. }
  377. }
  378. }
  379. if (location == "GE") {
  380. if (distanceTo(getDestination()) < random(5, 12)
  381. || distanceTo(getDestination()) > 40) {
  382. if (!walkPathMM(randomizePath(bankToYewsGE, 2, 2))) {
  383. walkToClosestTile(randomizePath(bankToYewsGE, 2, 2));
  384. return random(400, 600);
  385. }
  386. }
  387. }
  388. if (location == "S") {
  389. if (distanceTo(getDestination()) < random(5, 12)
  390. || distanceTo(getDestination()) > 40) {
  391. if (!walkPathMM(randomizePath(bankToYewsS, 2, 2))) {
  392. walkToClosestTile(randomizePath(bankToYewsS, 2, 2));
  393. return random(400, 600);
  394. }
  395. }
  396. }
  397. return random(100, 250);
  398. }
  399.  
  400. public int bank() {
  401. status = "Banking";
  402. if (bank.isOpen()) {
  403. bank.depositAllExcept(hatchetID);
  404. wait(random(800, 1000));
  405. }
  406. if (!(bank.isOpen())) {
  407. if (location == "R") {
  408. final RSObject bankBooth = getNearestObjectByID(bankBoothID);
  409. if (bankBooth != null) {
  410. atObject(bankBooth, "Use-Quickly");
  411. wait(random(200, 300));
  412. }
  413. if (bankBooth == null) {
  414. return random(100, 200);
  415. }
  416. }
  417. if (location == "GE") {
  418. final RSNPC bankNPC = getNearestNPCByID(bankerID);
  419. if (bankNPC != null) {
  420. atNPC(bankNPC, "Bank Banker");
  421. wait(random(200, 300));
  422. }
  423. if (bankNPC == null) {
  424. return random(100, 200);
  425. }
  426. }
  427. if (location == "S") {
  428. final RSObject bankBooth = getNearestObjectByID(bankBoothID);
  429. if (bankBooth != null) {
  430. atObject(bankBooth, "Use-Quickly");
  431. wait(random(200, 300));
  432. }
  433. if (bankBooth == null) {
  434. return random(100, 200);
  435. }
  436. }
  437. }
  438. return random(150, 350);
  439. }
  440.  
  441. // METHODS
  442.  
  443. @Override
  444. public void onRepaint(Graphics g) {
  445. ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
  446. RenderingHints.VALUE_ANTIALIAS_ON);
  447. if (showPaint == true) {
  448. if (isLoggedIn()) {
  449. int xpGained = 0;
  450. if (startexp == 0) {
  451. startexp = skills
  452. .getCurrentSkillExp(Constants.STAT_WOODCUTTING);
  453. }
  454. profit = (logs * yewCost);
  455. xpGained = skills
  456. .getCurrentSkillExp(Constants.STAT_WOODCUTTING)
  457. - startexp;
  458. long millis = System.currentTimeMillis() - startTime;
  459. long hours = millis / (1000 * 60 * 60);
  460. millis -= hours * (1000 * 60 * 60);
  461. long minutes = millis / (1000 * 60);
  462. millis -= minutes * (1000 * 60);
  463. long seconds = millis / 1000;
  464. float xpsec = 0;
  465. if ((minutes > 0 || hours > 0 || seconds > 0) && xpGained > 0) {
  466. xpsec = ((float) xpGained)
  467. / (float) (seconds + (minutes * 60) + (hours * 60 * 60));
  468. }
  469. float xpmin = xpsec * 60;
  470. float xphour = xpmin * 60;
  471. final int yewHour = (int) ((logs) * 3600000D / (System
  472. .currentTimeMillis() - startTime));
  473. final int profitHour = (int) ((profit) * 3600000D / (System
  474. .currentTimeMillis() - startTime));
  475. g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
  476. if (showGained == true) {
  477. g.setColor(new Color(0, 0, 0, 150));
  478. g.fillRoundRect(200, 213 + 18, 150, 100 - 18, 0, 0);
  479. g.setColor(Color.white);
  480. g.drawString("XP Gained: " + xpGained, 208, 230 + 18);
  481. g.drawString("Levels Gained: " + levels, 208, 248 + 18);
  482. g.drawString("Logs chopped: " + logs, 208, 284);
  483. g.drawString("Profit: " + profit + "gp", 208, 284 + 18);
  484. }
  485. if (showAveraging == true) {
  486. g.setColor(new Color(0, 0, 0, 150));
  487. g.fillRoundRect(286, 213 + 18, 200, 100 - 18, 0, 0);
  488. g.setColor(Color.white);
  489. g.drawString("Time running: " + hours + ":" + minutes + ":"
  490. + seconds, 294, 230 + 18);
  491. g
  492. .drawString("XP Hour: " + (int) xphour, 294,
  493. 230 + 18 + 18);
  494. g.drawString("Logs/Hour: " + yewHour, 294, 266 + 18);
  495. g.drawString("Profit/Hour: " + profitHour + "gp", 294,
  496. 284 + 18);
  497. }
  498. final int percent = skills
  499. .getPercentToNextLevel(Constants.STAT_WOODCUTTING);
  500. g.setColor(new Color(0, 0, 0, 150));
  501. g.fillRoundRect(4, 313, 511, 24, 0, 0);
  502. g.setColor(Color.white);
  503. g.draw3DRect(4, 313, 511, 24, true);
  504. g.setColor(new Color(149, 7, 17, 200));
  505. g.fillRoundRect(7, 315, 100, 20, 0, 0);
  506. g.setColor(new Color(0, 79, 0, 200));
  507. g.fillRoundRect(7, 315, percent, 20, 0, 0);
  508. g.setColor(Color.black);
  509. g.drawRect(7, 315, 100, 20);
  510. g.setColor(Color.white);
  511. g.drawString(percent + "% Done", 117, 330);
  512. g.draw3DRect(200, 313, 1, 24, true);
  513. g.drawString("Gained", 220, 330);
  514. g.draw3DRect(285, 313, 1, 24, true);
  515. g.drawString("Averaging", 305, 330);
  516. g.draw3DRect(390, 313, 1, 24, true);
  517. g.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
  518. g.drawString("" + status, 400, 330);
  519. }
  520. Mouse m = Bot.getClient().getMouse();
  521. if (m.x >= 200 && m.x < 200 + 85 && m.y >= 313 && m.y < 313 + 24) {
  522. showGained = true;
  523. } else {
  524. if (end == false){
  525. showGained = false;
  526. }
  527. }
  528. if (m.x >= 286 && m.x < 286 + 105 && m.y >= 313 && m.y < 313 + 24) {
  529. showAveraging = true;
  530. } else {
  531. showAveraging = false;
  532. }
  533. }
  534. }
  535.  
  536. @Override
  537. public void serverMessageRecieved(final ServerMessageEvent e) {
  538. final String serverString = e.getMessage();
  539. if (serverString.contains("logs.")) {
  540. logs++;
  541. }
  542. if (serverString.contains("You've just advanced")) {
  543. levels++;
  544. }
  545. }
  546. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement