Thondar

Untitled

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