Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.57 KB | None | 0 0
  1. import java.awt.Color;
  2.  
  3. import java.awt.Font;
  4.  
  5. import java.awt.Graphics;
  6.  
  7. import java.awt.Point;
  8.  
  9. import java.awt.Polygon;
  10.  
  11. import java.util.ArrayList;
  12.  
  13.  
  14. import org.rsbot.event.listeners.PaintListener;
  15.  
  16. import org.rsbot.script.Script;
  17.  
  18. import org.rsbot.script.ScriptManifest;
  19.  
  20. import org.rsbot.script.wrappers.*;
  21.  
  22.  
  23. @ScriptManifest(
  24.  
  25. authors = ("ibotlots"),
  26.  
  27. version = 1.0,
  28.  
  29. keywords = "Blast",
  30.  
  31. description = "Makes Mithril Bolts at the Blast Furnace",
  32.  
  33. name = "Blast Furnace"
  34.  
  35. )
  36.  
  37. public class BlastFurnace extends Script implements PaintListener{
  38.  
  39.  
  40.  
  41. //ID'S.
  42.  
  43. private int coaln = 454;
  44.  
  45. private int mithn = 448;
  46.  
  47. private int barID = 2359;
  48.  
  49. private int mith = 447;
  50.  
  51. private int coal = 453;
  52.  
  53. private int hammer = 2347;
  54.  
  55. private int bolts = 9379;
  56.  
  57. private int money = 995;
  58.  
  59.  
  60.  
  61. private int lol = 1;
  62.  
  63. private long startTime = 0;
  64.  
  65. private int barcount = 0;
  66.  
  67.  
  68.  
  69. @Override
  70.  
  71. public boolean onStart(){
  72.  
  73. startTime = System.currentTimeMillis();
  74.  
  75. log("Started Up");
  76.  
  77. return true;
  78.  
  79. }
  80.  
  81.  
  82.  
  83. @Override
  84.  
  85. public int loop() {
  86.  
  87. while( lol > 0){
  88.  
  89. RSItem Mith = inventory.getItem(448);
  90.  
  91. RSItem Coal = inventory.getItem(454);
  92.  
  93. RSNPC Ordan = npcs.getNearest("Ordan");
  94.  
  95. RSObject Belt = objects.getNearest(9100);
  96.  
  97. RSObject Dispenser = objects.getNearest(9092);
  98.  
  99. RSObject Anvil = objects.getNearest(17073);
  100.  
  101. RSTile beltTile = new RSTile(1943,4967);
  102.  
  103. RSTile ordanTile = new RSTile(1936, 4966);
  104.  
  105. RSTile dispenserTile = new RSTile(1940,4963);
  106.  
  107. RSTile anvilTile = new RSTile(1938,4971);
  108.  
  109. inventory.dropAllExcept(mithn,coaln,barID,mith,coal,hammer,bolts,money);
  110.  
  111. if(!inventory.containsAll(mithn,coaln,money,hammer)){
  112.  
  113. log("Out of Ore or Cash or Hammers");
  114.  
  115. lol = -1;
  116.  
  117. }
  118.  
  119. if(lol < 0){
  120.  
  121. return(0);
  122.  
  123. }
  124.  
  125. if(lol==1){
  126.  
  127. //Stage 1 - Un-noting Mithril
  128.  
  129. if(Ordan.isOnScreen() && inventory.getCount() < 6){
  130.  
  131. Mith.doAction("Use"); // Select mithril notes
  132.  
  133. sleep(random(20,150));
  134.  
  135. clickNPC(Ordan, "Use Mithril ore ->", false); // Use mithril on Ordan
  136.  
  137. sleep(random(3000,5000));
  138.  
  139. if(interfaces.get(232).isValid()){
  140.  
  141. interfaces.get(232).getComponent(5).doClick(); // Click X
  142.  
  143. sleep(random(1500,2000));
  144.  
  145. keyboard.sendText("23", true); //Type 23
  146.  
  147. sleep(random(1500,2000));
  148.  
  149. interfaces.get(241).getComponent(5).doClick(); //Click Continue
  150.  
  151. sleep(random(1500,2000));
  152.  
  153. interfaces.get(228).getComponent(2).doClick(); //It's a deal!
  154.  
  155. sleep(random(1500,2000));
  156.  
  157. interfaces.get(64).getComponent(5).doClick(); //Click to Continue
  158.  
  159. sleep(random(1000,1500));
  160.  
  161. }
  162.  
  163. }
  164.  
  165. else if(inventory.getCount()>25){
  166.  
  167. lol = 2;
  168.  
  169. }
  170.  
  171.  
  172.  
  173. else {
  174.  
  175. walking.walkTileOnScreen(ordanTile);
  176.  
  177. sleep(random(1000,2000));
  178.  
  179. }
  180.  
  181. }
  182.  
  183. if(lol==2){
  184.  
  185. //Placing Mithril on Belt
  186.  
  187. if(Belt.isOnScreen()){
  188.  
  189. Belt.doClick();
  190.  
  191. sleep(random(3000,5000));
  192.  
  193. interfaces.get(228).getComponent(2).doClick(); //Yes
  194.  
  195. sleep(random(2000,3000));
  196.  
  197. if(inventory.getCount()<=5){
  198.  
  199. lol=3;
  200.  
  201. }
  202.  
  203. }
  204.  
  205. else {
  206.  
  207. walking.walkTileOnScreen(beltTile);
  208.  
  209. sleep(random(1000,2000));
  210.  
  211. }
  212.  
  213. }
  214.  
  215. if(lol==3){
  216.  
  217. //Stage 3 - Un-noting Coal
  218.  
  219. if(Ordan.isOnScreen() && inventory.getCount() < 6){
  220.  
  221. Coal.doAction("Use"); // Select coal notes
  222.  
  223. sleep(random(20,150));
  224.  
  225. clickNPC(Ordan, "Use Coal ->", false); // Use coal on Ordan
  226.  
  227. sleep(random(3000,5000));
  228.  
  229. if(interfaces.get(232).isValid()){
  230.  
  231. interfaces.get(232).getComponent(5).doClick(); // Click X
  232.  
  233. sleep(random(1500,2000));
  234.  
  235. keyboard.sendText("23", true); //Type 23
  236.  
  237. sleep(random(1500,2000));
  238.  
  239. interfaces.get(241).getComponent(5).doClick(); //Click Continue
  240.  
  241. sleep(random(1500,2000));
  242.  
  243. interfaces.get(228).getComponent(2).doClick(); //It's a deal!
  244.  
  245. sleep(random(1500,2000));
  246.  
  247. interfaces.get(64).getComponent(5).doClick(); //Click to Continue
  248.  
  249. sleep(random(1000,1500));
  250.  
  251. }
  252.  
  253. }
  254.  
  255. else if(inventory.getCount()>25){
  256.  
  257. lol = 4;
  258.  
  259. }
  260.  
  261. else {
  262.  
  263. walking.walkTileOnScreen(ordanTile);
  264.  
  265. sleep(random(1000,2000));
  266.  
  267. }
  268.  
  269. }
  270.  
  271. if(lol==4){
  272.  
  273. //Placing Coal on Belt
  274.  
  275. if(Belt.isOnScreen()){
  276.  
  277. Belt.doClick();
  278.  
  279. sleep(random(3000,5000));
  280.  
  281. interfaces.get(228).getComponent(2).doClick(); //Yes
  282.  
  283. sleep(random(2000,3000));
  284.  
  285. if(inventory.getCount()<=5){
  286.  
  287. lol=5;
  288.  
  289. }
  290.  
  291. }
  292.  
  293. else {
  294.  
  295. walking.walkTileOnScreen(beltTile);
  296.  
  297. sleep(random(1000,2000));
  298.  
  299. }
  300.  
  301. }
  302.  
  303. if(lol==5){
  304.  
  305. //Stage 5 - Un-noting Coal Again
  306.  
  307. if(Ordan.isOnScreen() && inventory.getCount() < 6){
  308.  
  309. Coal.doAction("Use"); // Select coal notes
  310.  
  311. sleep(random(20,150));
  312.  
  313. clickNPC(Ordan, "Use Coal ->", false); // Use coal on Ordan
  314.  
  315. sleep(random(3000,5000));
  316.  
  317. if(interfaces.get(232).isValid()){
  318.  
  319. interfaces.get(232).getComponent(5).doClick(); // Click X
  320.  
  321. sleep(random(1500,2000));
  322.  
  323. keyboard.sendText("23", true); //Type 23
  324.  
  325. sleep(random(1500,2000));
  326.  
  327. interfaces.get(241).getComponent(5).doClick(); //Click Continue
  328.  
  329. sleep(random(1500,2000));
  330.  
  331. interfaces.get(228).getComponent(2).doClick(); //It's a deal!
  332.  
  333. sleep(random(1500,2000));
  334.  
  335. interfaces.get(64).getComponent(5).doClick(); //Click to Continue
  336.  
  337. sleep(random(1000,1500));
  338.  
  339. }
  340.  
  341. }
  342.  
  343. if(inventory.getCount()>25){
  344.  
  345. lol = 6;
  346.  
  347. }
  348.  
  349. else {
  350.  
  351. walking.walkTileOnScreen(ordanTile);
  352.  
  353. sleep(random(1000,2000));
  354.  
  355. }
  356.  
  357. }
  358.  
  359. if(lol==6){
  360.  
  361. //Placing Coal on Belt Again
  362.  
  363. if(Belt.isOnScreen()){
  364.  
  365. Belt.doClick();
  366.  
  367. sleep(random(3000,5000));
  368.  
  369. interfaces.get(228).getComponent(2).doClick(); //Yes
  370.  
  371. sleep(random(2000,3000));
  372.  
  373. if(inventory.getCount()<=5){
  374.  
  375. lol=7;
  376.  
  377. }
  378.  
  379. }
  380.  
  381. else {
  382.  
  383. walking.walkTileOnScreen(beltTile); //Walk to belt if not on screen
  384.  
  385. sleep(random(1000,2000));
  386.  
  387. }
  388.  
  389. }
  390.  
  391. if(lol==7){
  392.  
  393. while(!Dispenser.isOnScreen()){ //Walk to dispenser if it's not on screen
  394.  
  395. walking.walkTileOnScreen(dispenserTile);
  396.  
  397. }
  398.  
  399. while(inventory.getCount()<25){ //Picking up bars
  400.  
  401. sleep(random(5000,10000));
  402.  
  403. Dispenser.doClick();
  404.  
  405. sleep(random(1000,2000));
  406.  
  407. if(interfaces.get(28).getComponent(34).containsText("23")){
  408.  
  409. interfaces.get(28).getComponent(35).doClick();
  410.  
  411. sleep(random(1000,2000));
  412.  
  413. }
  414.  
  415. interfaces.get(28).getComponent(12).doClick();
  416.  
  417. }
  418.  
  419. lol = 8;
  420.  
  421. }
  422.  
  423. if(lol==8){
  424.  
  425. //Smithing the bars
  426.  
  427. if(Anvil.isOnScreen()&& getMyPlayer().isIdle()){
  428.  
  429. if(!interfaces.get(300).isValid()){
  430.  
  431. RSItem Bar = inventory.getItem(barID);
  432.  
  433. Bar.doAction("Use"); // Select a bar
  434.  
  435. sleep(random(1500,2000));
  436.  
  437. Anvil.doAction("Use Mithril bar -> Anvil");
  438.  
  439. sleep(random(3000,4000));
  440.  
  441. if(interfaces.get(300).isValid()){
  442.  
  443. interfaces.getComponent(300, 53).doAction("Make All");
  444.  
  445. sleep(57000);
  446.  
  447. }
  448.  
  449. sleep(3000);
  450.  
  451. }
  452.  
  453. }
  454.  
  455. else if(!Anvil.isOnScreen()){
  456.  
  457. walking.walkTileOnScreen(anvilTile);
  458.  
  459. sleep(random(1000,2000));
  460.  
  461. }
  462.  
  463. else {
  464.  
  465. sleep(random(1000,2000));
  466.  
  467. }
  468.  
  469. if(inventory.getCount()==5){
  470.  
  471. barcount = barcount + 23;
  472.  
  473. lol=1;
  474.  
  475. }
  476.  
  477. }
  478.  
  479. }
  480.  
  481. return(1);
  482.  
  483. }
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490. public void onFinish() {
  491.  
  492. log("All Done");
  493.  
  494. }
  495.  
  496.  
  497.  
  498. private boolean clickNPC(RSNPC npc, String action,
  499.  
  500. boolean useCentralClicking) {
  501.  
  502. Point p;
  503.  
  504. int def = mouse.getSpeed();
  505.  
  506. for (int i = 0; i < 4; i++) {
  507.  
  508. if (isPartiallyOnScreen(npc.getModel())) {
  509.  
  510. p = useCentralClicking ? getCentralPoint(npc.getModel())
  511.  
  512. : getPointOnScreen(npc.getModel(), true);
  513.  
  514. do {
  515.  
  516. p = useCentralClicking ? getCentralPoint(npc.getModel())
  517.  
  518. : getPointOnScreen(npc.getModel(), false);
  519.  
  520. mouse.move(p, 0, 0);
  521.  
  522. } while (isPartiallyOnScreen(npc.getModel()) && p.x != -1
  523.  
  524. && p.y != -1 && p != null && calc.pointOnScreen(p)
  525.  
  526. && !bank.isOpen()
  527.  
  528. && !mouse.getLocation().equals(p)
  529.  
  530. && !menu.contains(action));
  531.  
  532. String[] items = menu.getItems();
  533.  
  534. if (items.length > 0
  535.  
  536. && items[0].toLowerCase().startsWith(
  537.  
  538. action.toLowerCase())) {
  539.  
  540. mouse.click(true);
  541.  
  542. return true;
  543.  
  544. } else if (menu.contains(action)) {
  545.  
  546. mouse.setSpeed(random(6, 9));
  547.  
  548. mouse.click(false);
  549.  
  550. sleep(random(100, 200));
  551.  
  552. for (int x = 0; x < 4; x++) {
  553.  
  554. if (menu.doAction(action)) {
  555.  
  556. mouse.setSpeed(def);
  557.  
  558. return true;
  559.  
  560. }
  561.  
  562. }
  563.  
  564. }
  565.  
  566. if (!menu.contains(action) && menu.isOpen()) {
  567.  
  568. do {
  569.  
  570. mouse.moveRandomly(random(180, 422));
  571.  
  572. } while (menu.isOpen());
  573.  
  574. sleep(random(75, 220));
  575.  
  576. return false;
  577.  
  578. }
  579.  
  580. }
  581.  
  582. }
  583.  
  584. return false;
  585.  
  586. }
  587.  
  588.  
  589. private boolean isPartiallyOnScreen(RSModel m) {
  590.  
  591. return getPointOnScreen(m, true) != null;
  592.  
  593. }
  594.  
  595.  
  596. private Point getPointOnScreen(RSModel m, boolean first) {
  597.  
  598. if (m == null) {
  599.  
  600. return null;
  601.  
  602. }
  603.  
  604. ArrayList<Point> list = new ArrayList<Point>();
  605.  
  606. try {
  607.  
  608. Polygon[] tris = m.getTriangles();
  609.  
  610. for (int i = 0; i < tris.length; i++) {
  611.  
  612. Polygon p = tris[i];
  613.  
  614. for (int j = 0; j < p.xpoints.length; j++) {
  615.  
  616. Point pt = new Point(p.xpoints[j], p.ypoints[j]);
  617.  
  618. if (calc.pointOnScreen(pt)) {
  619.  
  620. if (first) {
  621.  
  622. return pt;
  623.  
  624. }
  625.  
  626. list.add(pt);
  627.  
  628. }
  629.  
  630. }
  631.  
  632. }
  633.  
  634. } catch (Exception e) {
  635.  
  636. }
  637.  
  638. return list.size() > 0 ? list.get(random(0, list.size())) : null;
  639.  
  640. }
  641.  
  642.  
  643. private Point getCentralPoint(RSModel m) {
  644.  
  645. if (m == null) {
  646.  
  647. return null;
  648.  
  649. }
  650.  
  651. try {
  652.  
  653. int x = 0, y = 0, total = 0;
  654.  
  655. for (Polygon poly : m.getTriangles()) {
  656.  
  657. for (int i = 0; i < poly.npoints; i++) {
  658.  
  659. x += poly.xpoints[i];
  660.  
  661. y += poly.ypoints[i];
  662.  
  663. total++;
  664.  
  665. }
  666.  
  667. }
  668.  
  669. Point central = new Point(x / total, y / total);
  670.  
  671. Point curCentral = null;
  672.  
  673. double dist = 20000;
  674.  
  675. for (Polygon poly : m.getTriangles()) {
  676.  
  677. for (int i = 0; i < poly.npoints; i++) {
  678.  
  679. Point p = new Point(poly.xpoints[i], poly.ypoints[i]);
  680.  
  681. if (!calc.pointOnScreen(p)) {
  682.  
  683. continue;
  684.  
  685. }
  686.  
  687. double dist2 = distanceBetween(central, p);
  688.  
  689. if (curCentral == null || dist2 < dist) {
  690.  
  691. curCentral = p;
  692.  
  693. dist = dist2;
  694.  
  695. }
  696.  
  697. }
  698.  
  699. }
  700.  
  701. return curCentral;
  702.  
  703. } catch (Exception e) {
  704.  
  705. }
  706.  
  707. return null;
  708.  
  709. }
  710.  
  711.  
  712. private double distanceBetween(Point p1, Point p2) {
  713.  
  714. return Math.sqrt(((p1.x - p2.x) * (p1.x - p2.x))
  715.  
  716. + ((p1.y - p2.y) * (p1.y - p2.y)));
  717.  
  718. }
  719.  
  720.  
  721.  
  722. //PAINT
  723.  
  724.  
  725. @Override
  726.  
  727. public void onRepaint(Graphics g) {
  728.  
  729. long millis = System.currentTimeMillis() - startTime;
  730.  
  731. long hours = millis / (1000*60*60);
  732.  
  733. millis -= hours * (1000*60*60);
  734.  
  735. long minutes = millis / (1000*60);
  736.  
  737. millis -= minutes * (1000*60);
  738.  
  739. long seconds = millis / 1000;
  740.  
  741. long experience = barcount*80;
  742.  
  743. long exppersec = experience / (60*60*hours+60*minutes+seconds);
  744.  
  745. long exppermin = exppersec / 60;
  746.  
  747. long expperhour = exppermin / 60;
  748.  
  749.  
  750.  
  751. g.setColor(Color.ORANGE);
  752.  
  753. g.drawRect(1, 340, 519, 135);
  754.  
  755.  
  756.  
  757. g.setColor(Color.BLACK);
  758.  
  759. g.setFont(new Font("Arial", 0, 12));
  760.  
  761. g.drawString("Runetime: "+hours+":"+minutes+":"+seconds,267,372);
  762.  
  763. g.drawString("Bars Used: "+barcount, 267, 387);
  764.  
  765. g.drawString("Experience Gained: "+experience, 267, 402);
  766.  
  767. g.drawString("Experience per Hour: "+expperhour, 267, 417);
  768.  
  769. }
  770.  
  771. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement