Thondar

sd

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