Thondar

GEBuyer v1.0

Jul 11th, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.94 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import javax.swing.*;
  5.  
  6. import org.powerbot.concurrent.Task;
  7. import org.powerbot.concurrent.strategy.Condition;
  8. import org.powerbot.concurrent.strategy.Strategy;
  9. import org.powerbot.game.api.ActiveScript;
  10. import org.powerbot.game.api.Manifest;
  11. import org.powerbot.game.api.methods.Tabs;
  12. import org.powerbot.game.api.methods.Walking;
  13. import org.powerbot.game.api.methods.Widgets;
  14. import org.powerbot.game.api.methods.input.Keyboard;
  15. import org.powerbot.game.api.methods.input.Mouse;
  16. import org.powerbot.game.api.methods.interactive.NPCs;
  17. import org.powerbot.game.api.methods.interactive.Players;
  18. import org.powerbot.game.api.methods.node.Menu;
  19. import org.powerbot.game.api.methods.widget.Camera;
  20. import org.powerbot.game.api.util.Random;
  21. import org.powerbot.game.api.util.Time;
  22. import org.powerbot.game.api.wrappers.Area;
  23. import org.powerbot.game.api.wrappers.Tile;
  24. import org.powerbot.game.api.wrappers.widget.WidgetChild;
  25. import org.powerbot.game.bot.event.listener.PaintListener;
  26.  
  27. @Manifest(name = "GE Buyer", description = "Buys stuff for you at GE", version = 1.0, authors = {"Thondar"})
  28. public class GEBuyer extends ActiveScript implements PaintListener{
  29.  
  30. long startTime;
  31. long runTime;
  32. long hr, min, sec;
  33. int SleepTimer;
  34. int ClerkID = 1419;
  35. int BuyProcent;
  36. int AmountBought;
  37. int StopAmount;
  38.  
  39. String time;
  40. String status;
  41. String ItemName;
  42. String ItemAmount;
  43. String BuyPro;
  44.  
  45. private static WidgetChild CheckWidget;
  46.  
  47. Tile GETile = new Tile(3178, 3505, 0);
  48.  
  49. Area GEArea = new Area(new Tile(3176, 3500, 0), new Tile(3185, 3510, 0));
  50.  
  51. geGUI g;
  52. private boolean guiWait = true;
  53.  
  54.  
  55. boolean start = false;
  56.  
  57. @Override
  58. protected void setup() {
  59. start = true;
  60. startTime = System.currentTimeMillis();
  61.  
  62. g = new geGUI();
  63. g.setVisible(true);
  64. final WaitGui guiTask = new WaitGui();
  65. provide(new Strategy(guiTask, guiTask));
  66. provide(new Strategy(new WaitGui(), new WaitGui()));
  67.  
  68. AntiBan ab = new AntiBan();
  69. Strategy abStrategy = new Strategy(ab, ab);
  70. provide(abStrategy);
  71.  
  72. Buy buy = new Buy();
  73. Strategy buyStrategy = new Strategy(buy, buy);
  74. provide(buyStrategy);
  75.  
  76. Accept accept = new Accept();
  77. Strategy acceptStrategy = new Strategy(accept, accept);
  78. provide(acceptStrategy);
  79.  
  80. Check check = new Check();
  81. Strategy checkStrategy = new Strategy(check, check);
  82. provide(checkStrategy);
  83.  
  84. Check1 check1 = new Check1();
  85. Strategy check1Strategy = new Strategy(check1, check1);
  86. provide(check1Strategy);
  87.  
  88. Run run = new Run();
  89. Strategy runStrategy = new Strategy(run, run);
  90. provide(runStrategy);
  91.  
  92. Tabs.INVENTORY.open(false);
  93.  
  94. CheckWidget = Widgets.get(105, 1);
  95.  
  96. }
  97.  
  98. private class WaitGui implements Task, Condition {
  99.  
  100. @Override
  101. public void run() {
  102. while (guiWait) {
  103. Time.sleep(500);
  104.  
  105. }
  106. }
  107.  
  108. public boolean validate() {
  109. return guiWait;
  110. }
  111.  
  112. }
  113.  
  114. private class AntiBan implements Task, Condition {
  115.  
  116. @Override
  117. public void run() {
  118. switch(Random.nextInt(1, 1000)){
  119. case 3:
  120. Camera.setAngle(Random.nextInt(1, 150));
  121. case 33:
  122. Camera.setAngle(Random.nextInt(1, 310));
  123. case 75:
  124. Camera.setAngle(Random.nextInt(1, 210));
  125. default:
  126. }
  127. Time.sleep(Random.nextInt(100, 200));
  128. }
  129.  
  130. @Override
  131. public boolean validate() {
  132. return start;
  133. }
  134.  
  135. }
  136.  
  137. private class Buy implements Task, Condition {
  138.  
  139. @Override
  140. public void run() {
  141. Mouse.move(Random.nextInt(204, 246), Random.nextInt(189, 210));
  142. Time.sleep(Random.nextInt(500, 800));
  143. Mouse.click(true);
  144. Time.sleep(Random.nextInt(2000, 3000));
  145. Buy();
  146. Time.sleep(Random.nextInt(500, 700));
  147. }
  148.  
  149. @Override
  150. public boolean validate() {
  151. return Menu.contains("Make Buy Offer") && GEArea.contains(Players.getLocal());
  152. }
  153.  
  154. }
  155.  
  156. private class Accept implements Task, Condition {
  157.  
  158. @Override
  159. public void run() {
  160. Mouse.move(Random.nextInt(204, 246), Random.nextInt(189, 210));
  161. Time.sleep(Random.nextInt(500, 800));
  162. Mouse.click(true);
  163. Time.sleep(Random.nextInt(5000, 7000));
  164. Accept();
  165. Time.sleep(Random.nextInt(500, 700));
  166.  
  167. }
  168.  
  169. @Override
  170. public boolean validate() {
  171. return Menu.contains("View Offer") && !Menu.contains("Abort Offer") && GEArea.contains(Players.getLocal());
  172. }
  173.  
  174. }
  175.  
  176.  
  177. private class Check implements Task, Condition {
  178.  
  179. @Override
  180. public void run() {
  181. Mouse.move(Random.nextInt(204, 246), Random.nextInt(189, 210));
  182. Time.sleep(Random.nextInt(600, 900));
  183. if (Menu.contains("Abort Offer")) {
  184. Time.sleep(SleepTimer);
  185. }
  186. Time.sleep(Random.nextInt(600, 900));
  187.  
  188. }
  189.  
  190. @Override
  191. public boolean validate() {
  192. return NPCs.getNearest(ClerkID).isOnScreen() && GEArea.contains(Players.getLocal()) && CheckWidget.isOnScreen();
  193. }
  194.  
  195. }
  196.  
  197. private class Check1 implements Task, Condition {
  198.  
  199. @Override
  200. public void run() {
  201. NPCs.getNearest(ClerkID).interact("Exchange");
  202. Time.sleep(Random.nextInt(1500, 1900));
  203. }
  204.  
  205. @Override
  206. public boolean validate() {
  207. return NPCs.getNearest(ClerkID).isOnScreen() && GEArea.contains(Players.getLocal()) && !CheckWidget.isOnScreen();
  208. }
  209.  
  210. }
  211.  
  212.  
  213. private class Run implements Task, Condition {
  214.  
  215. @Override
  216. public void run() {
  217. Walking.setRun(true);
  218. Walking.walk(GETile);
  219.  
  220. }
  221.  
  222. @Override
  223. public boolean validate() {
  224. return NPCs.getNearest(ClerkID) != null && !GEArea.contains(Players.getLocal());
  225. }
  226.  
  227. }
  228.  
  229. public void Buy() {
  230. Keyboard.sendText(ItemName, false);
  231. Time.sleep(Random.nextInt(1500, 2000));
  232. Mouse.move(Random.nextInt(70, 196), Random.nextInt(398, 402));
  233. Time.sleep(Random.nextInt(2000, 3000));
  234. Mouse.click(true);
  235. Time.sleep(Random.nextInt(2000, 3000));
  236. Mouse.move(Random.nextInt(227, 249), Random.nextInt(263, 278));
  237. Time.sleep(Random.nextInt(1100, 1700));
  238. Mouse.click(true);
  239. Time.sleep(Random.nextInt(1300, 1700));
  240. Keyboard.sendText(ItemAmount, true);
  241. Time.sleep(Random.nextInt(900, 1300));
  242. if(BuyProcent == 1){
  243. Mouse.move(Random.nextInt(279, 301), Random.nextInt(263, 278));
  244. Time.sleep(Random.nextInt(800, 1100));
  245. Mouse.click(true);
  246. Time.sleep(Random.nextInt(300, 500));
  247. Mouse.click(true);
  248. Time.sleep(Random.nextInt(800, 1100));
  249. Mouse.move(Random.nextInt(211, 316), Random.nextInt(336, 358));
  250. Time.sleep(Random.nextInt(900, 1300));
  251. Mouse.click(true);
  252. }else if(BuyProcent == 2){
  253. Mouse.move(Random.nextInt(279, 301), Random.nextInt(263, 278));
  254. Time.sleep(Random.nextInt(800, 1100));
  255. Mouse.click(true);
  256. Time.sleep(Random.nextInt(300, 500));
  257. Mouse.move(Random.nextInt(211, 316), Random.nextInt(311, 358));
  258. Time.sleep(Random.nextInt(900, 1300));
  259. Mouse.click(true);
  260. }else if(BuyProcent == 3){
  261. Mouse.move(Random.nextInt(236, 301), Random.nextInt(334, 355));
  262. Mouse.move(Random.nextInt(211, 316), Random.nextInt(336, 358));
  263. Time.sleep(Random.nextInt(900, 1300));
  264. Mouse.click(true);
  265. }else if(BuyProcent == 4){
  266. Mouse.move(Random.nextInt(430, 455), Random.nextInt(263, 278));
  267. Time.sleep(Random.nextInt(800, 1100));
  268. Mouse.click(true);
  269. Time.sleep(Random.nextInt(300, 500));
  270. Mouse.move(Random.nextInt(211, 316), Random.nextInt(336, 358));
  271. Time.sleep(Random.nextInt(900, 1300));
  272. Mouse.click(true);
  273. }else{
  274. Mouse.move(Random.nextInt(430, 455), Random.nextInt(263, 278));
  275. Time.sleep(Random.nextInt(800, 1100));
  276. Mouse.click(true);
  277. Time.sleep(Random.nextInt(800, 1100));
  278. Mouse.click(true);
  279. Time.sleep(Random.nextInt(300, 500));
  280. Mouse.move(Random.nextInt(211, 316), Random.nextInt(336, 358));
  281. Time.sleep(Random.nextInt(900, 1300));
  282. Mouse.click(true);
  283. }
  284. }
  285.  
  286. public void Accept() {
  287. Mouse.move(Random.nextInt(405, 430), Random.nextInt(335, 359));
  288. Time.sleep(Random.nextInt(1500, 2100));
  289. Mouse.click(true);
  290. Time.sleep(Random.nextInt(200, 300));
  291. Mouse.move(Random.nextInt(455, 477), Random.nextInt(335, 359));
  292. Time.sleep(Random.nextInt(1500, 2100));
  293. Mouse.click(true);
  294. Time.sleep(Random.nextInt(400, 600));
  295. Mouse.move(Random.nextInt(480, 490), Random.nextInt(87, 94));
  296. Time.sleep(Random.nextInt(500, 700));
  297. Mouse.click(true);
  298. Time.sleep(Random.nextInt(1000, 2000));
  299. }
  300.  
  301.  
  302.  
  303.  
  304. private AlphaComposite makeComposite(float alpha) {
  305. int type = AlphaComposite.SRC_OVER;
  306.  
  307. return(AlphaComposite.getInstance(type, alpha));
  308. }
  309.  
  310.  
  311. private final Font font1 = new Font("Segoe Print", 1, 20);
  312. private final Font font2 = new Font("Verdana", 0, 12);
  313. private final Font font3 = new Font("Segoe Print", 0, 12);
  314.  
  315.  
  316. @Override
  317. public void onRepaint(Graphics g) {
  318. Graphics2D g2d = (Graphics2D) g;
  319.  
  320.  
  321. Rectangle bg = new Rectangle(10, 60, 200, 110);
  322. g2d.setComposite(makeComposite(.4f));
  323. g2d.setColor(Color.BLACK);
  324. g2d.fill(bg);
  325.  
  326. g2d.setFont(font1);
  327. g2d.setComposite(makeComposite(1f));
  328. g2d.setColor(Color.RED);
  329. g2d.drawString("GE Buyer", 53, 80);
  330. g2d.setFont(font3);
  331. g2d.drawString("by Thondar", 65, 95);
  332.  
  333. g2d.setFont(font2);
  334. g2d.setComposite(makeComposite(.8f));
  335. g2d.setColor(Color.WHITE);
  336. g2d.drawString("Time Run: " + timeRun(), 40, 130);
  337.  
  338. g2d.drawString("Version 1.0", 65, 150);
  339.  
  340.  
  341.  
  342.  
  343.  
  344. }
  345. public String timeRun() {
  346. runTime = System.currentTimeMillis() - startTime;
  347. time = "";
  348. hr = runTime / (1000 * 60 * 60);
  349. min = (runTime % (1000 * 60 * 60)) / (1000 * 60);
  350. sec = ((runTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
  351.  
  352. if (hr < 10)
  353. time += "0" + hr + ":";
  354. else
  355. time += hr + ":";
  356.  
  357. if (min < 10)
  358. time += "0" + min + ":";
  359. else
  360. time += min + ":";
  361. if (sec < 10)
  362. time += "0" + sec;
  363. else
  364. time += sec;
  365. return time;
  366. }
  367.  
  368.  
  369.  
  370.  
  371. class geGUI extends JFrame {
  372. public geGUI() {
  373. initComponents();
  374. }
  375.  
  376. private void StartButtonActionPerformed(ActionEvent e) {
  377. String a = TimeCB.getSelectedItem().toString(); {
  378. if (a.equals("Every 5 sec")) {
  379. SleepTimer = 5000;
  380. } else if (a.equals("Every 30 sec")) {
  381. SleepTimer = 30000;
  382. } else if (a.equals("Every 1 min")) {
  383. SleepTimer = 60000;
  384. } else if (a.equals("Every 5 min")) {
  385. SleepTimer = 300000;
  386. } else if (a.equals("Every 10 min")) {
  387. SleepTimer = 600000;
  388. }
  389. }
  390. String b = AmountTF.getText(); {
  391. ItemAmount = b;
  392. }
  393. String c = NameTF.getText(); {
  394. ItemName = c;
  395. }
  396.  
  397. String d = PerCB.getSelectedItem().toString(); {
  398. if (d.equals("-10%")) {
  399. BuyProcent = 1;
  400. } else if (d.equals("-5%")) {
  401. BuyProcent = 2;
  402. } else if (d.equals("0%")) {
  403. BuyProcent = 3;
  404. } else if (d.equals("+5%")) {
  405. BuyProcent = 4;
  406. } else if (d.equals("+10%")) {
  407. BuyProcent = 5;
  408. }
  409. }
  410.  
  411. guiWait = false;
  412. g.dispose();
  413. }
  414.  
  415. private void initComponents() {
  416. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  417. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  418. label1 = new JLabel();
  419. label2 = new JLabel();
  420. StartButton = new JButton();
  421. TimeCB = new JComboBox();
  422. label3 = new JLabel();
  423. label4 = new JLabel();
  424. label5 = new JLabel();
  425. AmountTF = new JTextField();
  426. label6 = new JLabel();
  427. NameTF = new JTextField();
  428. PerCB = new JComboBox();
  429. label7 = new JLabel();
  430.  
  431. //======== this ========
  432. Container contentPane = getContentPane();
  433. contentPane.setLayout(null);
  434.  
  435. //---- label1 ----
  436. label1.setText("Grand Exchange Buyer");
  437. label1.setHorizontalAlignment(SwingConstants.CENTER);
  438. label1.setFont(new Font("Segoe Print", Font.BOLD, 26));
  439. contentPane.add(label1);
  440. label1.setBounds(5, 5, 375, 55);
  441.  
  442. //---- label2 ----
  443. label2.setText("By Thondar");
  444. label2.setHorizontalAlignment(SwingConstants.CENTER);
  445. label2.setFont(new Font("Segoe Print", Font.PLAIN, 14));
  446. contentPane.add(label2);
  447. label2.setBounds(0, 50, 385, 25);
  448.  
  449. //---- StartButton ----
  450. StartButton.setText("Start");
  451. StartButton.setFont(new Font("Verdana", Font.PLAIN, 16));
  452. StartButton.addActionListener(new ActionListener() {
  453. @Override
  454. public void actionPerformed(ActionEvent e) {
  455. StartButtonActionPerformed(e);
  456. }
  457. });
  458. contentPane.add(StartButton);
  459. StartButton.setBounds(0, 500, 395, 55);
  460.  
  461. //---- TimeCB ----
  462. TimeCB.setFont(new Font("Verdana", Font.PLAIN, 12));
  463. TimeCB.setModel(new DefaultComboBoxModel(new String[] {
  464. "Every 5 sec",
  465. "Every 30 sec",
  466. "Every 1 min",
  467. "Every 2 min",
  468. "Every 5 min",
  469. "Every 10 min"
  470. }));
  471. contentPane.add(TimeCB);
  472. TimeCB.setBounds(80, 300, 235, 30);
  473.  
  474. //---- label3 ----
  475. label3.setText("How often do you want the bot to check");
  476. label3.setFont(new Font("Verdana", Font.PLAIN, 12));
  477. label3.setHorizontalAlignment(SwingConstants.CENTER);
  478. contentPane.add(label3);
  479. label3.setBounds(0, 260, 395, 24);
  480.  
  481. //---- label4 ----
  482. label4.setText("if an item has been bought?");
  483. label4.setHorizontalAlignment(SwingConstants.CENTER);
  484. label4.setFont(new Font("Verdana", Font.PLAIN, 12));
  485. contentPane.add(label4);
  486. label4.setBounds(0, 280, 395, 20);
  487.  
  488. //---- label5 ----
  489. label5.setText("Enter the amount you want the bot to buy at a time");
  490. label5.setFont(new Font("Verdana", Font.PLAIN, 12));
  491. label5.setHorizontalAlignment(SwingConstants.CENTER);
  492. contentPane.add(label5);
  493. label5.setBounds(0, 95, 395, 30);
  494. contentPane.add(AmountTF);
  495. AmountTF.setBounds(160, 125, 75, 25);
  496.  
  497. //---- label6 ----
  498. label6.setText("Enter the EXACT name of the item you want the bot to buy");
  499. label6.setHorizontalAlignment(SwingConstants.CENTER);
  500. label6.setFont(new Font("Verdana", Font.PLAIN, 12));
  501. contentPane.add(label6);
  502. label6.setBounds(0, 180, 395, 20);
  503. contentPane.add(NameTF);
  504. NameTF.setBounds(30, 200, 335, 25);
  505.  
  506. //---- PerCB ----
  507. PerCB.setFont(new Font("Verdana", Font.PLAIN, 12));
  508. PerCB.setModel(new DefaultComboBoxModel(new String[] {
  509. "-10%",
  510. "-5%",
  511. "0%",
  512. "+5%",
  513. "+10%"
  514. }));
  515. contentPane.add(PerCB);
  516. PerCB.setBounds(160, 410, 75, 30);
  517. PerCB.setSelectedIndex(2);
  518.  
  519. //---- label7 ----
  520. label7.setText("What Percentage to buy at?");
  521. label7.setFont(new Font("Verdana", Font.PLAIN, 12));
  522. label7.setHorizontalAlignment(SwingConstants.CENTER);
  523. contentPane.add(label7);
  524. label7.setBounds(0, 390, 395, label7.getPreferredSize().height);
  525.  
  526. { // compute preferred size
  527. Dimension preferredSize = new Dimension();
  528. for(int i = 0; i < contentPane.getComponentCount(); i++) {
  529. Rectangle bounds = contentPane.getComponent(i).getBounds();
  530. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  531. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  532. }
  533. Insets insets = contentPane.getInsets();
  534. preferredSize.width += insets.right;
  535. preferredSize.height += insets.bottom;
  536. contentPane.setMinimumSize(preferredSize);
  537. contentPane.setPreferredSize(preferredSize);
  538. }
  539. pack();
  540. setLocationRelativeTo(getOwner());
  541. // JFormDesigner - End of component initialization //GEN-END:initComponents
  542. }
  543.  
  544. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  545. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  546. private JLabel label1;
  547. private JLabel label2;
  548. private JButton StartButton;
  549. private JComboBox TimeCB;
  550. private JLabel label3;
  551. private JLabel label4;
  552. private JLabel label5;
  553. private JTextField AmountTF;
  554. private JLabel label6;
  555. private JTextField NameTF;
  556. private JComboBox PerCB;
  557. private JLabel label7;
  558. // JFormDesigner - End of variables declaration //GEN-END:variables
  559. }
  560. }
Advertisement
Add Comment
Please, Sign In to add comment