Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.19 KB | None | 0 0
  1. /**----------------------
  2. * Update Logs
  3. * 1.0 - Release.
  4. * 1.1 - Fixed wrong spell IDs and paint issues.
  5. ----------------------*/
  6.  
  7. import java.awt.BasicStroke;
  8. import java.awt.Color;
  9. import java.awt.Container;
  10. import java.awt.Dimension;
  11. import java.awt.Font;
  12. import java.awt.Graphics;
  13. import java.awt.Graphics2D;
  14. import java.awt.Insets;
  15. import java.awt.Rectangle;
  16. import java.awt.event.ActionEvent;
  17. import java.awt.event.ActionListener;
  18. import java.awt.event.MouseEvent;
  19. import java.awt.event.MouseListener;
  20. import java.text.DecimalFormat;
  21.  
  22. import javax.swing.DefaultComboBoxModel;
  23. import javax.swing.JButton;
  24. import javax.swing.JComboBox;
  25. import javax.swing.JFrame;
  26. import javax.swing.JLabel;
  27. import javax.swing.JPanel;
  28. import javax.swing.SwingConstants;
  29. import javax.swing.WindowConstants;
  30.  
  31. import org.rsbot.event.listeners.PaintListener;
  32. import org.rsbot.script.Script;
  33. import org.rsbot.script.ScriptManifest;
  34. import org.rsbot.script.methods.Game;
  35. import org.rsbot.script.methods.Skills;
  36. import org.rsbot.script.util.Timer;
  37.  
  38. @ScriptManifest(authors = { "Shadow Storm" }, keywords = { "Magic", "Enchant" }, name = "Shadow Enchanter", version = 0.2, description = "Enchants your normal jewelry.")
  39. public class ShadowEnchanter extends Script implements PaintListener,
  40. MouseListener {
  41. final ScriptManifest properties = getClass().getAnnotation(
  42. ScriptManifest.class);
  43.  
  44. int[] clickID = { 1637, 1639, 1641, 1643, 1645, 1656, 1658, 1660, 1662,
  45. 1664, 1694, 1696, 1698, 1700, 1702, 11072, 11076, 11085, 11092,
  46. 11115 };
  47. public int madeID;
  48. public int cosmicID = 564;
  49. public int child;
  50. public String chantedName;
  51. public String status = ("Game Loading...");
  52. private int startXP = 0;
  53. private int startLVL = 0;
  54. private long scriptStartTime;
  55. public boolean startScript = false;
  56. private boolean randomsState = true;
  57. private boolean needToBank = true;
  58. public boolean setAltitude = false;
  59. Timer timer;
  60. int expGained;
  61. boolean guiExit, guiWait = true;
  62. private static final DecimalFormat k = new DecimalFormat("#.#");
  63. int casts;
  64. GUI gui;
  65. int mspeed;
  66.  
  67. @Override
  68. public boolean onStart() {
  69. gui = new GUI();
  70. while (guiWait) {
  71. sleep(100);
  72. }
  73. randomsState = env.disableRandom("Login");
  74. env.disableRandom("Login");
  75. needToBank = false;
  76. scriptStartTime = System.currentTimeMillis();
  77. startScript = true;
  78. timer = new Timer(0);
  79. startXP = skills.getCurrentExp(Skills.MAGIC);
  80. startLVL = skills.getCurrentLevel(Skills.MAGIC);
  81. return guiExit;
  82.  
  83. }
  84.  
  85. @Override
  86. public void onFinish() {
  87. logProgressReport();
  88. }
  89.  
  90. public void logProgressReport() {
  91. log("Thank you for using this script. Please visit it's page on powerbot.org");
  92. log(properties.name() + ", " + properties.version());
  93. log("Time ran: " + timer.toElapsedString());
  94. log("Experience: " + expGained);
  95. }
  96.  
  97. public int loop() {
  98. mouse.setSpeed(random(mspeed - 2, mspeed));
  99. if (!setAltitude) {
  100. camera.setPitch(true);
  101. sleep(random(250, 500));
  102. setAltitude = true;
  103. return random(50, 100);
  104. }
  105.  
  106. if (!handleEnchant() && randomsState) {
  107. if (randomsState) {
  108. randomsState = false;
  109. log.info("Randoms Able.");
  110. }
  111. } else {
  112. if (handleEnchant() && !randomsState) {
  113. if (randomsState) {
  114. randomsState = false;
  115. log.info("Randoms Able.");
  116. } else if (randomsState) {
  117. randomsState = false;
  118. log.info("Randoms Able.");
  119. } else {
  120. if (!randomsState) {
  121. randomsState = true;
  122. log.info("Randoms Unable.");
  123. }
  124. }
  125. }
  126. }
  127. if (!randomsState) {
  128. return 100;
  129. }
  130.  
  131. try {
  132. if (needToBank) {
  133. int ct = 0;
  134. boolean banked = false;
  135. do {
  136. banked = bank();
  137. sleep(random(100, 400));
  138. ct++;
  139. } while (ct < 5 && !banked);
  140.  
  141. if (bank.isOpen()) {
  142. if (inventory.getCount(cosmicID) > 0
  143. && inventory.getCount(madeID) > 0) {
  144. bank.close();
  145. needToBank = false;
  146. }
  147. return random(300, 400);
  148. }
  149. }
  150. if (bank.isOpen()) {
  151. bank.close();
  152. sleep(random(350, 450));
  153. }
  154.  
  155. return random(20, 30);
  156. } catch (Exception e) {
  157. e.printStackTrace();
  158. }
  159. return 1;
  160. }
  161.  
  162. public boolean handleEnchant() {
  163. antiBan();
  164. status = ("Enchanting");
  165. int ct = 0;
  166. sleep(random(200, 300));
  167. magic.castSpell(child);
  168. ct = 0;
  169. while (ct < 15 && (game.getCurrentTab() != Game.TAB_INVENTORY)) {
  170. ct++;
  171. sleep(random(150, 200));
  172. }
  173. if (!inventory.contains(cosmicID)) {
  174. log("You have ran out of cosmic runes! Stopping script...");
  175. stopScript(true);
  176. return false;
  177. }
  178.  
  179. if (needToBank = needMadeID(false)) {
  180. return true;
  181. }
  182. needToBank = needMadeID(true);
  183. if (!inventory.contains(madeID)) {
  184. mouse.click(true);
  185. return true;
  186. }
  187. if (!inventory.contains(madeID)) {
  188. mouse.click(true);
  189. return true;
  190. }
  191. ct = 0;
  192. while (ct < 10 && !inventory.getItem(madeID).doAction("Cast")) {
  193. sleep(random(1, 5));
  194. ct++;
  195. }
  196. casts++;
  197. ct = 0;
  198. while (ct < 75 && (game.getCurrentTab() != Game.TAB_MAGIC)) {
  199. ct++;
  200. sleep(random(15, 20));
  201. }
  202. return true;
  203. }
  204.  
  205. public boolean bank() {
  206. antiBan();
  207. status = ("Banking");
  208. int ct = 0;
  209. try {
  210. if (!bank.isOpen() && !inventory.contains(madeID)) {
  211. sleep(random(500, 800));
  212. if (bank.open())
  213. status = ("Bank Is Open...");
  214. sleep(random(300, 500));
  215. while (!bank.isOpen() && !inventory.contains(madeID)) {
  216. sleep(180);
  217. ct++;
  218. if (ct > 30)
  219. return false;
  220. }
  221. }
  222. } catch (final Exception e) {
  223. e.printStackTrace();
  224. }
  225.  
  226. try {
  227. if (bank.isOpen()) {
  228. status = ("Empting Inventory");
  229. if (bank.depositAllExcept(cosmicID))
  230. ;
  231. sleep(random(700, 800));
  232. if (bank.getCount(madeID) > 0) {
  233. sleep(random(600, 800));
  234. if (inventory.getCount(madeID) == 0) {
  235. sleep(random(600, 800));
  236. status = ("Getting " + madeID + "...");
  237. if (bank.withdraw(madeID, 0)) {
  238. sleep(random(400, 500));
  239. bank.close();
  240. }
  241. }
  242. } else {
  243. bank.close();
  244. sleep(random(10000, 12000));
  245. status = ("Logging out in 10 sec");
  246. game.logout(true);
  247. }
  248. }
  249. } catch (Exception e) {
  250. e.printStackTrace();
  251. }
  252. needToBank = true;
  253. return false;
  254. }
  255.  
  256. public boolean needMadeID(boolean castActive) {
  257. int cosmicIDnum = inventory.getCount(cosmicID);
  258. int madeIDnum = inventory.getCount(madeID);
  259. if (castActive) {
  260. if (madeIDnum < 1 || cosmicIDnum < 1) {
  261. return true;
  262. }
  263. }
  264. return false;
  265. }
  266.  
  267. private final Color color1 = new Color(0, 150, 150, 200);
  268. private final Color color2 = new Color(0, 0, 0);
  269. private final Color color3 = new Color(51, 204, 0);
  270.  
  271. private final BasicStroke stroke1 = new BasicStroke(1);
  272.  
  273. private final Font font1 = new Font("SansSerif", 1, 10);
  274.  
  275. boolean show = true;
  276.  
  277. public void onRepaint(final Graphics g1) {
  278. if (game.isLoggedIn()) {
  279. int levelsGained = skills.getCurrentLevel(Skills.MAGIC) - startLVL;
  280. int castsPerHour = 0;
  281. expGained = skills.getCurrentExp(Skills.MAGIC) - startXP;
  282. int expPerHour = 0;
  283. expPerHour = (int) ((expGained) * 3600000D / (System
  284. .currentTimeMillis() - scriptStartTime));
  285. castsPerHour = (int) ((casts) * 3600000D / (System
  286. .currentTimeMillis() - scriptStartTime));
  287. Graphics2D g = (Graphics2D) g1;
  288. if (show) {
  289. g.setColor(color1);
  290. g.fillRect(2, 3, 173, 146);
  291. g.setColor(color2);
  292. g.setStroke(stroke1);
  293. g.drawRect(2, 3, 173, 146);
  294. g.setColor(color1);
  295. g.fillRect(4, 5, 51, 18);
  296. g.setColor(color2);
  297. g.drawRect(4, 5, 51, 18);
  298. g.setFont(font1);
  299. g.drawString("Hide", 20, 18);
  300. g.drawString("Shadow Enchanter", 65, 18);
  301. g.drawString(
  302. "Exp.: " + k.format(expGained / 1000D)
  303. + "K | Per hour: "
  304. + k.format(expPerHour / 1000D) + "K", 5, 50);
  305. g.drawString(
  306. "Casts: " + casts + " | Per hour: " + castsPerHour, 5,
  307. 70);
  308. g.setColor(color3);
  309. g.fillRect(7, 131, skills.getPercentToNextLevel(Skills.MAGIC),
  310. 12);
  311. g.setColor(color2);
  312. g.drawString("Level: " + skills.getCurrentLevel(Skills.MAGIC)
  313. + " | Earned: " + levelsGained, 5, 90);
  314. g.drawString("Time running: " + timer.toElapsedString(), 5, 110);
  315. g.drawRect(6, 129, 165, 15);
  316. g.drawString(skills.getPercentToNextLevel(Skills.MAGIC)
  317. + "% to " + (skills.getCurrentLevel(Skills.MAGIC) + 1),
  318. 62, 140);
  319. } else {
  320. g.setColor(color1);
  321. g.fillRect(4, 5, 51, 18);
  322. g.setColor(color2);
  323. g.drawRect(4, 5, 51, 18);
  324. g.setFont(font1);
  325. g.drawString("Show", 18, 18);
  326. }
  327. }
  328. }
  329.  
  330. public void antiBan() {
  331. switch (random(0, 450)) {
  332. case 2:
  333. if (game.getCurrentTab() != Game.TAB_FRIENDS) {
  334. status = ("Friend Check");
  335. game.openTab(Game.TAB_FRIENDS);
  336. sleep(random(640, 920));
  337. } else {
  338. if (game.getCurrentTab() == Game.TAB_STATS) {
  339. status = ("HitPoint Check");
  340. game.openTab(Game.TAB_STATS);
  341. sleep(random(350, 780));
  342. mouse.move(636, 244, 5, 5);
  343. sleep(random(400, 700));
  344. }
  345. }
  346. break;
  347. case 3:
  348. if (game.getCurrentTab() != Game.TAB_STATS) {
  349. status = ("Attack Power Check");
  350. game.openTab(Game.TAB_STATS);
  351. sleep(random(500, 800));
  352. mouse.move(576, 245, 5, 5);
  353. sleep(random(800, 1200));
  354. } else {
  355. if (game.getCurrentTab() == Game.TAB_STATS) {
  356. status = ("Defence Check");
  357. game.openTab(Game.TAB_STATS);
  358. sleep(random(700, 900));
  359. mouse.move(570, 313, 5, 5);
  360. sleep(random(800, 1200));
  361. }
  362. }
  363. break;
  364. case 4:
  365. if (game.getCurrentTab() == Game.TAB_INVENTORY) {
  366. status = ("AntiBan");
  367. game.openTab(Game.TAB_STATS);
  368. sleep(random(300, 700));
  369. mouse.move(680, 280, 5, 5);
  370. sleep(random(500, 800));
  371. game.openTab(Game.TAB_INVENTORY);
  372. sleep(random(300, 600));
  373. mouse.move(582, 229, 5, 5);
  374. sleep(random(700, 1000));
  375. } else {
  376. if (game.getCurrentTab() == Game.TAB_STATS) {
  377. status = ("Stat Smith Check");
  378. game.openTab(Game.TAB_STATS);
  379. sleep(random(500, 700));
  380. mouse.move(680, 280, 5, 5);
  381. sleep(random(800, 1000));
  382. }
  383. }
  384. break;
  385. case 5:
  386. status = ("Equipment Check");
  387. mouse.move(random(0, 800), random(0, 800));
  388. sleep(random(300, 500));
  389. mouse.move(748, 847, 5, 5);
  390. sleep(random(500, 700));
  391. mouse.click(true);
  392. sleep(random(800, 1000));
  393. game.openTab(Game.TAB_EQUIPMENT);
  394. sleep(random(800, 1000));
  395. break;
  396. }
  397. }
  398.  
  399. public class GUI extends JPanel {
  400. private static final long serialVersionUID = 1L;
  401.  
  402. public GUI() {
  403. initComponents();
  404. }
  405.  
  406. @SuppressWarnings("static-access")
  407. private void button1ActionPerformed(ActionEvent e) {
  408. String jewel = comboBox1.getSelectedItem().toString();
  409. String speed = comboBox2.getSelectedItem().toString();
  410. if (jewel.equals("Ring of Recoil")) {
  411. madeID = 1637;
  412. chantedName = "Ring of Recoil";
  413. child = magic.SPELL_LVL1_ENCHANT;
  414. } else if (jewel.equals("Ring of Duelling")) {
  415. madeID = 1639;
  416. chantedName = "Ring of Duelling";
  417. child = magic.SPELL_LVL2_ENCHANT;
  418. } else if (jewel.equals("Ring of Forging")) {
  419. madeID = 1641;
  420. chantedName = "Ring of Forging";
  421. child = magic.SPELL_LVL3_ENCHANT;
  422. } else if (jewel.equals("Ring of Life")) {
  423. madeID = 1643;
  424. chantedName = "Ring of Life";
  425. child = magic.SPELL_LVL4_ENCHANT;
  426. } else if (jewel.equals("Ring of Wealth")) {
  427. madeID = 1645;
  428. chantedName = "Ring of Wealth";
  429. child = magic.SPELL_LVL5_ENCHANT;
  430. } else if (jewel.equals("Games Necklace")) {
  431. madeID = 1656;
  432. chantedName = "Games Necklace";
  433. child = magic.SPELL_LVL1_ENCHANT;
  434. } else if (jewel.equals("Necklace of Binding")) {
  435. madeID = 1658;
  436. chantedName = "Necklace of Binding";
  437. child = magic.SPELL_LVL2_ENCHANT;
  438. } else if (jewel.equals("Digsite Pendant")) {
  439. madeID = 1660;
  440. chantedName = "Digsite Pendant";
  441. child = magic.SPELL_LVL3_ENCHANT;
  442. } else if (jewel.equals("Phoenix Necklace")) {
  443. madeID = 1662;
  444. chantedName = "Phoenix Necklace";
  445. child = magic.SPELL_LVL4_ENCHANT;
  446. } else if (jewel.equals("Skills Necklace")) {
  447. madeID = 1664;
  448. chantedName = "Skills Necklace";
  449. child = magic.SPELL_LVL5_ENCHANT;
  450. } else if (jewel.equals("Amulet of Magic")) {
  451. madeID = 1694;
  452. chantedName = "Amulet of Magic";
  453. child = magic.SPELL_LVL1_ENCHANT;
  454. } else if (jewel.equals("Amulet of Defence")) {
  455. madeID = 1696;
  456. chantedName = "Amulet of Defence";
  457. child = magic.SPELL_LVL2_ENCHANT;
  458. } else if (jewel.equals("Amulet of Strength")) {
  459. madeID = 1698;
  460. chantedName = "Amulet of Strength";
  461. child = magic.SPELL_LVL3_ENCHANT;
  462. } else if (jewel.equals("Amulet of Power")) {
  463. madeID = 1700;
  464. chantedName = "Amulet of Power";
  465. child = magic.SPELL_LVL4_ENCHANT;
  466. } else if (jewel.equals("Amulet of Glory")) {
  467. madeID = 1702;
  468. chantedName = "Amulet of Glory";
  469. child = magic.SPELL_LVL5_ENCHANT;
  470. } else if (jewel.equals("Bracelet of Clay")) {
  471. madeID = 11072;
  472. chantedName = "Bracelet of Clay";
  473. child = magic.SPELL_LVL1_ENCHANT;
  474. } else if (jewel.equals("Castlewars Bracelet")) {
  475. madeID = 11076;
  476. chantedName = "Castlewars Bracelet";
  477. child = magic.SPELL_LVL2_ENCHANT;
  478. } else if (jewel.equals("Inoculation Brace")) {
  479. madeID = 11085;
  480. chantedName = "Inoculation Brace";
  481. child = magic.SPELL_LVL3_ENCHANT;
  482. } else if (jewel.equals("Forinthry Bracelet")) {
  483. madeID = 11092;
  484. chantedName = "Forinthry Bracelet";
  485. child = magic.SPELL_LVL4_ENCHANT;
  486. } else if (jewel.equals("Combat Bracelet")) {
  487. madeID = 11115;
  488. chantedName = "Combat Bracelet";
  489. child = magic.SPELL_LVL5_ENCHANT;
  490. } else if (jewel.equals("Onyx Ring")) {
  491. madeID = 0;
  492. chantedName = "";
  493. child = 88;
  494. }
  495. if (speed.equals("Extreme")) {
  496. mspeed = 3;
  497. } else if (speed.equals("Fast")) {
  498. mspeed = 5;
  499. } else if (speed.equals("Human")) {
  500. mspeed = 7;
  501. } else if (speed.equals("Slow")) {
  502. mspeed = 9;
  503. } else if (speed.equals("Turtle")) {
  504. mspeed = 11;
  505. }
  506. guiWait = false;
  507. guiExit = true;
  508. frame1.dispose();
  509. }
  510.  
  511. private void initComponents() {
  512. frame1 = new JFrame();
  513. label1 = new JLabel();
  514. label2 = new JLabel();
  515. comboBox1 = new JComboBox();
  516. label3 = new JLabel();
  517. comboBox2 = new JComboBox();
  518. button1 = new JButton();
  519.  
  520. // ======== frame1 ========
  521. {
  522. frame1.setVisible(true);
  523. frame1.setTitle("Shadow Enchanter GUI");
  524. Container frame1ContentPane = frame1.getContentPane();
  525. frame1ContentPane.setLayout(null);
  526. frame1.setAlwaysOnTop(true);
  527. frame1.setResizable(false);
  528. frame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  529.  
  530. // ---- label1 ----
  531. label1.setText("Shadow Enchanter");
  532. label1.setHorizontalAlignment(SwingConstants.CENTER);
  533. label1.setForeground(Color.red);
  534. label1.setFont(new Font("Tw Cen MT", Font.PLAIN, 16));
  535. frame1ContentPane.add(label1);
  536. label1.setBounds(0, 0, 220, 25);
  537.  
  538. // ---- label2 ----
  539. label2.setText("Enchant:");
  540. label2.setHorizontalAlignment(SwingConstants.CENTER);
  541. frame1ContentPane.add(label2);
  542. label2.setBounds(50, 50, 120, label2.getPreferredSize().height);
  543.  
  544. // ---- comboBox1 ----
  545. comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  546. "Ring of Recoil", "Ring of Duelling", "Ring of Forging",
  547. "Ring of Life", "Ring of Wealth", "Onyx Ring",
  548. "Games Necklace", "Necklace of Binding",
  549. "Digsite Pendant", "Phoenix Necklace",
  550. "Skills Necklace", "Amulet of Magic",
  551. "Amulet of Defense", "Amulet of Strength",
  552. "Amulet of Power", "Amulet of Glory",
  553. "Bracelet of Clay", "Castlewars Bracelet",
  554. "Inoculation Bracelet", "Forinthry Bracelet",
  555. "Combat Bracelet" }));
  556. frame1ContentPane.add(comboBox1);
  557. comboBox1.setBounds(50, 69, 120,
  558. comboBox1.getPreferredSize().height);
  559.  
  560. // ---- label3 ----
  561. label3.setText("Mouse:");
  562. label3.setHorizontalAlignment(SwingConstants.CENTER);
  563. frame1ContentPane.add(label3);
  564. label3.setBounds(50, 119, 120, label3.getPreferredSize().height);
  565.  
  566. // ---- comboBox2 ----
  567. comboBox2.setModel(new DefaultComboBoxModel(new String[] {
  568. "Extreme", "Fast", "Human", "Slow", "Turtle" }));
  569. frame1ContentPane.add(comboBox2);
  570. comboBox2.setBounds(50, 138, 120,
  571. comboBox2.getPreferredSize().height);
  572.  
  573. // ---- button1 ----
  574. button1.setText("Start");
  575. button1.addActionListener(new ActionListener() {
  576. public void actionPerformed(ActionEvent e) {
  577. button1ActionPerformed(e);
  578. }
  579. });
  580. frame1ContentPane.add(button1);
  581. button1.setBounds(75, 188, 70,
  582. button1.getPreferredSize().height);
  583.  
  584. {
  585. Dimension preferredSize = new Dimension();
  586. for (int i = 0; i < frame1ContentPane.getComponentCount(); i++) {
  587. Rectangle bounds = frame1ContentPane.getComponent(i)
  588. .getBounds();
  589. preferredSize.width = Math.max(bounds.x + bounds.width,
  590. preferredSize.width);
  591. preferredSize.height = Math.max(bounds.y
  592. + bounds.height, preferredSize.height);
  593. }
  594. Insets insets = frame1ContentPane.getInsets();
  595. preferredSize.width += insets.right;
  596. preferredSize.height += insets.bottom;
  597. frame1ContentPane.setMinimumSize(preferredSize);
  598. frame1ContentPane.setPreferredSize(preferredSize);
  599. }
  600. frame1.pack();
  601. frame1.setLocationRelativeTo(frame1.getOwner());
  602. }
  603. }
  604.  
  605. private JFrame frame1;
  606. private JLabel label1;
  607. private JLabel label2;
  608. private JComboBox comboBox1;
  609. private JLabel label3;
  610. private JComboBox comboBox2;
  611. private JButton button1;
  612. }
  613.  
  614. @Override
  615. public void mouseClicked(MouseEvent arg0) {
  616. Rectangle r = new Rectangle(4, 5, 51, 18);
  617. if (r.contains(arg0.getPoint())) {
  618. show = !show;
  619. }
  620. }
  621.  
  622. @Override
  623. public void mouseEntered(MouseEvent arg0) {
  624. // TODO Auto-generated method stub
  625.  
  626. }
  627.  
  628. @Override
  629. public void mouseExited(MouseEvent arg0) {
  630. // TODO Auto-generated method stub
  631.  
  632. }
  633.  
  634. @Override
  635. public void mousePressed(MouseEvent arg0) {
  636. // TODO Auto-generated method stub
  637.  
  638. }
  639.  
  640. @Override
  641. public void mouseReleased(MouseEvent arg0) {
  642. // TODO Auto-generated method stub
  643.  
  644. }
  645. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement