Advertisement
bmxican

whipzThiever

Aug 22nd, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.28 KB | None | 0 0
  1. package thieverWhipz;
  2.  
  3. import java.awt.BasicStroke;
  4. import java.awt.Color;
  5. import java.awt.EventQueue;
  6. import java.awt.Font;
  7. import java.awt.Graphics;
  8. import java.awt.Graphics2D;
  9. import java.awt.Polygon;
  10. import java.awt.Toolkit;
  11. import java.awt.event.ActionEvent;
  12. import java.awt.event.ActionListener;
  13. import java.util.ArrayList;
  14. import javax.swing.DefaultComboBoxModel;
  15. import javax.swing.GroupLayout;
  16. import javax.swing.JButton;
  17. import javax.swing.JComboBox;
  18. import javax.swing.JFrame;
  19. import javax.swing.JLabel;
  20. import javax.swing.JPanel;
  21. import javax.swing.GroupLayout.Alignment;
  22. import javax.swing.LayoutStyle.ComponentPlacement;
  23. import javax.swing.border.EmptyBorder;
  24.  
  25. import org.parabot.environment.api.interfaces.Paintable;
  26. import org.parabot.environment.api.utils.Time;
  27. import org.parabot.environment.scripts.Category;
  28. import org.parabot.environment.scripts.Script;
  29. import org.parabot.environment.scripts.ScriptManifest;
  30. import org.parabot.environment.scripts.framework.SleepCondition;
  31. import org.parabot.environment.scripts.framework.Strategy;
  32. import org.rev317.min.api.events.MessageEvent;
  33. import org.rev317.min.api.events.listeners.MessageListener;
  34. import org.rev317.min.api.methods.Inventory;
  35. import org.rev317.min.api.methods.Npcs;
  36. import org.rev317.min.api.methods.Players;
  37. import org.rev317.min.api.methods.SceneObjects;
  38. import org.rev317.min.api.methods.Skill;
  39. import org.rev317.min.api.wrappers.Npc;
  40. import org.rev317.min.api.wrappers.SceneObject;
  41. import org.rev317.min.api.wrappers.Tile;
  42.  
  43. @ScriptManifest(author = "Whipz", category = Category.THIEVING, description = "Theives at skilling area", name = "Whipz Theiver", servers = { "PkHonor" }, version = 1.02)
  44. public class whipzThiever extends Script implements Paintable, MessageListener {
  45.  
  46.     public int animation = 832;
  47.    
  48.     //stalls
  49.     public int bakerStall = 2561;
  50.     public int furStall = 2563;
  51.     public int silkStall = 2560;
  52.     public int silverStall = 2565;
  53.     public int spiceStall = 2564;
  54.     public int gemStall = 2562;
  55.     public int stealFrom;
  56.    
  57.     //coins
  58.     public int coins;
  59.    
  60.    
  61.     public SceneObject stallToInteract;
  62.    
  63.     //gui stuff
  64.     thieverGUI gui;
  65.     public String chosenStall;
  66.    
  67.     //Paint
  68.     public int startXP, startLvl, currentLvl, startCoins, currentCoins, coinsMade;
  69.     public long time;
  70.  
  71.     private final ArrayList<Strategy> strategies = new ArrayList<Strategy>();
  72.  
  73.     public boolean onExecute() {
  74.         gui = new thieverGUI();
  75.         gui.setVisible(true);
  76.         strategies.add(new Steal());
  77.         strategies.add(new AntiRandoms());
  78.         provide(strategies);
  79.         time = System.currentTimeMillis();
  80.         startXP = Skill.THIEVING.getExperience();
  81.         startLvl = Skill.THIEVING.getLevel();
  82.         startCoins = Inventory.getCount(true, coins);
  83.         return true;
  84.  
  85.     }
  86.    
  87.    
  88.     public class Steal implements Strategy {
  89.         public boolean activate() {
  90.             for (SceneObject so : SceneObjects.getNearest(stealFrom)) {
  91.                 if (Players.getMyPlayer().getAnimation() == -1) {
  92.                     stallToInteract = so;
  93.                     return true;
  94.                 }
  95.             }
  96.             return false;
  97.         }
  98.        
  99.        
  100.         @Override
  101.         public void execute() {
  102.             if (stallToInteract != null) {
  103.                 if (Players.getMyPlayer().getAnimation() == -1) {
  104.                     stallToInteract.interact(1);
  105.                     Time.sleep(new SleepCondition() {
  106.                         @Override
  107.                         public boolean isValid() {
  108.                             return Players.getMyPlayer().getAnimation() != -1;
  109.                         }
  110.                     } ,3000);
  111.  
  112.                     Time.sleep(500);
  113.                 }
  114.             }
  115.             Time.sleep(100,200);
  116.            
  117.         }
  118.     }
  119.    
  120.  
  121.     public void messageReceived(MessageEvent arg0) {
  122.            
  123.     }
  124.    
  125.    
  126.        
  127.     private final Color color1 = new Color(204, 0, 0);
  128.     private final Color color2 = new Color(255, 0, 0);
  129.  
  130.     private final BasicStroke stroke1 = new BasicStroke(5);
  131.  
  132.     private final Font font1 = new Font("Tahoma", 1, 15);
  133.     private final Font font2 = new Font("Tahoma", 1, 10);
  134.    
  135.  
  136.     public void paint(Graphics arg0) {
  137.         coinsMade = Inventory.getCount(true, coins) - startCoins;
  138.         currentLvl = Skill.THIEVING.getLevel();
  139.          long millis = System.currentTimeMillis() - time;
  140.          final long hours = millis / (1000 * 60 * 60);
  141.          millis -= hours * 1000 * 60 * 60;
  142.          final long minutes = millis / (1000 * 60);
  143.          millis -= minutes * 1000 * 60;
  144.          final long seconds = millis / 1000;
  145.         Graphics2D g = (Graphics2D) arg0;
  146.         g.setColor(color1);
  147.         g.setStroke(stroke1);
  148.         g.drawRoundRect(547, 207, 186, 259, 16, 16);
  149.         g.setFont(font1);
  150.         g.setColor(color2);
  151.         g.drawString("Whipz AIO Thiever", 569, 231);
  152.         g.setFont(font2);
  153.         g.drawString("RunTime: " +hours+":"+minutes+":"+seconds, 556, 251);
  154.         g.drawString("Current Lvl: " +currentLvl , 556, 271);
  155.         g.drawString("Money Gained: "+coinsMade, 556, 291);
  156.        
  157.     }
  158.    
  159.     public class thieverGUI extends JFrame {
  160.  
  161.         private JPanel contentPane;
  162.  
  163.         /**
  164.          * Launch the application.
  165.          */
  166.         public void main(String[] args) {
  167.             EventQueue.invokeLater(new Runnable() {
  168.                 public void run() {
  169.                     try {
  170.                         thieverGUI frame = new thieverGUI();
  171.                         frame.setVisible(true);
  172.                     } catch (Exception e) {
  173.                         e.printStackTrace();
  174.                     }
  175.                 }
  176.             });
  177.         }
  178.  
  179.         /**
  180.          * Create the frame.
  181.          */
  182.         public thieverGUI() {
  183.             setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  184.             setBounds(100, 100, 340, 152);
  185.             contentPane = new JPanel();
  186.             contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  187.             setContentPane(contentPane);
  188.            
  189.             JLabel lblWhipzAioThiever = new JLabel("Whipz AIO Thiever");
  190.             lblWhipzAioThiever.setForeground(Color.RED);
  191.             lblWhipzAioThiever.setFont(new Font("Tahoma", Font.BOLD, 15));
  192.            
  193.             JLabel lblWhatWouldYou = new JLabel("What would you like to steal from?");
  194.             lblWhatWouldYou.setForeground(Color.RED);
  195.             lblWhatWouldYou.setFont(new Font("Tahoma", Font.BOLD, 11));
  196.            
  197.             JComboBox chosen = new JComboBox();
  198.             chosen.setModel(new DefaultComboBoxModel(new String[] {"Bakery Stall", "Fur Stall", "Silk Stall", "Silver Stall", "Gem Stall"}));
  199.             chosen.setForeground(Color.RED);
  200.             chosen.setFont(new Font("Tahoma", Font.BOLD, 11));
  201.            
  202.             JButton startButton = new JButton("Start");
  203.             startButton.addActionListener(new ActionListener() {
  204.                 public void actionPerformed(ActionEvent arg0) {
  205.                     chosenStall = chosen.getSelectedItem().toString();;
  206.                     if(chosenStall.equals("Bakery Stall")) {
  207.                         stealFrom = bakerStall;
  208.                        
  209.                     }
  210.                     if(chosenStall.equals("Fur Stall")) {
  211.                         stealFrom = furStall;
  212.                        
  213.                     }
  214.                     if(chosenStall.equals("Silk Stall")) {
  215.                         stealFrom = silkStall;
  216.                        
  217.                     }
  218.                     if(chosenStall.equals("Silver Stall")) {
  219.                         stealFrom = silverStall;
  220.                        
  221.                     }
  222.                     if(chosenStall.equals("Gem Stall")) {
  223.                         stealFrom = gemStall;
  224.                        
  225.                     }
  226.                     if(chosenStall.equals("Spice Stall")) {
  227.                         stealFrom = spiceStall;
  228.                        
  229.                     }
  230.                     dispose();
  231.                 }
  232.             });
  233.             GroupLayout gl_contentPane = new GroupLayout(contentPane);
  234.             gl_contentPane.setHorizontalGroup(
  235.                 gl_contentPane.createParallelGroup(Alignment.LEADING)
  236.                     .addGroup(gl_contentPane.createSequentialGroup()
  237.                         .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
  238.                             .addGroup(gl_contentPane.createSequentialGroup()
  239.                                 .addContainerGap()
  240.                                 .addComponent(lblWhatWouldYou)
  241.                                 .addGap(18)
  242.                                 .addComponent(chosen, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  243.                             .addGroup(gl_contentPane.createSequentialGroup()
  244.                                 .addGap(88)
  245.                                 .addComponent(lblWhipzAioThiever))
  246.                             .addGroup(gl_contentPane.createSequentialGroup()
  247.                                 .addGap(131)
  248.                                 .addComponent(startButton)))
  249.                         .addContainerGap(7, Short.MAX_VALUE))
  250.             );
  251.             gl_contentPane.setVerticalGroup(
  252.                 gl_contentPane.createParallelGroup(Alignment.LEADING)
  253.                     .addGroup(gl_contentPane.createSequentialGroup()
  254.                         .addGap(6)
  255.                         .addComponent(lblWhipzAioThiever)
  256.                         .addPreferredGap(ComponentPlacement.UNRELATED)
  257.                         .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
  258.                             .addComponent(lblWhatWouldYou)
  259.                             .addComponent(chosen, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  260.                         .addPreferredGap(ComponentPlacement.UNRELATED)
  261.                         .addComponent(startButton)
  262.                         .addContainerGap(42, Short.MAX_VALUE))
  263.             );
  264.             contentPane.setLayout(gl_contentPane);
  265.         }
  266.     }
  267.  
  268.    
  269.    
  270.     //Credits to Minimal
  271.    
  272.         public class AntiRandoms implements Strategy
  273.         {
  274.             private Npc antiRandom;
  275.          
  276.             private Area bobsIsland = new Area(new Tile(2511, 4765),
  277.                     new Tile(2511, 4790),
  278.                     new Tile(2542, 4790),
  279.                     new Tile(2542, 4765));
  280.          
  281.             private final int[] RANDOMS = { 410, 1091, 3117, 3022, 3351, 409 };
  282.          
  283.             private final int BOB = 1091;
  284.             private final int SANDWICH_LADY = 3117;
  285.             private final int OLD_MAN = 410;
  286.             private final int PORTAL = 8987;
  287.          
  288.             public int randomCount;
  289.          
  290.             public final Runnable RUNNABLE = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.exclamation");
  291.          
  292.             public boolean activate()
  293.             {
  294.                 for (Npc n : Npcs.getNearest(RANDOMS))
  295.                 {
  296.                     if (n.getInteractingCharacter().equals(Players.getMyPlayer()) && n.distanceTo() < 3)
  297.                     {
  298.                         antiRandom = n;
  299.                         return true;
  300.                     }
  301.                 }
  302.          
  303.                 return false;
  304.             }
  305.          
  306.             public void execute()
  307.             {
  308.                 Time.sleep(1000);
  309.          
  310.                 if (RUNNABLE != null)
  311.                     RUNNABLE.run();
  312.          
  313.                 System.out.println("There is a random nearby!");
  314.          
  315.                 if (antiRandom != null)
  316.                 {
  317.                     if (antiRandom.getDef().getId() == BOB && bobsIsland.contains(Players.getMyPlayer().getLocation()))
  318.                     {
  319.                         for (SceneObject portal : SceneObjects.getNearest(PORTAL))
  320.                         {
  321.                             if (portal != null && bobsIsland.contains(Players.getMyPlayer().getLocation()))
  322.                             {
  323.                                 final SceneObject portalToInteract = portal;
  324.          
  325.                                 portal.interact(0);
  326.          
  327.                                 Time.sleep(new SleepCondition()
  328.                                 {
  329.                                     @Override
  330.                                     public boolean isValid()
  331.                                     {
  332.                                         return portalToInteract.getLocation().distanceTo() == 1;
  333.                                     }
  334.                                 }, 7500);
  335.          
  336.                                 Time.sleep(1000);
  337.                             }
  338.                             else
  339.                             {
  340.                                 break;
  341.                             }
  342.                         }
  343.          
  344.                         if (!bobsIsland.contains(Players.getMyPlayer().getLocation()))
  345.                         {
  346.                             System.out.println("The Bob random has been completed");
  347.                         }
  348.                     }
  349.                     else if (antiRandom.getDef().getId() == SANDWICH_LADY || antiRandom.getDef().getId() == OLD_MAN)
  350.                     {
  351.                         String str;
  352.          
  353.                         if (antiRandom.getDef().getId() == SANDWICH_LADY)
  354.                             str = "Sandwich Lady";
  355.                         else
  356.                             str = "Old man";
  357.          
  358.                         antiRandom.interact(0);
  359.          
  360.                         Time.sleep(1500);
  361.          
  362.                         System.out.println("The " + str + " random has been completed.");
  363.                     }
  364.                     else
  365.                     {
  366.                         System.out.println("A suspicious genie random has been called on us.");
  367.                         System.out.println("The client was closed to protect your account.");
  368.          
  369.                         System.exit(0);
  370.                     }
  371.                 }
  372.          
  373.                 randomCount++;
  374.             }
  375.          
  376.             public class Area {
  377.                 private Polygon p;
  378.          
  379.                 /**
  380.                  * Initializes a PolygonArea with the tiles given
  381.                  *
  382.                  * @param tiles
  383.                  *            tiles to use in the area
  384.                  */
  385.                 public Area(Tile... tiles) {
  386.                     this.p = new Polygon();
  387.                     for (int i = 0; i < tiles.length; i++) {
  388.                         p.addPoint(tiles[i].getX(), tiles[i].getY());
  389.                     }
  390.                 }
  391.          
  392.                 /**
  393.                  * Checks if a tile is in the area
  394.                  *
  395.                  * @param tile
  396.                  *            The tile to check
  397.                  * @return <b>true</b> if area does contain the tile, otherwise <b>false</b>
  398.                  */
  399.                 public boolean contains(Tile tile) {
  400.                     return this.contains(tile.getX(), tile.getY());
  401.                 }
  402.          
  403.                 public boolean contains(int x, int y) {
  404.                     int i;
  405.                     int j;
  406.                     boolean result = false;
  407.                     for (i = 0, j = p.npoints - 1; i < p.npoints; j = i++) {
  408.                         if ((p.ypoints[i] > y - 1) != (p.ypoints[j] > y - 1)
  409.                                 && (x <= (p.xpoints[j] - p.xpoints[i]) * (y - p.ypoints[i])
  410.                                 / (p.ypoints[j] - p.ypoints[i]) + p.xpoints[i])) {
  411.                             result = !result;
  412.                         }
  413.                     }
  414.                     return result;
  415.                 }
  416.             }
  417.         }
  418.  
  419.  
  420. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement