Thondar

Combiner

Jul 30th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.43 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4.  
  5. import javax.swing.*;
  6.  
  7. import org.powerbot.concurrent.Task;
  8. import org.powerbot.concurrent.strategy.Condition;
  9. import org.powerbot.concurrent.strategy.Strategy;
  10. import org.powerbot.game.api.ActiveScript;
  11. import org.powerbot.game.api.Manifest;
  12. import org.powerbot.game.api.methods.Tabs;
  13. import org.powerbot.game.api.methods.Widgets;
  14. import org.powerbot.game.api.methods.input.Mouse;
  15. import org.powerbot.game.api.methods.interactive.NPCs;
  16. import org.powerbot.game.api.methods.interactive.Players;
  17. import org.powerbot.game.api.methods.tab.Inventory;
  18. import org.powerbot.game.api.methods.widget.Camera;
  19. import org.powerbot.game.api.util.Random;
  20. import org.powerbot.game.api.util.Time;
  21. import org.powerbot.game.api.wrappers.widget.WidgetChild;
  22. import org.powerbot.game.bot.event.listener.PaintListener;
  23.  
  24.  
  25. @Manifest(name = "Combiner", description = "Combines to items of your choice", version = 1.0, authors = {"Thondar"})
  26. public class Combiner extends ActiveScript implements PaintListener {
  27.  
  28.  
  29. int Banker[] = {3418, 553, 496, 497, 9710, 42192, 2718, 3416, 3293, 4456, 4457, 4458, 4459, 6200, 2759};
  30. long startTime;
  31. long runTime, xpTime;
  32. long hr, min, sec, xphr, xpmin, xpsec;
  33. long xpGain;
  34.  
  35. String time;
  36. String status;
  37. int ID_1;
  38. int ID_2;
  39.  
  40. private static WidgetChild Check;
  41.  
  42. boolean start = true;
  43.  
  44. GUI g;
  45. private boolean guiWait = true;
  46.  
  47.  
  48. @Override
  49. protected void setup() {
  50. startTime = System.currentTimeMillis();
  51.  
  52. g = new GUI();
  53. g.setVisible(true);
  54.  
  55. final WaitGui guiTask = new WaitGui();
  56. provide(new Strategy(guiTask, guiTask));
  57. provide(new Strategy(new WaitGui(), new WaitGui()));
  58.  
  59. BankOpen bankopen = new BankOpen();
  60. Strategy bankopenStrategy = new Strategy(bankopen, bankopen);
  61. provide(bankopenStrategy);
  62.  
  63. Bank bank = new Bank();
  64. Strategy bankStrategy = new Strategy(bank, bank);
  65. provide(bankStrategy);
  66.  
  67. Combine Combine = new Combine();
  68. Strategy CombineStrategy = new Strategy(Combine, Combine);
  69. provide(CombineStrategy);
  70.  
  71. AntiBan ab = new AntiBan();
  72. Strategy abStrategy = new Strategy(ab, ab);
  73. provide(abStrategy);
  74.  
  75. Tabs.INVENTORY.open(false);
  76.  
  77.  
  78. }
  79.  
  80.  
  81. private class WaitGui implements Task, Condition {
  82.  
  83. @Override
  84. public void run() {
  85. while (guiWait) {
  86. Time.sleep(500);
  87. }
  88. }
  89.  
  90. public boolean validate() {
  91. return guiWait;
  92. }
  93.  
  94. }
  95.  
  96. private class BankOpen implements Task, Condition {
  97.  
  98. @Override
  99. public void run() {
  100. status = ("Banking");
  101. NPCs.getNearest(Banker).interact("Bank");
  102. Time.sleep(Random.nextInt(700, 1100));
  103. }
  104.  
  105. @Override
  106. public boolean validate() {
  107. return (Inventory.getCount(ID_1) == 0) && NPCs.getNearest(Banker).isOnScreen() && !org.powerbot.game.api.methods.widget.Bank.isOpen();
  108. }
  109.  
  110. }
  111.  
  112.  
  113. private class Bank implements Task, Condition {
  114.  
  115. @Override
  116. public void run() {
  117. status = ("Banking");
  118. org.powerbot.game.api.methods.widget.Bank.depositInventory();
  119. Time.sleep(Random.nextInt(300, 500));
  120. org.powerbot.game.api.methods.widget.Bank.withdraw(ID_1, 14);
  121. Time.sleep(Random.nextInt(300, 500));
  122. org.powerbot.game.api.methods.widget.Bank.withdraw(ID_2, 14);
  123. Time.sleep(Random.nextInt(300, 500));
  124. org.powerbot.game.api.methods.widget.Bank.close();
  125. }
  126.  
  127. @Override
  128. public boolean validate() {
  129. return Inventory.getCount(ID_1) < 1 && org.powerbot.game.api.methods.widget.Bank.isOpen();
  130. }
  131.  
  132. }
  133.  
  134. private class Combine implements Task, Condition {
  135.  
  136. @Override
  137. public void run() {
  138. Check = Widgets.get(905, 14);
  139. status = ("Combining");
  140. if(org.powerbot.game.api.methods.widget.Bank.isOpen()){
  141. org.powerbot.game.api.methods.widget.Bank.close();
  142. }if(!Check.isOnScreen()){
  143. Inventory.getItem(ID_1).getWidgetChild().interact("Use");
  144. Time.sleep(Random.nextInt(300, 500));
  145. Inventory.getItem(ID_2).getWidgetChild().interact("Use", "->");
  146. Time.sleep(Random.nextInt(300, 500));
  147. }if(Check.isOnScreen()){
  148. Check.click(true);
  149. Time.sleep(Random.nextInt(300, 500));
  150. }
  151. }
  152. @Override
  153. public boolean validate() {
  154. return (Inventory.getCount(ID_1) > 13) && (Players.getLocal().getAnimation() == -1);
  155. }
  156.  
  157. }
  158.  
  159.  
  160. private class AntiBan implements Task, Condition {
  161.  
  162. @Override
  163. public void run() {
  164. switch(Random.nextInt(1, 100)){
  165. case 3:
  166. Camera.setAngle(Random.nextInt(1, 150));
  167. case 33:
  168. Camera.setAngle(Random.nextInt(1, 310));
  169. case 75:
  170. Camera.setAngle(Random.nextInt(1, 210));
  171. default:
  172. }
  173. Time.sleep(Random.nextInt(500, 1000));
  174. }
  175.  
  176. @Override
  177. public boolean validate() {
  178. return start;
  179. }
  180.  
  181. }
  182.  
  183.  
  184.  
  185.  
  186. private AlphaComposite makeComposite(float alpha) {
  187. int type = AlphaComposite.SRC_OVER;
  188.  
  189. return(AlphaComposite.getInstance(type, alpha));
  190. }
  191.  
  192.  
  193. private final Font font1 = new Font("Verdana", 0, 16);
  194. private final Font font2 = new Font("Verdana", 0, 12);
  195. private final Font font3 = new Font("Verdana", 0, 13);
  196. private final Font font4 = new Font("Verdana", 0, 9);
  197.  
  198.  
  199. @Override
  200. public void onRepaint(Graphics g) {
  201. Graphics2D g2d = (Graphics2D) g;
  202.  
  203. g2d.setColor(Color.BLUE);
  204. g2d.drawLine((Mouse.getX() -3), Mouse.getY(), (Mouse.getX() +3), Mouse.getY());
  205. g2d.drawLine(Mouse.getX(), (Mouse.getY() - 3), Mouse.getX(), (Mouse.getY() + 3));
  206. g2d.drawLine((Mouse.getX() - 1), (Mouse.getY() - 1), (Mouse.getX() + 1), (Mouse.getY() + 1));
  207. g2d.drawLine((Mouse.getX() + 1), (Mouse.getY() - 1), (Mouse.getX() - 1), (Mouse.getY() + 1));
  208.  
  209.  
  210. Rectangle bg = new Rectangle(0, 0, 800, 50);
  211. g2d.setComposite(makeComposite(1f));
  212. g2d.setColor(Color.BLACK);
  213. g2d.fill(bg);
  214.  
  215. g2d.setFont(font1);
  216. g2d.setComposite(makeComposite(1f));
  217. g2d.setColor(Color.BLUE);
  218. g2d.drawString("Combiner", 15, 20);
  219. g2d.setFont(font3);
  220. g2d.drawString("by Thondar", 27, 35);
  221. g2d.setFont(font4);
  222. g2d.drawString("Version 1.0", 33, 45);
  223.  
  224. g2d.setFont(font2);
  225. g2d.setComposite(makeComposite(.8f));
  226. g2d.setColor(Color.WHITE);
  227. g2d.drawString("Time Run: " + timeRun(), 150, 20);
  228.  
  229. g2d.setComposite(makeComposite(.8f));
  230. g2d.setColor(Color.WHITE);
  231. g2d.drawString("Status: " + status, 150, 40);
  232.  
  233. g2d.setComposite(makeComposite(.8f));
  234. g2d.setColor(Color.WHITE);
  235. g2d.drawString("ID 1: " + ID_1, 350, 20);
  236.  
  237. g2d.setComposite(makeComposite(.8f));
  238. g2d.setColor(Color.WHITE);
  239. g2d.drawString("ID 2: " + ID_2, 350, 40);
  240.  
  241. }
  242.  
  243. public String timeRun() {
  244. runTime = System.currentTimeMillis() - startTime;
  245. time = "";
  246. hr = runTime / (1000 * 60 * 60);
  247. min = (runTime % (1000 * 60 * 60)) / (1000 * 60);
  248. sec = ((runTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
  249.  
  250. if (hr < 10)
  251. time += "0" + hr + ":";
  252. else
  253. time += hr + ":";
  254.  
  255. if (min < 10)
  256. time += "0" + min + ":";
  257. else
  258. time += min + ":";
  259. if (sec < 10)
  260. time += "0" + sec;
  261. else
  262. time += sec;
  263. return time;
  264. }
  265.  
  266. class GUI extends JFrame {
  267. public GUI() {
  268. initComponents();
  269. }
  270.  
  271. private void StartButtonActionPerformed(ActionEvent e) {
  272. ID_1 = Integer.parseInt(ID1.getText());
  273. ID_2 = Integer.parseInt(ID2.getText());
  274.  
  275. guiWait = false;
  276. g.dispose();
  277. }
  278.  
  279. private void initComponents() {
  280. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  281. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  282. label1 = new JLabel();
  283. label2 = new JLabel();
  284. StartButton = new JButton();
  285. label3 = new JLabel();
  286. ID1 = new JFormattedTextField();
  287. ID2 = new JFormattedTextField();
  288.  
  289. //======== this ========
  290. Container contentPane = getContentPane();
  291. contentPane.setLayout(null);
  292.  
  293. //---- label1 ----
  294. label1.setText("ID 1");
  295. label1.setHorizontalAlignment(SwingConstants.CENTER);
  296. label1.setFont(new Font("Verdana", Font.PLAIN, 12));
  297. contentPane.add(label1);
  298. label1.setBounds(0, 115, 295, 15);
  299.  
  300. //---- label2 ----
  301. label2.setText("ID 2");
  302. label2.setHorizontalAlignment(SwingConstants.CENTER);
  303. label2.setFont(new Font("Verdana", Font.PLAIN, 12));
  304. contentPane.add(label2);
  305. label2.setBounds(0, 220, 295, label2.getPreferredSize().height);
  306.  
  307. //---- StartButton ----
  308. StartButton.setText("Start");
  309. StartButton.setFont(new Font("Verdana", Font.PLAIN, 12));
  310. StartButton.addActionListener(new ActionListener() {
  311. @Override
  312. public void actionPerformed(ActionEvent e) {
  313. StartButtonActionPerformed(e);
  314. }
  315. });
  316. contentPane.add(StartButton);
  317. StartButton.setBounds(5, 330, 285, 50);
  318.  
  319. //---- label3 ----
  320. label3.setText("Combiner");
  321. label3.setHorizontalAlignment(SwingConstants.CENTER);
  322. label3.setFont(new Font("Segoe Print", Font.BOLD, 30));
  323. contentPane.add(label3);
  324. label3.setBounds(0, 0, 295, 70);
  325.  
  326. //---- ID1 ----
  327. ID1.setFont(new Font("Verdana", Font.PLAIN, 12));
  328. ID1.setHorizontalAlignment(SwingConstants.CENTER);
  329. contentPane.add(ID1);
  330. ID1.setBounds(125, 135, 45, ID1.getPreferredSize().height);
  331.  
  332. //---- ID2 ----
  333. ID2.setFont(new Font("Verdana", Font.PLAIN, 12));
  334. ID2.setHorizontalAlignment(SwingConstants.CENTER);
  335. contentPane.add(ID2);
  336. ID2.setBounds(125, 240, 45, ID2.getPreferredSize().height);
  337.  
  338. { // compute preferred size
  339. Dimension preferredSize = new Dimension();
  340. for(int i = 0; i < contentPane.getComponentCount(); i++) {
  341. Rectangle bounds = contentPane.getComponent(i).getBounds();
  342. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  343. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  344. }
  345. Insets insets = contentPane.getInsets();
  346. preferredSize.width += insets.right;
  347. preferredSize.height += insets.bottom;
  348. contentPane.setMinimumSize(preferredSize);
  349. contentPane.setPreferredSize(preferredSize);
  350. }
  351. pack();
  352. setLocationRelativeTo(getOwner());
  353. // JFormDesigner - End of component initialization //GEN-END:initComponents
  354. }
  355.  
  356. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  357. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  358. private JLabel label1;
  359. private JLabel label2;
  360. private JButton StartButton;
  361. private JLabel label3;
  362. private JFormattedTextField ID1;
  363. private JFormattedTextField ID2;
  364. // JFormDesigner - End of variables declaration //GEN-END:variables
  365. }
  366.  
  367.  
  368.  
  369. }
Advertisement
Add Comment
Please, Sign In to add comment