Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Insets;
- import java.awt.Rectangle;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.text.DecimalFormat;
- import java.util.Map;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.SwingConstants;
- import javax.swing.WindowConstants;
- import org.rsbot.bot.Bot;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.util.Timer;
- @ScriptManifest(authors = { "Shadow Storm" }, keywords = { "Magic", "Enchant" }, name = "Shadow Enchanter", version = 0.1, description = "Enchants your jewelry.")
- public class ShadowEnchanter extends Script implements PaintListener,
- MouseListener {
- final ScriptManifest properties = getClass().getAnnotation(
- ScriptManifest.class);
- int[] clickID = { 1637, 1639, 1641, 1643, 1645, 1656, 1658, 1660, 1662,
- 1664, 1694, 1696, 1698, 1700, 1702, 11072, 11076, 11085, 11092,
- 11115 };
- public int madeID;
- public int cosmicID = 564;
- public int child;
- public String chantedName;
- public String status = ("Game Loading...");
- private int startXP = 0;
- private int startLVL = 0;
- private long scriptStartTime;
- public boolean startScript = false;
- private boolean randomsState = true;
- private boolean needToBank = true;
- public boolean setAltitude = false;
- Timer timer;
- boolean guiExit, guiWait = true;
- private static final DecimalFormat k = new DecimalFormat("#.#");
- int casts;
- GUI gui;
- int mspeed;
- @Override
- public boolean onStart() {
- gui = new GUI();
- while (guiWait) {
- sleep(100);
- }
- randomsState = env.disableRandom("Login");
- env.disableRandom("Login");
- needToBank = false;
- scriptStartTime = System.currentTimeMillis();
- startScript = true;
- timer = new Timer(0);
- startXP = skills.getCurrentExp(Skills.MAGIC);
- startLVL = skills.getCurrentLevel(Skills.MAGIC);
- return guiExit;
- }
- @Override
- public void onFinish() {
- logProgressReport();
- }
- public void logProgressReport() {
- final int currentXP = skills.getCurrentExp(Skills.MAGIC);
- final int XPgained = currentXP - startXP;
- final long runTime = System.currentTimeMillis() - scriptStartTime;
- final int seconds = (int) ((runTime / 1000) % 60);
- final int minutes = (int) ((runTime / 1000) / 60) % 60;
- final int hours = (int) (((runTime / 1000) / 60) / 60) % 60;
- final StringBuilder t1 = new StringBuilder();
- if (hours < 10) {
- t1.append('0');
- }
- t1.append(hours);
- t1.append(" : ");
- if (minutes < 10) {
- t1.append('0');
- }
- t1.append(minutes);
- t1.append(" : ");
- if (seconds < 10) {
- t1.append('0');
- }
- t1.append(seconds);
- log("Thank you for using this script. Please visit its page on the Powerbot site");
- log(properties.name() + ", " + properties.version());
- log("Run Time: " + t1);
- log("XP Gained: " + XPgained);
- }
- public int loop() {
- mouse.setSpeed(random(mspeed - 2, mspeed));
- if (getMyPlayer().getAnimation() != -1) {
- casts++;
- }
- if (startXP == 0) {
- startXP = skills.getCurrentExp(Skills.MAGIC);
- startLVL = skills.getCurrentLevel(Skills.MAGIC);
- }
- if (!setAltitude) {
- camera.setPitch(true);
- sleep(random(250, 500));
- setAltitude = true;
- return random(50, 100);
- }
- if (!handleEnchant() && randomsState) {
- if (randomsState) {
- randomsState = false;
- log.info("Randoms Able.");
- }
- } else {
- if (handleEnchant() && !randomsState) {
- if (randomsState) {
- randomsState = false;
- log.info("Randoms Able.");
- } else if (randomsState) {
- randomsState = false;
- log.info("Randoms Able.");
- } else {
- if (!randomsState) {
- randomsState = true;
- log.info("Randoms Unable.");
- }
- }
- }
- }
- if (!randomsState) {
- return 100;
- }
- try {
- if (needToBank) {
- int ct = 0;
- boolean banked = false;
- do {
- banked = bank();
- sleep(random(100, 400));
- ct++;
- } while (ct < 5 && !banked);
- if (bank.isOpen()) {
- if (inventory.getCount(cosmicID) > 0
- && inventory.getCount(madeID) > 0) {
- bank.close();
- needToBank = false;
- }
- return random(300, 400);
- }
- }
- if (bank.isOpen()) {
- bank.close();
- sleep(random(350, 450));
- }
- return random(20, 30);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return 1;
- }
- public boolean handleEnchant() {
- antiBan();
- status = ("Enchanting");
- int ct = 0;
- sleep(random(200, 300));
- magic.castSpell(child);
- ct = 0;
- while (ct < 15 && (game.getCurrentTab() != Game.TAB_INVENTORY)) {
- ct++;
- sleep(random(150, 200));
- }
- if (!inventory.contains(cosmicID)) {
- log("You have ran out of cosmic runes! Stopping script...");
- stopScript(true);
- return false;
- }
- if (needToBank = needMadeID(false)) {
- return true;
- }
- needToBank = needMadeID(true);
- if (!inventory.contains(madeID)) {
- mouse.click(true);
- return true;
- }
- if (!inventory.contains(madeID)) {
- mouse.click(true);
- return true;
- }
- ct = 0;
- while (ct < 10 && !inventory.getItem(madeID).doAction("Cast")) {
- sleep(random(1, 5));
- ct++;
- }
- ct = 0;
- while (ct < 75 && (game.getCurrentTab() != Game.TAB_MAGIC)) {
- ct++;
- sleep(random(150, 200));
- }
- return true;
- }
- public boolean bank() {
- antiBan();
- status = ("Banking");
- int ct = 0;
- try {
- if (!bank.isOpen() && !inventory.contains(madeID)) {
- sleep(random(500, 800));
- if (bank.open())
- status = ("Bank Is Open...");
- sleep(random(300, 500));
- while (!bank.isOpen() && !inventory.contains(madeID)) {
- sleep(180);
- ct++;
- if (ct > 30)
- return false;
- }
- }
- } catch (final Exception e) {
- }
- if (bank.isOpen()) {
- status = ("Empting Inventory");
- if (bank.depositAllExcept(cosmicID))
- ;
- sleep(random(700, 800));
- if (bank.getCount(madeID) > 0) {
- sleep(random(600, 800));
- if (inventory.getCount(madeID) == 0) {
- sleep(random(600, 800));
- status = ("Getting " + madeID + "...");
- if (bank.withdraw(madeID, 0)) {
- sleep(random(400, 500));
- bank.close();
- }
- }
- } else {
- bank.close();
- sleep(random(10000, 12000));
- status = ("Logging out in 10 sec");
- game.logout(true);
- }
- }
- needToBank = true;
- return false;
- }
- public boolean needMadeID(boolean castActive) {
- int cosmicIDnum = inventory.getCount(cosmicID);
- int madeIDnum = inventory.getCount(madeID);
- if (castActive) {
- if (madeIDnum < 1 || cosmicIDnum < 1) {
- return true;
- }
- }
- return false;
- }
- private final Color color1 = new Color(0, 150, 150, 200);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(51, 204, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("SansSerif", 1, 10);
- boolean show = true;
- public void onRepaint(final Graphics g1) {
- if (game.isLoggedIn()) {
- final long runTime = System.currentTimeMillis() - scriptStartTime;
- final int seconds = (int) ((runTime / 1000) % 60);
- final int minutes = (int) ((runTime / 1000) / 60) % 60;
- final int hours = (int) (((runTime / 1000) / 60) / 60) % 60;
- int levelsGained = skills.getCurrentLevel(Skills.MAGIC) - startLVL;
- int castsPerHour = 0;
- int expGained = skills.getCurrentExp(Skills.MAGIC) - startXP;
- int expPerHour = 0;
- if (expGained > 0 && seconds > 0) {
- expPerHour = (int) (3600 * expGained / seconds);
- }
- if (casts > 0 && seconds > 0) {
- castsPerHour = (int) (3600 * casts / seconds);
- }
- Graphics2D g = (Graphics2D) g1;
- if (show) {
- g.setColor(color1);
- g.fillRect(2, 3, 173, 146);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(2, 3, 173, 146);
- g.setColor(color1);
- g.fillRect(4, 5, 51, 18);
- g.setColor(color2);
- g.drawRect(4, 5, 51, 18);
- g.setFont(font1);
- g.drawString("Hide", 20, 18);
- g.drawString("Shadow Enchanter", 65, 18);
- g.drawString("Exp. earned: " + k.format(expGained / 1000D)
- + "K | Per hour: " + k.format(expPerHour / 1000D), 5,
- 50);
- g.drawString("Casts: " + casts + "K | Per hour: "
- + castsPerHour, 5, 70);
- g.setColor(color3);
- g.fillRect(7, 131, skills.getPercentToNextLevel(Skills.MAGIC),
- 12);
- g.setColor(color2);
- g.drawString("Level: " + skills.getCurrentLevel(Skills.MAGIC)
- + " | Earned: " + levelsGained, 5, 90);
- g.drawString("Time running: " + timer.toElapsedString(), 5, 110);
- g.drawRect(6, 129, 165, 15);
- g.drawString(skills.getPercentToNextLevel(Skills.MAGIC)
- + "% to " + (skills.getCurrentLevel(Skills.MAGIC) + 1),
- 62, 140);
- } else {
- g.setColor(color1);
- g.fillRect(4, 5, 51, 18);
- g.setColor(color2);
- g.drawRect(4, 5, 51, 18);
- g.setFont(font1);
- g.drawString("Show", 20, 18);
- }
- }
- }
- public void antiBan() {
- switch (random(0, 450)) {
- case 2:
- if (game.getCurrentTab() != Game.TAB_FRIENDS) {
- status = ("Friend Check");
- game.openTab(Game.TAB_FRIENDS);
- sleep(random(640, 920));
- } else {
- if (game.getCurrentTab() == Game.TAB_STATS) {
- status = ("HitPoint Check");
- game.openTab(Game.TAB_STATS);
- sleep(random(350, 780));
- mouse.move(636, 244, 5, 5);
- sleep(random(400, 700));
- }
- }
- break;
- case 3:
- if (game.getCurrentTab() != Game.TAB_STATS) {
- status = ("Attack Power Check");
- game.openTab(Game.TAB_STATS);
- sleep(random(500, 800));
- mouse.move(576, 245, 5, 5);
- sleep(random(800, 1200));
- } else {
- if (game.getCurrentTab() == Game.TAB_STATS) {
- status = ("Defence Check");
- game.openTab(Game.TAB_STATS);
- sleep(random(700, 900));
- mouse.move(570, 313, 5, 5);
- sleep(random(800, 1200));
- }
- }
- break;
- case 4:
- if (game.getCurrentTab() == Game.TAB_INVENTORY) {
- status = ("AntiBan");
- game.openTab(Game.TAB_STATS);
- sleep(random(300, 700));
- mouse.move(680, 280, 5, 5);
- sleep(random(500, 800));
- game.openTab(Game.TAB_INVENTORY);
- sleep(random(300, 600));
- mouse.move(582, 229, 5, 5);
- sleep(random(700, 1000));
- } else {
- if (game.getCurrentTab() == Game.TAB_STATS) {
- status = ("Stat Smith Check");
- game.openTab(Game.TAB_STATS);
- sleep(random(500, 700));
- mouse.move(680, 280, 5, 5);
- sleep(random(800, 1000));
- }
- }
- break;
- case 5:
- status = ("Equipment Check");
- mouse.move(random(0, 800), random(0, 800));
- sleep(random(300, 500));
- mouse.move(748, 847, 5, 5);
- sleep(random(500, 700));
- mouse.click(true);
- sleep(random(800, 1000));
- game.openTab(Game.TAB_EQUIPMENT);
- sleep(random(800, 1000));
- break;
- }
- }
- public class GUI extends JPanel {
- private static final long serialVersionUID = 1L;
- public GUI() {
- initComponents();
- }
- private void button1ActionPerformed(ActionEvent e) {
- String jewel = comboBox1.getSelectedItem().toString();
- String speed = comboBox2.getSelectedItem().toString();
- if (jewel.equals("Ring of Recoil")) {
- madeID = 1637;
- chantedName = "Ring of Recoil";
- child = 29;
- } else if (jewel.equals("Ring of Duelling")) {
- madeID = 1639;
- chantedName = "Ring of Duelling";
- child = 41;
- } else if (jewel.equals("Ring of Forging")) {
- madeID = 1641;
- chantedName = "Ring of Forging";
- child = 53;
- } else if (jewel.equals("Ring of Life")) {
- madeID = 1643;
- chantedName = "Ring of Life";
- child = 61;
- } else if (jewel.equals("Ring of Wealth")) {
- madeID = 1645;
- chantedName = "Ring of Wealth";
- child = 76;
- } else if (jewel.equals("Games Necklace")) {
- madeID = 1656;
- chantedName = "Games Necklace";
- child = 29;
- } else if (jewel.equals("Necklace of Binding")) {
- madeID = 1658;
- chantedName = "Necklace of Binding";
- child = 41;
- } else if (jewel.equals("Digsite Pendant")) {
- madeID = 1660;
- chantedName = "Digsite Pendant";
- child = 53;
- } else if (jewel.equals("Phoenix Necklace")) {
- madeID = 1662;
- chantedName = "Phoenix Necklace";
- child = 61;
- } else if (jewel.equals("Skills Necklace")) {
- madeID = 1664;
- chantedName = "Skills Necklace";
- child = 76;
- } else if (jewel.equals("Amulet of Magic")) {
- madeID = 1694;
- chantedName = "Amulet of Magic";
- child = 29;
- } else if (jewel.equals("Amulet of Defence")) {
- madeID = 1696;
- chantedName = "Amulet of Defence";
- child = 41;
- } else if (jewel.equals("Amulet of Strength")) {
- madeID = 1698;
- chantedName = "Amulet of Strength";
- child = 53;
- } else if (jewel.equals("Amulet of Power")) {
- madeID = 1700;
- chantedName = "Amulet of Power";
- child = 61;
- } else if (jewel.equals("Amulet of Glory")) {
- madeID = 1702;
- chantedName = "Amulet of Glory";
- child = 76;
- } else if (jewel.equals("Bracelet of Clay")) {
- madeID = 11072;
- chantedName = "Bracelet of Clay";
- child = 29;
- } else if (jewel.equals("Castlewars Bracelet")) {
- madeID = 11076;
- chantedName = "Castlewars Bracelet";
- child = 41;
- } else if (jewel.equals("Inoculation Brace")) {
- madeID = 11085;
- chantedName = "Inoculation Brace";
- child = 53;
- } else if (jewel.equals("Forinthry Bracelet")) {
- madeID = 11092;
- chantedName = "Forinthry Bracelet";
- child = 61;
- } else if (jewel.equals("Combat Bracelet")) {
- madeID = 11115;
- chantedName = "Combat Bracelet";
- child = 76;
- } else if (jewel.equals("Onyx Ring")) {
- madeID = 0;
- chantedName = "";
- child = 88;
- }
- if (speed.equals("Extreme")) {
- mspeed = 3;
- } else if (speed.equals("Fast")) {
- mspeed = 5;
- } else if (speed.equals("Human")) {
- mspeed = 7;
- } else if (speed.equals("Slow")) {
- mspeed = 9;
- } else if (speed.equals("Turtle")) {
- mspeed = 11;
- }
- guiWait = false;
- guiExit = true;
- frame1.dispose();
- }
- private void initComponents() {
- frame1 = new JFrame();
- label1 = new JLabel();
- label2 = new JLabel();
- comboBox1 = new JComboBox();
- label3 = new JLabel();
- comboBox2 = new JComboBox();
- button1 = new JButton();
- // ======== frame1 ========
- {
- frame1.setVisible(true);
- frame1.setTitle("Shadow Enchanter GUI");
- Container frame1ContentPane = frame1.getContentPane();
- frame1ContentPane.setLayout(null);
- frame1.setAlwaysOnTop(true);
- frame1.setResizable(false);
- frame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- // ---- label1 ----
- label1.setText("Shadow Enchanter");
- label1.setHorizontalAlignment(SwingConstants.CENTER);
- label1.setForeground(Color.red);
- label1.setFont(new Font("Tw Cen MT", Font.PLAIN, 16));
- frame1ContentPane.add(label1);
- label1.setBounds(0, 0, 220, 25);
- // ---- label2 ----
- label2.setText("Enchant:");
- label2.setHorizontalAlignment(SwingConstants.CENTER);
- frame1ContentPane.add(label2);
- label2.setBounds(50, 50, 120, label2.getPreferredSize().height);
- // ---- comboBox1 ----
- comboBox1.setModel(new DefaultComboBoxModel(new String[] {
- "Ring of Recoil", "Ring of Dueling", "Ring of Forging",
- "Ring of Life", "Ring of Wealth", "Onyx Ring",
- "Games Necklace", "Necklace of Binding",
- "Digsite Pendant", "Phoenix Necklace",
- "Skills Necklace", "Amulet of Magic",
- "Amulet of Defense", "Amulet of Strength",
- "Amulet of Power", "Amulet of Glory",
- "Bracelet of Clay", "Castlewars Bracelet",
- "Inoculation Bracelet", "Forinthry Bracelet",
- "Combat Bracelet" }));
- frame1ContentPane.add(comboBox1);
- comboBox1.setBounds(50, 69, 120,
- comboBox1.getPreferredSize().height);
- // ---- label3 ----
- label3.setText("Mouse:");
- label3.setHorizontalAlignment(SwingConstants.CENTER);
- frame1ContentPane.add(label3);
- label3.setBounds(50, 119, 120, label3.getPreferredSize().height);
- // ---- comboBox2 ----
- comboBox2.setModel(new DefaultComboBoxModel(new String[] {
- "Extreme", "Fast", "Human", "Slow", "Turtle" }));
- frame1ContentPane.add(comboBox2);
- comboBox2.setBounds(50, 138, 120,
- comboBox2.getPreferredSize().height);
- // ---- button1 ----
- button1.setText("Start");
- button1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- button1ActionPerformed(e);
- }
- });
- frame1ContentPane.add(button1);
- button1.setBounds(75, 188, 70,
- button1.getPreferredSize().height);
- {
- Dimension preferredSize = new Dimension();
- for (int i = 0; i < frame1ContentPane.getComponentCount(); i++) {
- Rectangle bounds = frame1ContentPane.getComponent(i)
- .getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width,
- preferredSize.width);
- preferredSize.height = Math.max(bounds.y
- + bounds.height, preferredSize.height);
- }
- Insets insets = frame1ContentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- frame1ContentPane.setMinimumSize(preferredSize);
- frame1ContentPane.setPreferredSize(preferredSize);
- }
- frame1.pack();
- frame1.setLocationRelativeTo(frame1.getOwner());
- }
- }
- private JFrame frame1;
- private JLabel label1;
- private JLabel label2;
- private JComboBox comboBox1;
- private JLabel label3;
- private JComboBox comboBox2;
- private JButton button1;
- }
- @Override
- public void mouseClicked(MouseEvent arg0) {
- Rectangle r = new Rectangle(4, 5, 51, 18);
- if (r.contains(arg0.getPoint())) {
- show = !show;
- }
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement