Thondar

Untitled

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