Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.*;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Condition;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Tabs;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.methods.widget.Camera;
- import org.powerbot.game.api.util.Random;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.api.wrappers.widget.WidgetChild;
- import org.powerbot.game.bot.event.listener.PaintListener;
- @Manifest(name = "Combiner", description = "Combines to items of your choice", version = 1.0, authors = {"Thondar"})
- public class Combiner extends ActiveScript implements PaintListener {
- int Banker[] = {3418, 553, 496, 497, 9710, 42192, 2718, 3416, 3293, 4456, 4457, 4458, 4459, 6200, 2759};
- long startTime;
- long runTime, xpTime;
- long hr, min, sec, xphr, xpmin, xpsec;
- long xpGain;
- String time;
- String status;
- int ID_1;
- int ID_2;
- private static WidgetChild Check;
- boolean start = true;
- GUI g;
- private boolean guiWait = true;
- @Override
- protected void setup() {
- startTime = System.currentTimeMillis();
- g = new GUI();
- g.setVisible(true);
- final WaitGui guiTask = new WaitGui();
- provide(new Strategy(guiTask, guiTask));
- provide(new Strategy(new WaitGui(), new WaitGui()));
- BankOpen bankopen = new BankOpen();
- Strategy bankopenStrategy = new Strategy(bankopen, bankopen);
- provide(bankopenStrategy);
- Bank bank = new Bank();
- Strategy bankStrategy = new Strategy(bank, bank);
- provide(bankStrategy);
- Combine Combine = new Combine();
- Strategy CombineStrategy = new Strategy(Combine, Combine);
- provide(CombineStrategy);
- AntiBan ab = new AntiBan();
- Strategy abStrategy = new Strategy(ab, ab);
- provide(abStrategy);
- Tabs.INVENTORY.open(false);
- }
- private class WaitGui implements Task, Condition {
- @Override
- public void run() {
- while (guiWait) {
- Time.sleep(500);
- }
- }
- public boolean validate() {
- return guiWait;
- }
- }
- private class BankOpen implements Task, Condition {
- @Override
- public void run() {
- status = ("Banking");
- NPCs.getNearest(Banker).interact("Bank");
- Time.sleep(Random.nextInt(700, 1100));
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount(ID_1) == 0) && NPCs.getNearest(Banker).isOnScreen() && !org.powerbot.game.api.methods.widget.Bank.isOpen();
- }
- }
- private class Bank implements Task, Condition {
- @Override
- public void run() {
- status = ("Banking");
- org.powerbot.game.api.methods.widget.Bank.depositInventory();
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.withdraw(ID_1, 14);
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.withdraw(ID_2, 14);
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.close();
- }
- @Override
- public boolean validate() {
- return Inventory.getCount(ID_1) < 1 && org.powerbot.game.api.methods.widget.Bank.isOpen();
- }
- }
- private class Combine implements Task, Condition {
- @Override
- public void run() {
- Check = Widgets.get(905, 14);
- status = ("Combining");
- if(org.powerbot.game.api.methods.widget.Bank.isOpen()){
- org.powerbot.game.api.methods.widget.Bank.close();
- }if(!Check.isOnScreen()){
- Inventory.getItem(ID_1).getWidgetChild().interact("Use");
- Time.sleep(Random.nextInt(300, 500));
- Inventory.getItem(ID_2).getWidgetChild().interact("Use", "->");
- Time.sleep(Random.nextInt(300, 500));
- }if(Check.isOnScreen()){
- Check.click(true);
- Time.sleep(Random.nextInt(300, 500));
- }
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount(ID_1) > 13) && (Players.getLocal().getAnimation() == -1);
- }
- }
- private class AntiBan implements Task, Condition {
- @Override
- public void run() {
- switch(Random.nextInt(1, 100)){
- case 3:
- Camera.setAngle(Random.nextInt(1, 150));
- case 33:
- Camera.setAngle(Random.nextInt(1, 310));
- case 75:
- Camera.setAngle(Random.nextInt(1, 210));
- default:
- }
- Time.sleep(Random.nextInt(500, 1000));
- }
- @Override
- public boolean validate() {
- return start;
- }
- }
- private AlphaComposite makeComposite(float alpha) {
- int type = AlphaComposite.SRC_OVER;
- return(AlphaComposite.getInstance(type, alpha));
- }
- private final Font font1 = new Font("Verdana", 0, 16);
- private final Font font2 = new Font("Verdana", 0, 12);
- private final Font font3 = new Font("Verdana", 0, 13);
- private final Font font4 = new Font("Verdana", 0, 9);
- @Override
- public void onRepaint(Graphics g) {
- Graphics2D g2d = (Graphics2D) g;
- g2d.setColor(Color.BLUE);
- g2d.drawLine((Mouse.getX() -3), Mouse.getY(), (Mouse.getX() +3), Mouse.getY());
- g2d.drawLine(Mouse.getX(), (Mouse.getY() - 3), Mouse.getX(), (Mouse.getY() + 3));
- g2d.drawLine((Mouse.getX() - 1), (Mouse.getY() - 1), (Mouse.getX() + 1), (Mouse.getY() + 1));
- g2d.drawLine((Mouse.getX() + 1), (Mouse.getY() - 1), (Mouse.getX() - 1), (Mouse.getY() + 1));
- Rectangle bg = new Rectangle(0, 0, 800, 50);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.BLACK);
- g2d.fill(bg);
- g2d.setFont(font1);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.BLUE);
- g2d.drawString("Combiner", 15, 20);
- g2d.setFont(font3);
- g2d.drawString("by Thondar", 27, 35);
- g2d.setFont(font4);
- g2d.drawString("Version 1.0", 33, 45);
- g2d.setFont(font2);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.WHITE);
- g2d.drawString("Time Run: " + timeRun(), 150, 20);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.WHITE);
- g2d.drawString("Status: " + status, 150, 40);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.WHITE);
- g2d.drawString("ID 1: " + ID_1, 350, 20);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.WHITE);
- g2d.drawString("ID 2: " + ID_2, 350, 40);
- }
- public String timeRun() {
- runTime = System.currentTimeMillis() - startTime;
- time = "";
- hr = runTime / (1000 * 60 * 60);
- min = (runTime % (1000 * 60 * 60)) / (1000 * 60);
- sec = ((runTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
- if (hr < 10)
- time += "0" + hr + ":";
- else
- time += hr + ":";
- if (min < 10)
- time += "0" + min + ":";
- else
- time += min + ":";
- if (sec < 10)
- time += "0" + sec;
- else
- time += sec;
- return time;
- }
- class GUI extends JFrame {
- public GUI() {
- initComponents();
- }
- private void StartButtonActionPerformed(ActionEvent e) {
- ID_1 = Integer.parseInt(ID1.getText());
- ID_2 = Integer.parseInt(ID2.getText());
- guiWait = false;
- g.dispose();
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
- label1 = new JLabel();
- label2 = new JLabel();
- StartButton = new JButton();
- label3 = new JLabel();
- ID1 = new JFormattedTextField();
- ID2 = new JFormattedTextField();
- //======== this ========
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //---- label1 ----
- label1.setText("ID 1");
- label1.setHorizontalAlignment(SwingConstants.CENTER);
- label1.setFont(new Font("Verdana", Font.PLAIN, 12));
- contentPane.add(label1);
- label1.setBounds(0, 115, 295, 15);
- //---- label2 ----
- label2.setText("ID 2");
- label2.setHorizontalAlignment(SwingConstants.CENTER);
- label2.setFont(new Font("Verdana", Font.PLAIN, 12));
- contentPane.add(label2);
- label2.setBounds(0, 220, 295, label2.getPreferredSize().height);
- //---- StartButton ----
- StartButton.setText("Start");
- StartButton.setFont(new Font("Verdana", Font.PLAIN, 12));
- StartButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- StartButtonActionPerformed(e);
- }
- });
- contentPane.add(StartButton);
- StartButton.setBounds(5, 330, 285, 50);
- //---- label3 ----
- label3.setText("Combiner");
- label3.setHorizontalAlignment(SwingConstants.CENTER);
- label3.setFont(new Font("Segoe Print", Font.BOLD, 30));
- contentPane.add(label3);
- label3.setBounds(0, 0, 295, 70);
- //---- ID1 ----
- ID1.setFont(new Font("Verdana", Font.PLAIN, 12));
- ID1.setHorizontalAlignment(SwingConstants.CENTER);
- contentPane.add(ID1);
- ID1.setBounds(125, 135, 45, ID1.getPreferredSize().height);
- //---- ID2 ----
- ID2.setFont(new Font("Verdana", Font.PLAIN, 12));
- ID2.setHorizontalAlignment(SwingConstants.CENTER);
- contentPane.add(ID2);
- ID2.setBounds(125, 240, 45, ID2.getPreferredSize().height);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPane.getComponentCount(); i++) {
- Rectangle bounds = contentPane.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 = contentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- contentPane.setMinimumSize(preferredSize);
- contentPane.setPreferredSize(preferredSize);
- }
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
- private JLabel label1;
- private JLabel label2;
- private JButton StartButton;
- private JLabel label3;
- private JFormattedTextField ID1;
- private JFormattedTextField ID2;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment