gamemaste789

Untitled

Sep 9th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.40 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Graphics2D;
  4. import java.awt.Image;
  5. import java.awt.Point;
  6. import java.io.IOException;
  7. import java.net.URL;
  8. import javax.imageio.ImageIO;
  9. import org.rsbot.event.listeners.PaintListener;
  10. import org.rsbot.script.Script;
  11. import org.rsbot.script.ScriptManifest;
  12. import org.rsbot.script.methods.Skills;
  13. import org.rsbot.script.util.Timer;
  14. import java.awt.*;
  15. import java.awt.event.*;
  16. import javax.swing.*;
  17. import javax.swing.border.*;
  18.  
  19.  
  20. @ScriptManifest(
  21. authors = ("Fag3xx"),
  22. version = 2.3,
  23. keywords = {},
  24. description = "Fletches for you, start at bankbooth with materials in a bank tab (including knife)",
  25. name = "Fag3xx Fletcher"
  26. )
  27.  
  28. public class FletcherFag3xx extends Script implements PaintListener{
  29.  
  30. int knifeID = 946;
  31. int logID;
  32. int unstrungID;
  33. int bowID;
  34. int stringID = 1777;
  35. int left =1;
  36. int leftstring =1;
  37. int exp = 0;
  38. int expu = 0;
  39. int exphour = 0;
  40. int unstrung = 0;
  41. int unstrunghour = 0;
  42. int bows = 0;
  43. int bowshour = 0;
  44. int child = 0;
  45. int stringexp = 0;
  46. int fletchexp = 0;
  47. int method;
  48. int a=0;
  49. String display;
  50.  
  51. public String status = "start";
  52. Timer runTime = new Timer(0);
  53.  
  54. public boolean guiwait = true;
  55. gui gu = new gui();
  56.  
  57. public boolean onStart() {
  58. gu.setVisible(true);
  59. while(guiwait == true){
  60. sleep(500);
  61. }
  62. log("Script made by Fag3xx");
  63. log("Checking bank for materials and loading paint");
  64. while(!bank.isOpen()){
  65. bank.open();
  66. sleep(random(600,800));
  67. }
  68. left = bank.getCount(logID);
  69. sleep(random(600,800));
  70. return true;
  71. }
  72. public int loop (){
  73. mouse.setSpeed(random(8,9));
  74. if(left == 0){
  75. if(!(leftstring == 0)){
  76. status = ("string");
  77. if (players.getMyPlayer().getAnimation() == 6689) {
  78. antiBan();
  79. }
  80. if(!inventory.contains(unstrungID) || !inventory.contains(stringID)){
  81. bank2();
  82. }
  83. if(inventory.contains(unstrungID) && inventory.contains(stringID) && players.getMyPlayer().getAnimation() == -1){
  84. sleep(random(1500,1600));
  85. if(inventory.contains(unstrungID) && inventory.contains(stringID) && players.getMyPlayer().getAnimation() == -1){
  86. if(bank.isOpen()){
  87. bank.close();
  88. bows = bows +14;
  89. sleep(random(600,800));
  90. }
  91. stringbow();
  92. }
  93. }
  94. }else{
  95. kill();
  96. }
  97. }else{
  98. if (inventory.contains(knifeID)) {
  99. status = ("unstrung");
  100. if (players.getMyPlayer().getAnimation() == 7211) {
  101. antiBan();
  102. }
  103. if(inventory.contains(logID) && players.getMyPlayer().getAnimation() == -1){
  104. if(bank.isOpen()){
  105. bank.close();
  106. unstrung = unstrung +27;
  107. sleep(random(600,800));
  108. }
  109. fletchlog();
  110. }
  111. if(!inventory.contains(logID)){
  112. bank();
  113. }
  114. }else{
  115. takeknife();
  116. }
  117. }
  118. return random(100,200);
  119. }
  120.  
  121. private void fletchlog(){
  122. display = ("Fletching logs");
  123. if(!inventory.isItemSelected()){
  124. if(inventory.contains(knifeID)){
  125. inventory.getItem(knifeID).doClick(true);
  126. sleep(random(500, 600));
  127. }else{
  128. takeknife();
  129. }
  130. }
  131. if(inventory.isItemSelected()){
  132. if(inventory.contains(logID)){
  133. inventory.getItem(logID).doClick(true);
  134. sleep(random(1400, 1600));
  135. interfaces.getComponent(905, child).doHover();
  136. interfaces.getComponent(905, child).isValid();
  137. interfaces.getComponent(905, child).doClick();
  138. sleep(random(1400, 1600));
  139. }
  140. }
  141. }
  142.  
  143. private void stringbow(){
  144. display = ("Stringing bows");
  145. if(!inventory.isItemSelected()){
  146. inventory.getItem(unstrungID).doClick(true);
  147. sleep(random(200, 300));
  148. }
  149. if(inventory.isItemSelected()){
  150. if(inventory.contains(unstrungID)){
  151. inventory.getItem(stringID).doClick(true);
  152. sleep(random(1800, 2000));
  153. interfaces.getComponent(905, 14).isValid();
  154. interfaces.getComponent(905, 14).doClick();
  155. interfaces.getComponent(905, 14).doClick();
  156. sleep(random(1400, 1600));
  157. }
  158. }
  159. }
  160.  
  161. private void takeknife(){
  162. display = ("Taking knife");
  163. if(bank.isOpen()){
  164. bank.depositAll();
  165. sleep(random(300,400));
  166. bank.withdraw(knifeID, 1);
  167. sleep(random(2000,2200));
  168. }else{
  169. if (bank.open()) {
  170. bank.depositAllExcept(Inventory.getItemID("knife"));
  171.  
  172. return 0;
  173. sleep(random(400,600));
  174. }
  175. }
  176.  
  177. private void bank2(){
  178. display = ("Banking");
  179. if(bank.isOpen()){
  180. if(inventory.contains(bowID)){
  181. bank.depositAll();
  182. sleep(random(600,800));
  183. }
  184. if(inventory.contains(knifeID)){
  185. bank.deposit(knifeID, 0);
  186. }
  187. if(bank.getCount(unstrungID) < 15){
  188. kill();
  189. }else{
  190. if(!inventory.contains(unstrungID)){
  191. bank.withdraw(unstrungID, 14);
  192. }
  193. if(inventory.getCount(unstrungID) > 14){
  194. bank.depositAll();
  195. }
  196. if(0 == bank.getCount(stringID)){
  197. kill();
  198. }
  199. if(!inventory.contains(stringID)){
  200. bank.withdraw(stringID, 14);
  201. }
  202. }
  203. }else{
  204. if (bank.open()) {
  205. bank.depositAllExcept(inventory.getItemID("knife"));
  206.  
  207. return 0;
  208. }
  209.  
  210. }
  211.  
  212.  
  213. }
  214. }
  215.  
  216. private void bank(){
  217. display = ("Banking");
  218. if(bank.isOpen()){
  219. if(inventory.contains(unstrungID)){
  220. if(inventory.contains(knifeID)){
  221. bank.depositAllExcept(knifeID);
  222. leftstring = bank.getCount(unstrungID);
  223. sleep(random(400,600));
  224. }
  225. }
  226. left = bank.getCount(logID);
  227. bank.withdraw(logID, 0);
  228. sleep(random(100,200));
  229. }else{
  230. if (bank.open()) {
  231. bank.depositAllExcept(Inventory.getItemID("knife"));
  232.  
  233. return 0;
  234. }
  235. }
  236. }
  237.  
  238. private void kill(){
  239. env.saveScreenshot(true);
  240. log("out of materials to make bows");
  241. log("Please leave feedback on my forum post");
  242. stopScript();
  243. }
  244.  
  245. private final void antiBan() {
  246. int r = random(0, 40);
  247. switch(r) {
  248. case 1:
  249. mouse.setSpeed(random(4, 8));
  250. mouse.moveSlightly();
  251. mouse.moveSlightly();
  252. mouse.moveSlightly();
  253. break;
  254. case 8:
  255. mouse.moveSlightly();
  256. sleep(500, 800);
  257. break;
  258. case 11:
  259. mouse.moveRandomly(300, 500);
  260. break;
  261. case 15:
  262. camera.moveRandomly(random(400, 600));
  263. break;
  264. case 20:
  265. camera.setAngle(random(0, 360));
  266. sleep(random(300, 500));
  267. break;
  268. case 26:
  269. mouse.moveRandomly(300, 500);
  270. sleep(random(300, 500));
  271. break;
  272. case 28:
  273. mouse.moveOffScreen();
  274. sleep(2000, 3000);
  275. break;
  276. case 36:
  277. camera.setAngle(random(1,360));
  278. break;
  279. case 39:
  280. skills.doHover(Skills.INTERFACE_FLETCHING);
  281. sleep(random(2000, 3000));
  282. break;
  283. }
  284. }
  285.  
  286. /*
  287. * --------------- Paint --------------
  288. */
  289.  
  290. private Image getImage(String url) {
  291. try {
  292. return ImageIO.read(new URL(url));
  293. } catch (IOException e) {
  294. return null;
  295. }
  296. }
  297. private final Image img = getImage("http://i1138.photobucket.com/albums/n528/fag3xx/fletcher-1.png");
  298.  
  299. public void onRepaint(Graphics render) {
  300. Graphics2D g = (Graphics2D) render;
  301. Point m = mouse.getLocation();
  302.  
  303. unstrunghour= (int) (unstrung * (3600000D / runTime.getElapsed()));
  304. bowshour= (int) (bows * (3600000D / runTime.getElapsed()));
  305.  
  306. g.drawOval(m.x,m.y,8,8);
  307. g.drawImage(img, 0, 208, null);
  308. g.setColor(new Color(85, 48, 26));
  309.  
  310. g.drawString("Status: " + display, 10, 260);
  311.  
  312. if (status.equals("unstrung")) {
  313. expu = (fletchexp * unstrung) ;
  314. exphour= (int) (expu * (3600000D / runTime.getElapsed()));
  315. g.drawString("Unstrung made: " + unstrung, 40, 290);
  316. g.drawString("Unstrung/h: " + (int)unstrunghour, 40, 308);
  317. g.drawString("Exp gained: " + expu, 190, 290);
  318. g.drawString("Exp/h: " + (int)exphour, 190, 308);
  319. g.drawString("Exp to LvL: "+ skills.getExpToNextLevel(Skills.FLETCHING), 190, 324);
  320. }
  321.  
  322. if (status.equals("string")){
  323. exp = (stringexp * bows);
  324. exphour= (int) ((expu+exp) * (3600000D / runTime.getElapsed()));
  325. g.drawString("Bows made: " + bows, 40, 290);
  326. g.drawString("Unstrung made "+ unstrung, 40, 308);
  327. g.drawString("Exp gained: " + (expu + exp), 190, 290);
  328. g.drawString("Exp/h: " + (int)exphour, 190, 308);
  329. g.drawString("Exp to LvL: "+ skills.getExpToNextLevel(Skills.FLETCHING), 190, 324);
  330. }
  331.  
  332. g.drawString("Time Running: "+ runTime.toElapsedString(), 360, 290);
  333. g.drawString("Current LvL: "+ skills.getRealLevel(Skills.FLETCHING), 360, 308);
  334. g.drawString("% to LvL: "+ skills.getPercentToNextLevel(Skills.FLETCHING) + "%", 360, 324);
  335.  
  336. }
  337.  
  338. class gui extends JFrame {
  339. public gui() {
  340. initComponents();
  341. }
  342. private void button1ActionPerformed(ActionEvent e) {
  343. String type = comboBox2.getSelectedItem().toString();
  344. if(type.equals("longbow")){
  345. method = 0;
  346. }
  347. if(type.equals("shortbow")){
  348. method = 1;
  349. }
  350. String chosen = comboBox1.getSelectedItem().toString();
  351. if(chosen.equals("oak log")){
  352. logID = 1521;
  353. if(method == 0){
  354. unstrungID = 56;
  355. bowID = 845;
  356. child = 15;
  357. stringexp = 58;
  358. fletchexp = 58;
  359. }else{
  360. unstrungID = 54;
  361. bowID = 843;
  362. child = 14;
  363. stringexp = 50;
  364. fletchexp = 50;
  365. }
  366. }
  367. if(chosen.equals("willow log")){
  368. logID = 1519;
  369. if(method == 0){
  370. unstrungID =58;
  371. bowID = 847;
  372. child = 15;
  373. stringexp = 58;
  374. fletchexp = 58;
  375. }else{
  376. unstrungID = 60;
  377. bowID = 849;
  378. child = 14;
  379. stringexp = 50;
  380. fletchexp = 50;
  381. }
  382. }
  383. if(chosen.equals("maple log")){
  384. logID = 1517;
  385. if(method == 0){
  386. unstrungID = 62;
  387. bowID = 851;
  388. child = 15;
  389. stringexp = 58;
  390. fletchexp = 58;
  391. }else{
  392. unstrungID = 64;
  393. bowID = 853;
  394. child = 14;
  395. stringexp = 50;
  396. fletchexp = 50;
  397. }
  398. }
  399. if(chosen.equals("yew log")){
  400. logID = 1515;
  401. if(method == 0){
  402. unstrungID = 66;
  403. bowID = 855;
  404. child = 15;
  405. stringexp = 75;
  406. fletchexp = 75;
  407. }else{
  408. unstrungID = 68;
  409. bowID = 857;
  410. child = 14;
  411. stringexp = 67;
  412. fletchexp = 67;
  413. }
  414. }
  415. if(chosen.equals("magic log")){
  416. logID = 1513;
  417. if(method == 0){
  418. unstrungID = 70;
  419. bowID = 859;
  420. child = 15;
  421. stringexp = 91;
  422. fletchexp = 91;
  423. }else{
  424. unstrungID = 72;
  425. bowID = 861;
  426. child = 14;
  427. stringexp = 83;
  428. fletchexp = 83;
  429. }
  430. }
  431. guiwait = false;
  432. gu.dispose();
  433.  
  434. }
  435.  
  436. private void initComponents() {
  437. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  438. // Generated using JFormDesigner Open Source Project license - unknown
  439. dialogPane = new JPanel();
  440. contentPanel = new JPanel();
  441. label2 = new JLabel();
  442. label3 = new JLabel();
  443. comboBox1 = new JComboBox();
  444. comboBox2 = new JComboBox();
  445. button1 = new JButton();
  446. label1 = new JLabel();
  447.  
  448. //======== this ========
  449. Container contentPane = getContentPane();
  450. contentPane.setLayout(new BorderLayout());
  451.  
  452. //======== dialogPane ========
  453. {
  454. dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
  455. dialogPane.setLayout(new BorderLayout());
  456.  
  457. //======== contentPanel ========
  458. {
  459. contentPanel.setLayout(null);
  460.  
  461. //---- label2 ----
  462. label2.setText("Log type:");
  463. label2.setFont(new Font("Tahoma", Font.PLAIN, 14));
  464. contentPanel.add(label2);
  465. label2.setBounds(new Rectangle(new Point(5, 15), label2.getPreferredSize()));
  466.  
  467. //---- label3 ----
  468. label3.setText("Long/Short:");
  469. label3.setFont(new Font("Tahoma", Font.PLAIN, 14));
  470. contentPanel.add(label3);
  471. label3.setBounds(new Rectangle(new Point(5, 45), label3.getPreferredSize()));
  472.  
  473. //---- comboBox1 ----
  474. comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  475. "oak log",
  476. "willow log",
  477. "maple log",
  478. "yew log",
  479. "magic log"
  480. }));
  481. contentPanel.add(comboBox1);
  482. comboBox1.setBounds(105, 15, 95, comboBox1.getPreferredSize().height);
  483.  
  484. //---- comboBox2 ----
  485. comboBox2.setModel(new DefaultComboBoxModel(new String[] {
  486. "longbow",
  487. "shortbow"
  488. }));
  489. contentPanel.add(comboBox2);
  490. comboBox2.setBounds(105, 45, 95, comboBox2.getPreferredSize().height);
  491.  
  492. //---- button1 ----
  493. button1.setText("Start");
  494. button1.setFont(new Font("Tahoma", Font.PLAIN, 14));
  495. button1.addActionListener(new ActionListener() {
  496. public void actionPerformed(ActionEvent e) {
  497. button1ActionPerformed(e);
  498. }
  499. });
  500. contentPanel.add(button1);
  501. button1.setBounds(45, 75, 130, 35);
  502.  
  503. { // compute preferred size
  504. Dimension preferredSize = new Dimension();
  505. for(int i = 0; i < contentPanel.getComponentCount(); i++) {
  506. Rectangle bounds = contentPanel.getComponent(i).getBounds();
  507. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  508. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  509. }
  510. Insets insets = contentPanel.getInsets();
  511. preferredSize.width += insets.right;
  512. preferredSize.height += insets.bottom;
  513. contentPanel.setMinimumSize(preferredSize);
  514. contentPanel.setPreferredSize(preferredSize);
  515. }
  516. }
  517. dialogPane.add(contentPanel, BorderLayout.CENTER);
  518.  
  519. //---- label1 ----
  520. label1.setText("Fletcher by Fag3xx");
  521. label1.setFont(new Font("Tahoma", Font.PLAIN, 18));
  522. label1.setHorizontalAlignment(SwingConstants.CENTER);
  523. dialogPane.add(label1, BorderLayout.NORTH);
  524. }
  525. contentPane.add(dialogPane, BorderLayout.CENTER);
  526. pack();
  527. setLocationRelativeTo(getOwner());
  528. // JFormDesigner - End of component initialization //GEN-END:initComponents
  529. }
  530.  
  531. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  532. // Generated using JFormDesigner Open Source Project license - unknown
  533. private JPanel dialogPane;
  534. private JPanel contentPanel;
  535. private JLabel label2;
  536. private JLabel label3;
  537. private JComboBox comboBox1;
  538. private JComboBox comboBox2;
  539. private JButton button1;
  540. private JLabel label1;
  541. // JFormDesigner - End of variables declaration //GEN-END:variables
  542. }
  543. }
Advertisement
Add Comment
Please, Sign In to add comment