Thondar

sd

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