Himekp

ProWhiteBerries

May 23rd, 2011
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.37 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import java.awt.image.BufferedImage;
  5. import java.io.IOException;
  6. import java.net.MalformedURLException;
  7. import java.net.URL;
  8.  
  9. import javax.imageio.ImageIO;
  10. import javax.swing.*;
  11. import org.rsbot.event.events.MessageEvent;
  12. import org.rsbot.event.listeners.MessageListener;
  13. import org.rsbot.script.Script;
  14. import org.rsbot.script.ScriptManifest;
  15. import org.rsbot.script.wrappers.RSArea;
  16. import org.rsbot.script.wrappers.RSGroundItem;
  17. import org.rsbot.script.wrappers.RSObject;
  18. import org.rsbot.script.wrappers.RSTile;
  19.  
  20. @ScriptManifest(authors = "Himekp", keywords = "White Berries", name = "ProWhiteBerries", version = 1.03, description = "ProWhiteBerries, By: Himekp", website = "http://dl.dropbox.com/u/27626614/ProFisher.java")
  21. public class ProWhiteBerries2 extends Script implements MessageListener {
  22. public boolean invyisfull = false;
  23. private int[] gamesnecklaceIDs = {3853, 3855, 3857, 3859, 3861, 3863, 3865, 3867};
  24. public int[] dontBank = { 563, 3853, 3855, 3857, 3859, 3861, 3863, 3865, 3867, 1706, 1708, 1710, 1712 };
  25. public int gamesnecklace = 3853;
  26. public int laws = 563;
  27. public int[] glories = { 1706, 1708, 1710, 1712 };
  28. public int glory = 1712;
  29. public int berry = 239;
  30. public int teleportAnim = 9603;
  31. public String status = "";
  32. public String GettingThere = "";
  33. public String GettingBack = "";
  34. public String Method = "";
  35. public int mouseSpeed;
  36. boolean start;
  37. public boolean guiWait = true, guiExit = false;
  38. ProWhiteBerriesGUI gui;
  39. private boolean startScript;
  40. BufferedImage normal = null;
  41. BufferedImage clicked = null;
  42.  
  43. public boolean onStart(){
  44. log(Color.blue, "Welcome to Himekp's ProWhiteBerries");
  45. log(Color.red, "Check for updates by right clicking my script!");
  46. log(Color.red, "Then check the version and if it isn't V1.3 then theres an update!");
  47. log("Loading GUI...Please wait...");
  48. try {
  49. final URL cursorURL = new URL("http://i48.tinypic.com/313623n.png");
  50. final URL cursor80URL = new URL("http://i46.tinypic.com/9prjnt.png");
  51. normal = ImageIO.read(cursorURL);
  52. clicked = ImageIO.read(cursor80URL);
  53. } catch (MalformedURLException e) {
  54. log("Unable to buffer cursor.");
  55. } catch (IOException e) {
  56. log("Unable to open cursor image.");
  57. }
  58. gui = new ProWhiteBerriesGUI();
  59. gui.setVisible(true);
  60. log(Color.green, "The higher the Mouse Speed is, the faster your mouse is! Speed 6 is recomended!");
  61. startScript = true;
  62. while (!startScript) {
  63. sleep(10);
  64. }
  65. return true;
  66. }
  67.  
  68. public void onFinish(){
  69.  
  70. }
  71.  
  72. public boolean atSpot(){
  73. RSArea area = new RSArea(new RSTile(3200, 3745), new RSTile(3210, 3756));
  74. return area.contains(getMyPlayer().getLocation());
  75. }
  76.  
  77. private boolean berriesToCave(){
  78. RSTile tile = new RSTile(3214, 3782);
  79. web.generateRoute(getMyPlayer().getLocation(), tile).execute();
  80. return true;
  81. }
  82.  
  83. public boolean atEdge(){
  84. RSArea area = new RSArea(new RSTile(3082, 3485), new RSTile(3140, 3520));
  85. return area.contains(getMyPlayer().getLocation());
  86. }
  87.  
  88. public boolean atBank(){
  89. RSArea area = new RSArea(new RSTile(3091, 3488), new RSTile(3099, 3499));
  90. return area.contains(getMyPlayer().getLocation());
  91. }
  92.  
  93. private boolean atBerries() {
  94. RSArea area = new RSArea(new RSTile(3216, 3804), new RSTile(3224, 3809));
  95. return area.contains(getMyPlayer().getLocation());
  96. }
  97.  
  98. private boolean atCave(){
  99. RSArea area = new RSArea(new RSTile(3208, 3779), new RSTile(3217, 3785));
  100. return area.contains(getMyPlayer().getLocation());
  101. }
  102.  
  103. public boolean bank(){
  104. bank.open();
  105. sleep(800, 2400);
  106. bank.depositAllExcept(dontBank);
  107. if(!inventory.containsOneOf(glories)){
  108. bank.withdraw(glory, 1);
  109. }
  110. if(!inventory.contains(laws)){
  111. bank.withdraw(laws, 50);
  112. }
  113. if(!inventory.containsOneOf(gamesnecklaceIDs)){
  114. bank.withdraw(gamesnecklace, 1);
  115. }
  116. bank.close();
  117. sleep(2500, 3000);
  118. return true;
  119. }
  120.  
  121. private void telegrabBerries() {
  122. RSGroundItem berries = groundItems.getNearest(berry);
  123. camera.setPitch(true);
  124. camera.setAngle(random(306,318));
  125. if (magic.isSpellSelected() == false){
  126. magic.castSpell(44);
  127. }
  128. if (berries != null && berries.isOnScreen()){
  129. berries.doAction("Cast");
  130. sleep(2500,3000);
  131. }
  132. if(berries == null){
  133. sleep(500);
  134. }
  135. }
  136.  
  137. public boolean teleport(){
  138. if(getMyPlayer().getAnimation() == teleportAnim){
  139. sleep(3500, 4000);
  140. }
  141. if(inventory.containsOneOf(glories)){
  142. inventory.getItem(glories).doAction("Rub");
  143. sleep(1500, 2000);
  144. if(interfaces.get(238).isValid()){
  145. interfaces.getComponent(238, 1).doClick();
  146. sleep(3000, 3500);
  147. }
  148. }
  149. return true;
  150. }
  151.  
  152. private void teleportgames() {
  153. if(getMyPlayer().getAnimation() == teleportAnim){
  154. sleep(3500, 4000);
  155. }
  156. if (inventory.containsOneOf(gamesnecklaceIDs)) {
  157. inventory.getItem(gamesnecklaceIDs).doAction("Rub Games necklace");
  158. sleep(1000);
  159. if (interfaces.getComponent(238, 4).isValid()) {
  160. interfaces.getComponent(238, 4).doClick();
  161. }else{
  162. sleep(300);
  163. }
  164.  
  165. sleep(300, 350);
  166. }
  167. }
  168.  
  169. public void messageReceived(MessageEvent e){
  170. String message = e.getMessage();
  171. if(message.contains("You don't have enough")) {
  172. invyisfull = true;
  173. berriesToCave();
  174. }
  175. if(message.contains("You do not have enough Law Runes")) {
  176. invyisfull = true;
  177. berriesToCave();
  178. }
  179. }
  180.  
  181. public boolean gotoBerries(){
  182. if(!atBerries()){
  183. RSTile tile = new RSTile(3220, 3807);
  184. web.generateRoute(getMyPlayer().getLocation(), tile).execute();
  185. }
  186. return true;
  187. }
  188.  
  189. public boolean gothroughcave(){
  190. RSObject cave = objects.getNearest(37928);
  191. if (cave != null && cave.isOnScreen()) {
  192. cave.doAction("Go-through");
  193. sleep(3000,3500);
  194. }
  195. return true;
  196. }
  197.  
  198. public boolean gothroughCave(){
  199. RSObject cave = objects.getNearest(38815);
  200. if (cave != null && cave.isOnScreen()) {
  201. cave.doAction("Go-through");
  202. sleep(3000,3500);
  203. }
  204. return true;
  205. }
  206.  
  207. public boolean walktobank(){
  208. if(!atBank()){
  209. RSTile tile = new RSTile(3093, 3490);
  210. web.generateRoute(getMyPlayer().getLocation(), tile).execute();
  211. }
  212. return true;
  213. }
  214.  
  215.  
  216. public int loop(){
  217. if(invyisfull == true && !atSpot()){
  218. RSTile tile = new RSTile(3204, 3750);
  219. web.generateRoute(getMyPlayer().getLocation(), tile).execute();
  220. }
  221. if (atBerries() && !getMyPlayer().getLocation().equals(new RSTile(3219, 3806)) && !inventory.isFull() && invyisfull == false) {
  222. walking.walkTileOnScreen(new RSTile(3219, 3806));
  223. sleep(1000,1200);
  224. }
  225.  
  226. if (getMyPlayer().getLocation().equals(new RSTile(3219, 3806)) && atBerries() && invyisfull == false) {
  227. telegrabBerries();
  228. while (getMyPlayer().getAnimation() == 723) {
  229. sleep(200);
  230. }
  231. }
  232. if (atBank() && !inventory.isFull() && inventory.containsOneOf(glories) && inventory.containsOneOf(gamesnecklaceIDs) && inventory.contains(laws)){
  233. teleportgames();
  234. }
  235. if(game.getPlane() == 2 && !inventory.isFull()){
  236. RSObject cave = objects.getNearest(37928);
  237. if (cave != null && cave.isOnScreen()) {
  238. cave.doAction("Go-through");
  239. sleep(3000,3500);
  240. }
  241. else if(!cave.isOnScreen()){
  242. walking.walkTo(cave.getLocation());
  243. sleep(800, 2600);
  244. }
  245. }
  246. if(!atBerries() && !inventory.isFull() && invyisfull == false){
  247. gotoBerries();
  248. }
  249. if(!atBank() && atEdge() && invyisfull == true){
  250. walktobank();
  251. }
  252. if(atBank() && inventory.isFull() && atEdge()){
  253. bank();
  254. invyisfull = false;
  255. }
  256. if(atCave() && inventory.isFull()){
  257. RSObject cave = objects.getNearest(38815);
  258. if (cave != null && cave.isOnScreen()) {
  259. cave.doAction("Go-through");
  260. sleep(3000,3500);
  261. }
  262. else if(!cave.isOnScreen()){
  263. walking.walkTo(cave.getLocation());
  264. sleep(800, 2600);
  265. }
  266. }
  267. if(atSpot() && invyisfull == true){
  268. teleport();
  269. }
  270.  
  271. return 10;
  272. }
  273.  
  274. public class ProWhiteBerriesGUI extends JPanel {
  275. private static final long serialVersionUID = 1L;
  276. public ProWhiteBerriesGUI() {
  277. initComponents();
  278. }
  279.  
  280. private void button1ActionPerformed(ActionEvent e) {
  281. GettingThere = comboBox1.getSelectedItem().toString();
  282. GettingBack = comboBox2.getSelectedItem().toString();
  283. Method = comboBox3.getSelectedItem().toString();
  284. mouseSpeed = slider1.getValue();
  285.  
  286. if (slider1.getValue() == 10) {
  287. mouseSpeed = 1;
  288. } else if (slider1.getValue() == 9) {
  289. mouseSpeed = 2;
  290. } else if (slider1.getValue() == 8) {
  291. mouseSpeed = 3;
  292. } else if (slider1.getValue() == 7) {
  293. mouseSpeed = 4;
  294. } else if (slider1.getValue() == 6) {
  295. mouseSpeed = 5;
  296. } else if (slider1.getValue() == 5) {
  297. mouseSpeed = 6;
  298. } else if (slider1.getValue() == 4) {
  299. mouseSpeed = 7;
  300. } else if (slider1.getValue() == 3) {
  301. mouseSpeed = 8;
  302. } else if (slider1.getValue() == 2) {
  303. mouseSpeed = 9;
  304. } else if (slider1.getValue() == 1) {
  305. mouseSpeed = 10;
  306. } else if (slider1.getValue() == 0) {
  307. mouseSpeed = 11;
  308. }
  309. start = true;
  310. guiWait = false;
  311. frame1.dispose();
  312. }
  313.  
  314. private void initComponents() {
  315. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  316. // Generated using JFormDesigner Evaluation license - Joe Carter
  317. frame1 = new JFrame();
  318. label1 = new JLabel();
  319. label2 = new JLabel();
  320. label3 = new JLabel();
  321. comboBox1 = new JComboBox();
  322. button1 = new JButton();
  323. slider1 = new JSlider();
  324. label4 = new JLabel();
  325. label5 = new JLabel();
  326. comboBox2 = new JComboBox();
  327. label7 = new JLabel();
  328. comboBox3 = new JComboBox();
  329.  
  330. //======== frame1 ========
  331. {
  332. Container frame1ContentPane = frame1.getContentPane();
  333. frame1ContentPane.setLayout(null);
  334. frame1.setVisible(true);
  335. frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  336.  
  337. //---- label1 ----
  338. label1.setText("ProWhiteBerries");
  339. label1.setFont(new Font("Aerosol", Font.BOLD, 32));
  340. frame1ContentPane.add(label1);
  341. label1.setBounds(new Rectangle(new Point(5, 10), label1.getPreferredSize()));
  342.  
  343. //---- label2 ----
  344. label2.setText("By: Himekp");
  345. label2.setFont(new Font("Aerosol", Font.PLAIN, 28));
  346. frame1ContentPane.add(label2);
  347. label2.setBounds(new Rectangle(new Point(115, 40), label2.getPreferredSize()));
  348.  
  349. //---- label3 ----
  350. label3.setText("Getting There:");
  351. label3.setFont(new Font("Tahoma", Font.PLAIN, 22));
  352. label3.setEnabled(false);
  353. frame1ContentPane.add(label3);
  354. label3.setBounds(new Rectangle(new Point(10, 80), label3.getPreferredSize()));
  355.  
  356. //---- comboBox ----
  357. frame1ContentPane.add(comboBox1);
  358. comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  359. "Canoe Method",
  360. "Games Necklace"
  361. }));
  362. comboBox1.setBounds(155, 80, 130, 26);
  363.  
  364. //---- button1 ----
  365. button1.setText("Start");
  366. button1.addActionListener(new ActionListener() {
  367. @Override
  368. public void actionPerformed(ActionEvent e) {
  369. button1ActionPerformed(e);
  370. }
  371. });
  372. button1.setFont(button1.getFont().deriveFont(button1.getFont().getSize() + 13f));
  373. frame1ContentPane.add(button1);
  374. button1.setBounds(5, 255, 295, 80);
  375.  
  376. //---- slider1 ----
  377. slider1.setPaintLabels(true);
  378. slider1.setPaintTicks(true);
  379. slider1.setSnapToTicks(true);
  380. slider1.setMajorTickSpacing(1);
  381. slider1.setMaximum(10);
  382. slider1.setValue(5);
  383. frame1ContentPane.add(slider1);
  384. slider1.setBounds(5, 205, 295, slider1.getPreferredSize().height);
  385.  
  386. //---- label4 ----
  387. label4.setText("Mouse Speed");
  388. label4.setEnabled(false);
  389. label4.setFont(new Font("Tahoma", Font.PLAIN, 22));
  390. frame1ContentPane.add(label4);
  391. label4.setBounds(new Rectangle(new Point(95, 175), label4.getPreferredSize()));
  392.  
  393. //---- label5 ----
  394. label5.setText("Getting Back:");
  395. label5.setEnabled(false);
  396. label5.setFont(new Font("Tahoma", Font.PLAIN, 22));
  397. frame1ContentPane.add(label5);
  398. label5.setBounds(new Rectangle(new Point(10, 110), label5.getPreferredSize()));
  399.  
  400. //---- comboBox2 ----
  401. frame1ContentPane.add(comboBox2);
  402. comboBox2.setModel(new DefaultComboBoxModel(new String[] {
  403. "Glory",
  404. "V-Tele Tab"
  405. }));
  406. comboBox2.setBounds(145, 110, 140, 25);
  407.  
  408. //---- label7 ----
  409. label7.setText("Method:");
  410. label7.setEnabled(false);
  411. label7.setFont(new Font("Tahoma", Font.PLAIN, 22));
  412. frame1ContentPane.add(label7);
  413. label7.setBounds(10, 140, 95, 25);
  414.  
  415. //---- comboBox3
  416. frame1ContentPane.add(comboBox3);
  417. comboBox3.setModel(new DefaultComboBoxModel(new String[] {
  418. "Telegrab",
  419. "Normal Walking Pickup"
  420. }));
  421. comboBox3.setBounds(95, 140, 190, 25);
  422.  
  423. { // compute preferred size
  424. Dimension preferredSize = new Dimension();
  425. for(int i = 0; i < frame1ContentPane.getComponentCount(); i++) {
  426. Rectangle bounds = frame1ContentPane.getComponent(i).getBounds();
  427. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  428. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  429. }
  430. Insets insets = frame1ContentPane.getInsets();
  431. preferredSize.width += insets.right;
  432. preferredSize.height += insets.bottom;
  433. frame1ContentPane.setMinimumSize(preferredSize);
  434. frame1ContentPane.setPreferredSize(preferredSize);
  435. }
  436. frame1.pack();
  437. frame1.setLocationRelativeTo(frame1.getOwner());
  438. }
  439. // JFormDesigner - End of component initialization //GEN-END:initComponents
  440. }
  441.  
  442. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  443. // Generated using JFormDesigner Evaluation license - Joe Carter
  444. private JFrame frame1;
  445. private JLabel label1;
  446. private JLabel label2;
  447. private JLabel label3;
  448. private JComboBox comboBox1;
  449. private JButton button1;
  450. private JSlider slider1;
  451. private JLabel label4;
  452. private JLabel label5;
  453. private JComboBox comboBox2;
  454. private JLabel label7;
  455. private JComboBox comboBox3;
  456. // JFormDesigner - End of variables declaration //GEN-END:variables
  457. }
  458.  
  459. }
Advertisement
Add Comment
Please, Sign In to add comment