Thondar

s

Jun 11th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.15 KB | None | 0 0
  1. import org.rsbot.event.listeners.PaintListener;
  2.  
  3.  
  4. @ScriptManifest(authors = {"TT Production"}, keywords = {"Al kharid", "Smelter"}, name = "TT Smelter", description = "Smelts ores in Al Kharid", version = 0.1)
  5.  
  6. public class TTSmelter extends Script implements PaintListener{
  7.  
  8. RSTile furnaceTile = new RSTile (3276,3186);
  9. RSTile bankTile = new RSTile (3270,3166);
  10.  
  11. int oreID1;
  12. int oreID2;
  13. int oreAmount1;
  14. int oreAmount2;
  15. int paintOre1;
  16. int paintOre2;
  17. int barID;
  18. int buttonID;
  19. int bankerID = 496;
  20. int furnaceID = 11666;
  21. int Inventory = 0;
  22. int ironOre = 440;
  23. int ironSteel = 440;
  24. int idle = -1;
  25. int smelting = 3243;
  26. int barsGot;
  27. int barPrice;
  28. int orePrice1;
  29. int orePrice2;
  30. int barcheck;
  31. int expGained = 0;
  32. int expStart = 0;
  33.  
  34. long starttime;
  35.  
  36. private boolean restCheck;
  37. private boolean antibanCheck;
  38.  
  39. gui g = new gui();
  40.  
  41. private boolean guiWait = true;
  42.  
  43. String optionBar;
  44.  
  45.  
  46. @Override
  47. public boolean onStart() {
  48. mouse.setSpeed(random(4, 6));
  49. starttime = System.currentTimeMillis();
  50. expStart = skills.getCurrentExp(Skills.SMITHING);
  51. g.setVisible(true);
  52. while(guiWait) sleep(500);
  53. barPrice = grandExchange.lookup(barID).getGuidePrice();
  54. orePrice1 = grandExchange.lookup(oreID1).getGuidePrice();
  55. orePrice2 = grandExchange.lookup(oreID2).getGuidePrice();
  56. walking.setRun(true);
  57. return true;
  58. }
  59.  
  60. public void bank() {
  61. RSNPC banker = npcs.getNearest(bankerID);
  62. camera.turnTo(banker);
  63. if(restCheck == true);
  64. if(walking.getEnergy() < 30)
  65. walking.rest(random(70,95));
  66. if (bank.isOpen() && !inventory.contains(oreID1)) {
  67. bank.depositAll();
  68. Inventory = inventory.getCount(barID);
  69. barsGot += Inventory;
  70. sleep(400, 650);
  71. bank.withdraw(oreID1, oreAmount1);
  72. sleep(500, 750);
  73. if (oreID1 == 436 | oreID1 == ironSteel | oreID1 == 447 | oreID1 == 449 | oreID1 == 451){
  74. bank.withdraw(oreID2, oreAmount2);
  75. }
  76. sleep(1500, 1900);
  77. bank.close();
  78. } else {
  79. if(banker != null) {
  80. if(banker.isOnScreen())
  81. banker.doAction("Bank Banker");{
  82. } sleep(1800, 2100);
  83. } else {
  84. walking.getPath(bankTile).traverse();
  85. }
  86. }
  87. }
  88.  
  89. public void smeltOres(){
  90. barcheck = inventory.getCount(barID);
  91. RSObject furnace = objects.getNearest(furnaceID);
  92. if(restCheck == true);
  93. if(walking.getEnergy() < 30)
  94. walking.rest(random(70,95));
  95. if (furnace.isOnScreen()){
  96. if (barcheck < 1)
  97. furnace.doAction("Smelt");
  98. sleep (1500, 1800);
  99. mouse.click(280,424,true);
  100. sleep(1700, 1900);
  101. }
  102. }
  103.  
  104.  
  105. public boolean atBank(){
  106. RSArea BankArea = new RSArea(new RSTile(3265, 3160),
  107. new RSTile(3272, 3273));
  108. return BankArea.contains(getMyPlayer().getLocation());
  109. }
  110.  
  111. public boolean atAlKharid(){
  112. RSArea AlKharidArea = new RSArea(new RSTile(3264, 3160),
  113. new RSTile(3286, 3197));
  114. return AlKharidArea.contains(getMyPlayer().getLocation());
  115. }
  116.  
  117.  
  118. public boolean atFurnace(){
  119. RSArea FurnaceArea = new RSArea(new RSTile(3272, 3181),
  120. new RSTile(3279, 3188));
  121. return FurnaceArea.contains(getMyPlayer().getLocation());
  122. }
  123.  
  124. private void rest() {
  125. if(restCheck == true);
  126. if(walking.getEnergy() < 30)
  127. walking.rest(random(70,95));
  128. }
  129.  
  130. public int loop() {
  131. if(atBank() && !inventory.contains(oreID1)){
  132. bank();
  133. log ("1");
  134. }
  135. if(atBank() && inventory.contains(barID)){
  136. bank();
  137. log ("2");
  138. }
  139. if(atFurnace() && inventory.contains(oreID1)){
  140. smeltOres();
  141. log ("3");
  142. }
  143. if(!atFurnace() && inventory.contains(oreID1)){
  144. walking.walkTo(furnaceTile);
  145. log ("4");
  146. }
  147. if(!atBank() && !inventory.contains(oreID1)){
  148. walking.walkTo(bankTile);
  149. log ("5");
  150. }
  151.  
  152. if(antibanCheck == true) {
  153. antiBan();
  154. }
  155. if(restCheck == true) {
  156. rest();
  157. }
  158. return random(500, 1500);
  159. }
  160.  
  161. private void antiBan() {
  162. int t = random(0, 10);
  163. int r = random(0, 15);
  164. if (t == 7);
  165. if (r == 2) {
  166. mouse.moveSlightly();
  167. sleep(500, 800);
  168. }
  169.  
  170. if (r == 3) {
  171. mouse.moveRandomly(10, 50);
  172. }
  173.  
  174. if (r == 5) {
  175. camera.moveRandomly(random(350, 650));
  176. }
  177.  
  178. if (r == 6) {
  179. camera.moveRandomly(random(450, 750));
  180. }
  181.  
  182. if (r == 8) {
  183. camera.moveRandomly(random(150, 450));
  184. }
  185.  
  186. if (r == 10) {
  187. camera.moveRandomly(random(750, 1250));
  188. }
  189.  
  190. if (r == 12) {
  191. mouse.moveOffScreen();
  192. }
  193.  
  194. if (r == 14) {
  195. camera.moveRandomly(random(500, 900));
  196. }
  197. }
  198.  
  199.  
  200. public void onFinish() {
  201. }
  202.  
  203. //---------- PAINT -------------//
  204.  
  205. private Image getImage(String url) {
  206. try {
  207. return ImageIO.read(new URL(url));
  208. } catch(IOException e) {
  209. return null;
  210. }
  211. }
  212.  
  213. private final Color color1 = new Color(255, 255, 255);
  214.  
  215. private final Font font1 = new Font("Calibri", 0, 18);
  216.  
  217. private final Image img1 = getImage("http://i.imgur.com/Dtg7V.jpg");
  218. private final Image img2 = getImage("http://i.imgur.com/cYgmN.png");
  219. private final Image img3 = getImage("http://i.imgur.com/cwGcs.gif");
  220. private final Image img4 = getImage("http://i.imgur.com/DZYci.png");
  221. private final Image img5 = getImage("http://i.imgur.com/qpagD.png");
  222. private final Image img6 = getImage("http://i.imgur.com/1d2Ws.png");
  223. private final Image img9 = getImage("http://i.imgur.com/cayCD.png");
  224. private final Image img8 = getImage("http://i.imgur.com/AwBMJ.png");
  225. private final Image img10 = getImage("http://i.imgur.com/jUylh.png");
  226. private final Image img14 = getImage("http://i.imgur.com/0g8dI.png");
  227. private final Image img15 = getImage("http://i.imgur.com/e6Fw2.png");
  228. private final Image img16 = getImage("http://i.imgur.com/aUisg.png");
  229. private final Image img17 = getImage("http://i.imgur.com/2fxLu.png");
  230.  
  231.  
  232. public void onRepaint(Graphics g1) {
  233.  
  234. expGained = skills.getCurrentExp(Skills.SMITHING) - expStart;
  235.  
  236. long millis = System.currentTimeMillis() - starttime;
  237. long hours = millis / (1000 * 60 * 60);
  238. millis -= hours * (1000 * 60 * 60);
  239. long minutes = millis / (1000 * 60);
  240. millis -= minutes * (1000 * 60);
  241. long seconds = millis / 1000;
  242.  
  243. float barsec = 0;
  244. if ((minutes > 0 || hours > 0 || seconds > 0) && barsGot > 0) {
  245. barsec = ((float) barsGot)/(float)(seconds + (minutes*60) + (hours*60*60));
  246. }
  247.  
  248. float xpsec = 0;
  249. if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
  250. xpsec = ((float) expGained)/(float)(seconds + (minutes*60) + (hours*60*60));
  251. }
  252.  
  253. float barmin = barsec * 60;
  254. float abarhour = barmin * 60;
  255. float xpmin = xpsec * 60;
  256. float axphour = xpmin * 60;
  257. int ore1spend = orePrice1 * paintOre1;
  258. int ore2spend = orePrice2 * paintOre2;
  259. int goldspend = ore1spend + ore2spend;
  260. int totalBarPrice = barPrice - goldspend;
  261. float agoldhour = abarhour * totalBarPrice;
  262. int goldearned = barsGot * totalBarPrice;
  263. int barhour = Math.round(abarhour);
  264. int goldhour = Math.round(agoldhour);
  265. int xphour = Math.round(axphour);
  266.  
  267.  
  268. Graphics2D g = (Graphics2D)g1;
  269. g.drawImage(img1, 7, 345, null);
  270. g.drawImage(img2, 11, 439, null);
  271. g.drawImage(img3, 9, 392, null);
  272. g.drawImage(img4, 8, 349, null);
  273. g.setFont(font1);
  274. g.setColor(color1);
  275. g.drawString(+ hours + ":" + minutes + ":" + seconds, 428, 469);
  276. g.drawString("" + goldearned, 70, 417);
  277. g.drawString("" + goldhour, 240, 417);
  278. g.drawString("" + barsGot, 70, 462);
  279. g.drawString("" + barhour, 240, 462);
  280. g.drawString("" + xphour, 240, 371);
  281. g.drawString("" + expGained, 70, 371);
  282. g.drawImage(img5, -4, 428, null);
  283. g.drawImage(img5, -4, 382, null);
  284. g.drawImage(img9, -11, 338, null);
  285. g.drawImage(img6, 510, 332, null);
  286. g.drawImage(img10, 39, 340, null);
  287. g.drawImage(img10, 39, 386, null);
  288. g.drawImage(img10, 378, 340, null);
  289. g.drawImage(img10, 203, 340, null);
  290. g.drawImage(img10, 378, 386, null);
  291. g.drawImage(img10, 203, 385, null);
  292. g.drawImage(img8, -2, 335, null);
  293. g.drawImage(img8, -2, 468, null);
  294. g.drawImage(img14, 150, 403, null);
  295. g.drawImage(img14, 150, 448, null);
  296. g.drawImage(img14, 150, 360, null);
  297. g.drawImage(img15, 325, 403, null);
  298. g.drawImage(img15, 325, 448, null);
  299. g.drawImage(img15, 325, 360, null);
  300. g.drawImage(img16, 398, 346, null);
  301. g.drawImage(img17, 75, 292, null);
  302.  
  303. }
  304.  
  305.  
  306. //------------ GUI -------------//
  307.  
  308. class gui extends JFrame {
  309. public gui() {
  310. initComponents();
  311. }
  312.  
  313. private void startButtonActionPerformed(ActionEvent e) {
  314. String optionBar = oresToSmelt.getSelectedItem().toString();
  315.  
  316. if(optionBar.equals("Bronze")) {
  317. barID = 2349;
  318. oreID1 = 436;
  319. oreID2 = 438;
  320. oreAmount1 = 14;
  321. oreAmount2 = 14;
  322. paintOre1 = 1;
  323. paintOre2 = 1;
  324. }
  325. else if(optionBar.equals("Iron")) {
  326. barID = 2351;
  327. oreID1 = ironOre;
  328. oreAmount1 = 28;
  329. paintOre1 = 1;
  330. paintOre2 = 0;
  331. }
  332. else if(optionBar.equals("Silver")) {
  333. barID = 2355;
  334. oreID1 = 442;
  335. oreAmount1 = 28;
  336. paintOre1 = 1;
  337. paintOre2 = 0;
  338. }
  339. else if(optionBar.equals("Steel")) {
  340. barID = 2353;
  341. oreID1 = ironSteel;
  342. oreID2 = 453;
  343. oreAmount1 = 9;
  344. oreAmount2 = 18;
  345. paintOre1 = 1;
  346. paintOre2 = 2;
  347. }
  348. else if(optionBar.equals("Gold")) {
  349. barID = 2357;
  350. oreID1 = 444;
  351. oreAmount1 = 28;
  352. paintOre1 = 1;
  353. paintOre2 = 0;
  354. }
  355. else if(optionBar.equals("Mithril")) {
  356. barID = 2359;
  357. oreID1 = 447;
  358. oreID2 = 453;
  359. oreAmount1 = 5;
  360. oreAmount2 = 20;
  361. paintOre1 = 1;
  362. paintOre2 = 4;
  363. }
  364. else if(optionBar.equals("Adamantite")) {
  365. barID = 2361;
  366. oreID1 = 449;
  367. oreID2 = 453;
  368. oreAmount1 = 4;
  369. oreAmount2 = 24;
  370. paintOre1 = 1;
  371. paintOre2 = 6;
  372. }
  373. else {
  374. barID = 2363;
  375. oreID1 = 451;
  376. oreID2 = 453;
  377. oreAmount1 = 3;
  378. oreAmount2 = 24;
  379. paintOre1 = 1;
  380. paintOre2 = 8;
  381. }
  382. guiWait = false;
  383. g.dispose();
  384. }
  385.  
  386. private void initComponents() {
  387. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  388. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  389. label1 = new JLabel();
  390. label2 = new JLabel();
  391. checkBox1 = new JCheckBox();
  392. checkBox2 = new JCheckBox();
  393. startButton = new JButton();
  394. oresToSmelt = new JComboBox();
  395.  
  396. //======== this ========
  397. Container contentPane = getContentPane();
  398.  
  399. //---- label1 ----
  400. label1.setText("TT Smelter");
  401. label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 9f));
  402. label1.setHorizontalAlignment(SwingConstants.CENTER);
  403.  
  404. //---- label2 ----
  405. label2.setText("Ores to smelt:");
  406. label2.setFont(label2.getFont().deriveFont(label2.getFont().getSize() + 2f));
  407.  
  408. //---- checkBox1 ----
  409. checkBox1.setText("Rest");
  410.  
  411. //---- checkBox2 ----
  412. checkBox2.setText("Antiban");
  413.  
  414. //---- startButton ----
  415. startButton.setText("Start");
  416. startButton.setFont(startButton.getFont().deriveFont(startButton.getFont().getSize() + 2f));
  417. startButton.addActionListener(new ActionListener() {
  418. @Override
  419. public void actionPerformed(ActionEvent e) {
  420. startButtonActionPerformed(e);
  421. startButtonActionPerformed(e);
  422. }
  423. });
  424.  
  425. //---- oresToSmelt ----
  426. oresToSmelt.setModel(new DefaultComboBoxModel(new String[] {
  427. "Bronze",
  428. "Silver",
  429. "Gold",
  430. "Iron",
  431. "Steel",
  432. "Mithril",
  433. "Adamantite",
  434. "Runite"
  435. }));
  436.  
  437. GroupLayout contentPaneLayout = new GroupLayout(contentPane);
  438. contentPane.setLayout(contentPaneLayout);
  439. contentPaneLayout.setHorizontalGroup(
  440. contentPaneLayout.createParallelGroup()
  441. .addGroup(contentPaneLayout.createSequentialGroup()
  442. .addContainerGap()
  443. .addGroup(contentPaneLayout.createParallelGroup()
  444. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  445. .addGroup(contentPaneLayout.createParallelGroup()
  446. .addGroup(contentPaneLayout.createSequentialGroup()
  447. .addComponent(label2, GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
  448. .addGap(18, 18, 18)
  449. .addComponent(oresToSmelt, GroupLayout.PREFERRED_SIZE, 154, GroupLayout.PREFERRED_SIZE))
  450. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  451. .addComponent(checkBox1, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
  452. .addGap(34, 34, 34)
  453. .addComponent(checkBox2, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)))
  454. .addGap(20, 20, 20))
  455. .addGroup(contentPaneLayout.createSequentialGroup()
  456. .addComponent(startButton, GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
  457. .addContainerGap())
  458. .addGroup(contentPaneLayout.createSequentialGroup()
  459. .addComponent(label1, GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
  460. .addContainerGap())))
  461. );
  462. contentPaneLayout.setVerticalGroup(
  463. contentPaneLayout.createParallelGroup()
  464. .addGroup(contentPaneLayout.createSequentialGroup()
  465. .addGap(6, 6, 6)
  466. .addComponent(label1, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
  467. .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
  468. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  469. .addComponent(label2, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
  470. .addComponent(oresToSmelt, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
  471. .addGap(18, 18, 18)
  472. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  473. .addComponent(checkBox2)
  474. .addComponent(checkBox1))
  475. .addGap(12, 12, 12)
  476. .addComponent(startButton, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
  477. .addContainerGap())
  478. );
  479. pack();
  480. setLocationRelativeTo(getOwner());
  481. // JFormDesigner - End of component initialization //GEN-END:initComponents
  482. }
  483.  
  484. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  485. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  486. private JLabel label1;
  487. private JLabel label2;
  488. private JCheckBox checkBox1;
  489. private JCheckBox checkBox2;
  490. private JButton startButton;
  491. private JComboBox oresToSmelt;
  492. // JFormDesigner - End of variables declaration //GEN-END:variables
  493. }
  494. }
Advertisement
Add Comment
Please, Sign In to add comment