Thondar

sd

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