Himekp

ProConstruction

May 18th, 2011
1,697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.54 KB | None | 0 0
  1. /**
  2. * Welcome to Himekp's ProScript's
  3. * This is Version 1.03
  4. **********ProConstruction**********
  5. ************By: Himekp*************
  6. */
  7.  
  8.  
  9. import java.awt.BasicStroke;
  10. import java.awt.Color;
  11. import java.awt.Container;
  12. import java.awt.Dimension;
  13. import java.awt.Font;
  14. import java.awt.Graphics;
  15. import java.awt.Graphics2D;
  16. import java.awt.Image;
  17. import java.awt.Insets;
  18. import java.awt.Point;
  19. import java.awt.Rectangle;
  20. import java.awt.event.ActionEvent;
  21. import java.awt.event.ActionListener;
  22. import java.awt.image.BufferedImage;
  23. import java.io.IOException;
  24. import java.net.MalformedURLException;
  25. import java.net.URL;
  26.  
  27. import javax.imageio.ImageIO;
  28. import javax.swing.DefaultComboBoxModel;
  29. import javax.swing.JButton;
  30. import javax.swing.JComboBox;
  31. import javax.swing.JFrame;
  32. import javax.swing.JLabel;
  33. import javax.swing.JPanel;
  34. import javax.swing.JSlider;
  35.  
  36. import org.rsbot.script.Script;
  37. import org.rsbot.event.listeners.PaintListener;
  38. import org.rsbot.script.ScriptManifest;
  39. import org.rsbot.script.methods.Skills;
  40.  
  41. @ScriptManifest(authors = "Himekp", keywords = "Construction", name = "ProConstruction", version = 1.03, description = "ProConstruction, By: Himekp", website = "http://www.powerbot.org/vb/showthread.php?t=787874")
  42. public class ProConstruction extends Script implements PaintListener{
  43. public int oakPlank = 8778;
  44. public int oakDungeon = 13345;
  45. public int oakDungeonnull = 15327;
  46. public int oakLarder = 13566;
  47. public int oakLardernull = 15403;
  48. public int mahTable = 13298;
  49. public int mahTablenull = 15298;
  50. public int mahPlank = 8782;
  51. public int teakWard = 18790;
  52. public int teakWardnull = 18811;
  53. public int teakPlank = 8780;
  54. private int WhattoBuild;
  55. private int Butler;
  56. private int WhattoBuild2;
  57. private int Plank;
  58. private int Number;
  59. private int Number2;
  60. public int normalButler = 4241;
  61. public int demonButler = 4243;
  62. public int Saw = 8794;
  63. public int Hammer = 2347;
  64. private String TypeofObject = "";
  65. private String TypeofServent = "";
  66. public int Object = 0;
  67. private int mouseSpeed;
  68. private boolean startScript;
  69. boolean start;
  70. public boolean guiWait = true, guiExit = false;
  71. ProConstructionGUI gui;
  72. public int startLevel;
  73. public int XPgained;
  74. public int XPhour;
  75. public int LardersBuilt = 0;
  76. public int EXPgained = 0;
  77. public int EXPperhour = 0;
  78. public int planksperhour = 0;
  79. public int timetilllevel = 0;
  80. public int currentLevel = 0;
  81. public int planksUsed = 0;
  82. public long startTime = System.currentTimeMillis();
  83. public long currentXP;
  84. public long startingXP;
  85. BufferedImage normal = null;
  86. BufferedImage clicked = null;
  87.  
  88. public boolean onStart(){
  89. log(Color.blue, "Welcome to Himekp's ProConstruction Bot");
  90. log(Color.red, "Check for updates by right clicking my script!");
  91. log(Color.red, "Then check the version and if it isn't V1.03 then theres an update! Recopy and recompile!");
  92. log("Loading GUI...Please wait...");
  93. currentXP = skills.getCurrentExp(Skills.CONSTRUCTION);
  94. startingXP = skills.getCurrentExp(Skills.CONSTRUCTION);
  95. try {
  96. final URL cursorURL = new URL("http://i48.tinypic.com/313623n.png");
  97. final URL cursor80URL = new URL("http://i46.tinypic.com/9prjnt.png");
  98. normal = ImageIO.read(cursorURL);
  99. clicked = ImageIO.read(cursor80URL);
  100. } catch (MalformedURLException e) {
  101. log("Unable to buffer cursor.");
  102. } catch (IOException e) {
  103. log("Unable to open cursor image.");
  104. }
  105. gui = new ProConstructionGUI();
  106. gui.setVisible(true);
  107. log("The higher the Mouse Speed number is, the faster your mouse will be! Speed 6 is recomended!");
  108. startScript = true;
  109. while (!startScript) {
  110. sleep(10);
  111. }
  112. return true;
  113. }
  114.  
  115. //START: Code generated using Enfilade's Easel
  116. private Image getImage(String url) {
  117. try {
  118. return ImageIO.read(new URL(url));
  119. } catch(IOException e) {
  120. return null;
  121. }
  122. }
  123.  
  124. private final Color color1 = new Color(153, 153, 0, 147);
  125. private final Color color2 = new Color(0, 0, 0);
  126. private final Color color3 = new Color(255, 255, 255);
  127.  
  128. private final BasicStroke stroke1 = new BasicStroke(1);
  129.  
  130. private final Font font1 = new Font("Harlow Solid Italic", 0, 22);
  131. private final Font font2 = new Font("Harlow Solid Italic", 1, 24);
  132. private final Font font3 = new Font("Arial", 0, 12);
  133.  
  134. private final Image img1 = getImage("http://www.top1gaming.com/images/ItemDBImage/geitemimage_8794.gif");
  135. private final Image img2 = getImage("http://s3.amazonaws.com/readers/2010/07/31/constructionuntrimmed_1.png");
  136.  
  137. public void onRepaint(Graphics g1) {
  138. Graphics2D g = (Graphics2D)g1;
  139.  
  140. long runTime = 0;
  141. long seconds = 0;
  142. long minutes = 0;
  143. long hours = 0;
  144. runTime = System.currentTimeMillis() - startTime;
  145. seconds = runTime / 1000;
  146. if (seconds >= 60) {
  147. minutes = seconds / 60;
  148. seconds -= (minutes * 60);
  149. }
  150.  
  151. if (minutes >= 60) {
  152. hours = minutes / 60;
  153. minutes -= (hours * 60);
  154. }
  155. currentXP = skills.getCurrentExp(Skills.getIndex("construction"));
  156. EXPperhour = (int) ((currentXP-startingXP) * 3600000.0 / runTime);
  157. EXPgained = (int) (currentXP-startingXP);
  158. currentLevel = skills.getCurrentLevel(Skills.CONSTRUCTION);
  159. planksperhour = (int) ((planksUsed) * 3600000.0 / runTime);
  160. final int percent = skills.getPercentToNextLevel(Skills.CONSTRUCTION);
  161. g.drawString("Percent till next level: ", 379, 459);
  162. g.setColor(Color.red);
  163. g.fillRoundRect(379, 459, 100, 10, 15, 15);
  164. g.setColor(Color.green);
  165. g.fillRoundRect(379, 459, percent, 10, 15, 15);
  166. g.setColor(Color.black);
  167. g.drawString("" + percent + "%" , 412, 469);
  168. g.setColor(color1);
  169. g.fillRoundRect(548, 204, 189, 262, 16, 16);
  170. g.setColor(color2);
  171. g.setStroke(stroke1);
  172. g.drawRoundRect(548, 204, 189, 262, 16, 16);
  173. g.drawImage(img1, 614, 380, null);
  174. g.setFont(font1);
  175. g.setColor(color3);
  176. g.drawString("By: Himekp", 614, 245);
  177. g.setFont(font2);
  178. g.drawString("ProConstruction", 548, 226);
  179. g.drawImage(img2, 552, 267, null);
  180. g.setFont(font3);
  181. g.drawString("XP Gained : " + EXPgained, 629, 300);
  182. g.drawString("XP / Hour : " + EXPperhour, 629, 321);
  183. g.drawString("Total Time : " + hours + ":" + minutes + ":" + seconds, 628, 279);
  184. g.drawString("Planks Used : " + planksUsed, 628, 342);
  185. g.drawString("Planks / Hour : " + planksperhour, 628, 361);
  186. g.drawString("Current Level : " + currentLevel, 628, 380);
  187.  
  188. }
  189. //END: Code generated using Enfilade's Easel
  190.  
  191. public void onFinish(){
  192. log("Thanks for using my script, remember to post proggies!");
  193. }
  194.  
  195. public boolean getinterfacesoaklarderbutler(){
  196. if(getMyPlayer().isMoving()){
  197. sleep(10);
  198. }
  199. if(Object == 1){
  200. if(interfaces.get(394).isValid()){
  201. interfaces.getComponent(394, 30).doClick();
  202. sleep(random(1000, 2000));
  203. planksUsed += Number;
  204. }
  205. }
  206. else if(Object == 2){
  207. if(interfaces.get(394).isValid()){
  208. interfaces.getComponent(394, 29).doClick();
  209. sleep(random(1000, 2000));
  210. planksUsed += Number;
  211. }
  212. }
  213. else if(Object == 3){
  214. if(interfaces.get(394).isValid()){
  215. interfaces.getComponent(394, 54).doClick();
  216. sleep(random(1000, 2000));
  217. planksUsed += Number;
  218. }
  219. }
  220. else if(Object == 4){
  221. if(interfaces.get(394).isValid()){
  222. interfaces.getComponent(394, 52).doClick();
  223. sleep(random(1000, 2000));
  224. planksUsed += Number;
  225. }
  226. }
  227. //---- Removing the Object ----
  228. if(objects.getNearest(WhattoBuild) != null && !interfaces.get(228).isValid()){
  229. objects.getNearest(WhattoBuild).doAction("Remove");
  230. sleep(random(1000, 2000));
  231. }
  232. //---- Remove Interface ----
  233. if(interfaces.get(228).isValid()) {
  234. interfaces.getComponent(228, 2).doClick();
  235. sleep(random(1000, 2000));
  236. }
  237. //---- Paying the Butler ----
  238. if(interfaces.get(242).isValid()) {
  239. interfaces.getComponent(242, 6).doClick();
  240. sleep(random(1000, 2000));
  241. }
  242. //---- Paying the Demon Butler ----
  243. if(interfaces.get(243).isValid()) {
  244. interfaces.getComponent(243, 7).doClick();
  245. sleep(random(1000, 2000));
  246. }
  247. if(interfaces.get(234).isValid()) {
  248. interfaces.getComponent(234, 2).doClick();
  249. sleep(random(1000, 2000));
  250. }
  251. if(interfaces.get(232).isValid()) {
  252. interfaces.getComponent(232, 3).doClick();
  253. sleep(random(1000, 2000));
  254. }
  255. //---- Building the Object Choosen ----
  256. if(objects.getNearest(WhattoBuild) == null && inventory.getCount(Plank) > Number){
  257. objects.getNearest(WhattoBuild2).doAction("Build");
  258. sleep(random(1000, 2000));
  259. }
  260. if(inventory.getCount(Plank) < Number2 && npcs.getNearest(Butler) == null){
  261. sleep(random(100,150));
  262. }
  263. //---- Telling Butler to Fetch from Bank ----
  264. if(npcs.getNearest(Butler) != null && !interfaces.get(394).isValid() && inventory.getCount(Plank) < Number2){
  265. npcs.getNearest(Butler).doAction("Fetch-from-bank");
  266. sleep(random(1000, 2000));
  267. }
  268. if(TypeofServent.equals("Normal Butler")){
  269. if(interfaces.get(232).isValid()) {
  270. interfaces.getComponent(232, 3).doClick();
  271. sleep(random(750,1250));
  272. keyboard.sendText("20", true);
  273. sleep(random(200, 400));
  274. }
  275. }
  276. if(TypeofServent.equals("Demon Butler")){
  277. if(interfaces.get(232).isValid()) {
  278. interfaces.getComponent(232, 3).doClick();
  279. sleep(random(750,1250));
  280. keyboard.sendText("26", true);
  281. sleep(random(200, 400));
  282. }
  283. }
  284. if(TypeofObject.equals("Oak Dungeon Door")){
  285. if (objects.getNearest(13351) != null) {
  286. objects.getNearest(13351).doAction("Close");
  287. }
  288. }
  289. return true;
  290. }
  291.  
  292. public int loop(){
  293. mouse.setSpeed(mouseSpeed);
  294. getinterfacesoaklarderbutler();
  295. return 100;
  296. }
  297.  
  298. public class ProConstructionGUI extends JPanel {
  299. private static final long serialVersionUID = 1L;
  300. public ProConstructionGUI() {
  301. initComponents();
  302. }
  303.  
  304. private void button1ActionPerformed(ActionEvent e) {
  305. TypeofObject = comboBox2.getSelectedItem().toString();
  306. TypeofServent = comboBox1.getSelectedItem().toString();
  307. mouseSpeed = slider1.getValue();
  308.  
  309. if(TypeofServent.equals("Normal Butler")){
  310. Butler = normalButler;
  311. }
  312. if(TypeofServent.equals("Demon Butler")){
  313. Butler = demonButler;
  314. }
  315. if(TypeofObject.equals("Oak Larder")){
  316. WhattoBuild = oakLarder;
  317. WhattoBuild2 = oakLardernull;
  318. Number = 8;
  319. Plank = oakPlank;
  320. Object = 1;
  321. Number2 = 16;
  322. }
  323. if(TypeofObject.equals("Oak Dungeon Door")){
  324. WhattoBuild = oakDungeon;
  325. WhattoBuild2 = oakDungeonnull;
  326. Number = 10;
  327. Plank = oakPlank;
  328. Object = 2;
  329. Number2 = 20;
  330. }
  331. if(TypeofObject.equals("Mahogany Table")){
  332. WhattoBuild = mahTable;
  333. WhattoBuild2 = mahTablenull;
  334. Number = 6;
  335. Plank = mahPlank;
  336. Object = 3;
  337. Number2 = 12;
  338. }
  339. if(TypeofObject.equals("Teak Carved Magic Wardrobe")){
  340. WhattoBuild = teakWard;
  341. WhattoBuild2 = teakWardnull;
  342. Number = 6;
  343. Plank = teakPlank;
  344. Object = 4;
  345. Number2 = 12;
  346. }
  347.  
  348. if (slider1.getValue() == 10) {
  349. mouseSpeed = 1;
  350. } else if (slider1.getValue() == 9) {
  351. mouseSpeed = 2;
  352. } else if (slider1.getValue() == 8) {
  353. mouseSpeed = 3;
  354. } else if (slider1.getValue() == 7) {
  355. mouseSpeed = 4;
  356. } else if (slider1.getValue() == 6) {
  357. mouseSpeed = 5;
  358. } else if (slider1.getValue() == 5) {
  359. mouseSpeed = 6;
  360. } else if (slider1.getValue() == 4) {
  361. mouseSpeed = 7;
  362. } else if (slider1.getValue() == 3) {
  363. mouseSpeed = 8;
  364. } else if (slider1.getValue() == 2) {
  365. mouseSpeed = 9;
  366. } else if (slider1.getValue() == 1) {
  367. mouseSpeed = 10;
  368. } else if (slider1.getValue() == 0) {
  369. mouseSpeed = 11;
  370. }
  371. start = true;
  372. guiWait = false;
  373. frame1.dispose();
  374. }
  375.  
  376. private void initComponents() {
  377. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  378. frame1 = new JFrame();
  379. label1 = new JLabel();
  380. label2 = new JLabel();
  381. comboBox1 = new JComboBox();
  382. label3 = new JLabel();
  383. label4 = new JLabel();
  384. comboBox2 = new JComboBox();
  385. label5 = new JLabel();
  386. slider1 = new JSlider();
  387. button1 = new JButton();
  388.  
  389. //======== frame1 ========
  390. {
  391. Container frame1ContentPane = frame1.getContentPane();
  392. frame1ContentPane.setLayout(null);
  393. frame1.setVisible(true);
  394. frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  395.  
  396.  
  397. //---- label1 ----
  398. label1.setText("ProConstruction");
  399. label1.setFont(new Font("Aerosol", Font.BOLD, 36));
  400. frame1ContentPane.add(label1);
  401. label1.setBounds(10, 10, 345, label1.getPreferredSize().height);
  402.  
  403. //---- label2 ----
  404. label2.setText("By: Himekp");
  405. label2.setFont(new Font("Aerosol", Font.PLAIN, 30));
  406. frame1ContentPane.add(label2);
  407. label2.setBounds(new Rectangle(new Point(115, 45), label2.getPreferredSize()));
  408.  
  409. //---- comboBox1 ----
  410. frame1ContentPane.add(comboBox1);
  411. comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  412. "Normal Butler",
  413. "Demon Butler"
  414. }));
  415. comboBox1.setBounds(160, 95, 180, 30);
  416.  
  417. //---- label3 ----
  418. label3.setText("Type of Butler:");
  419. label3.setFont(new Font("Tahoma", Font.PLAIN, 22));
  420. label3.setEnabled(false);
  421. frame1ContentPane.add(label3);
  422. label3.setBounds(new Rectangle(new Point(10, 95), label3.getPreferredSize()));
  423.  
  424. //---- label4 ----
  425. label4.setText("What to Make:");
  426. label4.setFont(new Font("Tahoma", Font.PLAIN, 22));
  427. label4.setEnabled(false);
  428. frame1ContentPane.add(label4);
  429. label4.setBounds(new Rectangle(new Point(10, 135), label4.getPreferredSize()));
  430.  
  431. //---- comboBox2 ----
  432. frame1ContentPane.add(comboBox2);
  433. comboBox2.setModel(new DefaultComboBoxModel(new String[] {
  434. "Oak Larder",
  435. "Teak Carved Magic Wardrobe",
  436. "Mahogany Table",
  437. "Oak Dungeon Door"
  438. }));
  439. comboBox2.setBounds(160, 135, 180, 30);
  440.  
  441. //---- label5 ----
  442. label5.setText("Mouse Speed");
  443. label5.setEnabled(false);
  444. label5.setFont(new Font("Tahoma", Font.PLAIN, 24));
  445. frame1ContentPane.add(label5);
  446. label5.setBounds(new Rectangle(new Point(100, 170), label5.getPreferredSize()));
  447.  
  448. //---- slider1 ----
  449. slider1.setMajorTickSpacing(1);
  450. slider1.setMaximum(10);
  451. slider1.setSnapToTicks(true);
  452. slider1.setPaintTicks(true);
  453. slider1.setPaintLabels(true);
  454. frame1ContentPane.add(slider1);
  455. slider1.setBounds(15, 205, 325, slider1.getPreferredSize().height);
  456.  
  457. //---- button1 ----
  458. button1.setText("Start");
  459. button1.addActionListener(new ActionListener() {
  460. @Override
  461. public void actionPerformed(ActionEvent e) {
  462. button1ActionPerformed(e);
  463. }
  464. });
  465. button1.setFont(new Font("Tahoma", Font.PLAIN, 22));
  466. frame1ContentPane.add(button1);
  467. button1.setBounds(5, 255, 340, 100);
  468.  
  469. { // compute preferred size
  470. Dimension preferredSize = new Dimension();
  471. for(int i = 0; i < frame1ContentPane.getComponentCount(); i++) {
  472. Rectangle bounds = frame1ContentPane.getComponent(i).getBounds();
  473. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  474. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  475. }
  476. Insets insets = frame1ContentPane.getInsets();
  477. preferredSize.width += insets.right;
  478. preferredSize.height += insets.bottom;
  479. frame1ContentPane.setMinimumSize(preferredSize);
  480. frame1ContentPane.setPreferredSize(preferredSize);
  481. }
  482. frame1.pack();
  483. frame1.setLocationRelativeTo(frame1.getOwner());
  484. }
  485. // JFormDesigner - End of component initialization //GEN-END:initComponents
  486. }
  487.  
  488. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  489. private JFrame frame1;
  490. private JLabel label1;
  491. private JLabel label2;
  492. private JComboBox comboBox1;
  493. private JLabel label3;
  494. private JLabel label4;
  495. private JComboBox comboBox2;
  496. private JLabel label5;
  497. private JSlider slider1;
  498. private JButton button1;
  499. // JFormDesigner - End of variables declaration //GEN-END:variables
  500. }
  501. }
Advertisement
Add Comment
Please, Sign In to add comment