Thondar

s

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