Advertisement
Guest User

Untitled

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