Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.81 KB | None | 0 0
  1. //Imports
  2. import org.rsbot.event.listeners.PaintListener;
  3. import org.rsbot.script.Script;
  4. import org.rsbot.script.ScriptManifest;
  5. import org.rsbot.script.methods.GrandExchange.GEItem;
  6. import org.rsbot.script.wrappers.RSGroundItem;
  7. import org.rsbot.script.wrappers.RSPath;
  8. import org.rsbot.script.wrappers.RSTile;
  9. import java.awt.*;
  10. import java.awt.event.ActionEvent;
  11. import java.awt.event.ActionListener;
  12. import java.awt.event.MouseEvent;
  13. import java.awt.event.MouseListener;
  14. import javax.swing.ButtonGroup;
  15. import javax.swing.JButton;
  16. import javax.swing.JCheckBox;
  17. import javax.swing.JFrame;
  18. import javax.swing.JLabel;
  19. import javax.swing.JRadioButton;
  20. import javax.swing.SwingConstants;
  21. import javax.swing.SwingUtilities;
  22.  
  23. @ScriptManifest(
  24. authors = { "Thondar" },
  25. name = "Asher", version = 0.01, keywords = {"Ash", "money", "low", "GE"}, description = "Picks Ashes at GE")
  26. public class Asher extends Script {
  27.  
  28. //Variables
  29. // - Integers
  30. int Ashes = 592;
  31. int ashes_gained = 0;
  32. int ashes_price = 0;
  33. int money_gained = 0;
  34. int ashes_in_bank = 0;
  35. int cache = 0;
  36. int ashes_hr = 0;
  37. int money_hr = 0;
  38. int x = 0;
  39. int y = 0;
  40. // - Strings, GEItems, RSTiles, Booleans, GUIs, RSPaths
  41. String antiban_status;
  42. String location;
  43. GEItem ashes_ge;
  44. RSTile GETile = new RSTile (3168, 3487);
  45. RSTile DVTile = new RSTile (3092, 3247);
  46. boolean transparent = false;
  47. boolean rest_enabled = true;
  48. boolean guistart = false;
  49. boolean started_w = false;
  50. AshesToGold_GUI gui = new AshesToGold_GUI();
  51. RSPath path;
  52. // - Anti-Ban
  53. int ar_1 = 1;
  54. int ar_2 = 1;
  55. boolean antiban_t = true;
  56. // - Time
  57. public long startTime = 0;
  58. public long millis = 0;
  59. public long hours = 0;
  60. public long minutes = 0;
  61. public long seconds = 0;
  62. public long last = 0;
  63.  
  64. //Startup program
  65. public boolean onStart() {
  66. //GUI
  67. SwingUtilities.invokeLater(new Runnable() {
  68. public void run() {
  69. gui.setVisible(true);
  70. gui.setResizable(false);
  71. gui.setTitle("AshesToGold");
  72. }
  73. });
  74. //Wait till GUI is done
  75. while (!guistart) {
  76. sleep(100);
  77. }
  78. //Timer
  79. startTime = System.currentTimeMillis();
  80. //Prices
  81. log("Loading script");
  82. ashes_ge = grandExchange.lookup(Ashes);
  83. ashes_price = ashes_ge.getGuidePrice();
  84. log("Ash price: " + ashes_price);
  85. mouse.setSpeed(random(4, 7));
  86. camera.setPitch(true);
  87. log("AshesToGold Started");
  88. return true;
  89. }
  90.  
  91. //Finishing Program
  92. public void onFinish(){
  93. log("Ashes Gained: " + ashes_gained);
  94. log("Money Gained: " + money_gained);
  95. log("Thanks for using AshesToGold!");
  96. }
  97.  
  98. //The all mighty loop
  99. @Override
  100. public int loop() {
  101.  
  102. //Start walking program
  103. if (started_w == false) {
  104. if (location == "Grand Exchange") {
  105. walktoge();
  106. } else if (location == "Draynor Village") {
  107. walktodv();
  108. }
  109. }
  110.  
  111. //Start the Anti-Ban
  112. if (antiban_t == true) {
  113. antiban();
  114. } else {
  115. antiban_status = "Off";
  116. }
  117.  
  118. //Sets camera pitch
  119. if (camera.getPitch() < 1851) {
  120. camera.setPitch(true);
  121. }
  122.  
  123. //If rest is enabled
  124. if (rest_enabled == true && walking.getEnergy() < random(20, 30) || walking.getEnergy() < 20) {
  125. while (walking.getEnergy() < random(70, 90)) {
  126. if (walking.rest() == false) {
  127. walking.rest();
  128. sleep(random(2000, 3000));
  129. }
  130. }
  131. } else {
  132.  
  133. //Main looping sequence
  134.  
  135. //Check if player is running
  136. if (!walking.isRunEnabled() && walking.getEnergy() > random(50, 90)) {
  137. walking.setRun(true);
  138. }
  139.  
  140. //Get ashes or go to bank
  141. if (!inventory.isFull()) {
  142. takeashes();
  143. } else {
  144. inventory.dropAllExcept(Ashes);
  145. if (inventory.isFull()) {
  146. if (location == "Grand Exchange") {
  147. walktoge();
  148. } else if (location == "Draynor Village") {
  149. walktodv();
  150. }
  151. sleep(random(1000, 2000));
  152. bankashes();
  153. }
  154. }
  155. }
  156.  
  157. //Final commands
  158. started_w = true;
  159. ash_count();
  160. return random(300, 500);
  161. }
  162.  
  163. //Anti-Ban Program
  164. public void antiban() {
  165. // 1/40 chance of running an anti-ban
  166. ar_1 = random(1, 40);
  167. if (ar_1 == 27) {
  168.  
  169. ar_2 = random(1, 8);
  170.  
  171. if (ar_2 == 1){
  172. antiban_status = "Mouse";
  173. mouse.moveOffScreen();
  174. sleep(random(200, 1000));
  175. }
  176. else if (ar_2 == 2) {
  177. antiban_status = "Mouse";
  178. mouse.moveSlightly();
  179. mouse.moveSlightly();
  180. mouse.moveSlightly();
  181. }
  182. else if (ar_2 == 3) {
  183. antiban_status = "Mouse";
  184. mouse.setSpeed(random(4, 8));
  185. }
  186. else if (ar_2 == 4) {
  187. antiban_status = "Mouse";
  188. mouse.moveSlightly();
  189. mouse.moveSlightly();
  190. }
  191. else if (ar_2 == 5) {
  192. antiban_status = "Mouse";
  193. mouse.moveOffScreen();
  194. sleep(random(3000, 6000));
  195. }
  196. else if (ar_2 == 6) {
  197. antiban_status = "Camera";
  198. if(random(1, 3) == 2) {
  199. int r = random(1,2);
  200. camera.setAngle(random(1,359));
  201. if(r!=1)
  202. camera.setPitch(random(1,99));
  203. }
  204. }
  205. else if (ar_2 == 7) {
  206. antiban_status = "Camera";
  207. if(random(1, 3) == 2) {
  208. int r = random(1,2);
  209. camera.setAngle(random(1,359));
  210. if(r!=1)
  211. camera.setPitch(random(1,99));
  212. }
  213. }
  214. else if (ar_2 == 8) {
  215. antiban_status = "Camera";
  216. if(random(1, 3) == 2) {
  217. int r = random(1,2);
  218. camera.setAngle(random(1,359));
  219. if(r!=1)
  220. camera.setPitch(random(1,99));
  221. }
  222. }
  223. else {
  224. antiban_status = "Running";
  225. }
  226. sleep(2000);
  227. }
  228. antiban_status = "Running";
  229. }
  230.  
  231. //Take ashes action
  232. public void takeashes() {
  233. RSGroundItem ashes = groundItems.getNearest(Ashes);
  234. if (!getMyPlayer().isMoving()) {
  235. if ((groundItems.getNearest(Ashes) != null) && (calc.tileOnScreen(ashes.getLocation())) && getMyPlayer().isIdle()) {
  236. ashes.doAction("Take");
  237. }
  238. else if ((groundItems.getNearest(Ashes) != null) && (!calc.tileOnScreen(ashes.getLocation()))) {
  239. walking.walkTileMM(groundItems.getNearest(Ashes).getLocation());
  240. cursor_move();
  241. sleep(random(1000, 1500));
  242. if (!calc.tileOnScreen(ashes.getLocation()) && getMyPlayer().isIdle() && !getMyPlayer().isMoving()) {
  243. if (location == "Grand Exchange") {
  244. walktoge();
  245. } else if (location == "Draynor Village") {
  246. walktodv();
  247. }
  248. }
  249. } else {
  250. if (getMyPlayer().getLocation() == GETile) {
  251. cursor_move();
  252. sleep(random(2000, 5000));
  253. } else {
  254. if (location == "Grand Exchange") {
  255. walktoge();
  256. } else if (location == "Draynor Village") {
  257. walktodv();
  258. }
  259. }
  260. }
  261. }
  262. }
  263.  
  264. //Check ashes
  265. public void ash_count() {
  266. ashes_gained = inventory.getCount(Ashes) + ashes_in_bank;
  267. money_gained = ashes_gained * ashes_price;
  268. }
  269.  
  270. //Cursor move
  271. public void cursor_move() {
  272. if (random(1, 8) == 2) {
  273. mouse.moveSlightly();
  274. mouse.moveSlightly();
  275. }
  276. }
  277.  
  278. //Walk to GE program
  279. public void walktoge() {
  280. walkto(GETile);
  281. }
  282.  
  283. //Walk to DV program
  284. public void walktodv() {
  285. walkto(DVTile);
  286. }
  287.  
  288. //Walking program
  289. public void walkto(RSTile tile) {
  290. path = walking.getPath(tile);
  291. path.traverse();
  292. }
  293.  
  294. //Bank ashes program
  295. public void bankashes() {
  296. if (!getMyPlayer().isMoving()) {
  297. bank.open();
  298. mouse.setSpeed(8);
  299. sleep(random(1500, 2000));
  300. cache = inventory.getCount(Ashes);
  301. sleep(random(200, 300));
  302. bank.depositAll();
  303. sleep(random(2000, 2500));
  304. bank.close();
  305. if (inventory.getCount(Ashes) == 0) {
  306. ashes_in_bank += cache;
  307. }
  308. cache = 0;
  309. sleep(random(200, 500));
  310. mouse.setSpeed(random(4, 8));
  311. }
  312. }
  313.  
  314. //Toggles for paint
  315. public void toggles() {
  316.  
  317. //Mouse check
  318. //(x >= *most left* && x < *most left* + *plus most right* && y >= *most up* && y < *most up* + *plus most down*)
  319.  
  320. //Rest toggle
  321. if (x >= 583 && x < 583 + 44 && y >= 409 && y < 409 + 18) {
  322. rest_enabled = !rest_enabled;
  323. x = 0;
  324. y = 0;
  325. }
  326.  
  327. //Transparent toggle
  328. if (x >= 643 && x < 643 + 100 && y >= 409 && y < 409 + 18) {
  329. transparent = !transparent;
  330. x = 0;
  331. y = 0;
  332. }
  333.  
  334. //Anti-Ban toggle
  335. if (x >= 619 && x < 619 + 50 && y >= 430 && y < 430 + 18) {
  336. antiban_t = !antiban_t;
  337. x = 0;
  338. y = 0;
  339. }
  340.  
  341. }
  342.  
  343. //Mouse location for toggles
  344. public void mouseClicked(MouseEvent e) {
  345. x = e.getX();
  346. y = e.getY();
  347. }
  348.  
  349. //Variables for paint
  350. // - Colors
  351. private Color color1 = new Color(0, 0, 0);
  352. private Color color2 = new Color(255, 255, 255);
  353. private Color color3 = new Color(51, 255, 0);
  354. private Color color4 = new Color(255, 0, 0);
  355. private Color mouse1 = new Color(51, 255, 0);
  356. // - Fonts
  357. private final Font font1 = new Font("Arial", 1, 24);
  358. private final Font font2 = new Font("Arial", 1, 12);
  359. private final Font font3 = new Font("Arial", 1, 10);
  360. private final Font font4 = new Font("Arial", 1, 14);
  361. // - Other
  362. private final BasicStroke stroke1 = new BasicStroke(1);
  363.  
  364. //Java graphics
  365. public void onRepaint(Graphics g1) {
  366. Graphics2D g = (Graphics2D)g1;
  367.  
  368. if (transparent == true) {
  369. color1 = new Color(0, 0, 0, 50);
  370. color2 = new Color(255, 255, 255, 50);
  371. color3 = new Color(51, 255, 0, 50);
  372. color4 = new Color(255, 0, 0, 50);
  373. } else {
  374. color1 = new Color(0, 0, 0);
  375. color2 = new Color(255, 255, 255);
  376. color3 = new Color(51, 255, 0);
  377. color4 = new Color(255, 0, 0);
  378. }
  379.  
  380. //Check toggles
  381. toggles();
  382.  
  383. //Cursor paint
  384. final int mouse_x = mouse.getLocation().x;
  385. final int mouse_y = mouse.getLocation().y;
  386. g.setColor(mouse1);
  387. g.fillOval(mouse_x - 10, mouse_y - 1, 22, 3);
  388. g.fillOval(mouse_x - 1, mouse_y - 10, 3, 22);
  389.  
  390. // Time calculations
  391. ashes_hr = (int) ((ashes_gained) * 3600000D / (System.currentTimeMillis() - startTime));
  392. money_hr = ashes_hr * ashes_price;
  393. millis = System.currentTimeMillis() - startTime;
  394. hours = millis / (1000 * 60 * 60);
  395. millis -= hours * (1000 * 60 * 60);
  396. minutes = millis / (1000 * 60);
  397. millis -= minutes * (1000 * 60);
  398. seconds = millis / 1000;
  399. // Background
  400. g.setColor(color1);
  401. g.fillRect(549, 209, 187, 254);
  402. g.setColor(color2);
  403. g.setStroke(stroke1);
  404. g.drawRect(549, 209, 187, 254);
  405. // Text
  406. g.setFont(font1);
  407. g.drawString("AshesToGold", 562, 238);
  408. g.setFont(font2);
  409. g.drawString("By Nunnsy", 609, 256);
  410. g.setFont(font3);
  411. g.drawString("Ashes: " + ashes_gained, 557, 286);
  412. g.drawString("Money: " + money_gained, 557, 300);
  413. g.drawString("Ashes/Hr: " + ashes_hr, 643, 286);
  414. g.drawString("Money/Hr: " + money_hr, 643, 300);
  415. g.drawString("Running: " + hours +":"+ minutes + ":" + seconds, 557, 272);
  416. g.drawString("Ash Price: " + ashes_price, 557, 314);
  417. g.drawString("Location: " + location, 557, 342);
  418. g.drawString("Anti-Ban: " + antiban_status, 557, 328);
  419. // Settings
  420. g.setFont(font4);
  421. g.drawString("---------- Settings ----------", 559, 364);
  422. g.setFont(font3);
  423. if (rest_enabled == true) {
  424. g.setColor(color3);
  425. } else {
  426. g.setColor(color4);
  427. }
  428. g.drawString("Resting", 588, 420);
  429. if (transparent == true) {
  430. g.setColor(color3);
  431. } else {
  432. g.setColor(color4);
  433. }
  434. g.drawString("Transparent", 647, 420);
  435. if (antiban_t == true) {
  436. g.setColor(color3);
  437. } else {
  438. g.setColor(color4);
  439. }
  440. g.drawString("Anti-Ban", 620, 442);
  441. }
  442.  
  443. //AshesToGold GUI class
  444. public class AshesToGold_GUI extends JFrame {
  445. private static final long serialVersionUID = 1L;
  446.  
  447. //Main control
  448. public AshesToGold_GUI() {
  449. initGUI();
  450. }
  451.  
  452. //GUI code
  453. private void initGUI() {
  454. getContentPane().setLayout(null);
  455.  
  456. //AshesToGold label
  457. JLabel lblAshestogold = new JLabel("AshesToGold");
  458. lblAshestogold.setHorizontalAlignment(SwingConstants.CENTER);
  459. lblAshestogold.setFont(new Font("Arial", Font.PLAIN, 24));
  460. lblAshestogold.setBounds(6, 6, 242, 43);
  461. getContentPane().add(lblAshestogold);
  462.  
  463. //Location label
  464. JLabel lblLocation = new JLabel("Location:");
  465. lblLocation.setBounds(16, 49, 61, 16);
  466. getContentPane().add(lblLocation);
  467. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  468. setBounds(100, 100, 254, 261);
  469.  
  470. //Font for Java objects
  471. lblAshestogold.setFont(new Font("Arial", Font.PLAIN, 24));
  472. lblAshestogold.setHorizontalAlignment(SwingConstants.CENTER);
  473.  
  474. //Location - Grand Exchange
  475. final JRadioButton rdbtnGrandExchange = new JRadioButton("Grand Exchange");
  476. rdbtnGrandExchange.setSelected(true);
  477. rdbtnGrandExchange.setBounds(76, 45, 141, 23);
  478. getContentPane().add(rdbtnGrandExchange);
  479.  
  480. //Location - Draynor Village
  481. final JRadioButton rdbtnDraynorVillage = new JRadioButton("Draynor Village");
  482. rdbtnDraynorVillage.setBounds(76, 69, 141, 23);
  483. getContentPane().add(rdbtnDraynorVillage);
  484.  
  485. //Anti-Ban check box
  486. final JCheckBox chckbxAntiban = new JCheckBox("Anti-Ban");
  487. chckbxAntiban.setSelected(true);
  488. chckbxAntiban.setBounds(6, 104, 94, 23);
  489. getContentPane().add(chckbxAntiban);
  490.  
  491. //Resting check box
  492. final JCheckBox chckbxResting = new JCheckBox("Resting");
  493. chckbxResting.setSelected(true);
  494. chckbxResting.setBounds(6, 127, 79, 23);
  495. getContentPane().add(chckbxResting);
  496.  
  497. //Transparent check box
  498. final JCheckBox chckbxTransparent = new JCheckBox("Transparent");
  499. chckbxTransparent.setBounds(6, 150, 107, 23);
  500. getContentPane().add(chckbxTransparent);
  501.  
  502. //Start button
  503. JButton btnStart = new JButton("Start!");
  504. btnStart.setFont(new Font("Arial", Font.PLAIN, 20));
  505. btnStart.setBounds(6, 190, 242, 43);
  506. getContentPane().add(btnStart);
  507.  
  508. //Group location buttons
  509. final ButtonGroup place = new ButtonGroup();
  510.  
  511. place.add(rdbtnGrandExchange);
  512. place.add(rdbtnDraynorVillage);
  513.  
  514. //Functions
  515. btnStart.addActionListener(new ActionListener() {
  516. public void actionPerformed(ActionEvent arg0) {
  517.  
  518. //Location
  519. if (rdbtnGrandExchange.isSelected()) {
  520. location = "Grand Exchange";
  521. }
  522. else if (rdbtnDraynorVillage.isSelected()) {
  523. location = "Draynor Village";
  524. }
  525.  
  526. //Check box settings
  527. transparent = chckbxTransparent.getModel().isSelected();
  528. rest_enabled = chckbxResting.getModel().isSelected();
  529. antiban_t = chckbxAntiban.getModel().isSelected();
  530.  
  531. //GUI helpers
  532. guistart = true;
  533. gui.setVisible(false);
  534. }
  535. });
  536. }
  537. }
  538. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement