Advertisement
Guest User

Untitled

a guest
Feb 27th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.91 KB | None | 0 0
  1.  
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6. import java.awt.Rectangle;
  7. import java.awt.Point;
  8. import java.awt.BasicStroke;
  9. import java.awt.Stroke;
  10. import java.io.IOException;
  11. import java.net.URL;
  12.  
  13.  
  14.  
  15. import javax.imageio.ImageIO;
  16.  
  17. import java.awt.event.ActionEvent;
  18. import java.awt.event.ActionListener;
  19. import java.awt.event.MouseEvent;
  20. import java.awt.event.MouseListener;
  21. import com.rarebot.event.events.MessageEvent;
  22. import com.rarebot.event.listeners.MessageListener;
  23. import com.rarebot.event.listeners.PaintListener;
  24. import com.rarebot.script.Script;
  25. import com.rarebot.script.ScriptManifest;
  26. import com.rarebot.script.wrappers.RSObject;
  27. import com.rarebot.script.wrappers.RSTile;
  28. import com.rarebot.script.wrappers.RSTilePath;
  29. import com.rarebot.script.wrappers.RSComponent;
  30. import com.rarebot.script.wrappers.RSInterface;
  31. import com.rarebot.script.methods.Skills;
  32. import com.rarebot.script.methods.Walking;
  33. import com.rarebot.script.wrappers.RSArea;
  34. import com.rarebot.script.wrappers.RSTile;
  35.  
  36.  
  37.  
  38.  
  39.  
  40. @ScriptManifest(
  41. authors = {"Atomika"},
  42. version = 1.2,
  43. keywords = {"Mining", "resource", "Dungeon"},
  44. description = "Mines coal ores in lvl 15 resource dungeon and uses Desposit box!",
  45. name = "coalcrusherDungeonMiner(ergu)"
  46. )
  47.  
  48. public class DungCoal extends Script implements PaintListener,MouseListener{
  49. /* coal IDs: 32428, 32427, 32426*/
  50. private final static int[] PICKAXE_ID = {1275, 1271, 1273, 1267, 1269};
  51. private final static int[] ORE_OBJECTS = {32428, 32427, 32426};
  52. private final static int[] COAL_OBJECTS = {32428, 32427, 32426};
  53. private final static int BOX_ID = 25937;
  54. private final static int IRON_ID = 447;
  55. private final static int COAL_ID = 453;
  56. private static final RSTile[] tilesToMine = {new RSTile(1049, 4574), new RSTile(1056, 4574), new RSTile(1063, 4573)};
  57. RSTilePath pathToBank;
  58. private final static RSTile[] BOX_LOL = {new RSTile(3034, 9772)};
  59. private final static RSTile[] HelpImLost = {new RSTile(1064, 4573), new RSTile(1058, 4573), new RSTile(1052, 4574), new RSTile(1047, 4577)};
  60. private final static int MINING_ANIMATION = -1;
  61. private long startTime;
  62. private int coalPrice = 0;
  63. private int oresMined;
  64. public String statusText;
  65. public String myName;
  66. public int oresHour = 0;
  67. public boolean showPaint = true ;
  68. RSTilePath BOX,REORIENT;
  69. int startExp = 0;
  70. int expGained = 0;
  71. int profit = 0;
  72. int profithour = 0;
  73.  
  74.  
  75.  
  76.  
  77. public boolean onStart()
  78. {
  79.  
  80.  
  81.  
  82. statusText = "FUCKING INITIALIZING";
  83. if (!game.isLoggedIn())
  84. {
  85. log.severe("Try logging in first then restart the script!");
  86. stopScript();
  87. return false;
  88. }
  89. else
  90. {
  91. mouse.setSpeed(4);
  92. startTime = System.currentTimeMillis();
  93. startExp = skills.getCurrentExp(skills.MINING);
  94. coalPrice = 297;
  95. pathToBank = walking.newTilePath(tilesToMine);
  96. BOX = walking.newTilePath(BOX_LOL);
  97. REORIENT = walking.newTilePath(HelpImLost);
  98. log("Welcome to coalcrusherDungeonMiner by erguland!");
  99. log("Let's hope the script dont fuck up.");
  100. myName = account.getName();
  101. myName = myName.substring(0, 3);
  102. sleep(8000);
  103. if(checkJoin())
  104. {
  105. return true;
  106. }
  107. else
  108. {
  109. return false;
  110. }
  111. }
  112. }
  113.  
  114. public void mouseClicked(MouseEvent e)
  115. {
  116. RSComponent inter = interfaces.get(137).getComponent(0);
  117. if (inter.getArea().contains(e.getPoint())) {
  118. showPaint = !showPaint;
  119.  
  120. }
  121.  
  122. }
  123.  
  124. private final Color color1 = new Color(51, 51, 51);
  125. private final Color color2 = new Color(0, 0, 0);
  126. private final Color color3 = new Color(0, 153, 0);
  127.  
  128. private final BasicStroke stroke1 = new BasicStroke(1);
  129.  
  130. private final Font font1 = new Font("Arial", 0, 19);
  131.  
  132. public void walk() {
  133. pathToBank.traverse();
  134. }
  135. public void onRepaint(Graphics g) {
  136. expGained = skills.getCurrentExp(skills.MINING) - startExp;
  137.  
  138. long millis = System.currentTimeMillis() - startTime;
  139. long hours = millis / (1000 * 60 * 60);
  140. millis -= hours * (1000 * 60 * 60);
  141. long minutes = millis / (1000 * 60);
  142. millis -= minutes * (1000 * 60);
  143. long seconds = millis / 1000;
  144.  
  145. float oresMined = expGained / 50;
  146. float oresHour = (int) ((oresMined) * 3600000D / (System.currentTimeMillis() - startTime));
  147. float profit = oresMined * coalPrice;
  148. profithour = (int) ((profit) * 3600000D/ (System.currentTimeMillis() - startTime));
  149. float xpsec = 0;
  150. if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
  151. xpsec = ((float) expGained) / (float)(seconds + (minutes*60) + (hours*60*60));
  152.  
  153. }
  154. float xpmin = xpsec * 60;
  155. float xphour = xpmin * 60;
  156. float expGained = skills.getCurrentExp(skills.MINING) - startExp;
  157.  
  158. g.setFont(new Font("Arial", 0, 15));
  159. g.setColor(color1);
  160. g.fillRoundRect(549, 208, 190, 254, 16, 16);
  161. g.setColor(color2);
  162. g.drawRoundRect(549, 208, 190, 254, 16, 16);
  163. g.setFont(new Font("Arial", 0, 15));
  164. g.setColor(Color.CYAN);
  165. g.drawString("Mining skillcape almost here:P", 260, 470);
  166. g.drawString(statusText, 562, 226);
  167. g.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds, 562, 246);
  168. g.drawString("Experience gained: " + expGained, 562, 266);
  169. g.drawString("Exp/h: " + (int)xphour, 562, 286);
  170. g.drawString("Ores mined: " + oresMined , 562, 306);
  171. g.drawString("ores mined/h: " + oresHour , 562, 326);
  172. g.drawString("Profit: " + profit, 562, 346);
  173. g.drawString("profit/h: " + (int)profithour, 562, 366);
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180. }
  181.  
  182.  
  183.  
  184.  
  185.  
  186. private void setRun()
  187. {
  188. if (!walking.isRunEnabled() && walking.getEnergy() > 40)
  189. {
  190. statusText = "FUCKING RUNNING";
  191. walking.setRun(true);
  192. sleep(random(600, 800));
  193. return;
  194. }
  195. }
  196.  
  197. public void checkIntercept()
  198. {
  199. RSInterface chatBox = interfaces.get(137);
  200. if(chatBox != null)
  201. {
  202. for(int x = 180; x < 240; x++)
  203. {
  204. if(chatBox.getComponent(x) != null && chatBox.getComponent(x).getAbsoluteY() > 330)
  205. {
  206. String curCompText = chatBox.getComponent(x).getText();
  207. if(curCompText.contains("Does your house have stairs") && (!(curCompText.contains(myName))))
  208. {
  209. keyboard.sendText("|||", true);
  210. sleep(2000);
  211. }
  212. }
  213. }
  214. }
  215. }
  216.  
  217. public boolean checkJoin()
  218. {
  219. RSInterface chatBox = interfaces.get(137);
  220. if(chatBox != null)
  221. {
  222. for(int x = 180; x < 280; x++)
  223. {
  224. if(chatBox.getComponent(x) != null && chatBox.getComponent(x).getAbsoluteY() > 330)
  225. {
  226. String curCompText = chatBox.getComponent(x).getText();
  227. if(curCompText.contains("|||"))
  228. {
  229. log.severe("This mine already has a bot running in it. Switch to another world.");
  230. return false;
  231. }
  232.  
  233. }
  234. }
  235. return true;
  236. }
  237. return true;
  238. }
  239.  
  240.  
  241. private final void openBox()
  242. {
  243. RSObject box = objects.getNearest(BOX_ID);
  244. if(!box.isOnScreen() && box != null)
  245. {
  246. camera.turnTo(box);
  247. camera.setPitch(10);
  248. }
  249. else
  250. {
  251. if(box.isOnScreen() && box != null)
  252. {
  253. box.interact("Deposit");
  254. sleep(2000, 2500);
  255. }
  256. }
  257. }
  258.  
  259. private void goToBox()
  260. {
  261. BOX.traverse();
  262. }
  263.  
  264. private final void gobackplease()
  265. {
  266. REORIENT.traverse();
  267. sleep(2000, 2500);
  268. }
  269.  
  270.  
  271. private final void depositOres()
  272. {
  273. mouse.move(330, 261, 3, 3);
  274. mouse.click(true);
  275. sleep(800, 1200);
  276. }
  277.  
  278. private final boolean atBox()
  279. {
  280. RSObject boxy = objects.getNearest(BOX_ID);
  281. if(boxy != null) {
  282. if(boxy.isOnScreen()) {
  283. return true;
  284. } else {
  285. camera.turnTo(boxy);
  286. return false;
  287. }
  288. }
  289. return false;
  290. }
  291.  
  292. private final void mine()
  293. {
  294. RSObject oremine = objects.getNearest(ORE_OBJECTS);
  295. if(getMyPlayer().getAnimation() == MINING_ANIMATION && oremine != null)
  296. {
  297. statusText = "RUNNIN TO THE ORE";
  298. oremine.interact("Mine");
  299. }
  300. else
  301. {
  302. statusText = "FUCKING MINING";
  303. objects.getNearest(ORE_OBJECTS);
  304. }
  305. sleep(1800,2000);
  306.  
  307. }
  308.  
  309. private final void minecoal()
  310. {
  311. RSObject oremine = objects.getNearest(COAL_OBJECTS);
  312. if(getMyPlayer().getAnimation() == MINING_ANIMATION && oremine != null)
  313. {
  314. statusText = "RUNNIN TO THE COAL";
  315. oremine.interact("Mine");
  316. }
  317. else
  318. {
  319. statusText = "MINING THE DAMN COAL";
  320. objects.getNearest(COAL_OBJECTS);
  321. }
  322. sleep(1800,2000);
  323.  
  324. }
  325.  
  326.  
  327.  
  328. public void do_Nothing()
  329. {
  330. sleep(random(10, 50));
  331. }
  332.  
  333.  
  334. private final boolean atOres()
  335. {
  336. RSObject ores = objects.getNearest(ORE_OBJECTS);
  337. if(ores != null)
  338. {
  339. if(ores.isOnScreen())
  340. {
  341. return true;
  342. }
  343. }
  344. return false;
  345. }
  346.  
  347. @Override
  348.  
  349. public int loop()
  350. {
  351. checkIntercept();
  352. antiban(); setRun();
  353. if(!atOres() && !inventory.isFull())
  354. {
  355. RSObject oreo = objects.getNearest(ORE_OBJECTS);
  356. if(oreo != null)
  357. {
  358. statusText = "SHEARCHING FOR ROCKS";
  359. camera.turnTo(oreo);
  360. camera.setPitch(100);
  361. sleep(random(800, 1000));
  362. walk();
  363.  
  364. }
  365. else
  366. {
  367. RSObject coaly = objects.getNearest(COAL_OBJECTS);
  368. if(coaly != null)
  369. {
  370. camera.turnTo(coaly);
  371. camera.setPitch(100);
  372. minecoal();
  373. }
  374. else
  375. {
  376. statusText = "SHEARCHING FOR COAL";
  377. walk();
  378. camera.setPitch(100);
  379. sleep(random(800, 1000));
  380. }
  381. }
  382. }
  383.  
  384. if(atOres() && !inventory.isFull())
  385. {
  386. mine();
  387. }
  388. if(inventory.isFull())
  389. {
  390. while(!atBox())
  391. {
  392. statusText = "SEARCHING FOR DEPOSIT BOX";
  393. gobackplease();
  394. sleep(random(500, 1000));
  395. }
  396. while(!bank.isDepositOpen())
  397. {
  398. goToBox();
  399. statusText = "OPENING DEPOSIT BOX";
  400. openBox();
  401. sleep(random(500, 1000));
  402.  
  403. }
  404. statusText = "BANK THAT SHIT";
  405. bank.depositAll();
  406. sleep(random(500, 3000));
  407. bank.close();
  408. sleep(random(500, 2000));
  409. gobackplease();
  410. }
  411.  
  412. if(combat.getLifePoints() < 60)
  413. {
  414. statusText = "FUCKING DEAD";
  415. log.severe("------------------------------------------------------------------------");
  416. log.severe("Hey, you're probably going to die--not that this script will do anything");
  417. log.severe("------------------------------------------------------------------------");
  418. stopScript();
  419. sleep(5000);
  420. }
  421.  
  422. return 1;
  423. }
  424.  
  425.  
  426. public void antiban() {
  427.  
  428. statusText = "FUCKING WITH THE ANTIBAN";
  429. int b = random(0, 10);
  430. switch (b) {
  431. case 1:
  432. if (random(0, 10) == 5) {
  433. log("[Antiban] move mouse");
  434. mouse.moveSlightly();
  435. sleep(200, 600);
  436. mouse.moveRandomly(150, 350);
  437. }
  438. break;
  439. case 2:
  440. if (random(0, 13) == 2) {
  441. log("[Antiban] Turn screen");
  442. camera.setAngle(random(30, 70));
  443. sleep(400, 1200);
  444.  
  445. }
  446. break;
  447. case 3:
  448. if (random(0, 24) == 6) {
  449. log("[Antiban] mouse off screen");
  450. mouse.moveOffScreen();
  451. sleep(random(600, random(1200, 2000)));
  452. }
  453. break;
  454. case 4:
  455. if (random(0, 30) == 4) {
  456. log("[antiban] Setting camera pitch.");
  457. camera.setPitch(random(10, 99));
  458. sleep(2500, 3400);
  459. }
  460. break;
  461. case 5:
  462. if (random(0, 28) == 5) {
  463. log("[antiban] Checking Xp.");
  464. game.openTab(2);
  465. skills.doHover(Skills.INTERFACE_MINING);
  466. sleep(2000, 2200);
  467. }
  468. default:
  469. break;
  470. }
  471. }
  472.  
  473. public void onFinish()
  474. {
  475. log("Nap time.");
  476. log("Ores mined " + oresMined);
  477. log("Experience gained: " + expGained);
  478. log("Profit: " + profit);
  479. }
  480.  
  481. @Override
  482. public void mouseEntered(MouseEvent e) {
  483. // TODO Auto-generated method stub
  484.  
  485. }
  486.  
  487. @Override
  488. public void mouseExited(MouseEvent e) {
  489. // TODO Auto-generated method stub
  490.  
  491. }
  492.  
  493. @Override
  494. public void mousePressed(MouseEvent e) {
  495. // TODO Auto-generated method stub
  496.  
  497. }
  498.  
  499. @Override
  500. public void mouseReleased(MouseEvent e) {
  501. // TODO Auto-generated method stub
  502.  
  503. }
  504.  
  505.  
  506.  
  507. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement