Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.86 KB | None | 0 0
  1. import org.rsbot.event.events.MessageEvent;
  2. import org.rsbot.event.listeners.MessageListener;
  3. import org.rsbot.event.listeners.PaintListener;
  4. import org.rsbot.script.Script;
  5. import org.rsbot.script.ScriptManifest;
  6. import org.rsbot.script.methods.Skills;
  7. import org.rsbot.script.wrappers.RSObject;
  8. import org.rsbot.script.wrappers.RSTile;
  9. import org.rsbot.script.wrappers.RSTilePath;
  10.  
  11. import java.awt.*;
  12. import java.awt.event.*;
  13. import java.awt.BasicStroke;
  14. import javax.swing.*;
  15. import javax.swing.GroupLayout;
  16. import javax.swing.LayoutStyle;
  17.  
  18. @ScriptManifest(
  19. authors = {"Ecstacy"},
  20. version = 1,
  21. keywords = {"mining", "banking", "money", "tin"},
  22. description = "Start either by East Varrock Mine or the Bank",
  23. name = "AIOVarrockMiner"
  24. )
  25. public class AIOVarrockMiner extends Script implements PaintListener, MessageListener {
  26.  
  27.  
  28. int boothID = 782;
  29. int[] TIN_ID = {11959, 11957, 11058};
  30. int[] COPPER_ID = {11962, 11960, 11961};
  31. int[] IRON_ID = {11954, 11955, 11956};
  32. int[] SILVER_ID = {};
  33. int[] CLAY_ID = {};
  34. int miningAnimation = 625;
  35.  
  36. int[] pickID = {1275};
  37.  
  38. int TIN_ORE = 438;
  39. int COPPER_ORE = 0;
  40. int IRON_ORE = 440;
  41. int SILVER_ORE = 0;
  42. int CLAY_ORE = 434;
  43.  
  44. RSTile[] tilesToBank = {new RSTile(3285, 3366), new RSTile(3286, 3372), new RSTile(3291, 3377),
  45. new RSTile(3292, 3387), new RSTile(3291, 3396), new RSTile(3291, 3403), new RSTile(3288, 3411),
  46. new RSTile(3287, 3419), new RSTile(3284, 3426), new RSTile(3276, 3428), new RSTile(3268, 3428), new RSTile(3258, 3429), new RSTile(3254, 3425), new RSTile(3252, 3420)};
  47. RSTilePath pathToBank;
  48.  
  49. long startTime;
  50.  
  51. int expGained = 0;
  52. int startExp = 0;
  53. int oresMined = 0;
  54.  
  55. int[] oresToMine;
  56. int oreID = 0;
  57.  
  58. boolean guiWait = true;
  59. gui g = new gui();
  60.  
  61. public boolean onStart() {
  62. pathToBank = walking.newTilePath(tilesToBank);
  63. startTime = System.currentTimeMillis();
  64. startExp = skills.getCurrentExp(skills.MINING);
  65.  
  66. g.setVisible(true);
  67. while(guiWait) sleep(500);
  68.  
  69. return true;
  70. }
  71.  
  72. @Override
  73. public int loop() {
  74. if(inventory.isFull()) {
  75. if(atBank()) {
  76. doBank();
  77. } else {
  78. walk();
  79. }
  80. } else {
  81. if(atMine()) {
  82. try {
  83. mineOres();
  84. } catch (Exception e) {
  85.  
  86. }
  87. } else {
  88. walkR();
  89. }
  90. }
  91. return random(600, 800);
  92. }
  93.  
  94. private void mineOres() {
  95. RSObject rock = objects.getNearest(oresToMine);
  96. if(getMyPlayer().getAnimation() != miningAnimation) {
  97. rock.doAction("Mine");
  98. }
  99. sleep(1800, 2000);
  100.  
  101. }
  102.  
  103. private void walkR() {
  104. pathToBank.reverse();
  105. pathToBank.traverse();
  106. pathToBank.reverse();
  107. }
  108.  
  109. private void walk() {
  110. pathToBank.traverse();
  111. }
  112.  
  113. public void onFinish() {
  114. log("Thank you for using AIOVarrockMiner!");
  115. }
  116.  
  117. private boolean atBank() {
  118. RSObject bank = objects.getNearest(boothID);
  119. if(bank != null) {
  120. if(bank.isOnScreen()) {
  121. return true;
  122. }
  123. }
  124. return false;
  125. }
  126.  
  127. private void doBank() {
  128. if(bank.isOpen()) {
  129. bank.depositAllExcept(pickID);
  130. sleep(800, 1200);
  131. } else {
  132. bank.open();
  133. sleep(1800, 2200);
  134. }
  135. }
  136.  
  137. private boolean atMine() {
  138. RSObject ore = objects.getNearest(oresToMine);
  139. if(ore != null) {
  140. if(ore.isOnScreen()) {
  141. return true;
  142. }
  143. }
  144. return false;
  145. }
  146.  
  147.  
  148. //START: Code generated using Enfilade's Easel
  149. private final Color color1 = new Color(242, 230, 244);
  150. private final Color color2 = new Color(0, 0, 0);
  151. private final Color color3 = new Color(102, 5, 117);
  152.  
  153. private final BasicStroke stroke1 = new BasicStroke(1);
  154.  
  155. private final Font font1 = new Font("Arial", 0, 12);
  156. //END: Code generated using Enfilade's Easel
  157.  
  158. /*
  159. * ----- PAINT -----
  160. */
  161.  
  162.  
  163. @Override
  164. public void onRepaint(Graphics g) {
  165.  
  166. final int percent = skills.getPercentToNextLevel(skills.MINING);
  167.  
  168. expGained = skills.getCurrentExp(Skills.MINING) - startExp;
  169.  
  170. long millis = System.currentTimeMillis() - startTime;
  171. long hours = millis / (1000 * 60 * 60);
  172. millis -= hours * (1000 * 60 * 60);
  173. long minutes = millis / (1000 * 60);
  174. millis -= minutes * (1000 * 60);
  175. long seconds = millis / 1000;
  176.  
  177. float xpsec = 0;
  178. if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
  179. xpsec = ((float) expGained)/(float)(seconds + (minutes*60) + (hours*60*60));
  180. }
  181. float xpmin = xpsec * 60;
  182. float xphour = xpmin * 60;
  183.  
  184. float oresec = 0;
  185. if ((minutes > 0 || hours > 0 || seconds > 0) && oresMined > 0) {
  186. oresec = ((float) oresMined)/(float)(seconds + (minutes*60) + (hours*60*60));
  187. }
  188. float oremin = oresec * 60;
  189. float orehour = oremin * 60;
  190.  
  191. Graphics2D g1 = (Graphics2D)g;
  192. g.setColor(color1);
  193. g.fillRect(263, 351, 223, 99);
  194. g.setColor(color2);
  195. g.drawRect(263, 351, 223, 99);
  196. g.setFont(font1);
  197. g.setColor(color3);
  198. g.drawString("Runtime:" + hours + ":" + minutes + ":" + seconds, 268, 366);
  199. g.drawString("Experience Gained:" + expGained + " Exp/h: " + (int)xphour, 268, 382);
  200. g.drawString("Ores Mined:" + oresMined + " Ores/h: " + (int)orehour, 268, 397);
  201.  
  202.  
  203. g.setColor(Color.red);
  204. g.fillRoundRect(268, 425, 101, 11, 16, 16); //these must be on same cordinates
  205. g.setColor(Color.black);
  206. g.fillRoundRect(268, 425, percent, 11, 16, 16); //these must be on same cordinates
  207. g.setColor(Color.white);
  208. g.drawString("" + percent + "%", 317, 435); //this must be in the center of the bar
  209. g.setColor(Color.blue);
  210.  
  211. g.setColor(Color.black);
  212. g.drawRoundRect(268, 425, 101, 11, 16, 16); //these must be on same cordinates
  213.  
  214. }
  215.  
  216. @Override
  217. public void messageReceived(MessageEvent e) {
  218. String txt = e.getMessage();
  219. if(txt.contains("You manage to mine")) {
  220. oresMined++;
  221. }
  222. }
  223.  
  224. class gui extends JFrame {
  225. public gui() {
  226. initComponents();
  227. }
  228.  
  229. private void startButtonActionPerformed(ActionEvent e) {
  230. String chosen = oreSelected.getSelectedItem().toString();
  231. if(chosen.equals("Tin")) {
  232. oreID = TIN_ORE;
  233. oresToMine = TIN_ID;
  234. } else if(chosen.equals("Copper")) {
  235. oreID = COPPER_ORE;
  236. oresToMine = COPPER_ID;
  237. } else if(chosen.equals("Iron")) {
  238. oreID = IRON_ORE;
  239. oresToMine = IRON_ID;
  240. } else if(chosen.equals("Silver")) {
  241. oreID = SILVER_ORE;
  242. oresToMine = SILVER_ID;
  243. } else {
  244. oreID = CLAY_ORE;
  245. oresToMine = CLAY_ID;
  246. }
  247. guiWait = false;
  248. g.dispose();
  249. }
  250.  
  251. private void initComponents() {
  252. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  253. // Generated using JFormDesigner Evaluation license - eric fatasscartmanfff
  254. label1 = new JLabel();
  255. label2 = new JLabel();
  256. oreSelected = new JComboBox();
  257. label3 = new JLabel();
  258. startButton = new JButton();
  259.  
  260. //======== this ========
  261. setBackground(Color.black);
  262. Container contentPane = getContentPane();
  263.  
  264. //---- label1 ----
  265. label1.setText("AIOVarrockMiner");
  266. label1.setFont(new Font("Arial", Font.ITALIC, 12));
  267. label1.setForeground(Color.cyan);
  268. label1.setHorizontalAlignment(SwingConstants.CENTER);
  269.  
  270. //---- label2 ----
  271. label2.setText("Ores to Mine: ");
  272. label2.setFont(new Font("Arial", Font.ITALIC, 12));
  273. label2.setForeground(Color.cyan);
  274.  
  275. //---- oreSelected ----
  276. oreSelected.setForeground(Color.cyan);
  277. oreSelected.setBackground(Color.black);
  278. oreSelected.setFont(new Font("Arial", Font.ITALIC, 11));
  279. oreSelected.setModel(new DefaultComboBoxModel(new String[] {
  280. "Tin",
  281. "Copper",
  282. "Iron",
  283. }));
  284.  
  285. //---- label3 ----
  286. label3.setText("Made by: Ecstacy");
  287. label3.setFont(new Font("Arial", Font.BOLD, 11));
  288. label3.setForeground(Color.cyan);
  289.  
  290. //---- startButton ----
  291. startButton.setText("Start");
  292. startButton.setFont(new Font("Arial", Font.ITALIC, 12));
  293. startButton.setForeground(Color.cyan);
  294. startButton.addActionListener(new ActionListener() {
  295. @Override
  296. public void actionPerformed(ActionEvent e) {
  297. startButtonActionPerformed(e);
  298. }
  299. });
  300.  
  301. GroupLayout contentPaneLayout = new GroupLayout(contentPane);
  302. contentPane.setLayout(contentPaneLayout);
  303. contentPaneLayout.setHorizontalGroup(
  304. contentPaneLayout.createParallelGroup()
  305. .addGroup(contentPaneLayout.createSequentialGroup()
  306. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
  307. .addGroup(contentPaneLayout.createSequentialGroup()
  308. .addGap(64, 64, 64)
  309. .addComponent(label1))
  310. .addGroup(contentPaneLayout.createSequentialGroup()
  311. .addContainerGap()
  312. .addComponent(label2)
  313. .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  314. .addComponent(oreSelected, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  315. .addContainerGap(71, Short.MAX_VALUE))
  316. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  317. .addContainerGap(136, Short.MAX_VALUE)
  318. .addComponent(label3))
  319. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  320. .addContainerGap(162, Short.MAX_VALUE)
  321. .addComponent(startButton)
  322. .addContainerGap())
  323. );
  324. contentPaneLayout.setVerticalGroup(
  325. contentPaneLayout.createParallelGroup()
  326. .addGroup(contentPaneLayout.createSequentialGroup()
  327. .addContainerGap()
  328. .addComponent(label1)
  329. .addGap(18, 18, 18)
  330. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  331. .addComponent(label2)
  332. .addComponent(oreSelected, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  333. .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
  334. .addComponent(startButton)
  335. .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
  336. .addComponent(label3))
  337. );
  338. pack();
  339. setLocationRelativeTo(getOwner());
  340. // JFormDesigner - End of component initialization //GEN-END:initComponents
  341. }
  342.  
  343. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  344. // Generated using JFormDesigner Evaluation license - eric fatasscartmanfff
  345. private JLabel label1;
  346. private JLabel label2;
  347. private JComboBox oreSelected;
  348. private JLabel label3;
  349. private JButton startButton;
  350. // JFormDesigner - End of variables declaration //GEN-END:variables
  351. }
  352.  
  353. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement