Advertisement
Guest User

Untitled

a guest
Jan 13th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.75 KB | None | 0 0
  1. package scripts;
  2.  
  3. import javafx.application.Application;
  4.  
  5. import javax.swing.DefaultComboBoxModel;
  6. import javax.swing.JComboBox;
  7. import javax.swing.JLabel;
  8. import javax.swing.JOptionPane;
  9. import javax.swing.JPanel;
  10.  
  11. import java.awt.Color;
  12. import java.awt.Font;
  13. import java.awt.Graphics;
  14. import java.awt.Graphics2D;
  15. import java.awt.Image;
  16. import java.awt.Rectangle;
  17. import java.io.IOException;
  18. import java.net.URL;
  19. import java.util.ArrayList;
  20. import java.util.Random;
  21.  
  22. import javax.imageio.ImageIO;
  23.  
  24. import org.tribot.api.General;
  25. import org.tribot.api.input.Keyboard;
  26. import org.tribot.api.input.Mouse;
  27. import org.tribot.api.interfaces.Positionable;
  28. import org.tribot.api2007.Banking;
  29. import org.tribot.api2007.Equipment;
  30. import org.tribot.api2007.Game;
  31. import org.tribot.api2007.GameTab;
  32. import org.tribot.api2007.GameTab.TABS;
  33. import org.tribot.api2007.ChooseOption;
  34. import org.tribot.api2007.Interfaces;
  35. import org.tribot.api2007.Inventory;
  36. import org.tribot.api2007.Objects;
  37. import org.tribot.api2007.Player;
  38. import org.tribot.api2007.Walking;
  39. import org.tribot.api2007.WebWalking;
  40. import org.tribot.api2007.Skills.SKILLS;
  41. import org.tribot.api2007.types.RSInterface;
  42. import org.tribot.api2007.types.RSInterfaceChild;
  43. import org.tribot.api2007.types.RSItem;
  44. import org.tribot.api2007.types.RSObject;
  45. import org.tribot.api2007.types.RSTile;
  46. import org.tribot.script.Script;
  47. import org.tribot.script.ScriptManifest;
  48. import org.tribot.api.Timing;
  49. import org.tribot.api2007.Skills;
  50. import org.tribot.script.interfaces.MessageListening07;
  51. import org.tribot.script.interfaces.Painting;
  52.  
  53. @ScriptManifest(authors = { "ITryNotToTroll" }, category = "Smithing", name = "Troll Smelter v2")
  54. public class TrollSmelter extends Script implements Painting, MessageListening07{
  55.  
  56. State state;
  57. Bar bar;
  58.  
  59. public static TrollSmelterGUI gui = new TrollSmelterGUI();
  60.  
  61. //IDs
  62. private final int
  63. BAR_SELECT_INTERFACE_ID = 311,
  64. SMELTING_ANIMATION_ID = 899,
  65. BAR_SELECT_INTERFACE_BRONZE_ID = 4,
  66. BAR_SELECT_INTERFACE_IRON_ID = 6,
  67. BAR_SELECT_INTERFACE_SILVER_ID = 7,
  68. BAR_SELECT_INTERFACE_STEEL_ID = 8,
  69. BAR_SELECT_INTERFACE_GOLD_ID = 9,
  70. BAR_SELECT_INTERFACE_MITHRIL_ID = 10,
  71. BAR_SELECT_INTERFACE_ADAMANTITE_ID = 11,
  72. BAR_SELECT_INTERFACE_RUNITE_ID = 12,
  73. CANNONBALL_SELECT_INTERFACE_ID = 309,
  74. CANNONBALL_SELECT_INTERFACE_CHILD_ID = 7;
  75.  
  76.  
  77. //GUI Variables
  78. private static RSTile furnaceTile;
  79. private boolean usingForging = true;
  80. public static ArrayList<String> barArrayList = new ArrayList<String>();
  81. public static ArrayList<Integer> stoppingConditionList = new ArrayList<Integer>();
  82. //Paint Variables
  83. private int currentLevel;
  84. private long currentXP;
  85. private int barsMade = 0;
  86.  
  87. //Paint Constants
  88. private final int START_LEVEL = Skills.getActualLevel(SKILLS.SMITHING);
  89. private final int START_XP = Skills.getXP(SKILLS.SMITHING);
  90. private final long START_TIME = System.currentTimeMillis();
  91. private final double VERSION = 2;
  92. //Script Variables
  93. private int randomInput = (int) Math.random() * 71 + 28;
  94. public static boolean running = false;
  95. private int actionsLoop = 0;
  96. private int lastAmountBarsMade = 0;
  97. private Rectangle hoverBox;
  98.  
  99. //Enums
  100. enum State {
  101. USE_BANK,
  102. CLOSE_BANK,
  103. EQUIP_FORGING,
  104. WALK_TO_FURNACE,
  105. WALK_TO_BANK,
  106. USE_FURNACE,
  107. CLICK_BAR,
  108. OPEN_BANK,
  109. USE_FIRST_INTERFACE,
  110. USE_SECOND_INTERFACE,
  111. ANIMATING
  112. }
  113.  
  114. enum Bar {
  115. BRONZE,
  116. IRON,
  117. STEEL,
  118. MITHRIL,
  119. ADAMANTITE,
  120. RUNITE,
  121. SILVER,
  122. GOLD,
  123. CANNONBALLS;
  124. }
  125.  
  126. //Really? It runs!
  127. @Override
  128. public void run() {
  129. initialiseScript();
  130. for(;actionsLoop<barArrayList.size();actionsLoop++)
  131. {
  132. bar = setBar(barArrayList.get(actionsLoop));
  133. int barsToMake = stoppingConditionList.get(actionsLoop);
  134. lastAmountBarsMade = barsMade;
  135. while(barsMade - lastAmountBarsMade < barsToMake)
  136. {
  137. state = getState();
  138. switch(state)
  139. {
  140. case USE_BANK:
  141. useBank();
  142. break;
  143. case CLOSE_BANK:
  144. closeBank();
  145. break;
  146. case OPEN_BANK:
  147. openBank();
  148. break;
  149. case EQUIP_FORGING:
  150. equipForging();
  151. break;
  152. case WALK_TO_FURNACE:
  153. walkToFurnace();
  154. break;
  155. case WALK_TO_BANK:
  156. walkToBank();
  157. break;
  158. case USE_FURNACE:
  159. useFurnace();
  160. break;
  161. case USE_FIRST_INTERFACE:
  162. useFirstInterface();
  163. break;
  164. case USE_SECOND_INTERFACE:
  165. useSecondInterface();
  166. break;
  167. case CLICK_BAR:
  168. clickBar();
  169. break;
  170. case ANIMATING:
  171. animatingSleep();
  172. break;
  173. }
  174. sleep(20, 70);
  175. }
  176. }
  177. }
  178.  
  179. //Get current state of script
  180. public State getState()
  181. {
  182. if(Banking.isInBank())
  183. {
  184. if(needToEquipForging())
  185. {
  186. if(Banking.isBankScreenOpen())
  187. {
  188. return State.CLOSE_BANK;
  189. }
  190. else
  191. {
  192. return State.EQUIP_FORGING;
  193. }
  194. }
  195. else
  196. {
  197. if(needToBank())
  198. {
  199.  
  200. if(!Banking.isBankScreenOpen())
  201. {
  202. return State.OPEN_BANK;
  203. }
  204. else
  205. {
  206. return State.USE_BANK;
  207. }
  208. }
  209. else
  210. {
  211. return State.WALK_TO_FURNACE;
  212. }
  213. }
  214. }
  215. else
  216. {
  217. if(isInFurnace())
  218. {
  219. if(needToBank())
  220. {
  221. return State.WALK_TO_BANK;
  222. }
  223. else
  224. {
  225. if(isFirstInterfaceOpen())
  226. {
  227. return State.USE_FIRST_INTERFACE;
  228. }
  229. else
  230. {
  231. if(isSecondInterfaceOpen() && !isFirstInterfaceOpen())
  232. {
  233. return State.USE_SECOND_INTERFACE;
  234. }
  235. else
  236. {
  237. if(bar == Bar.CANNONBALLS)
  238. {
  239. if(Game.isUptext("Use Steel"))
  240. {
  241. return State.USE_FURNACE;
  242. }
  243. else
  244. {
  245. if(isAnimating())
  246. {
  247. return State.ANIMATING;
  248. }
  249. else
  250. {
  251. return State.CLICK_BAR;
  252. }
  253. }
  254. }
  255. else
  256. {
  257. if(isAnimating())
  258. {
  259. return State.ANIMATING;
  260. }
  261. else
  262. {
  263. return State.USE_FURNACE;
  264. }
  265. }
  266. }
  267.  
  268. }
  269. }
  270. }
  271. else
  272. {
  273. return State.WALK_TO_BANK;
  274. }
  275. }
  276. }
  277.  
  278. private void initialiseScript()
  279. {
  280. gui.setVisible(true);
  281. while(!running)
  282. {
  283. sleep(20, 50);
  284. }
  285.  
  286. if(furnaceTile == null)
  287. {
  288. println("Please re-run then select a furnace tile");
  289. running = false;
  290. }
  291. else
  292. {
  293. if(barArrayList.size() == 0 || stoppingConditionList.size() == 0)
  294. {
  295. println("Please re-run then select items (and their amounts!) to smelt");
  296. running = false;
  297. }
  298. }
  299. }
  300.  
  301. private Bar setBar(String string)
  302. {
  303. switch(string)
  304. {
  305. case "Bronze Bar":
  306. return Bar.BRONZE;
  307. case "Iron Bar":
  308. return Bar.IRON;
  309. case "Steel Bar":
  310. return Bar.STEEL;
  311. case "Mithril Bar":
  312. return Bar.MITHRIL;
  313. case "Adamantite Bar":
  314. return Bar.ADAMANTITE;
  315. case "Runite Bar":
  316. return Bar.RUNITE;
  317. case "Cannonballs":
  318. return Bar.CANNONBALLS;
  319. case "Gold Bar":
  320. return Bar.GOLD;
  321. case "Silver Bar":
  322. return Bar.SILVER;
  323. }
  324. return Bar.CANNONBALLS;
  325. }
  326.  
  327. private boolean needToBank()
  328. {
  329. switch(bar)
  330. {
  331. case BRONZE:
  332. return Inventory.getCount("Tin ore") == 0 || Inventory.getCount("Copper ore") == 0;
  333. case IRON:
  334. return Inventory.getCount("Iron ore") == 0;
  335. case STEEL:
  336. return Inventory.getCount("Iron ore") == 0 || Inventory.getCount("Coal") < 2;
  337. case MITHRIL:
  338. return Inventory.getCount("Mithril ore") == 0 || Inventory.getCount("Coal") < 4;
  339. case ADAMANTITE:
  340. return Inventory.getCount("Adamantite ore") == 0 || Inventory.getCount("Coal") < 6;
  341. case RUNITE:
  342. return Inventory.getCount("Runite ore") == 0 || Inventory.getCount("Coal") < 8;
  343. case SILVER:
  344. return Inventory.getCount("Silver ore") == 0;
  345. case GOLD:
  346. return Inventory.getCount("Gold ore") == 0;
  347. case CANNONBALLS:
  348. return Inventory.getCount("Steel bar") ==0 || Inventory.getCount("Ammo mould") == 0;
  349. }
  350. return true;
  351. }
  352.  
  353. private boolean needToEquipForging()
  354. {
  355. return Inventory.getCount("Ring of forging") > 0 && !Equipment.isEquipped("Ring of forging") && usingForging;
  356. }
  357.  
  358. private boolean isInFurnace()
  359. {
  360. return Player.getPosition().distanceTo(furnaceTile) < 3;
  361. }
  362.  
  363. private boolean isAnimating()
  364. {
  365. if(Player.getPosition().distanceTo(furnaceTile) < 5
  366. && (Inventory.getCount(barArrayList.get(actionsLoop)) >0
  367. || Inventory.isFull()))
  368. {
  369. long timeout = System.currentTimeMillis();
  370. while(timeout + 3000 > System.currentTimeMillis())
  371. {
  372. if(Player.getAnimation() != -1)
  373. {
  374. return true;
  375. }
  376. sleep(50, 100);
  377. }
  378. return false;
  379. }
  380. else
  381. {
  382. return false;
  383. }
  384. }
  385.  
  386. private boolean isFirstInterfaceOpen()
  387. {
  388. RSInterface barSmeltInterface;
  389. switch(bar)
  390. {
  391. case BRONZE:
  392. case IRON:
  393. case STEEL:
  394. case MITHRIL:
  395. case ADAMANTITE:
  396. case RUNITE:
  397. case SILVER:
  398. case GOLD:
  399. barSmeltInterface = Interfaces.get(BAR_SELECT_INTERFACE_ID,BAR_SELECT_INTERFACE_BRONZE_ID);
  400. return barSmeltInterface != null && !barSmeltInterface.isHidden();
  401. case CANNONBALLS:
  402. barSmeltInterface = Interfaces.get(CANNONBALL_SELECT_INTERFACE_ID, CANNONBALL_SELECT_INTERFACE_CHILD_ID);
  403. return barSmeltInterface != null && !barSmeltInterface.isHidden();
  404. }
  405. return false;
  406. }
  407.  
  408. private boolean isSecondInterfaceOpen()
  409. {
  410. return Interfaces.get(548, 119) != null && !Interfaces.get(548, 119).isHidden();
  411. }
  412.  
  413. private void useBank()
  414. {
  415. long timeout;
  416. switch(bar)
  417. {
  418. case BRONZE:
  419. Banking.depositAll();
  420. Banking.withdraw(14, "Tin ore");
  421. timeout = System.currentTimeMillis();
  422. while(timeout + 2000 > System.currentTimeMillis()
  423. && Inventory.getCount("Tin ore") == 0)
  424. {
  425. sleep(20, 70);
  426. }
  427. Banking.withdraw(14, "Copper ore");
  428. timeout = System.currentTimeMillis();
  429. while(timeout + 2000 > System.currentTimeMillis()
  430. && Inventory.getCount("Copper ore") == 0)
  431. {
  432. sleep(20, 70);
  433. }
  434. break;
  435. case IRON:
  436. Banking.depositAll();
  437. if(usingForging && Inventory.getCount("Ring of forging") == 0 && !Equipment.isEquipped("Ring of forging"))
  438. {
  439. Banking.withdraw(1, "Ring of forging");
  440. timeout = System.currentTimeMillis();
  441. while(timeout + 2000 > System.currentTimeMillis()
  442. && Inventory.getCount("Ring of forging") == 0)
  443. {
  444. sleep(20, 70);
  445. }
  446. }
  447. else
  448. {
  449. Banking.withdraw(0, "Iron ore");
  450. timeout = System.currentTimeMillis();
  451. while(timeout + 2000 > System.currentTimeMillis()
  452. && Inventory.getCount("Iron ore") == 0)
  453. {
  454. sleep(20, 70);
  455. }
  456. }
  457. break;
  458. case STEEL:
  459. Banking.depositAll();
  460. Banking.withdraw(9, "Iron ore");
  461. timeout = System.currentTimeMillis();
  462. while(timeout + 2000 > System.currentTimeMillis()
  463. && Inventory.getCount("Iron ore") == 0)
  464. {
  465. sleep(20, 70);
  466. }
  467. Banking.withdraw(0, "Coal");
  468. timeout = System.currentTimeMillis();
  469. while(timeout + 2000 > System.currentTimeMillis()
  470. && Inventory.getCount("Coal") == 0)
  471. {
  472. sleep(20, 70);
  473. }
  474. break;
  475. case MITHRIL:
  476. Banking.depositAll();
  477. Banking.withdraw(5, "Mithril ore");
  478. timeout = System.currentTimeMillis();
  479. while(timeout + 2000 > System.currentTimeMillis()
  480. && Inventory.getCount("Mithril ore") == 0)
  481. {
  482. sleep(20, 70);
  483. }
  484. Banking.withdraw(0, "Coal");
  485. timeout = System.currentTimeMillis();
  486. while(timeout + 2000 > System.currentTimeMillis()
  487. && Inventory.getCount("Coal") == 0)
  488. {
  489. sleep(20, 70);
  490. }
  491. break;
  492. case ADAMANTITE:
  493. Banking.depositAll();
  494. Banking.withdraw(4, "Admantite ore");
  495. timeout = System.currentTimeMillis();
  496. while(timeout + 2000 > System.currentTimeMillis()
  497. && Inventory.getCount("Adamantite ore") == 0)
  498. {
  499. sleep(20, 70);
  500. }
  501. Banking.withdraw(0, "Coal");
  502. timeout = System.currentTimeMillis();
  503. while(timeout + 2000 > System.currentTimeMillis()
  504. && Inventory.getCount("Coal") == 0)
  505. {
  506. sleep(20, 70);
  507. }
  508. break;
  509. case RUNITE:
  510. Banking.depositAll();
  511. Banking.withdraw(3, "Runite ore");
  512. timeout = System.currentTimeMillis();
  513. while(timeout + 2000 > System.currentTimeMillis()
  514. && Inventory.getCount("Runite ore") == 0)
  515. {
  516. sleep(20, 70);
  517. }
  518. Banking.withdraw(0, "Coal");
  519. timeout = System.currentTimeMillis();
  520. while(timeout + 2000 > System.currentTimeMillis()
  521. && Inventory.getCount("Coal") == 0)
  522. {
  523. sleep(20, 70);
  524. }
  525. break;
  526. case SILVER:
  527. Banking.depositAll();
  528. Banking.withdraw(0, "Silver ore");
  529. timeout = System.currentTimeMillis();
  530. while(timeout + 2000 > System.currentTimeMillis()
  531. && Inventory.getCount("Silver ore") == 0)
  532. {
  533. sleep(20, 70);
  534. }
  535. break;
  536. case GOLD:
  537. Banking.depositAll();
  538. Banking.withdraw(0, "Gold ore");
  539. timeout = System.currentTimeMillis();
  540. while(timeout + 2000 > System.currentTimeMillis()
  541. && Inventory.getCount("Gold ore") == 0)
  542. {
  543. sleep(20, 70);
  544. }
  545. break;
  546. case CANNONBALLS:
  547. Banking.depositAllExcept("Ammo mould");
  548. if(Inventory.getCount("Ammo mould") == 0)
  549. {
  550. Banking.withdraw(1, "Ammo mould");
  551. timeout = System.currentTimeMillis();
  552. while(timeout + 2000 > System.currentTimeMillis()
  553. && Inventory.getCount("Ammo mould") == 0)
  554. {
  555. sleep(20, 70);
  556. }
  557. }
  558. Banking.withdraw(0, "Steel bar");
  559. timeout = System.currentTimeMillis();
  560. while(timeout + 2000 > System.currentTimeMillis()
  561. && Inventory.getCount("Steel bar") == 0)
  562. {
  563. sleep(20, 70);
  564. }
  565. break;
  566. }
  567. }
  568.  
  569. private void closeBank()
  570. {
  571. Banking.close();
  572. long timeout = System.currentTimeMillis();
  573. while(timeout + 2000 > System.currentTimeMillis()
  574. && Banking.isBankScreenOpen())
  575. {
  576. sleep(20, 70);
  577. }
  578. }
  579.  
  580. private void openBank()
  581. {
  582. Banking.openBank();
  583. while(Player.isMoving())
  584. {
  585. sleep(20, 70);
  586. }
  587. long timeout = System.currentTimeMillis();
  588. while(timeout + 500 > System.currentTimeMillis()
  589. && !Banking.isBankScreenOpen())
  590. {
  591. sleep(20, 70);
  592. }
  593. }
  594.  
  595. private void equipForging()
  596. {
  597. if(GameTab.getOpen() != TABS.INVENTORY)
  598. {
  599. Inventory.open();
  600. }
  601. RSItem[] forging = Inventory.find("Ring of forging");
  602. if(forging.length > 0 && forging[0] != null)
  603. {
  604. forging[0].click();
  605. long timeout = System.currentTimeMillis();
  606. while(timeout + 2000 > System.currentTimeMillis()
  607. && Inventory.getCount("Ring of forging") > 0)
  608. {
  609. sleep(20, 70);
  610. }
  611. }
  612. }
  613.  
  614. private void walkToFurnace()
  615. {
  616. if(Player.getPosition().distanceTo(new RSTile(3687, 3466)) < 10)
  617. {
  618. Walking.clickTileMM(new RSTile(3687, 3479), 1);
  619. }
  620. else
  621. {
  622. WebWalking.walkTo(furnaceTile);
  623. }
  624. while(Player.isMoving())
  625. {
  626. sleep(20, 70);
  627. }
  628. }
  629.  
  630. private void walkToBank()
  631. {
  632. if(Player.getPosition().distanceTo(new RSTile(3687, 3479)) < 10)
  633. {
  634. Walking.clickTileMM(new RSTile(3687, 3466), 1);
  635. }
  636. else
  637. {
  638. WebWalking.walkToBank();
  639. }
  640. while(Player.isMoving())
  641. {
  642. sleep(20, 70);
  643. }
  644. }
  645.  
  646. private void useFurnace()
  647. {
  648. RSObject[] furnace = Objects.find(10, "Furnace");
  649. if(furnace.length > 0 && furnace[0] != null)
  650. {
  651. if(bar == Bar.CANNONBALLS)
  652. {
  653. furnace[0].click(Game.getUptext() + " Furnace");
  654. }
  655. else
  656. {
  657. furnace[0].click("Smelt Furnace");
  658. if(hoverBox != null)
  659. {
  660. Random rand = new Random();
  661. int x = (int) (rand.nextInt((int) (hoverBox.getWidth() + 1)) + hoverBox.getX());
  662. rand = new Random();
  663. int y = (int) (rand.nextInt((int) (hoverBox.getHeight() + 1)) + hoverBox.getY());
  664. Mouse.move(x, y);
  665. }
  666. }
  667. }
  668. while(Player.isMoving())
  669. {
  670. sleep(50, 100);
  671. }
  672. long timeout = System.currentTimeMillis();
  673. while(timeout + 2000 > System.currentTimeMillis()
  674. && !isFirstInterfaceOpen())
  675. {
  676. sleep(20, 70);
  677. }
  678. }
  679.  
  680. private void useFirstInterface()
  681. {
  682. RSInterface smeltInterface;
  683. switch(bar)
  684. {
  685. case BRONZE:
  686. smeltInterface = Interfaces.get(BAR_SELECT_INTERFACE_ID, BAR_SELECT_INTERFACE_BRONZE_ID);
  687. if(smeltInterface != null)
  688. {
  689. if(Game.getUptext().contains("Smelt 1 Bronze"))
  690. {
  691. Mouse.click(3);
  692. chooseOption("Smelt X Bronze");
  693. }
  694. else
  695. {
  696. smeltInterface.click("Smelt X Bronze");
  697. }
  698. }
  699. hoverBox = smeltInterface.getAbsoluteBounds();
  700. break;
  701. case IRON:
  702. smeltInterface = Interfaces.get(BAR_SELECT_INTERFACE_ID, BAR_SELECT_INTERFACE_IRON_ID);
  703. if(smeltInterface != null)
  704. {
  705. if(Game.getUptext().contains("Smelt 1 Iron"))
  706. {
  707. Mouse.click(3);
  708. chooseOption("Smelt X Iron");
  709. }
  710. else
  711. {
  712. smeltInterface.click("Smelt X Iron");
  713. }
  714. }
  715. hoverBox = smeltInterface.getAbsoluteBounds();
  716. break;
  717. case STEEL:
  718. smeltInterface = Interfaces.get(BAR_SELECT_INTERFACE_ID, BAR_SELECT_INTERFACE_STEEL_ID);
  719. if(smeltInterface != null)
  720. {
  721. if(Game.getUptext().contains("Smelt 1 Steel"))
  722. {
  723. Mouse.click(3);
  724. chooseOption("Smelt 10 Steel");
  725. }
  726. else
  727. {
  728. smeltInterface.click("Smelt 10 Steel");
  729. }
  730. }
  731. hoverBox = smeltInterface.getAbsoluteBounds();
  732. break;
  733. case MITHRIL:
  734. smeltInterface = Interfaces.get(BAR_SELECT_INTERFACE_ID, BAR_SELECT_INTERFACE_MITHRIL_ID);
  735. if(smeltInterface != null)
  736. {
  737. if(Game.getUptext().contains("Smelt 1 Mithril"))
  738. {
  739. Mouse.click(3);
  740. chooseOption("Smelt 10 Mithril");
  741. }
  742. else
  743. {
  744. smeltInterface.click("Smelt 10 Mithril");
  745. }
  746. }
  747. hoverBox = smeltInterface.getAbsoluteBounds();
  748. break;
  749. case ADAMANTITE:
  750. smeltInterface = Interfaces.get(BAR_SELECT_INTERFACE_ID, BAR_SELECT_INTERFACE_ADAMANTITE_ID);
  751. if(smeltInterface != null)
  752. {
  753. if(Game.getUptext().contains("Smelt 1 Adamant"))
  754. {
  755. Mouse.click(3);
  756. chooseOption("Smelt 5 Adamant");
  757. }
  758. else
  759. {
  760. smeltInterface.click("Smelt 5 Adamant");
  761. }
  762. }
  763. hoverBox = smeltInterface.getAbsoluteBounds();
  764. break;
  765. case RUNITE:
  766. smeltInterface = Interfaces.get(BAR_SELECT_INTERFACE_ID, BAR_SELECT_INTERFACE_RUNITE_ID);
  767. if(smeltInterface != null)
  768. {
  769. if(Game.getUptext().contains("Smelt 1 Rune"))
  770. {
  771. Mouse.click(3);
  772. chooseOption("Smelt 5 Rune");
  773. }
  774. else
  775. {
  776. smeltInterface.click("Smelt 5 Rune");
  777. }
  778. }
  779. hoverBox = smeltInterface.getAbsoluteBounds();
  780. break;
  781. case SILVER:
  782. smeltInterface = Interfaces.get(BAR_SELECT_INTERFACE_ID, BAR_SELECT_INTERFACE_SILVER_ID);
  783. if(smeltInterface != null)
  784. {
  785. if(Game.getUptext().contains("Smelt 1 Silver"))
  786. {
  787. Mouse.click(3);
  788. chooseOption("Smelt X Silver");
  789. }
  790. else
  791. {
  792. smeltInterface.click("Smelt X Silver");
  793. }
  794. }
  795. hoverBox = smeltInterface.getAbsoluteBounds();
  796. break;
  797. case GOLD:
  798. smeltInterface = Interfaces.get(BAR_SELECT_INTERFACE_ID, BAR_SELECT_INTERFACE_GOLD_ID);
  799. if(smeltInterface != null)
  800. {
  801. if(Game.getUptext().contains("Smelt 1 Gold"))
  802. {
  803. Mouse.click(3);
  804. chooseOption("Smelt X Gold");
  805. }
  806. else
  807. {
  808. smeltInterface.click("Smelt X Gold");
  809. }
  810. }
  811. hoverBox = smeltInterface.getAbsoluteBounds();
  812. break;
  813. case CANNONBALLS:
  814. smeltInterface = Interfaces.get(CANNONBALL_SELECT_INTERFACE_ID, CANNONBALL_SELECT_INTERFACE_CHILD_ID);
  815. if(smeltInterface != null)
  816. {
  817. smeltInterface.click();
  818. }
  819. hoverBox = smeltInterface.getAbsoluteBounds();
  820. break;
  821. }
  822. long timeout = System.currentTimeMillis();
  823. while(timeout + 2000 > System.currentTimeMillis()
  824. && isFirstInterfaceOpen())
  825. {
  826. sleep(20, 70);
  827. }
  828. }
  829.  
  830. private void chooseOption(String option)
  831. {
  832. long timeout = System.currentTimeMillis();
  833. while(System.currentTimeMillis() - 2000 < timeout
  834. && !ChooseOption.isOpen())
  835. {
  836. sleep(50, 100);
  837. }
  838. Interfaces.closeAll();
  839. if(ChooseOption.isOpen())
  840. {
  841. if(ChooseOption.isOptionValid(option))
  842. {
  843. ChooseOption.select(option);
  844. return;
  845. }
  846. else
  847. {
  848. ChooseOption.close();
  849. }
  850. }
  851. }
  852.  
  853. private void useSecondInterface()
  854. {
  855. Keyboard.typeSend("" + randomInput);
  856. long timeout = System.currentTimeMillis();
  857. while(timeout + 2000 > System.currentTimeMillis()
  858. && (isSecondInterfaceOpen() || isFirstInterfaceOpen()))
  859. {
  860. sleep(20, 70);
  861. }
  862. }
  863.  
  864. private void clickBar()
  865. {
  866. RSItem[] bar = Inventory.find("Steel bar");
  867. if(bar.length > 0 && bar[0] != null)
  868. {
  869. bar[0].click("Use");
  870. }
  871. long timeout = System.currentTimeMillis();
  872. while(timeout + 2000 > System.currentTimeMillis()
  873. && !Game.isUptext("Use Steel bar"))
  874. {
  875. sleep(20, 70);
  876. }
  877. }
  878.  
  879. private void animatingSleep()
  880. {
  881. sleep(50, 100);
  882. }
  883.  
  884. @Override
  885. public void onPaint(Graphics g) {
  886.  
  887. currentXP = Skills.getXP(SKILLS.SMITHING);
  888. currentLevel = Skills.getActualLevel(SKILLS.SMITHING);
  889. long timeRan = System.currentTimeMillis() - START_TIME;
  890. long xpGained = currentXP - START_XP;
  891. double multiplier = timeRan / 3600000D;
  892. int xpPerHour = (int) (xpGained / multiplier);
  893. int barsPerHour = (int) (barsMade / multiplier);
  894. int levelsGained = currentLevel - START_LEVEL;
  895. g.setColor(Color.WHITE);
  896. g.drawString("ITryNotToTroll's Smither", 10, 70);
  897. g.drawString("Bar Being Smelted: " + bar, 10, 90);
  898. g.drawString("Running for: " + Timing.msToString(timeRan), 10, 110);
  899. g.drawString("Levels Gained: " + levelsGained, 10, 130);
  900. g.drawString("Xp gained: " + xpGained + " (" + xpPerHour + "/h)", 10,
  901. 150);
  902. g.drawString("Bars made: " + barsMade + " (" + barsPerHour + "/h)",
  903. 10, 170);
  904. g.drawString("State: " + state, 10, 190);
  905.  
  906. g.drawString("Actions left", 10, 210);
  907. if(barArrayList.size() > 0)
  908. {
  909. g.drawString(barArrayList.get(0) + ", " + (stoppingConditionList.get(0) - (barsMade - lastAmountBarsMade)), 10, 230);
  910. for(int i = actionsLoop + 1;i<barArrayList.size();i++)
  911. {
  912. g.drawString(barArrayList.get(i) + ", " + stoppingConditionList.get(i), 10, 250 + (20* (i-actionsLoop)) );
  913. }
  914. }
  915.  
  916. }
  917.  
  918. public static boolean setFurnaceTile()
  919. {
  920. RSTile tempTile = Player.getPosition();
  921. if(tempTile != null)
  922. {
  923. furnaceTile = tempTile;
  924. return true;
  925. }
  926. return false;
  927. }
  928.  
  929. @Override
  930. public void clanMessageReceived(String arg0, String arg1) {
  931. // TODO Auto-generated method stub
  932.  
  933. }
  934.  
  935. @Override
  936. public void duelRequestReceived(String arg0, String arg1) {
  937. // TODO Auto-generated method stub
  938.  
  939. }
  940.  
  941. @Override
  942. public void personalMessageReceived(String arg0, String arg1) {
  943. // TODO Auto-generated method stub
  944.  
  945. }
  946.  
  947. @Override
  948. public void playerMessageReceived(String arg0, String arg1) {
  949. // TODO Auto-generated method stub
  950.  
  951. }
  952.  
  953. @Override
  954. public void serverMessageReceived(String mes) {
  955. if (mes.contains("You retrieve")) {
  956. barsMade++;
  957. }
  958. if (mes.contains("You remove the cannonballs from the mould")) {
  959. barsMade++;
  960. }
  961. }
  962.  
  963. @Override
  964. public void tradeRequestReceived(String arg0) {
  965. // TODO Auto-generated method stub
  966.  
  967. }
  968. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement