Advertisement
Rudie221

GuildMinerR

Apr 24th, 2011
2,534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.03 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.imageio.ImageIO;
  3. import java.io.IOException;
  4. import java.net.URL;
  5. import org.rsbot.event.events.MessageEvent;
  6. import org.rsbot.event.listeners.MessageListener;
  7. import org.rsbot.event.listeners.PaintListener;
  8. import org.rsbot.script.Script;
  9. import org.rsbot.script.ScriptManifest;
  10. import org.rsbot.script.wrappers.RSObject;
  11. import org.rsbot.script.wrappers.RSTile;
  12. import org.rsbot.script.wrappers.RSTilePath;
  13.  
  14. @ScriptManifest(
  15. authors = {"Rudie"},
  16. version = 1.00,
  17. keywords = ("miner"),
  18. description = "Mines and banks coal at the mining guild.",
  19. name = "GuildMinerR"
  20. )
  21. public class GuildMinerR extends Script implements PaintListener, MessageListener {
  22.  
  23. int[] boothID = {11758};
  24. int[] oreID = {5770, 5771, 5772};
  25. int miningAnimation = 625;
  26. int[] pickID = {1265, 1267, 1269, 1271, 1273, 1275};
  27. int dstairID = 2113;
  28. int ustairID = 6226;
  29.  
  30. RSTile[] fromBankToStairs = {new RSTile(3015, 3355)};
  31. RSTilePath bankToStairs;
  32.  
  33. RSTile[] fromStairsToBank = {new RSTile(3019, 3342)};
  34. RSTilePath stairsToBank;
  35.  
  36. RSTile[] MiningAreaE = {new RSTile(3027, 9739), new RSTile(3034, 9738),
  37. new RSTile(3044, 9738)};
  38. RSTilePath MiningArea;
  39.  
  40. long startTime;
  41.  
  42. int expGained = 0;
  43. int startExp = 0;
  44. int oresMined = 0;
  45. int lvlsGained = 0;
  46. int gemsFound = 0;
  47. private String Status = "Loading...";
  48.  
  49. public boolean onStart() {
  50. bankToStairs = walking.newTilePath(fromBankToStairs);
  51. stairsToBank = walking.newTilePath(fromStairsToBank);
  52. MiningArea = walking.newTilePath(MiningAreaE);
  53. startTime = System.currentTimeMillis();
  54. mouse.setSpeed(random(3, 5));
  55. startExp = skills.getCurrentExp(skills.MINING);
  56. return true;
  57.  
  58. }
  59.  
  60. @Override
  61. public int loop() {
  62. if(inventory.isFull()) {
  63. if(atBank()) {
  64. doBank();
  65. } else if(atUp()) {
  66. goUp();
  67. } else {
  68. BtS();
  69. StB();
  70. MiningPlace();
  71. }
  72. } else {
  73. if(atMine()) {
  74. mineOres();
  75. } else if(atDown()) {
  76. goDown();
  77. } else {
  78. BtSS();
  79. StBB();
  80. MiningPlacee();
  81. }
  82. }
  83. return random(600, 800);
  84. }
  85.  
  86. private void mineOres() {
  87. RSObject rock = objects.getNearest(oreID);
  88. if(getMyPlayer().getAnimation() != miningAnimation) {
  89. rock.doAction("Mine");
  90. Status = "Mining.";
  91. AntiBan();
  92. AntiBanCamera();
  93. }
  94. sleep(2500, 4000);
  95. }
  96.  
  97. private void goDown() {
  98. RSObject ladder = objects.getNearest(dstairID);
  99. if(getMyPlayer().getAnimation() != miningAnimation) {
  100. ladder.doAction("Climb-down");
  101. Status = "Going down.";
  102. AntiBan();
  103. AntiBanCamera();
  104. }
  105. sleep(3000, 4500);
  106. }
  107.  
  108. private void goUp() {
  109. RSObject ladder = objects.getNearest(ustairID);
  110. if(getMyPlayer().getAnimation() != miningAnimation) {
  111. ladder.doAction("Climb-up");
  112. Status = "Going up.";
  113. AntiBan();
  114. AntiBanCamera();
  115. }
  116. sleep(5000, 6500);
  117. }
  118.  
  119. private void BtS() {
  120. bankToStairs.reverse();
  121. bankToStairs.traverse();
  122. bankToStairs.reverse();
  123. AntiBanCamera();
  124. Status = "Walk to mine.";
  125. }
  126.  
  127. private void BtSS() {
  128. bankToStairs.traverse();
  129. AntiBanCamera();
  130. Status = "Walk to mine.";
  131. }
  132.  
  133. private void StB() {
  134. stairsToBank.reverse();
  135. stairsToBank.traverse();
  136. stairsToBank.reverse();
  137. AntiBanCamera();
  138. Status = "Walk to bank.";
  139. }
  140.  
  141. private void StBB() {
  142. stairsToBank.traverse();
  143. AntiBanCamera();
  144. Status = "Walk to bank.";
  145. }
  146.  
  147. private void MiningPlace() {
  148. MiningArea.reverse();
  149. MiningArea.traverse();
  150. MiningArea.reverse();
  151. AntiBanCamera();
  152. Status = "Walk to bank.";
  153. }
  154.  
  155. private void MiningPlacee() {
  156. MiningArea.traverse();
  157. AntiBanCamera();
  158. Status = "Walk to mine.";
  159. }
  160.  
  161. public void onFinish() {
  162. log("Ty for using GuildMinerR.");
  163. env.saveScreenshot(true);
  164. }
  165.  
  166. private boolean atBank() {
  167. RSObject bank = objects.getNearest(boothID);
  168. if(bank != null) {
  169. if(bank.isOnScreen()) {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175.  
  176. private void doBank() {
  177. if(bank.isOpen()) {
  178. bank.depositAllExcept(pickID);
  179. sleep(800, 1200);
  180. Status = "Banking.";
  181. } else {
  182. bank.open();
  183. Status = "Banking.";
  184. sleep(1800, 2200);
  185. }
  186. }
  187.  
  188. private boolean atMine() {
  189. RSObject ore = objects.getNearest(oreID);
  190. AntiBan();
  191. AntiBanCamera();
  192. if(ore != null) {
  193. if(ore.isOnScreen()) {
  194. return true;
  195. }
  196. }
  197. return false;
  198. }
  199.  
  200. private boolean atDown() {
  201. RSObject ladder = objects.getNearest(dstairID);
  202. AntiBan();
  203. AntiBanCamera();
  204. if(ladder != null) {
  205. if(ladder.isOnScreen()) {
  206. return true;
  207. }
  208. }
  209. return false;
  210. }
  211.  
  212. private boolean atUp() {
  213. RSObject ladder = objects.getNearest(ustairID);
  214. AntiBan();
  215. AntiBanCamera();
  216. if(ladder != null) {
  217. if(ladder.isOnScreen()) {
  218. return true;
  219. }
  220. }
  221. return false;
  222. }
  223.  
  224. //START: Code generated using Enfilade's Easel
  225. private Image getImage(String url) {
  226. try {
  227. return ImageIO.read(new URL(url));
  228. } catch(IOException e) {
  229. return null;
  230. }
  231. }
  232.  
  233. private final Color color1 = new Color(204, 0, 0, 136);
  234. private final Color color2 = new Color(0, 0, 0);
  235. private final Color color3 = new Color(255, 255, 255);
  236.  
  237. private final BasicStroke stroke1 = new BasicStroke(1);
  238.  
  239. private final Font font1 = new Font("Verdana", 0, 20);
  240. private final Font font2 = new Font("Verdana", 0, 17);
  241. private final Font font3 = new Font("Arial", 2, 10);
  242.  
  243. private final Image img1 = getImage("http://images3.wikia.nocookie.net/__cb20100407061734/runescape/images/thumb/f/fd/Coal_detail.png/120px-Coal_detail.png");
  244.  
  245.  
  246. //END: Code generated using Enfilade's Easel
  247.  
  248. /*
  249. * ----- PAINT -----
  250. */
  251.  
  252. @Override
  253. public void onRepaint(Graphics g) {
  254. drawModel(g, objects.getNearest(oreID), Color.RED, "", Color.GREEN);
  255. drawModel(g, objects.getNearest(boothID), Color.WHITE, "", Color.GREEN);
  256.  
  257.  
  258. expGained = skills.getCurrentExp(skills.MINING) - startExp;
  259.  
  260. long millis = System.currentTimeMillis() - startTime;
  261. long hours = millis / (1000 * 60 * 60);
  262. millis -= hours * (1000 * 60 * 60);
  263. long minutes = millis / (1000 * 60);
  264. millis -= minutes * (1000 * 60);
  265. long seconds = millis / 1000;
  266.  
  267. float xpsec = 0;
  268. if((minutes > 0 || hours > 0 || seconds > 0)&& expGained > 0) {
  269. xpsec = ((float) expGained)/(float)(seconds + (minutes*60) + (hours*60*60));
  270. }
  271. float xpmin = xpsec * 60;
  272. float xphour = xpmin * 60;
  273.  
  274. float oresec = 0;
  275. if((minutes > 0 || hours > 0 || seconds > 0)&& oresMined > 0) {
  276. oresec = ((float) oresMined)/(float)(seconds + (minutes*60) + (hours*60*60));
  277. }
  278. float oremin = oresec * 60;
  279. float orehour = oremin * 60;
  280.  
  281. Graphics2D g1 = (Graphics2D)g;
  282. g1.setColor(color1);
  283. g.setColor(Color.RED);
  284. g.drawLine(0, (int)(mouse.getLocation().getY()), 800, (int)(mouse.getLocation().getY()));
  285. g.setColor(Color.RED);
  286. g.drawLine((int)(mouse.getLocation().getX()), 0, (int)(mouse.getLocation().getX()), 800);
  287. g.setColor(Color.BLACK);
  288. g.fillRect(4, 318, 512, 20);
  289. g.setColor(Color.BLACK);
  290. g.fillRect(6, 320, 508, 16);
  291. g.setColor(Color.RED);
  292. g.fillRect(6, 320, 508, 16);
  293. g.setColor(Color.GREEN);
  294. g.fillRect(6, 320, skills.getPercentToNextLevel(14) * (508/100), 16);
  295. g.setColor(Color.BLACK);
  296. g.drawString("" + skills.getPercentToNextLevel(14) + "% to lvl " + (skills.getCurrentLevel(14) + 1) + " Mining", 194, 332);
  297. g1.setColor(color1);
  298. g1.fillRoundRect(545, 203, 195, 262, 16, 16);
  299. g1.setColor(color2);
  300. g1.setStroke(stroke1);
  301. g1.drawRoundRect(545, 203, 195, 262, 16, 16);
  302. g1.setFont(font1);
  303. g1.setColor(color3);
  304. g1.drawString("GuildMinerR", 574, 228);
  305. g1.setFont(font2);
  306. g1.drawString("Status: " + Status, 550, 257);
  307. g1.drawString("Exp Gained: " + expGained, 550, 273);
  308. g1.drawString("Exp/H: " + (int)xphour, 550, 288);
  309. g1.drawString("Coal Mined: " + oresMined, 550, 303);
  310. g1.drawString("Coal/H: " + (int)orehour, 550, 318);
  311. g1.drawString("RunTime: " + hours + ":" + minutes + ":" + seconds, 550, 333);
  312. g1.drawString("Gems Found: " + gemsFound, 550, 348);
  313. g1.drawString("Current Lvl: " + skills.getCurrentLevel(skills.MINING), 550, 363);
  314. g1.drawString("Lvl's Gained: " + lvlsGained, 550, 378);
  315. g1.drawImage(img1, 576, 380, null);
  316. g1.setFont(font3);
  317. g1.drawString("GuildMinerR ®", 548, 462);
  318. g1.drawString("© 2011", 699, 462);
  319.  
  320. }
  321. public void drawModel(Graphics g, RSObject o, Color c, String s, Color tc) {
  322. if(o != null) {
  323. Polygon[] model = o.getModel().getTriangles();
  324. Point point = calc.tileToScreen(o.getLocation());
  325. for(Polygon p : model) {
  326. g.setColor(c);
  327. g.fillPolygon(p);
  328. g.setColor(c.darker());
  329. g.drawPolygon(p);
  330. }
  331.  
  332. g.setColor(tc);
  333. g.drawString(s, point.x - 75, point.y - 35);
  334. }
  335. }
  336. public RSTile[] reversePath(RSTile[] other) {
  337. RSTile[] t = new RSTile[other.length];
  338. for (int i = 0; i < t.length; i++) {
  339. t[i] = other[other.length - i - 1];
  340. }
  341. return t;
  342. }
  343.  
  344.  
  345.  
  346. public void messageReceived(MessageEvent e) {
  347. String svrmsg = e.getMessage();
  348. if (svrmsg.contains("You've")) {
  349. lvlsGained++;
  350. }
  351. if (svrmsg.contains("coal")) {
  352. oresMined++;
  353. }
  354. if (svrmsg.contains("just found")) {
  355. gemsFound++;
  356. }
  357. }
  358.  
  359. private void AntiBan() {
  360. int randomProd = random(1, 60);
  361. if (randomProd == 1) {
  362. int randomMore = random(1, 5);
  363. if (randomMore == 1) {
  364. if (game.getCurrentTab() != 2) {
  365. game.openTab(2);
  366. sleep(350, 500);
  367. mouse.move(random(678, 728), random(213, 232));
  368. sleep(2000, 3500);
  369. } else {
  370. mouse.move(random(678, 728), random(213, 232));
  371. sleep(2000, 3500);
  372. }
  373. } else {
  374. sleep(1200, 2500);
  375. }
  376. }
  377. if (randomProd == 2 || randomProd == 3 || randomProd == 4) {
  378. sleep(1000, 2500);
  379. }
  380. if (randomProd >= 52) {
  381. mouse.moveRandomly(65, 350);
  382. } else
  383. sleep(10, 30);
  384. }
  385.  
  386. private void AntiBanCamera() {
  387. int randomNum = random(1, 50);
  388. if (randomNum == 1 || randomNum == 2 || randomNum == 3) {
  389. camera.moveRandomly(random(2000, 5500));
  390. }
  391. if (randomNum == 4 || randomNum == 5) {
  392. camera.setAngle(random(10, 40));
  393. }
  394. if (randomNum == 6) {
  395. camera.setPitch(random(40, 68));
  396. }
  397. if (randomNum == 7) {
  398. camera.setPitch(random(20, 45));
  399. }
  400. if (randomNum == 8) {
  401. camera.setPitch(random(68, 90));
  402. } else
  403. sleep(50, 70);
  404. }
  405. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement