Thondar

dsa

Oct 9th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.36 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.imageio.ImageIO;
  3. import java.io.IOException;
  4. import java.net.MalformedURLException;
  5. import java.net.URL;
  6. import org.rsbot.event.listeners.PaintListener;
  7. import org.rsbot.script.*;
  8. import org.rsbot.script.methods.Equipment;
  9. import org.rsbot.script.methods.Game;
  10. import org.rsbot.script.methods.Magic;
  11. import org.rsbot.script.util.Filter;
  12. import org.rsbot.script.wrappers.*;
  13. import java.awt.image.BufferedImage;
  14.  
  15. import java.awt.event.*;
  16. import javax.swing.*;
  17.  
  18.  
  19. @ScriptManifest(authors = {"Tarth, Thondar"}, keywords = {"Cow, Hide, Lumbridge"}, name = "CowHider", description = "A Cowhide looter, loots cowhides near Lumbridge", version = 1.3)
  20.  
  21. public class CowHider extends Script implements PaintListener{
  22. int lumbridgecheck = 6539;
  23. int bankerID = 9710;
  24. int gateID = 45212;
  25. int cowhide = 1739;
  26. int bones = 526;
  27. int cowhideprice;
  28. int bonesprice;
  29. int bankerLU = 36786;
  30. int staircase1 = 36773;
  31. int staircase2 = 36774;
  32. int staircase3 = 36775;
  33. int luBankTop = 33505;
  34. private int[] closedGate = {45210,45212};
  35. String status;
  36. long starttime;
  37. public int Inventory = 0;
  38. public int bonesInv = 0;
  39. public int hidesgot;
  40. public int bonesgot;
  41. private boolean bankTele;
  42. RSTile lootpath = new RSTile(3256,3284);
  43. RSTile BankTile = new RSTile (3450,3717);
  44. RSTile LUBankTile = new RSTile (3206,3209);
  45. RSTile TopBankTile = new RSTile (3208,3220,2);
  46. RSTile cowpath = new RSTile(3252,3266);
  47.  
  48. BufferedImage normal = null;
  49. BufferedImage clicked = null;
  50.  
  51. private boolean restCheck;
  52. private boolean antibanCheck;
  53.  
  54. private boolean guiWait = true;
  55.  
  56. cowhider g = new cowhider();
  57.  
  58. @Override
  59. public boolean onStart() {
  60. try {
  61. final URL cursorURL = new URL(
  62. "http://i.imgur.com/zNRwd.png"); // This is the link of your mouse when it isn't clicked
  63. final URL cursor80URL = new URL(
  64. "http://i.imgur.com/4yNUQ.png"); // This is the link of your mouse when it is clicked
  65. normal = ImageIO.read(cursorURL);
  66. clicked = ImageIO.read(cursor80URL);
  67. } catch (MalformedURLException e) {
  68. log("Unable to buffer cursor.");
  69. } catch (IOException e) {
  70. log("Unable to open cursor image.");
  71. }
  72. mouse.setSpeed(random(4, 6));
  73. starttime = System.currentTimeMillis();
  74. g.setVisible(true);
  75. while(guiWait) sleep(500);
  76. walking.setRun(true);
  77. cowhideprice = grandExchange.lookup(cowhide).getGuidePrice();
  78. bonesprice = grandExchange.lookup(bones).getGuidePrice();
  79. atLumbridge();
  80. if (atLumbridge() == false && atField() == false && atGate() == false){
  81. lumbridgeTeleport();
  82. }
  83. return true;
  84. }
  85.  
  86. public void lumbridgeTeleport(){
  87. final int lumbridge = Magic.SPELL_HOME_TELEPORT;
  88. if (players.getMyPlayer().getAnimation() == -1)
  89. magic.castSpell(lumbridge);
  90. sleep(1250, 1750);
  91. status = ("Teleporting...");
  92.  
  93. }
  94.  
  95. private void moveToCowField() {
  96. if (restCheck == true) {
  97. rest();
  98. }
  99. walking.getPath(cowpath).traverse();
  100. status = ("Moving to field...");
  101. }
  102.  
  103.  
  104. public boolean openGate() {
  105. status = ("Looting...");
  106. RSObject x = objects.getNearest(closedGate);
  107. if (x != null && x.isOnScreen())
  108. {
  109. return x.doClick();
  110. }
  111. return false;
  112. }
  113.  
  114. public boolean atLumbridge(){
  115. RSArea LUArea = new RSArea(new RSTile(3201, 3201), new RSTile(3249,
  116. 3273));
  117. return LUArea.contains(getMyPlayer().getLocation());
  118. }
  119.  
  120. public boolean atLumbridgeTop(){
  121. RSObject BankTop = objects.getNearest(luBankTop);
  122. if(BankTop != null)
  123. if(BankTop.isOnScreen());
  124. return true;
  125. }
  126.  
  127. public boolean atField(){
  128. RSArea TopArea = new RSArea(new RSTile(3250, 3255), new RSTile(3265, 3299));
  129. return TopArea.contains(getMyPlayer().getLocation());
  130. }
  131.  
  132. public boolean atField2(){
  133. RSArea TopArea = new RSArea(new RSTile(3239, 3278), new RSTile(3252, 3298));
  134. return TopArea.contains(getMyPlayer().getLocation());
  135. }
  136.  
  137. public boolean atGate(){
  138. RSArea TopArea = new RSArea(new RSTile(3247, 3256), new RSTile(3252, 3271));
  139. return TopArea.contains(getMyPlayer().getLocation());
  140. }
  141.  
  142. public boolean atDaem(){
  143. RSArea DaemArea = new RSArea(new RSTile(3391, 3651),
  144. new RSTile(3490, 3773));
  145. return DaemArea.contains(getMyPlayer().getLocation());
  146. }
  147.  
  148. public void bankLumbridge() {
  149. RSObject stairs = objects.getNearest(staircase1, staircase2);
  150. if (restCheck == true) {
  151. rest();
  152. }
  153. if(stairs.isOnScreen())
  154. stairs.interact("Climb-up Staircase");
  155. sleep(300, 500);
  156. }
  157.  
  158. public void bankLumbridgeTop() {
  159. RSObject banker = objects.getNearest(bankerLU);
  160. RSObject stairs = objects.getNearest(staircase2);
  161. if (restCheck == true) {
  162. rest();
  163. }
  164. if(stairs != null)
  165. if(stairs.isOnScreen())
  166. stairs.interact("Climb-up Staircase");
  167. sleep(300, 500);
  168. if (bank.isOpen()) {
  169. bank.depositAll();
  170. Inventory = inventory.getCount(cowhide);
  171. hidesgot += Inventory;
  172. bonesInv = inventory.getCount(bones);
  173. bonesgot += bonesInv;
  174. sleep(800, 1100);
  175. bank.close();
  176. } else {
  177. if(banker != null) {
  178. if(banker.isOnScreen())
  179. banker.interact("Use-quickly Bank booth");{
  180. } sleep(1800, 2100);
  181. }else{
  182. walking.getPath(TopBankTile);
  183. }
  184. }
  185. }
  186.  
  187. private void rest() {
  188. if(restCheck == true);
  189. if(walking.getEnergy() < 30)
  190. walking.rest(random(70,95));
  191. }
  192.  
  193. public void loot(){
  194. RSGroundItem hide = groundItems.getNearest(cowhide);
  195. if (restCheck == true) {
  196. rest();
  197. }
  198. if(!inventory.isFull())
  199. if(hide != null) {
  200. if(hide.isOnScreen()){
  201. hidePickup();
  202. status = ("Looting...");
  203. if (hide.interact("Take")){
  204. sleep(800,1000);
  205. while(getMyPlayer().isMoving())
  206. sleep(100,150);
  207. antiBan();
  208. sleep(150, 250);
  209. }
  210. } else {
  211. walking.walkTileMM(new RSTile(hide.getLocation().getX(), hide.getLocation().getY()));
  212. }
  213. }
  214. else {
  215. walking.getPath(lootpath).traverse();
  216. }
  217. }
  218.  
  219. private void antiBan() {
  220.  
  221. int r = random(0, 25);
  222. switch (r) {
  223. case 1:
  224. if (r == 2) {
  225. mouse.moveSlightly();
  226. sleep(500, 800);
  227. }
  228. break;
  229. case 2:
  230. if (r == 6) {
  231. camera.moveRandomly(random(450, 750));
  232. }
  233. break;
  234. }
  235. }
  236.  
  237.  
  238. public void Bank() {
  239. status = ("Banking...");
  240. RSNPC banker = npcs.getNearest(bankerID);
  241. if (bank.isOpen()) {
  242. bank.depositAll();
  243. Inventory = inventory.getCount(cowhide);
  244. hidesgot += Inventory;
  245. bonesInv = inventory.getCount(bones);
  246. bonesgot += bonesInv;
  247. sleep(800, 1100);
  248. bank.close();
  249. } else {
  250. if(banker != null) {
  251. if(banker.isOnScreen())
  252. banker.interact("Bank Fremennik banker");{
  253. } sleep(1800, 2100);
  254. } else {
  255. walking.getPath(BankTile).traverse();
  256. }
  257. }
  258. }
  259.  
  260. private void teleport() {
  261. status = ("Teleporting...");
  262. if (game.getCurrentTab() != Game.TAB_EQUIPMENT) {
  263. game.openTab(Game.TAB_EQUIPMENT);
  264. sleep(random(300, 600));
  265. }
  266. interfaces.get(Equipment.INTERFACE_EQUIPMENT)
  267. .getComponent(Equipment.RING).interact("Teleport");
  268. sleep(750, 1250);
  269. }
  270.  
  271.  
  272. private RSGroundItem hidePickup() {
  273. return groundItems.getNearest(new Filter<RSGroundItem>() {
  274. public boolean accept(RSGroundItem g) {
  275. return g.getItem().getID() == cowhide;
  276. }
  277. });
  278. }
  279.  
  280. public int loop() {
  281. if(atLumbridge() && !inventory.isFull()) {
  282. moveToCowField();
  283. return 0;}
  284. if(atField() && !inventory.isFull()) {
  285. loot();
  286. openGate();
  287. return 0;}
  288. if(atField2() && !inventory.isFull()) {
  289. loot();
  290. return 0;}
  291. if(atDaem() && !inventory.isFull()) {
  292. lumbridgeTeleport();
  293. return 0;}
  294. if(atDaem() && inventory.isFull()) {
  295. walking.walkTo(BankTile);
  296. Bank();
  297. return 0;}
  298. if(atLumbridgeTop() && !inventory.isFull()) {
  299. lumbridgeTeleport();
  300. return 0;}
  301. if(atLumbridge() && inventory.isFull()) {
  302. walking.walkTileMM(LUBankTile);
  303. bankLumbridge();
  304. return 0;}
  305. if(atField() && inventory.isFull() && bankTele == true) {
  306. if (players.getMyPlayer().getAnimation() == -1)
  307. lumbridgeTeleport();
  308. sleep(900, 1300);
  309. return 0;}
  310. if(atField() && inventory.isFull() && bankTele == false) {
  311. if (players.getMyPlayer().getAnimation() == -1)
  312. teleport();
  313. sleep(900, 1300);
  314. return 0;}
  315. if(atField2() && inventory.isFull() && bankTele == false) {
  316. if (players.getMyPlayer().getAnimation() == -1)
  317. teleport();
  318. sleep(900, 1300);
  319. return 0;}
  320. if(atLumbridgeTop() && inventory.isFull()) {
  321. bankLumbridgeTop();
  322. return 0;}
  323. if(antibanCheck == true) {
  324. antiBan();
  325. }
  326. return random(500, 1500);
  327. }
  328.  
  329. @Override
  330. public void onFinish() {
  331. env.saveScreenshot(true);
  332. }
  333.  
  334. // --------------- PAINT --------------- //
  335.  
  336. private Image getImage(String url) {
  337. try {
  338. return ImageIO.read(new URL(url));
  339. } catch(IOException e) {
  340. return null;
  341. }
  342. }
  343.  
  344. private final Color color1 = new Color(150, 110, 75);
  345.  
  346. private final Font font1 = new Font("Calibri", 0, 18);
  347.  
  348. private final Image img1 = getImage("http://i.imgur.com/Rxa1A.jpg");
  349. private final Image img2 = getImage("http://i.imgur.com/pzrmW.gif");
  350. private final Image img3 = getImage("http://i.imgur.com/cwGcs.gif");
  351. private final Image img4 = getImage("http://i.imgur.com/wJiPx.png");
  352. private final Image img5 = getImage("http://imageshack.us/m/713/2005/cooltext524990002.png");
  353. private final Image img6 = getImage("http://imageshack.us/m/29/834/cooltext524988541.png");
  354. private final Image img7 = getImage("http://imageshack.us/m/811/825/cooltext524990524.png");
  355. private final Image img8 = getImage("http://imageshack.us/m/36/5995/cooltext524986645.png");
  356. private final Image img9 = getImage("http://imageshack.us/m/7/4655/cooltext524991734.png");
  357. private final Image img14 = getImage("http://i.imgur.com/eUH7L.png");
  358. private final Image img15 = getImage("http://i.imgur.com/JWplE.png");
  359. private final Image img16 = getImage("http://i.imgur.com/aUisg.png");
  360.  
  361. public void onRepaint(Graphics g1) {
  362.  
  363. long millis = System.currentTimeMillis() - starttime;
  364. long hours = millis / (1000 * 60 * 60);
  365. millis -= hours * (1000 * 60 * 60);
  366. long minutes = millis / (1000 * 60);
  367. millis -= minutes * (1000 * 60);
  368. long seconds = millis / 1000;
  369.  
  370. float hidesec = 0;
  371. if ((minutes > 0 || hours > 0 || seconds > 0) && hidesgot > 0) {
  372. hidesec = ((float) hidesgot)/(float)(seconds + (minutes*60) + (hours*60*60));
  373. }
  374.  
  375. float bonessec = 0;
  376. if ((minutes > 0 || hours > 0 || seconds > 0) && bonesgot > 0) {
  377. bonessec = ((float) bonesgot)/(float)(seconds + (minutes*60) + (hours*60*60));
  378. }
  379.  
  380. float bonesmin = bonessec * 60;
  381. float bboneshour = bonesmin * 60;
  382. float bgoldhour = bboneshour * bonesprice;
  383. float hidemin = hidesec * 60;
  384. float hhidehour = hidemin * 60;
  385. float hgoldhour = hhidehour * cowhideprice;
  386. float agoldhour = bgoldhour + hgoldhour;
  387. int agoldearned = hidesgot * cowhideprice;
  388. int bgoldearned = bonesgot * bonesprice;
  389. int goldearned = agoldearned + bgoldearned;
  390. int hidehour = Math.round(hhidehour);
  391. int goldhour = Math.round(agoldhour);
  392.  
  393. Graphics2D g = (Graphics2D)g1;
  394. g.drawImage(img1, 7, 345, null);
  395. g.drawImage(img2, 11, 439, null);
  396. g.drawImage(img3, 9, 392, null);
  397. g.drawImage(img4, 10, 349, null);
  398. g.setFont(font1);
  399. g.setColor(color1);
  400. g.drawString(+ hours + ":" + minutes + ":" + seconds, 70, 371);
  401. g.drawString("" + status, 240, 371);
  402. g.drawString("" + goldearned, 70, 417);
  403. g.drawString("" + goldhour, 240, 417);
  404. g.drawString("" + hidesgot, 70, 462);
  405. g.drawString("" + hidehour, 240, 462);
  406. g.drawImage(img5, -4, 342, null);
  407. g.drawImage(img5, -4, 388, null);
  408. g.drawImage(img6, -25, 304, null);
  409. g.drawImage(img6, -25, 343, null);
  410. g.drawImage(img7, 371, 327, null);
  411. g.drawImage(img7, 200, 327, null);
  412. g.drawImage(img7, 33, 328, null);
  413. g.drawImage(img8, -19, 249, null);
  414. g.drawImage(img6, -25, 380, null);
  415. g.drawImage(img6, 488, 302, null);
  416. g.drawImage(img6, 488, 338, null);
  417. g.drawImage(img7, 371, 428, null);
  418. g.drawImage(img7, 33, 427, null);
  419. g.drawImage(img7, 200, 427, null);
  420. g.drawImage(img8, -18, 383, null);
  421. g.drawImage(img6, 488, 378, null);
  422. g.drawImage(img7, 371, 370, null);
  423. g.drawImage(img7, 371, 400, null);
  424. g.drawImage(img7, 200, 370, null);
  425. g.drawImage(img7, 200, 397, null);
  426. g.drawImage(img7, 371, 343, null);
  427. g.drawImage(img7, 200, 341, null);
  428. g.drawImage(img7, 33, 353, null);
  429. g.drawImage(img7, 33, 381, null);
  430. g.drawImage(img7, 33, 402, null);
  431. g.drawImage(img9, 28, 258, null);
  432. g.drawImage(img14, 144, 395, null);
  433. g.drawImage(img14, 144, 440, null);
  434. g.drawImage(img15, 316, 395, null);
  435. g.drawImage(img15, 316, 440, null);
  436. g.drawImage(img16, 398, 356, null);
  437.  
  438.  
  439. final Point p = mouse.getLocation();
  440. final Point c = mouse.getPressLocation();
  441. final long mpt = System.currentTimeMillis()- mouse.getPressTime();
  442. if (mouse.getPressTime() == -1 || mpt >= 1000) {
  443. g.drawImage(normal, p.x - 8, p.y - 8, null);
  444. }
  445. if (mpt < 2050) {
  446. g.drawImage(normal, p.x - 8, p.y - 8, null);
  447. g.drawImage(clicked, c.x - 8, c.y - 8, null);
  448. }
  449.  
  450.  
  451. }
  452.  
  453. class cowhider extends JFrame {
  454. public cowhider() {
  455. initComponents();
  456. }
  457.  
  458. private void startButtonActionPerformed(ActionEvent e) {
  459. String chosen = comboBox1.getSelectedItem().toString();
  460. if(chosen.equals("Lumbridge")) {
  461. bankTele = true;
  462. }else{
  463. bankTele = false;
  464. }
  465. if(checkBox1.isSelected()) {
  466. restCheck = true;
  467. }
  468. if(checkBox2.isSelected()) {
  469. antibanCheck = true;
  470. }
  471.  
  472. guiWait = false;
  473. g.dispose();
  474. }
  475.  
  476. private void initComponents() {
  477. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  478. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  479. label1 = new JLabel();
  480. comboBox1 = new JComboBox();
  481. label2 = new JLabel();
  482. startButton = new JButton();
  483. label3 = new JLabel();
  484. checkBox1 = new JCheckBox();
  485. checkBox2 = new JCheckBox();
  486.  
  487. //======== this ========
  488. Container contentPane = getContentPane();
  489.  
  490. //---- label1 ----
  491. label1.setText("Cowhider");
  492. label1.setFont(new Font("Calibri", Font.PLAIN, 30));
  493. label1.setHorizontalAlignment(SwingConstants.CENTER);
  494.  
  495. //---- comboBox1 ----
  496. comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  497. "Daemonheim"
  498. }));
  499.  
  500. //---- label2 ----
  501. label2.setText("Where to bank:");
  502.  
  503. //---- startButton ----
  504. startButton.setText("Start");
  505. startButton.addActionListener(new ActionListener() {
  506. @Override
  507. public void actionPerformed(ActionEvent e) {
  508. startButtonActionPerformed(e);
  509. }
  510. });
  511.  
  512. //---- label3 ----
  513. label3.setText("NB! Banking requiers a \"Ring of kinship\"");
  514. label3.setFont(new Font("Tahoma", Font.ITALIC, 11));
  515.  
  516. //---- checkBox1 ----
  517. checkBox1.setText("Rest");
  518.  
  519. //---- checkBox2 ----
  520. checkBox2.setText("Antiban");
  521.  
  522. GroupLayout contentPaneLayout = new GroupLayout(contentPane);
  523. contentPane.setLayout(contentPaneLayout);
  524. contentPaneLayout.setHorizontalGroup(
  525. contentPaneLayout.createParallelGroup()
  526. .addGroup(contentPaneLayout.createSequentialGroup()
  527. .addContainerGap()
  528. .addGroup(contentPaneLayout.createParallelGroup()
  529. .addComponent(startButton, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
  530. .addComponent(label1, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
  531. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  532. .addComponent(label2)
  533. .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
  534. .addComponent(comboBox1, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE))
  535. .addComponent(label3, GroupLayout.Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 262, GroupLayout.PREFERRED_SIZE)
  536. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  537. .addComponent(checkBox1, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)
  538. .addGap(28, 28, 28)
  539. .addComponent(checkBox2, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE)))
  540. .addContainerGap())
  541. );
  542. contentPaneLayout.setVerticalGroup(
  543. contentPaneLayout.createParallelGroup()
  544. .addGroup(contentPaneLayout.createSequentialGroup()
  545. .addContainerGap()
  546. .addComponent(label1)
  547. .addGap(18, 18, 18)
  548. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
  549. .addComponent(label2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  550. .addComponent(comboBox1, GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE))
  551. .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  552. .addComponent(label3)
  553. .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
  554. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  555. .addComponent(checkBox1)
  556. .addComponent(checkBox2))
  557. .addGap(18, 18, 18)
  558. .addComponent(startButton, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
  559. .addContainerGap())
  560. );
  561. pack();
  562. setLocationRelativeTo(getOwner());
  563. // JFormDesigner - End of component initialization //GEN-END:initComponents
  564. }
  565.  
  566. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  567. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  568. private JLabel label1;
  569. private JComboBox comboBox1;
  570. private JLabel label2;
  571. private JButton startButton;
  572. private JLabel label3;
  573. private JCheckBox checkBox1;
  574. private JCheckBox checkBox2;
  575. // JFormDesigner - End of variables declaration //GEN-END:variables
  576. }
  577.  
  578.  
  579. }
Advertisement
Add Comment
Please, Sign In to add comment