Guest User

Untitled

a guest
Jul 15th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.66 KB | None | 0 0
  1.  
  2. import com.rarebot.script.Script;
  3. import com.rarebot.script.ScriptManifest;
  4. import com.rarebot.script.util.Timer;
  5. import com.rarebot.script.wrappers.RSNPC;
  6. import com.rarebot.script.wrappers.RSObject;
  7. import com.rarebot.script.methods.Magic;
  8. import com.rarebot.script.methods.Skills;
  9. import com.rarebot.event.listeners.PaintListener;
  10. import java.awt.*;
  11. import java.awt.event.*;
  12. import javax.swing.*;
  13.  
  14. @ScriptManifest(authors = "DBoWZ", version = 1.01, description = "Superheating all ores. Start at any bank.", name = "DBoWZ Super Heater")
  15. public class DBoWZSuperHeater extends Script implements PaintListener {
  16.  
  17. GUI g = new GUI();
  18.  
  19. private String[] BANKER_ID = { "Banker", "Counter" };
  20. private String SELECTED;
  21. private String status = "Unknown";
  22.  
  23. private static final int NATURE_RUNE = 561;
  24.  
  25. private static int COPPER_ORE = 436;
  26. private static int TIN_ORE = 438;
  27. private static int IRON_ORE = 440;
  28. private static int SILVER_ORE = 442;
  29. private static int GOLD_ORE = 444;
  30. private static int COAL_ORE = 453;
  31. private static int MITHRIL_ORE = 447;
  32. private static int ADAMANT_ORE = 449;
  33. private static int RUNE_ORE = 451;
  34. private static int ORE_ID;
  35. private static int ORE_2_ID;
  36.  
  37. private static int BRONZE_BAR = 2349;
  38. private static int IRON_BAR = 2351;
  39. private static int STEEL_BAR = 2353;
  40. private static int SILVER_BAR = 2355;
  41. private static int GOLD_BAR = 2357;
  42. private static int MITHRIL_BAR = 2359;
  43. private static int ADAMANT_BAR = 2361;
  44. private static int RUNE_BAR = 2363;
  45. private static int BAR_ID;
  46.  
  47. private boolean BRONZE, IRON, STEEL, SILVER, GOLD, MITHRIL, ADAMANT, RUNE,
  48. BANK_CHEST, SAFE_MODE = false, USE_2_ORES,
  49. GUI_WAIT = true;
  50.  
  51. private int START_EXP_MAGE, START_EXP_SMITHING, EXP_GAINED_MAGE, EXP_GAINED_SMITHING, EXP_GAINED;
  52.  
  53. Timer RUN_TIME;
  54. public long START_TIME = System.currentTimeMillis();
  55.  
  56. private enum State {
  57. SUPERHEAT, BANK, ERROR
  58. }
  59.  
  60. public boolean onStart() {
  61. g.setVisible(true);
  62. while(GUI_WAIT) sleep(500);
  63. RUN_TIME = new Timer(0);
  64. START_EXP_MAGE = skills.getCurrentExp(Skills.MAGIC);
  65. START_EXP_SMITHING = skills.getCurrentExp(Skills.SMITHING);
  66. log(Color.RED, "NOTE: The exp counter is for both magic and smithing!");
  67. if(chestCheck()) {
  68. BANK_CHEST = true;
  69. } else {
  70. BANK_CHEST = false;
  71. }
  72. return game.isLoggedIn();
  73. }
  74.  
  75. public void onFinish() {
  76. log("Ran for " + RUN_TIME.toElapsedString() + " and gained " + EXP_GAINED + " exp!");
  77. }
  78.  
  79. private boolean chestCheck() {
  80. RSObject chest = objects.getNearest("Chest");
  81. if(chest != null) {
  82. if(calc.distanceTo(chest) < 6) {
  83. return true;
  84. }
  85. }
  86. return false;
  87. }
  88.  
  89. public State getState() {
  90. try {
  91. if(USE_2_ORES == true) {
  92. if(!inventory.contains(ORE_ID) || !inventory.contains(ORE_2_ID)) {
  93. return State.BANK;
  94. } else {
  95. return State.SUPERHEAT;
  96. }
  97. } else {
  98. if(!inventory.contains(ORE_ID)) {
  99. return State.BANK;
  100. } else {
  101. return State.SUPERHEAT;
  102. }
  103. }
  104. } catch(Exception e) {
  105. return State.ERROR;
  106. }
  107. }
  108.  
  109. private void antiban() {
  110. switch(random(1,8)) {
  111.  
  112. case 3:
  113. mouse.moveSlightly();
  114. break;
  115.  
  116. case 6:
  117. mouse.moveOffScreen();
  118. break;
  119. }
  120. }
  121.  
  122. public int loop() {
  123. if(random(1,1000) < 100) {
  124. antiban();
  125. }
  126. try {
  127. switch(getState()) {
  128.  
  129. case SUPERHEAT:
  130. heat();
  131. break;
  132.  
  133. case BANK:
  134. bank();
  135. break;
  136.  
  137. case ERROR:
  138. log(Color.RED, "ERROR!");
  139. break;
  140.  
  141. }
  142. } catch(Exception e) { }
  143. return 100;
  144. }
  145.  
  146. private void bank() {
  147. if(bank.isOpen()) {
  148. if(inventory.contains(BAR_ID)) {
  149. status = "Depositing";
  150. bank.depositAllExcept(NATURE_RUNE);
  151. sleep(500);
  152. }
  153. if(USE_2_ORES == false) {
  154. if(!inventory.contains(ORE_ID)) {
  155. if(bank.getCount(ORE_ID) > 0) {
  156. status = "Withdrawing ores";
  157. bank.withdraw(ORE_ID, 27);
  158. sleep(600, 700);
  159. }
  160. }
  161. } else {
  162. if(!inventory.contains(ORE_ID)) {
  163. if(BRONZE == true) {
  164. status = "Withdrawing tin";
  165. bank.withdraw(ORE_ID, 13); //Tin
  166. sleep(600, 700);
  167. } else if(STEEL == true) {
  168. status = "Withdrawing iron";
  169. bank.withdraw(ORE_ID, 8); //Iron
  170. sleep(600, 700);
  171. } else if(MITHRIL == true) {
  172. status = "Withdrawing mithril";
  173. bank.withdraw(ORE_ID, 8); //Mithril
  174. sleep(600, 700);
  175. } else if(ADAMANT == true) {
  176. status = "Withdrawing adamant";
  177. bank.withdraw(ORE_ID, 4); //Adamant
  178. sleep(600, 700);
  179. } else if(RUNE == true) {
  180. status = "Withdrawing rune";
  181. bank.withdraw(ORE_ID, 3); //Rune
  182. sleep(600, 700);
  183. }
  184. }
  185. if(!inventory.contains(ORE_2_ID)) {
  186. if(BRONZE == true) {
  187. status = "Withdrawing copper";
  188. bank.withdraw(ORE_2_ID, 13); //Copper
  189. sleep(600, 700);
  190. } else if(STEEL == true) {
  191. status = "Withdrawing coal";
  192. bank.withdraw(ORE_2_ID, 18); //Coal
  193. sleep(600, 700);
  194. } else if(MITHRIL == true) {
  195. status = "Withdrawing coal";
  196. bank.withdraw(ORE_2_ID, 16); //Coal
  197. sleep(600, 700);
  198. } else if(ADAMANT == true) {
  199. status = "Withdrawing coal";
  200. bank.withdraw(ORE_2_ID, 23); //Coal
  201. sleep(600, 700);
  202. } else if(RUNE == true) {
  203. status = "Withdrawing coal";
  204. bank.withdraw(ORE_2_ID, 24); //Coal
  205. sleep(600, 700);
  206. }
  207. }
  208. }
  209. if(!inventory.contains(NATURE_RUNE)) {
  210. if(bank.getCount(NATURE_RUNE) > 0) {
  211. status = "Looking for nature runes";
  212. bank.searchItem("Nature rune");
  213. sleep(200, 500);
  214. bank.withdraw(NATURE_RUNE, 10000);
  215. sleep(1000, 2000);
  216. }
  217. }
  218. if(inventory.contains(ORE_ID)
  219. && inventory.contains(NATURE_RUNE)) {
  220. if(USE_2_ORES == true) {
  221. if(inventory.contains(ORE_2_ID)) {
  222. status = "Closing bank";
  223. bank.close();
  224. }
  225. } else {
  226. status = "Closing bank";
  227. bank.close();
  228. }
  229. }
  230. } else {
  231. if(BANK_CHEST == true) {
  232. RSObject chest = objects.getNearest("Chest");
  233. if(chest != null) {
  234. if(chest.isOnScreen()) {
  235. status = "Opening bank";
  236. chest.doClick(true);
  237. sleep(1500);
  238. } else {
  239. camera.turnTo(chest);
  240. }
  241. }
  242. } else {
  243. RSNPC banker = npcs.getNearest(BANKER_ID);
  244. if(banker != null) {
  245. if(banker.isOnScreen()) {
  246. status = "Opening bank";
  247. if(banker.interact("Bank bank")) {
  248. sleep(1000, 2000);
  249. }
  250. } else {
  251. camera.turnTo(banker);
  252. }
  253. }
  254. }
  255. }
  256. }
  257.  
  258. private void heat() {
  259. if(!bank.isOpen()) {
  260. if(SAFE_MODE == false) {
  261. status = "Superheating";
  262. magic.castSpell(Magic.SPELL_SUPERHEAT_ITEM);
  263. while(inventory.contains(ORE_ID)) {
  264. magic.castSpell(Magic.SPELL_SUPERHEAT_ITEM);
  265. sleep(50, 150);
  266. if(inventory.contains(ORE_ID)) {
  267. if(magic.isSpellSelected()) {
  268. Point p = inventory.getItem(ORE_ID).getPoint();
  269. mouse.hop(p);
  270. mouse.click(true);
  271. }
  272. } else {
  273. break;
  274. }
  275. sleep(500);
  276. }
  277. } else {
  278. status = "Superheating";
  279. magic.castSpell(Magic.SPELL_SUPERHEAT_ITEM);
  280. while(inventory.contains(ORE_ID)) {
  281. magic.castSpell(Magic.SPELL_SUPERHEAT_ITEM);
  282. sleep(50, 150);
  283. if(inventory.contains(ORE_ID)) {
  284. if(magic.isSpellSelected()) {
  285. inventory.getItem(ORE_ID).doClick(true);
  286. }
  287. } else {
  288. break;
  289. }
  290. sleep(500);
  291. }
  292. }
  293. } else {
  294. status = "Closing bank";
  295. bank.close();
  296. }
  297. }
  298.  
  299. private final Color color1 = new Color(0, 0, 0, 190);
  300. private final Color color2 = new Color(0, 255, 0);
  301.  
  302. private final BasicStroke stroke1 = new BasicStroke(1);
  303.  
  304. private final Font font1 = new Font("Arial", 1, 16);
  305. private final Font font2 = new Font("Arial", 0, 13);
  306.  
  307. public void onRepaint(Graphics g1) {
  308. Graphics2D g = (Graphics2D)g1;
  309.  
  310. EXP_GAINED_MAGE = skills.getCurrentExp(Skills.MAGIC) - START_EXP_MAGE;
  311. EXP_GAINED_SMITHING = skills.getCurrentExp(Skills.SMITHING) - START_EXP_SMITHING;
  312. EXP_GAINED = EXP_GAINED_MAGE + EXP_GAINED_SMITHING;
  313.  
  314. g.setColor(color1);
  315. g.fillRect(3, 3, 514, 59);
  316. g.setColor(color2);
  317. g.setStroke(stroke1);
  318. g.drawRect(3, 3, 514, 59);
  319. g.setFont(font1);
  320. g.drawString("DBoWZ Super Heater", 19, 37);
  321. g.setFont(font2);
  322. g.drawString("Timer: " + RUN_TIME.toElapsedString(), 175, 50);
  323. g.drawString("Magic Exp: " + EXP_GAINED_MAGE + " (" + getHourly(EXP_GAINED_MAGE) + "/hr)", 325, 25);
  324. g.drawString("Smithing Exp: " + EXP_GAINED_SMITHING + " (" + getHourly(EXP_GAINED_SMITHING) + "/hr)", 325, 50);
  325. g.drawString("Status: " + status, 175, 25);
  326. }
  327.  
  328. private int getHourly(final int input) {
  329. double millis = System.currentTimeMillis() - START_TIME;
  330. return (int) ((input / millis) * 3600000);
  331. }
  332.  
  333. public class GUI extends JFrame {
  334. public GUI() {
  335. initComponents();
  336. }
  337.  
  338. private void btnQuitActionPerformed(ActionEvent e) {
  339. this.setVisible(false);
  340. stopScript(true);
  341. }
  342.  
  343. private void btnStartActionPerformed(ActionEvent e) {
  344. SELECTED = cbType.getSelectedItem().toString();
  345. if(SELECTED.equals("Bronze")) {
  346. BAR_ID = BRONZE_BAR;
  347. USE_2_ORES = true;
  348. BRONZE = true;
  349. ORE_ID = TIN_ORE;
  350. ORE_2_ID = COPPER_ORE;
  351. } else if(SELECTED.equals("Iron")) {
  352. BAR_ID = IRON_BAR;
  353. ORE_ID = IRON_ORE;
  354. } else if(SELECTED.equals("Steel")) {
  355. BAR_ID = STEEL_BAR;
  356. USE_2_ORES = true;
  357. STEEL = true;
  358. ORE_ID = IRON_ORE;
  359. ORE_2_ID = COAL_ORE;
  360. } else if(SELECTED.equals("Silver")) {
  361. BAR_ID = SILVER_BAR;
  362. ORE_ID = SILVER_ORE;
  363. } else if(SELECTED.equals("Gold")) {
  364. BAR_ID = GOLD_BAR;
  365. ORE_ID = GOLD_ORE;
  366. } else if(SELECTED.equals("Mithril")) {
  367. BAR_ID = MITHRIL_BAR;
  368. USE_2_ORES = true;
  369. MITHRIL = true;
  370. ORE_ID = MITHRIL_ORE;
  371. ORE_2_ID = COAL_ORE;
  372. } else if(SELECTED.equals("Adamantite")) {
  373. BAR_ID = ADAMANT_BAR;
  374. USE_2_ORES = true;
  375. ADAMANT = true;
  376. ORE_ID = ADAMANT_ORE;
  377. ORE_2_ID = COAL_ORE;
  378. } else if(SELECTED.equals("Runite")) {
  379. BAR_ID = RUNE_BAR;
  380. USE_2_ORES = true;
  381. RUNE = true;
  382. ORE_ID = RUNE_ORE;
  383. ORE_2_ID = COAL_ORE;
  384. }
  385. if(cbMode.getSelectedItem().toString().equals("Normal")) {
  386. SAFE_MODE = true;
  387. } if(cbMode.getSelectedItem().toString().equals("Fast")) {
  388. SAFE_MODE = false;
  389. }
  390. GUI_WAIT = false;
  391. dispose();
  392. }
  393.  
  394. private void initComponents() {
  395. panel1 = new JPanel();
  396. btnStart = new JButton();
  397. tabbedPane1 = new JTabbedPane();
  398. pMain = new JPanel();
  399. lBar = new JLabel();
  400. cbType = new JComboBox();
  401. lMode = new JLabel();
  402. cbMode = new JComboBox();
  403. pUpdates = new JPanel();
  404. lVersion = new JLabel();
  405. tfVersion = new JTextField();
  406. lUpdate = new JLabel();
  407. tfLastUpdate = new JTextField();
  408. btnQuit = new JButton();
  409. lTitle = new JLabel();
  410.  
  411. //======== this ========
  412. setResizable(false);
  413. setAlwaysOnTop(true);
  414. setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  415. setTitle("made by DBoWZ");
  416. Container contentPane = getContentPane();
  417. contentPane.setLayout(null);
  418.  
  419. //======== panel1 ========
  420. {
  421. panel1.setLayout(null);
  422.  
  423. //---- btnStart ----
  424. btnStart.setText("Start");
  425. btnStart.addActionListener(new ActionListener() {
  426. public void actionPerformed(ActionEvent e) {
  427. btnStartActionPerformed(e);
  428. }
  429. });
  430. panel1.add(btnStart);
  431. btnStart.setBounds(140, 135, 75, 33);
  432.  
  433. //======== tabbedPane1 ========
  434. {
  435.  
  436. //======== pMain ========
  437. {
  438. pMain.setLayout(null);
  439.  
  440. //---- lBar ----
  441. lBar.setText("Select Bar:");
  442. lBar.setFont(lBar.getFont().deriveFont(lBar.getFont().getStyle() | Font.BOLD));
  443. pMain.add(lBar);
  444. lBar.setBounds(new Rectangle(new Point(10, 5), lBar.getPreferredSize()));
  445.  
  446. //---- cbType ----
  447. cbType.setModel(new DefaultComboBoxModel(new String[] {
  448. "Bronze",
  449. "Iron",
  450. "Steel",
  451. "Silver",
  452. "Gold",
  453. "Mithril",
  454. "Adamantite",
  455. "Runite"
  456. }));
  457. pMain.add(cbType);
  458. cbType.setBounds(new Rectangle(new Point(10, 25), cbType.getPreferredSize()));
  459.  
  460. //---- lMode ----
  461. lMode.setText("Select Mode:");
  462. lMode.setFont(lMode.getFont().deriveFont(lMode.getFont().getStyle() | Font.BOLD));
  463. pMain.add(lMode);
  464. lMode.setBounds(new Rectangle(new Point(105, 5), lMode.getPreferredSize()));
  465.  
  466. //---- cbMode ----
  467. cbMode.setModel(new DefaultComboBoxModel(new String[] {
  468. "Fast",
  469. "Normal"
  470. }));
  471. pMain.add(cbMode);
  472. cbMode.setBounds(105, 25, 80, cbMode.getPreferredSize().height);
  473.  
  474. { // compute preferred size
  475. Dimension preferredSize = new Dimension();
  476. for(int i = 0; i < pMain.getComponentCount(); i++) {
  477. Rectangle bounds = pMain.getComponent(i).getBounds();
  478. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  479. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  480. }
  481. Insets insets = pMain.getInsets();
  482. preferredSize.width += insets.right;
  483. preferredSize.height += insets.bottom;
  484. pMain.setMinimumSize(preferredSize);
  485. pMain.setPreferredSize(preferredSize);
  486. }
  487. }
  488. tabbedPane1.addTab("Main", pMain);
  489.  
  490.  
  491. //======== pUpdates ========
  492. {
  493. pUpdates.setLayout(null);
  494.  
  495. //---- lVersion ----
  496. lVersion.setText("Version:");
  497. lVersion.setFont(lVersion.getFont().deriveFont(lVersion.getFont().getStyle() | Font.BOLD));
  498. pUpdates.add(lVersion);
  499. lVersion.setBounds(new Rectangle(new Point(10, 10), lVersion.getPreferredSize()));
  500.  
  501. //---- tfVersion ----
  502. tfVersion.setEditable(false);
  503. tfVersion.setText("1.01");
  504. tfVersion.setToolTipText("Current script version");
  505. pUpdates.add(tfVersion);
  506. tfVersion.setBounds(90, 5, 100, tfVersion.getPreferredSize().height);
  507.  
  508. //---- lUpdate ----
  509. lUpdate.setText("Last update:");
  510. lUpdate.setFont(lUpdate.getFont().deriveFont(lUpdate.getFont().getStyle() | Font.BOLD));
  511. pUpdates.add(lUpdate);
  512. lUpdate.setBounds(new Rectangle(new Point(10, 35), lUpdate.getPreferredSize()));
  513.  
  514. //---- tfLastUpdate ----
  515. tfLastUpdate.setEditable(false);
  516. tfLastUpdate.setText("Added GUI and support for all ores & banks.");
  517. tfLastUpdate.setToolTipText("Latest update information");
  518. pUpdates.add(tfLastUpdate);
  519. tfLastUpdate.setBounds(90, 30, 100, 20);
  520.  
  521. { // compute preferred size
  522. Dimension preferredSize = new Dimension();
  523. for(int i = 0; i < pUpdates.getComponentCount(); i++) {
  524. Rectangle bounds = pUpdates.getComponent(i).getBounds();
  525. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  526. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  527. }
  528. Insets insets = pUpdates.getInsets();
  529. preferredSize.width += insets.right;
  530. preferredSize.height += insets.bottom;
  531. pUpdates.setMinimumSize(preferredSize);
  532. pUpdates.setPreferredSize(preferredSize);
  533. }
  534. }
  535. tabbedPane1.addTab("Updates", pUpdates);
  536.  
  537. }
  538. panel1.add(tabbedPane1);
  539. tabbedPane1.setBounds(10, 35, 205, 95);
  540.  
  541. //---- btnQuit ----
  542. btnQuit.setText("Quit");
  543. btnQuit.addActionListener(new ActionListener() {
  544. public void actionPerformed(ActionEvent e) {
  545. btnQuitActionPerformed(e);
  546. }
  547. });
  548. panel1.add(btnQuit);
  549. btnQuit.setBounds(10, 135, 75, 33);
  550.  
  551. //---- lTitle ----
  552. lTitle.setText("DBoWZ Super Heater");
  553. lTitle.setFont(new Font("Vrinda", Font.BOLD, 24));
  554. panel1.add(lTitle);
  555. lTitle.setBounds(new Rectangle(new Point(15, 0), lTitle.getPreferredSize()));
  556.  
  557. { // compute preferred size
  558. Dimension preferredSize = new Dimension();
  559. for(int i = 0; i < panel1.getComponentCount(); i++) {
  560. Rectangle bounds = panel1.getComponent(i).getBounds();
  561. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  562. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  563. }
  564. Insets insets = panel1.getInsets();
  565. preferredSize.width += insets.right;
  566. preferredSize.height += insets.bottom;
  567. panel1.setMinimumSize(preferredSize);
  568. panel1.setPreferredSize(preferredSize);
  569. }
  570. }
  571. contentPane.add(panel1);
  572. panel1.setBounds(0, 0, 225, 175);
  573.  
  574. { // compute preferred size
  575. Dimension preferredSize = new Dimension();
  576. for(int i = 0; i < contentPane.getComponentCount(); i++) {
  577. Rectangle bounds = contentPane.getComponent(i).getBounds();
  578. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  579. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  580. }
  581. Insets insets = contentPane.getInsets();
  582. preferredSize.width += insets.right;
  583. preferredSize.height += insets.bottom;
  584. contentPane.setMinimumSize(preferredSize);
  585. contentPane.setPreferredSize(preferredSize);
  586. }
  587. pack();
  588. setLocationRelativeTo(getOwner());
  589. }
  590. private JPanel panel1;
  591. private JButton btnStart;
  592. private JTabbedPane tabbedPane1;
  593. private JPanel pMain;
  594. private JLabel lBar;
  595. private JComboBox cbType;
  596. private JLabel lMode;
  597. private JComboBox cbMode;
  598. private JPanel pUpdates;
  599. private JLabel lVersion;
  600. private JTextField tfVersion;
  601. private JLabel lUpdate;
  602. private JTextField tfLastUpdate;
  603. private JButton btnQuit;
  604. private JLabel lTitle;
  605. }
  606. }
Add Comment
Please, Sign In to add comment