Advertisement
Guest User

xobot guard maker

a guest
Oct 1st, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.45 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Dimension;
  4. import java.awt.FlowLayout;
  5. import java.awt.Font;
  6. import java.awt.Graphics;
  7. import java.awt.Graphics2D;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10.  
  11. import javax.swing.JButton;
  12. import javax.swing.JComboBox;
  13. import javax.swing.JDialog;
  14.  
  15. import xobot.client.callback.listeners.PaintListener;
  16. import xobot.script.ActiveScript;
  17. import xobot.script.Manifest;
  18. import xobot.script.methods.GameObjects;
  19. import xobot.script.methods.Packets;
  20. import xobot.script.methods.Widgets;
  21. import xobot.script.methods.tabs.Skills;
  22. import xobot.script.util.Time;
  23. import xobot.script.util.Timer;
  24. import xobot.script.wrappers.interactive.GameObject;
  25.  
  26. @Manifest(authors = { "Neo" }, name = "Guard Maker")
  27. public class GuardMaker extends ActiveScript implements PaintListener{
  28.  
  29.     private final int[] guardIds = {13366,13367,13368,13372};
  30.     private int interfaceId = -1;
  31.     private int startXP;
  32.    
  33.     private Timer timer;
  34.    
  35.     @Override
  36.     public boolean onStart() {
  37.         startXP = Skills.CONSTRUCTION.getCurrentExp();
  38.         timer = new Timer();
  39.         JDialog frame = new JDialog();
  40.         frame.setPreferredSize(new Dimension(250,90));
  41.         frame.setLocationRelativeTo(null);
  42.         frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  43.         FlowLayout layout = new FlowLayout();
  44.         layout.setHgap(5);
  45.         layout.setVgap(5);
  46.         frame.setLayout(layout);
  47.        
  48.         JComboBox<String> combo = new JComboBox<String>();
  49.         combo.setPreferredSize(new Dimension(150,30));
  50.         combo.setFocusable(false);
  51.         combo.addItem("Skeleton");
  52.         combo.addItem("Dog");
  53.         combo.addItem("Hobgoblin");
  54.         combo.addItem("Baby red dragon");
  55.        
  56.         JButton button = new JButton("Start");
  57.         button.setFocusable(false);
  58.         button.setPreferredSize(new Dimension(60,32));
  59.         button.addActionListener(new ActionListener() {
  60.  
  61.             @Override
  62.             public void actionPerformed(ActionEvent arg0) {
  63.                 switch((String)combo.getSelectedItem()) {
  64.                 case "Skeleton":
  65.                     interfaceId = 39600;
  66.                     break;
  67.                 case "Dog":
  68.                     interfaceId = 39601;
  69.                     break;
  70.                 case "Hobgoblin":
  71.                     interfaceId = 39602;
  72.                     break;
  73.                 case "Baby red dragon":
  74.                     interfaceId = 39603;
  75.                     break;
  76.                 }
  77.                 frame.dispose();
  78.             }
  79.            
  80.         });
  81.        
  82.         frame.add(combo);
  83.         frame.add(button);
  84.         frame.setTitle("Guard Maker");
  85.  
  86.         frame.pack();
  87.         frame.setVisible(true);
  88.         while(frame.isVisible()) {
  89.             Time.sleep(500);
  90.         }
  91.         return interfaceId != -1;
  92.     }
  93.    
  94.     @Override
  95.     public int loop() {
  96.         GameObject space = GameObjects.getNearest(15337);
  97.         if(space != null) {
  98.             if(Widgets.getOpenInterface() == 39550) {
  99.                 Packets.sendAction(632, 0, 0, interfaceId, 1);
  100.                 Time.sleep(() -> GameObjects.getNearest(15337) == null, 3000);
  101.                 return 150;
  102.             }else {
  103.                 space.interact("build");
  104.                 Time.sleep(() -> Widgets.getOpenInterface() == 39550, 3000);
  105.                 return 150;
  106.             }
  107.         }else {
  108.             if(Widgets.getBackDialogId() == 2459) {
  109.                 Packets.sendAction(315, -1, 0, 2461, 1);
  110.                 Time.sleep(() -> GameObjects.getNearest(guardIds) == null, 3000);
  111.                 return 150;
  112.             }
  113.             GameObject guard = GameObjects.getNearest(guardIds);
  114.             if(guard != null) {
  115.                 guard.interact("remove");
  116.                 Time.sleep(() -> Widgets.getBackDialogId() == 2459, 3000);
  117.                 return 150;
  118.             }
  119.         }
  120.         return 150;
  121.     }
  122.  
  123.     private final Color color1 = new Color(255, 255, 255, 84);
  124.     private final Color color2 = new Color(0, 0, 0);
  125.  
  126.     private final BasicStroke stroke1 = new BasicStroke(1);
  127.  
  128.     private final Font font1 = new Font("Arial", 0, 23);
  129.     private final Font font2 = new Font("Arial", 0, 16);
  130.    
  131.     @Override
  132.     public void repaint(Graphics g1) {
  133.         int xp = Skills.CONSTRUCTION.getCurrentExp() - startXP;
  134.         int ph = (int) ((xp) * 3600000D / (timer.getElapsed()));
  135.        
  136.         Graphics2D g = (Graphics2D)g1;
  137.         g.setColor(color1);
  138.         g.fillRect(343, 205, 171, 133);//155
  139.         g.setColor(color2);
  140.         g.setStroke(stroke1);
  141.         g.drawRect(343, 205, 171, 133);
  142.         g.setFont(font1);
  143.         g.drawString("Guard maker", 367, 234);
  144.         g.setFont(font2);
  145.         g.drawString("Time: " + timer.toElapsedString(), 352, 269);
  146.         g.drawString("XP: " + format(xp), 352, 299);
  147.         g.drawString("XP(h): " + format(ph), 352, 315);
  148.         g.drawString("Neo", 481, 334);
  149.     }
  150.    
  151.     private String format(int i) {
  152.         if(i > 1000000) {
  153.             return (i / 1000000) + "M";
  154.         }else if(i > 1000) {
  155.             return (i / 1000) + "K";
  156.         }
  157.         return String.valueOf(i);
  158.     }
  159.    
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement