Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.42 KB | None | 0 0
  1. import java.awt.AlphaComposite;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Composite;
  5. import java.awt.Font;
  6. import java.awt.Graphics;
  7. import java.awt.Graphics2D;
  8. import java.awt.Point;
  9. import java.awt.Rectangle;
  10. import java.awt.RenderingHints;
  11. import java.awt.event.MouseEvent;
  12. import java.io.BufferedReader;
  13. import java.io.BufferedWriter;
  14. import java.io.File;
  15. import java.io.FileWriter;
  16. import java.io.IOException;
  17. import java.io.InputStreamReader;
  18. import java.net.URL;
  19. import java.net.URLConnection;
  20. import java.text.NumberFormat;
  21. import java.util.ArrayList;
  22. import java.util.HashMap;
  23. import java.awt.Container;
  24. import java.awt.image.BufferedImage;
  25. import java.util.List;
  26. import java.util.Map;
  27. import java.util.logging.Level;
  28. import java.util.prefs.Preferences;
  29. import javax.swing.JCheckBox;
  30. import javax.swing.JComboBox;
  31. import javax.swing.JOptionPane;
  32. import javax.swing.JSpinner;
  33. import javax.swing.event.MouseInputListener;
  34.  
  35. import org.rsbot.event.events.ServerMessageEvent;
  36. import org.rsbot.event.listeners.PaintListener;
  37. import org.rsbot.event.listeners.ServerMessageListener;
  38. import org.rsbot.script.Script;
  39. import org.rsbot.script.ScriptManifest;
  40. import org.rsbot.script.methods.Game;
  41. import org.rsbot.script.methods.Skills;
  42. import org.rsbot.script.util.Timer;
  43. import org.rsbot.script.util.WindowUtil;
  44. import org.rsbot.script.wrappers.RSArea;
  45. import org.rsbot.script.wrappers.RSInterface;
  46. import org.rsbot.script.wrappers.RSItem;
  47. import org.rsbot.script.wrappers.RSNPC;
  48. import org.rsbot.script.wrappers.RSObject;
  49. import org.rsbot.script.wrappers.RSTile;
  50. import org.rsbot.util.GlobalConfiguration;
  51. import java.awt.BorderLayout;
  52. import java.awt.Color;
  53. import java.awt.FlowLayout;
  54. import java.awt.Font;
  55. import java.awt.Graphics;
  56. import java.awt.Graphics2D;
  57. import java.lang.String;
  58. import java.awt.Point;
  59. import java.awt.Polygon;
  60. import org.rsbot.script.methods.Walking;
  61. import java.awt.RenderingHints;
  62. import org.rsbot.script.methods.MethodProvider;
  63. import org.rsbot.script.wrappers.RSObject;
  64. import org.rsbot.script.methods.Keyboard;
  65. import java.awt.event.ActionEvent;
  66. import java.awt.event.ActionListener;
  67. import java.awt.event.MouseEvent;
  68. import java.awt.event.MouseListener;
  69. import java.io.File;
  70. import java.io.FileInputStream;
  71. import java.io.FileOutputStream;
  72. import java.text.NumberFormat;
  73. import java.util.ArrayList;
  74. import java.util.HashMap;
  75. import java.util.Map;
  76. import java.util.Properties;
  77. import org.rsbot.script.wrappers.RSObject;
  78.  
  79. import javax.swing.BorderFactory;
  80. import javax.swing.BoxLayout;
  81. import javax.swing.JButton;
  82. import javax.swing.JCheckBox;
  83. import javax.swing.JFrame;
  84. import javax.swing.JLabel;
  85. import javax.swing.JOptionPane;
  86. import javax.swing.JPanel;
  87. import javax.swing.JTextField;
  88. import javax.swing.JRadioButton;
  89. import javax.swing.JSlider;
  90.  
  91. import org.rsbot.event.listeners.PaintListener;
  92. import org.rsbot.script.Script;
  93. import org.rsbot.script.ScriptManifest;
  94. import org.rsbot.script.methods.Skills;
  95. import org.rsbot.script.util.Filter;
  96. import org.rsbot.script.wrappers.RSCharacter;
  97. import org.rsbot.script.wrappers.RSComponent;
  98. import org.rsbot.script.wrappers.RSGroundItem;
  99. import org.rsbot.script.wrappers.RSItem;
  100. import org.rsbot.script.wrappers.RSModel;
  101. import org.rsbot.script.wrappers.RSNPC;
  102. import org.rsbot.script.wrappers.RSPlayer;
  103. import org.rsbot.script.wrappers.RSTile;
  104. import org.rsbot.util.GlobalConfiguration;
  105. import java.awt.Color;
  106. import java.awt.Graphics;
  107. import java.util.Map;
  108. import java.awt.*;
  109. import javax.swing.*;
  110. import java.awt.Window;
  111.  
  112. import org.rsbot.bot.Bot;
  113. import org.rsbot.event.listeners.PaintListener;
  114.  
  115. import org.rsbot.script.Script;
  116. import org.rsbot.script.ScriptManifest;
  117. import org.rsbot.script.wrappers.RSInterface;
  118. import org.rsbot.script.wrappers.RSTile;
  119. import org.rsbot.script.wrappers.RSNPC;
  120.  
  121. @ScriptManifest(authors = { "happyfeet" }, name = "ConstructionBot", version = 1.10, description = "Welcome! Options are in the GUI. Enjoy!")
  122.  
  123. public class ConstructionBot extends Script implements PaintListener{
  124.  
  125. //START OF CLASS VARIABLES//
  126. private int teakB = 18790;
  127. private int teakUn = 18811;
  128. public String status = "";
  129. private int teakPlank = 8780;
  130. private int mahoganyPlank = 8782;
  131. private int oakDB = 13345;
  132. private int oakDUn = 15327;
  133. private int mahB = 13298;
  134. private int mouseSpeed;
  135. private int mahUn = 15298;
  136. private int mahPlank = 8782;
  137. private long startingTime;
  138. private boolean guiStart = false;
  139. private int startXP = 0;
  140. private int startLvl = 0;
  141. private long scriptStartTime = 0;
  142. final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
  143. private Rectangle experienceProgressBar;
  144. BufferedImage normal = null;
  145. BufferedImage clicked = null;
  146. private int normalButler = 4241;
  147. private int demonButler = 4243;
  148. private int Built, Unbuilt, plank, whatToMake;
  149. private int butler;
  150. private long startExp, st, startLevel;
  151. private RSTile nearWardrobe;
  152. private boolean ButlerHere = true;
  153. //END OF CLASS VARIABLES//
  154.  
  155. //START OF GUI//
  156. public class ConstructionGUI extends JPanel {
  157.  
  158. public ConstructionGUI() {
  159. initComponents();
  160. }
  161.  
  162. //START OF COMPONENTS
  163. private void initComponents() {
  164. frame1 = new JFrame();
  165. panel1 = new JPanel();
  166. comboBox1 = new JComboBox();
  167. comboBox2 = new JComboBox();
  168. label1 = new JLabel();
  169. label2 = new JLabel();
  170. label3 = new JLabel();
  171. slider1 = new JSlider();
  172. label4 = new JLabel();
  173. label5 = new JLabel();
  174. label6 = new JLabel();
  175. label7 = new JLabel();
  176. label8 = new JLabel();
  177. label9 = new JLabel();
  178. label10 = new JLabel();
  179. button1 = new JButton();
  180.  
  181. //======== frame1 ========
  182. {
  183. Container frame1ContentPane = frame1.getContentPane();
  184. frame1ContentPane.setLayout(null);
  185. frame1.setVisible(true);
  186. frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  187.  
  188. //======== panel1 ========
  189. {
  190.  
  191. // JFormDesigner evaluation mark
  192. panel1.setBorder(new javax.swing.border.CompoundBorder(
  193. new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
  194. "", javax.swing.border.TitledBorder.CENTER,
  195. javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
  196. java.awt.Color.red), panel1.getBorder())); panel1.addPropertyChangeListener(
  197. new java.beans.PropertyChangeListener(){
  198. public void propertyChange(java.beans.PropertyChangeEvent e){
  199. if("border".equals(e.getPropertyName()))throw new RuntimeException();}});
  200.  
  201. panel1.setLayout(null);
  202.  
  203. //---- comboBox1 ----
  204. comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  205. "Normal Butler",
  206. "Demon Butler"
  207. }));
  208. panel1.add(comboBox1);
  209. comboBox1.setBounds(95, 215, 185, comboBox1.getPreferredSize().height);
  210.  
  211. //---- comboBox2 ----
  212. comboBox2.setModel(new DefaultComboBoxModel(new String[] {
  213. "Oak Dungeon Door",
  214. "Mahogany Table",
  215. "Carved teak magic wardrobe"
  216. }));
  217. panel1.add(comboBox2);
  218. comboBox2.setBounds(95, 255, 185, comboBox2.getPreferredSize().height);
  219.  
  220. //---- label1 ----
  221. label1.setText("Mida teha tahad:");
  222. panel1.add(label1);
  223. label1.setBounds(new Rectangle(new Point(120, 240), label1.getPreferredSize()));
  224.  
  225. //---- label2 ----
  226. label2.setText("määne toateenija sul on:");
  227. panel1.add(label2);
  228. label2.setBounds(new Rectangle(new Point(125, 200), label2.getPreferredSize()));
  229.  
  230. //---- label3 ----
  231. label3.setText("mingi munni script on see");
  232. label3.setFont(new Font("Tahoma", Font.PLAIN, 24));
  233. panel1.add(label3);
  234. label3.setBounds(new Rectangle(new Point(35, 25), label3.getPreferredSize()));
  235.  
  236. //---- slider1 ----
  237. slider1.setPaintTicks(true);
  238. slider1.setPaintLabels(true);
  239. slider1.setSnapToTicks(true);
  240. slider1.setValue(4);
  241. slider1.setMaximum(8);
  242. slider1.setMajorTickSpacing(1);
  243. slider1.setMinorTickSpacing(1);
  244. panel1.add(slider1);
  245. slider1.setBounds(new Rectangle(new Point(95, 150), slider1.getPreferredSize()));
  246.  
  247. //---- label4 ----
  248. label4.setText("Mouse Speed:");
  249. panel1.add(label4);
  250. label4.setBounds(new Rectangle(new Point(155, 135), label4.getPreferredSize()));
  251.  
  252. //---- label5 ----
  253. label5.setText("0 on väga kiire");
  254. panel1.add(label5);
  255. label5.setBounds(new Rectangle(new Point(40, 155), label5.getPreferredSize()));
  256.  
  257. //---- label6 ----
  258. label6.setText("8 in kõige aeglasem");
  259. panel1.add(label6);
  260. label6.setBounds(new Rectangle(new Point(300, 155), label6.getPreferredSize()));
  261.  
  262. //---- label7 ----
  263. label7.setText("Üks buggine bot");
  264. panel1.add(label7);
  265. label7.setBounds(new Rectangle(new Point(45, 55), label7.getPreferredSize()));
  266.  
  267. //---- label8 ----
  268. label8.setText("alusta oma majas");
  269. panel1.add(label8);
  270. label8.setBounds(new Rectangle(new Point(20, 70), label8.getPreferredSize()));
  271.  
  272. //---- label9 ----
  273. label9.setText("saag ja haamer olgu kotis ja saada toateenija laudade järele");
  274. panel1.add(label9);
  275. label9.setBounds(new Rectangle(new Point(25, 85), label9.getPreferredSize()));
  276.  
  277. //---- label10 ----
  278. label10.setText("enne alustamist seisa ehitatava eseme lähedale");
  279. panel1.add(label10);
  280. label10.setBounds(new Rectangle(new Point(35, 100), label10.getPreferredSize()));
  281.  
  282. //---- button1 ----
  283. button1.setText("Start!");
  284. panel1.add(button1);
  285. button1.setBounds(95, 285, 190, button1.getPreferredSize().height);
  286.  
  287. { // compute preferred size
  288. Dimension preferredSize = new Dimension();
  289. for(int i = 0; i < panel1.getComponentCount(); i++) {
  290. Rectangle bounds = panel1.getComponent(i).getBounds();
  291. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  292. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  293. }
  294. Insets insets = panel1.getInsets();
  295. preferredSize.width += insets.right;
  296. preferredSize.height += insets.bottom;
  297. panel1.setMinimumSize(preferredSize);
  298. panel1.setPreferredSize(preferredSize);
  299. }
  300. }
  301. frame1ContentPane.add(panel1);
  302. panel1.setBounds(-5, -20, 390, 320);
  303.  
  304. { // compute preferred size
  305. Dimension preferredSize = new Dimension();
  306. for(int i = 0; i < frame1ContentPane.getComponentCount(); i++) {
  307. Rectangle bounds = frame1ContentPane.getComponent(i).getBounds();
  308. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  309. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  310. }
  311. Insets insets = frame1ContentPane.getInsets();
  312. preferredSize.width += insets.right;
  313. preferredSize.height += insets.bottom;
  314. frame1ContentPane.setMinimumSize(preferredSize);
  315. frame1ContentPane.setPreferredSize(preferredSize);
  316. }
  317. frame1.pack();
  318. frame1.setLocationRelativeTo(frame1.getOwner());
  319. button1.addActionListener(
  320. new java.awt.event.ActionListener() {
  321. public void actionPerformed(
  322. java.awt.event.ActionEvent arg0) {
  323. if(comboBox2.getSelectedItem().equals("Carved teak magic wardrobe")){
  324. Built = teakB;
  325. Unbuilt = 18811;
  326. plank = teakPlank;
  327. whatToMake = 0;
  328. log("Making teak wardrobes.");
  329. }
  330. else if(comboBox2.getSelectedItem().equals("Oak Dungeon Door"))
  331. {
  332. Built = oakDB;
  333. Unbuilt = oakDUn;
  334. plank = teakPlank;
  335. whatToMake = 1;
  336. log("Making oak dungeon doors");
  337. }
  338. else if(comboBox2.getSelectedItem().equals("Mahogany Table"))
  339. {
  340. Built = mahB;
  341. Unbuilt = mahUn;
  342. plank = mahPlank;
  343. whatToMake = 2;
  344. log("Making mahogany tables.");
  345. }
  346. if(comboBox1.getSelectedItem().equals("Normal Butler"))
  347. {
  348. butler = normalButler;
  349. log("Your Butler is the normal one.");
  350. }
  351. if(comboBox1.getSelectedItem().equals("Demon Butler"))
  352. {
  353. butler = demonButler;
  354. log("You have the demon Butler.");
  355. }
  356.  
  357. if (slider1.getValue() == 0) {
  358. mouseSpeed = 0;
  359. }
  360. else if (slider1.getValue() == 1) {
  361. mouseSpeed = 1;
  362. }
  363. else if (slider1.getValue() == 2) {
  364. mouseSpeed = 2;
  365. }
  366. else if (slider1.getValue() == 3) {
  367. mouseSpeed = 3;
  368. }
  369. else if (slider1.getValue() == 4) {
  370. mouseSpeed = 4;
  371. }
  372. else if (slider1.getValue() == 5) {
  373. mouseSpeed = 5;
  374. }
  375. else if (slider1.getValue() == 6) {
  376. mouseSpeed = 6;
  377. }
  378. else if (slider1.getValue() == 7) {
  379. mouseSpeed = 7;
  380. }
  381. else if (slider1.getValue() == 8) {
  382. mouseSpeed = 8;
  383. }
  384.  
  385. log("Your mouse speed is " + mouseSpeed + ".");
  386. guiStart = true;
  387. frame1.dispose();
  388. }
  389. });
  390. }
  391. }
  392. //END OF COMPONENTS//
  393.  
  394. private JFrame frame1;
  395. private JPanel panel1;
  396. private JComboBox comboBox1;
  397. private JComboBox comboBox2;
  398. private JLabel label1;
  399. private JLabel label2;
  400. private JLabel label3;
  401. private JSlider slider1;
  402. private JLabel label4;
  403. private JLabel label5;
  404. private JLabel label6;
  405. private JLabel label7;
  406. private JLabel label8;
  407. private JLabel label9;
  408. private JLabel label10;
  409. private JButton button1;
  410. }
  411. //END OF GUI//
  412.  
  413. public int getMouseSpeed() {
  414. if (mouseSpeed == 8) {
  415. return 8;
  416. }
  417. if (mouseSpeed == 7) {
  418. return 7;
  419. }
  420. else if (mouseSpeed == 6) {
  421. return 6;
  422. }
  423. else if (mouseSpeed == 5) {
  424. return 5;
  425. }
  426. else if (mouseSpeed == 4) {
  427. return 4;
  428. }
  429. else if (mouseSpeed == 3) {
  430. return 3;
  431. }
  432. else if (mouseSpeed == 2) {
  433. return 2;
  434. }
  435. else if (mouseSpeed == 1) {
  436. return 1;
  437. }
  438. else
  439. return 0;
  440. }
  441.  
  442. //WHAT TO DO RIGHT WHEN THE BOT STARTS//
  443. public boolean onStart() {
  444.  
  445. final ConstructionGUI GUI = new ConstructionGUI();
  446. GUI.setVisible(true);
  447. while(!guiStart){
  448. sleep(50);
  449. }
  450.  
  451. scriptStartTime = System.currentTimeMillis();
  452. startXP = skills.getCurrentExp(Skills.CONSTRUCTION);
  453. startLvl = skills.getCurrentLevel(Skills.CONSTRUCTION);
  454. st = System.currentTimeMillis();
  455.  
  456. log("Started");
  457.  
  458. return true;
  459. }
  460. //END OF ONSTART METHOD//
  461.  
  462. //MAIN LOOP , WHERE EVERYTHING OCCURS//
  463. public int loop(){
  464.  
  465. mouse.setSpeed(getMouseSpeed());
  466.  
  467. if (calc.distanceTo(nearWardrobe) > 3) {
  468. walking.walkTo(nearWardrobe);
  469. return 1300;
  470. }
  471. if (interfacesss()) {
  472. return 800;
  473. }
  474. if (inventory.getCount(plank) < 16) {
  475. if (npcs.getNearest(butler) != null) {
  476. if (ButlerHere == false) {
  477. ButlerHere = true;
  478. int waitCount = 24;
  479. if (inventory.getCount(plank) < 1) {
  480. CountTheInventory(plank, waitCount, 3000);
  481. }
  482.  
  483. }
  484.  
  485. if(whatToMake == 0){
  486. if ( inventory.getCount(plank) <= 10 && objects.getNearest(Unbuilt) != null ) {
  487. npcs.getNearest(butler).doAction("Fetch-from-bank");
  488. sleep(500);
  489. if (interfaces.get(242).isValid() || interfaces.get(232).isValid() || interfaces.get(234).isValid()) {
  490. interfacesss();
  491. return 1500;
  492. }
  493. return(1200);
  494. }
  495. }
  496. else if(whatToMake == 1){
  497. if ( inventory.getCount(plank) <= 16 && objects.getNearest(Unbuilt) != null) {
  498. npcs.getNearest(butler).doAction("Fetch-from-bank");
  499. sleep(500);
  500. if (interfaces.get(242).isValid() || interfaces.get(232).isValid() || interfaces.get(234).isValid()) {
  501. interfacesss();
  502. return 1500;
  503. }
  504. return(1200);
  505. }
  506. }
  507. else if(whatToMake == 2){
  508. if ( inventory.getCount(plank) <= 8 && objects.getNearest(Unbuilt) != null) {
  509. npcs.getNearest(butler).doAction("Fetch-from-bank");
  510. sleep(500);
  511. if (interfaces.get(242).isValid() || interfaces.get(232).isValid() || interfaces.get(234).isValid()) {
  512. interfacesss();
  513. return 1500;
  514. }
  515. }
  516. return(1200);
  517. }
  518. if (inventory.getCount(plank) >= 16)
  519. return 1500;
  520. }
  521. // else {
  522. // ButlerHere = false;
  523. // if (objects.getNearest(Built) != null) {
  524. // objects.getNearest(Built).doAction("Remove");
  525. // return(1500);
  526. // }
  527. // }
  528. }
  529. if (objects.getNearest(Built) != null && inventory.getCount(plank) > 6) {
  530. objects.getNearest(Built).doAction("Remove");
  531. return(1500);
  532. }
  533. if(whatToMake == 0){
  534. if(objects.getNearest(Unbuilt) != null && inventory.getCount(plank) > 7 ) {
  535. while(interfaces.get(394).isValid() != true ){
  536. objects.getNearest(Unbuilt).doAction("Build");
  537. }
  538. sleep(1500);
  539. mouse.move(random(101, 122), random(128, 151));
  540. sleep(600);
  541. mouse.click(true);
  542. sleep(500);
  543. return(1200);
  544. }
  545. }
  546. else if(whatToMake == 1){
  547. if(objects.getNearest(Unbuilt) != null && inventory.getCount(plank) > 5 ) {
  548. while(interfaces.get(394).isValid() != true){
  549. objects.getNearest(Unbuilt).doAction("Build");
  550. }
  551. sleep(1500);
  552. mouse.move(random(100, 120), random(60, 90));
  553. sleep(600);
  554. mouse.click(true);
  555. sleep(500);
  556. return(1200);
  557. }
  558. }
  559. else if(whatToMake == 2){
  560. if( objects.getNearest(Unbuilt) != null && inventory.getCount(plank) > 7 ) {
  561. while(interfaces.get(394).isValid() != true){
  562. objects.getNearest(Unbuilt).doAction("Build");
  563. }
  564. sleep(1200);
  565. mouse.move(random(290,310), random(131,147));
  566. sleep(600);
  567. mouse.click(true);
  568. sleep(500);
  569. return(1200);
  570. }
  571. }
  572. return 500;
  573. }
  574. //END OF MAIN LOOP//
  575.  
  576. private boolean interfacesss() {
  577. if (isValid(interfaces.get(242),5)) {
  578. if(interfaces.get(232).containsText("any of those ite")) {
  579. log("No more Planks! Thanks for using the ConstructionBot");
  580. stopScript(true);
  581. return true;
  582. }
  583. }
  584.  
  585. if (interfaces.get(394).isValid()) {
  586. WardrobeClick(8234);
  587. nearWardrobe = getMyPlayer().getLocation();
  588. return true;
  589. }
  590. if (isValid(interfaces.get(232),3)) {//pay from bank
  591. if(interfaces.get(232).containsText("Pay servant")) {
  592. interfaces.getComponent(232,3).doClick();
  593. return true;
  594. }
  595. }
  596. if (isValid(interfaces.get(228),2)) {
  597. mouse.move(random(250, 280), random(398, 412));
  598. sleep(random(15,50));
  599. mouse.click(true);
  600. return true;
  601. }
  602. if (isValid(interfaces.get(241),5)) {
  603. if (interfaces.get(241).containsText("Yes, madam?") || interfaces.get(241).containsText("Yes, sir?") ||interfaces.get(241).containsText("Your goods") )
  604. return false;
  605. interfaces.getComponent(241,5).doClick();
  606. return true;
  607. }
  608. if (isValid(interfaces.get(234),2)) {
  609. if (inventory.getCount(plank) < 16) {
  610. interfaces.getComponent(234,2).doClick();
  611. }
  612. // else {
  613. // objects.getNearest(Built).doAction( "Walk here" );
  614. // }
  615. return true;
  616. }
  617.  
  618. if (isValid(interfaces.get(232),3)) {
  619. interfaces.getComponent(232, 3).doClick();
  620. sleep (random(1000,2000));
  621. keyboard.sendText("24", true);
  622. sleep(random(100, 200));
  623. return true;
  624. }
  625. if (isValid(interfaces.get(242),6)) {interfaces.getComponent(242,6).doClick();
  626. return true;}
  627. if (interfaces.get(243).containsText("until thou art ready."))
  628. return false;
  629. if (isValid(interfaces.get(243), 7)) {
  630. interfaces.getComponent(243, 7).doClick();
  631. return true;
  632. }
  633. return false;
  634.  
  635. }
  636.  
  637. public int CountTheInventory(int item, int count, int timeout) {
  638. long start = System.currentTimeMillis();
  639. while (System.currentTimeMillis() - start < timeout) {
  640. if ( inventory.getCount(item) >= count) {
  641. break;
  642. }
  643. }
  644. return inventory.getCount(item);
  645. }
  646.  
  647. private boolean isValid (RSInterface a, int child) {
  648. return (a.isValid() && a.getComponent(child).getAbsoluteY() > 30);
  649. }
  650.  
  651. public boolean WardrobeClick(int itemID) {
  652.  
  653. RSComponent WardrobeMenu = interfaces.get(394).getComponent(11);
  654. if (WardrobeMenu == null || WardrobeMenu.getComponents() == null)
  655. return false;
  656.  
  657. for (RSComponent item : WardrobeMenu.getComponents()) {
  658. if (item != null && item.getComponentID() == itemID) {
  659. WardrobeMenu.doClick();
  660. sleep(1000);
  661. }
  662. }
  663. return true;
  664. }
  665.  
  666. public int getThatAnimation(){
  667. return getMyPlayer().getAnimation();
  668. }
  669.  
  670. public void drawMouse(final Graphics g) {
  671. if (normal != null) {
  672. final double mouseX = mouse.getLocation().getX() - 8,
  673. mouseY = mouse.getLocation().getY() - 8;
  674. final double mousePressX = mouse.getPressLocation().getX() - 8,
  675. mousePressY = mouse.getPressLocation().getY() - 8;
  676. if (System.currentTimeMillis() - mouse.getPressTime() < 400) {
  677. g.drawImage(clicked, (int) mousePressX, (int) mousePressY, null);
  678. }
  679. g.drawImage(normal, (int) mouseX, (int) mouseY, null);
  680. }
  681. }
  682.  
  683. public void onRepaint(Graphics g) {
  684.  
  685. long runTime = 0;
  686. long seconds = 0;
  687. long minutes = 0;
  688. long hours = 0;
  689. int percent = 0;
  690. int currentXP = 0;
  691. int currentLVL = 0;
  692. int gainedXP = 0;
  693. int gainedLVL = 0;
  694. int lapsPerHour = 0;
  695. int expPerHour = 0;
  696.  
  697. runTime = System.currentTimeMillis() - scriptStartTime;
  698.  
  699. /* ************************ NEW PAINT ******************* */
  700. percent = skills.getPercentToNextLevel(Skills.CONSTRUCTION);
  701. currentXP = skills.getCurrentExp(Skills.CONSTRUCTION);
  702. currentLVL = skills.getCurrentLevel(Skills.CONSTRUCTION);
  703. gainedXP = currentXP - startXP;
  704. gainedLVL = currentLVL - startLvl;
  705. expPerHour = (int) (3600000.0 / (double) runTime * gainedXP);
  706. final int fillBar = (int) (4.7 * (double) percent);
  707. drawMouse(g);
  708.  
  709.  
  710. g.setColor(new Color(32, 0, 0, 175)); // border-top-right
  711. g.fillRect(23, 387, 470, 26); // border-top-right
  712. g.setColor(new Color(108, 108, 108, 200)); // border-bottom-left
  713. g.fillRect(25, 389, 470, 26); // border-bottom-left
  714.  
  715.  
  716. g.setColor(new Color(0, 0, 0, 175));
  717. g.fillRoundRect(7, 345, 506, 129, 7, 7);
  718.  
  719. g.setColor(new Color(139, 0, 0, 175)); // red1
  720. g.fillRect(24, 388, 470, 26); // red1
  721. g.setColor(new Color(0, 166, 0, 200)); // green1
  722. g.fillRect(24, 388, fillBar, 26); // green1
  723.  
  724. g.setColor(new Color(207, 58, 58, 175)); // red2
  725. g.fillRect(24, 401, 470, 13); // red2
  726. g.setColor(new Color(128, 219, 128, 200)); // green2
  727. g.fillRect(24, 401, fillBar, 13); // green2
  728.  
  729. g.setFont(new Font("Verdana", 0, 14));
  730. g.setColor(new Color(0, 0, 0, 255));
  731. g.drawString(percent + "% - " + skills.getExpToNextLevel(Skills.CONSTRUCTION) + "xp remaining", 43, 406);
  732.  
  733. // title
  734. g.setFont(new Font( "Verdana", Font.ITALIC | Font.BOLD , 20 ));
  735. g.setColor(Color.red);
  736. g.drawString("DemonButlerOakLarder by Happyfeet",48,375);
  737.  
  738. g.setFont(new Font("Verdana", 0, 12));
  739. g.setColor(new Color(225, 225, 225, 175));
  740.  
  741. // left side
  742. g.drawString("Current Lvl: " + currentLVL + " (+ " + gainedLVL + ")", 24, 445);
  743. g.drawString("Exp Gained: " + gainedXP + " (" + expPerHour + "/hr)", 24, 460);
  744.  
  745. // right side
  746. g.drawString("Run Time: " + Timer.format(runTime), 250, 445);
  747. try {
  748. if (expPerHour > 0) {
  749. long sTNL = (skills.getExpToNextLevel(Skills.CONSTRUCTION)) / (expPerHour / 3600);
  750. long hTNL = sTNL / (60 * 60);
  751. sTNL -= hTNL * (60 * 60);
  752. long mTNL = sTNL / 60;
  753. sTNL -= mTNL * 60;
  754. g.drawString("Level in: " + hTNL + ":" + mTNL + ":" + sTNL + " (" + percent + "%)", 250, 460);
  755. }
  756. else {
  757. g.drawString("Level in: 0:0:0 (" + percent + "%)", 250, 460);
  758. }
  759. }
  760. catch(Exception e) {
  761. g.drawString("Level in: -1:-1:-1 (" + percent + "%)", 250, 460);
  762. }
  763. }
  764. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement