Thondar

Combiner 1.0

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