Thondar

sd

Jun 11th, 2011
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.64 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.  
  41. long starttime;
  42.  
  43. private boolean restCheck;
  44. private boolean antibanCheck;
  45.  
  46. gui g = new gui();
  47.  
  48. private boolean guiWait = true;
  49.  
  50. String optionBar;
  51.  
  52.  
  53. @Override
  54. public boolean onStart() {
  55. mouse.setSpeed(random(4, 6));
  56. starttime = System.currentTimeMillis();
  57. g.setVisible(true);
  58. while(guiWait) sleep(500);
  59. barPrice = grandExchange.lookup(barID).getGuidePrice();
  60. orePrice1 = grandExchange.lookup(oreID1).getGuidePrice();
  61. orePrice2 = grandExchange.lookup(oreID2).getGuidePrice();
  62.  
  63. walking.setRun(true);
  64. return true;
  65. }
  66.  
  67. public void bank() {
  68. RSNPC banker = npcs.getNearest(bankerID);
  69. if (bank.isOpen() && !inventory.contains(oreID1)) {
  70. bank.depositAll();
  71. Inventory = inventory.getCount(barID);
  72. barsGot += Inventory;
  73. sleep(400, 650);
  74. bank.withdraw(oreID1, oreAmount1);
  75. sleep(500, 750);
  76. if (oreID1 == 436 | oreID1 == 440 | oreID1 == 447 | oreID1 == 449 | oreID1 == 451){
  77. bank.withdraw(oreID2, oreAmount2);
  78. }
  79. sleep(800, 1100);
  80. bank.close();
  81. } else {
  82. if(banker != null) {
  83. if(banker.isOnScreen())
  84. banker.doAction("Bank Banker");{
  85. } sleep(1800, 2100);
  86. } else {
  87. walking.getPath(bankTile).traverse();
  88. }
  89. }
  90. }
  91.  
  92. public void smeltOres(){
  93. barcheck = inventory.getCount(barID);
  94. RSObject furnace = objects.getNearest(furnaceID);
  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. long millis = System.currentTimeMillis() - starttime;
  235. long hours = millis / (1000 * 60 * 60);
  236. millis -= hours * (1000 * 60 * 60);
  237. long minutes = millis / (1000 * 60);
  238. millis -= minutes * (1000 * 60);
  239. long seconds = millis / 1000;
  240.  
  241. float barsec = 0;
  242. if ((minutes > 0 || hours > 0 || seconds > 0) && barsGot > 0) {
  243. barsec = ((float) barsGot)/(float)(seconds + (minutes*60) + (hours*60*60));
  244. }
  245.  
  246. float barmin = barsec * 60;
  247. float abarhour = barmin * 60;
  248. int ore1spend = orePrice1 * paintOre1;
  249. int ore2spend = orePrice2 * paintOre2;
  250. int goldspend = ore1spend + ore2spend;
  251. int totalBarPrice = barPrice - goldspend;
  252. float agoldhour = abarhour * totalBarPrice;
  253. int goldearned = barsGot * totalBarPrice;
  254. int barhour = Math.round(abarhour);
  255. int goldhour = Math.round(agoldhour);
  256.  
  257.  
  258. Graphics2D g = (Graphics2D)g1;
  259. g.drawImage(img1, 7, 345, null);
  260. g.drawImage(img2, 11, 439, null);
  261. g.drawImage(img3, 9, 392, null);
  262. g.drawImage(img4, 10, 349, null);
  263. g.setFont(font1);
  264. g.setColor(color1);
  265. g.drawString(+ hours + ":" + minutes + ":" + seconds, 190, 371);
  266. g.drawString("" + goldearned, 70, 417);
  267. g.drawString("" + goldhour, 240, 417);
  268. g.drawString("" + barsGot, 70, 462);
  269. g.drawString("" + barhour, 240, 462);
  270. g.drawImage(img5, -4, 428, null);
  271. g.drawImage(img5, -4, 382, null);
  272. g.drawImage(img9, -11, 338, null);
  273. g.drawImage(img6, 510, 332, null);
  274. g.drawImage(img10, 39, 340, null);
  275. g.drawImage(img10, 39, 386, null);
  276. g.drawImage(img10, 378, 340, null);
  277. g.drawImage(img10, 203, 340, null);
  278. g.drawImage(img10, 378, 386, null);
  279. g.drawImage(img10, 203, 385, null);
  280. g.drawImage(img8, -2, 335, null);
  281. g.drawImage(img8, -2, 468, null);
  282. g.drawImage(img14, 150, 403, null);
  283. g.drawImage(img14, 150, 448, null);
  284. g.drawImage(img14, 150, 360, null);
  285. g.drawImage(img15, 325, 403, null);
  286. g.drawImage(img15, 325, 448, null);
  287. g.drawImage(img15, 325, 360, null);
  288. g.drawImage(img16, 398, 356, null);
  289. g.drawImage(img17, 75, 292, null);
  290.  
  291. }
  292.  
  293.  
  294. //------------ GUI -------------//
  295.  
  296. class gui extends JFrame {
  297. public gui() {
  298. initComponents();
  299. }
  300.  
  301. private void startButtonActionPerformed(ActionEvent e) {
  302. String optionBar = oresToSmelt.getSelectedItem().toString();
  303.  
  304. if(optionBar.equals("Bronze")) {
  305. barID = 2349;
  306. oreID1 = 436;
  307. oreID2 = 438;
  308. oreAmount1 = 14;
  309. oreAmount2 = 14;
  310. paintOre1 = 1;
  311. paintOre2 = 1;
  312. }
  313. else if(optionBar.equals("Iron")) {
  314. barID = 2351;
  315. oreID1 = ironOre;
  316. oreAmount1 = 28;
  317. paintOre1 = 1;
  318. paintOre2 = 0;
  319. }
  320. else if(optionBar.equals("Silver")) {
  321. barID = 2355;
  322. oreID1 = 442;
  323. oreAmount1 = 28;
  324. paintOre1 = 1;
  325. paintOre2 = 0;
  326. }
  327. else if(optionBar.equals("Steel")) {
  328. barID = 2353;
  329. oreID1 = 440;
  330. oreID2 = 453;
  331. oreAmount1 = 9;
  332. oreAmount2 = 18;
  333. paintOre1 = 1;
  334. paintOre2 = 2;
  335. }
  336. else if(optionBar.equals("Gold")) {
  337. barID = 2357;
  338. oreID1 = 444;
  339. oreAmount1 = 28;
  340. paintOre1 = 1;
  341. paintOre2 = 0;
  342. }
  343. else if(optionBar.equals("Mithril")) {
  344. barID = 2359;
  345. oreID1 = 447;
  346. oreID2 = 453;
  347. oreAmount1 = 5;
  348. oreAmount2 = 20;
  349. paintOre1 = 1;
  350. paintOre2 = 4;
  351. }
  352. else if(optionBar.equals("Adamantite")) {
  353. barID = 2361;
  354. oreID1 = 449;
  355. oreID2 = 453;
  356. oreAmount1 = 4;
  357. oreAmount2 = 24;
  358. paintOre1 = 1;
  359. paintOre2 = 6;
  360. }
  361. else {
  362. barID = 2363;
  363. oreID1 = 451;
  364. oreID2 = 453;
  365. oreAmount1 = 3;
  366. oreAmount2 = 24;
  367. paintOre1 = 1;
  368. paintOre2 = 8;
  369. }
  370. guiWait = false;
  371. g.dispose();
  372. }
  373.  
  374. private void initComponents() {
  375. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  376. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  377. label1 = new JLabel();
  378. label2 = new JLabel();
  379. checkBox1 = new JCheckBox();
  380. checkBox2 = new JCheckBox();
  381. startButton = new JButton();
  382. oresToSmelt = new JComboBox();
  383.  
  384. //======== this ========
  385. Container contentPane = getContentPane();
  386.  
  387. //---- label1 ----
  388. label1.setText("TT Smelter");
  389. label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 9f));
  390. label1.setHorizontalAlignment(SwingConstants.CENTER);
  391.  
  392. //---- label2 ----
  393. label2.setText("Ores to smelt:");
  394. label2.setFont(label2.getFont().deriveFont(label2.getFont().getSize() + 2f));
  395.  
  396. //---- checkBox1 ----
  397. checkBox1.setText("Rest");
  398.  
  399. //---- checkBox2 ----
  400. checkBox2.setText("Antiban");
  401.  
  402. //---- startButton ----
  403. startButton.setText("Start");
  404. startButton.setFont(startButton.getFont().deriveFont(startButton.getFont().getSize() + 2f));
  405. startButton.addActionListener(new ActionListener() {
  406. @Override
  407. public void actionPerformed(ActionEvent e) {
  408. startButtonActionPerformed(e);
  409. startButtonActionPerformed(e);
  410. }
  411. });
  412.  
  413. //---- oresToSmelt ----
  414. oresToSmelt.setModel(new DefaultComboBoxModel(new String[] {
  415. "Bronze",
  416. "Silver",
  417. "Gold",
  418. "Iron",
  419. "Steel",
  420. "Mithril",
  421. "Adamantite",
  422. "Runite"
  423. }));
  424.  
  425. GroupLayout contentPaneLayout = new GroupLayout(contentPane);
  426. contentPane.setLayout(contentPaneLayout);
  427. contentPaneLayout.setHorizontalGroup(
  428. contentPaneLayout.createParallelGroup()
  429. .addGroup(contentPaneLayout.createSequentialGroup()
  430. .addContainerGap()
  431. .addGroup(contentPaneLayout.createParallelGroup()
  432. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  433. .addGroup(contentPaneLayout.createParallelGroup()
  434. .addGroup(contentPaneLayout.createSequentialGroup()
  435. .addComponent(label2, GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
  436. .addGap(18, 18, 18)
  437. .addComponent(oresToSmelt, GroupLayout.PREFERRED_SIZE, 154, GroupLayout.PREFERRED_SIZE))
  438. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  439. .addComponent(checkBox1, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
  440. .addGap(34, 34, 34)
  441. .addComponent(checkBox2, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)))
  442. .addGap(20, 20, 20))
  443. .addGroup(contentPaneLayout.createSequentialGroup()
  444. .addComponent(startButton, GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
  445. .addContainerGap())
  446. .addGroup(contentPaneLayout.createSequentialGroup()
  447. .addComponent(label1, GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
  448. .addContainerGap())))
  449. );
  450. contentPaneLayout.setVerticalGroup(
  451. contentPaneLayout.createParallelGroup()
  452. .addGroup(contentPaneLayout.createSequentialGroup()
  453. .addGap(6, 6, 6)
  454. .addComponent(label1, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
  455. .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
  456. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  457. .addComponent(label2, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
  458. .addComponent(oresToSmelt, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
  459. .addGap(18, 18, 18)
  460. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  461. .addComponent(checkBox2)
  462. .addComponent(checkBox1))
  463. .addGap(12, 12, 12)
  464. .addComponent(startButton, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
  465. .addContainerGap())
  466. );
  467. pack();
  468. setLocationRelativeTo(getOwner());
  469. // JFormDesigner - End of component initialization //GEN-END:initComponents
  470. }
  471.  
  472. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  473. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  474. private JLabel label1;
  475. private JLabel label2;
  476. private JCheckBox checkBox1;
  477. private JCheckBox checkBox2;
  478. private JButton startButton;
  479. private JComboBox oresToSmelt;
  480. // JFormDesigner - End of variables declaration //GEN-END:variables
  481. }
  482. }
Advertisement
Add Comment
Please, Sign In to add comment