BrownBirdScripts

BBgoldMiner v0.1.1

Apr 27th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.32 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Point;
  4. import java.awt.Polygon;
  5. import java.awt.Rectangle;
  6.  
  7. import org.powerbot.concurrent.Task;
  8. import org.powerbot.concurrent.strategy.Condition;
  9. import org.powerbot.concurrent.strategy.Strategy;
  10. import org.powerbot.game.api.ActiveScript;
  11. import org.powerbot.game.api.Manifest;
  12. import org.powerbot.game.api.methods.Calculations;
  13. import org.powerbot.game.api.methods.Tabs;
  14. import org.powerbot.game.api.methods.Walking;
  15. import org.powerbot.game.api.methods.Widgets;
  16. import org.powerbot.game.api.methods.input.Mouse;
  17. import org.powerbot.game.api.methods.interactive.Players;
  18. import org.powerbot.game.api.methods.node.Menu;
  19. import org.powerbot.game.api.methods.node.SceneEntities;
  20. import org.powerbot.game.api.methods.tab.Inventory;
  21. import org.powerbot.game.api.methods.tab.Skills;
  22. import org.powerbot.game.api.methods.widget.Camera;
  23. import org.powerbot.game.api.util.Random;
  24. import org.powerbot.game.api.util.Time;
  25. import org.powerbot.game.api.wrappers.Tile;
  26. import org.powerbot.game.api.wrappers.node.SceneObject;
  27. import org.powerbot.game.bot.event.MessageEvent;
  28. import org.powerbot.game.bot.event.listener.MessageListener;
  29. import org.powerbot.game.bot.event.listener.PaintListener;
  30.  
  31. import java.awt.*;
  32. import javax.imageio.ImageIO;
  33. import java.io.IOException;
  34. import java.net.URL;
  35.  
  36.  
  37. /**
  38. * @author BrownBirdScripts
  39. * @version 0.00
  40. * Copyright 2011 - 2012 All Rights Reserved
  41. * ONLY BrownBird may edit this script, no exception.
  42. * Website: www.brownbirdscripts.net78.net
  43. */
  44.  
  45. @Manifest(authors = { "BrownBirdScripts" }, name = "BBgoldMiner", description = "Mines gold ore for money.", version = 0.00, website = "http://www.brownbirdscripts.net78.net", premium = false)
  46. public class BBgoldMiner extends ActiveScript implements PaintListener, MessageListener{
  47.  
  48.  
  49.  
  50. //IDS
  51. final static private int[] goldOreRock = {9720, 9722};
  52. //final static private int[] goldOreRockUsed = {9725, 9723};
  53. final static private int bank = 11758;
  54. final static private int goldOre = 444;
  55.  
  56. //PAINT
  57. private int startExp = 0;
  58. private int expGained;
  59. public int mined;
  60. public int gems;
  61. String status = "";
  62. public long startTime = 0;
  63. public long millis = 0;
  64. public long hours = 0;
  65. public long minutes = 0;
  66. public long seconds = 0;
  67. public long last = 0;
  68. public int expHour = 0;
  69.  
  70. //TILES
  71. private Tile[] pathToBank = new Tile[] { new Tile(2977, 3238, 0),
  72. new Tile(2978, 3245, 0), new Tile(2978, 3251, 0),
  73. new Tile(2981, 3258, 0), new Tile(2989, 3267, 0),
  74. new Tile(2996, 3275, 0), new Tile(3001, 3279, 0),
  75. new Tile(3005, 3284, 0), new Tile(3006, 3294, 0),
  76. new Tile(3006, 3306, 0), new Tile(3006, 3314, 0),
  77. new Tile(3006, 3321, 0), new Tile(3006, 3327, 0),
  78. new Tile(3007, 3332, 0), new Tile(3007, 3338, 0),
  79. new Tile(3007, 3345, 0), new Tile(3007, 3352, 0),
  80. new Tile(3007, 3359, 0), new Tile(3011, 3356, 0)};
  81. private Tile[] pathToMine = new Tile[] {new Tile(3011, 3356, 0),
  82. new Tile(3007, 3359, 0), new Tile(3007, 3352, 0),
  83. new Tile(3007, 3345, 0), new Tile(3007, 3338, 0),
  84. new Tile(3007, 3332, 0), new Tile(3006, 3327, 0),
  85. new Tile(3006, 3321, 0), new Tile(3006, 3314, 0),
  86. new Tile(3006, 3306, 0), new Tile(3006, 3294, 0),
  87. new Tile(3005, 3284, 0), new Tile(3001, 3279, 0),
  88. new Tile(2996, 3275, 0), new Tile(2989, 3267, 0),
  89. new Tile(2981, 3258, 0), new Tile(2978, 3251, 0),
  90. new Tile(2978, 3245, 0), new Tile(2977, 3238, 0),
  91. new Tile(2976, 3234, 0),};
  92.  
  93.  
  94.  
  95. @Override
  96. protected void setup() {
  97.  
  98. startTime = System.currentTimeMillis();
  99. startExp = Skills.getExperience(Skills.MINING);
  100.  
  101. mineGold mG = new mineGold();
  102. Strategy mGStrategy = new Strategy(mG, mG);
  103. provide(mGStrategy);
  104.  
  105. walkToBank wB = new walkToBank();
  106. Strategy wBStrategy = new Strategy(wB, wB);
  107. provide(wBStrategy);
  108.  
  109. useBank uB = new useBank();
  110. Strategy uBStrategy = new Strategy(uB, uB);
  111. provide(uBStrategy);
  112.  
  113. walkToMine wM = new walkToMine();
  114. Strategy wMStrategy = new Strategy(wM, wM);
  115. provide(wMStrategy);
  116.  
  117. Antiban ab = new Antiban();
  118. Strategy abStrategy = new Strategy(ab, ab);
  119. provide(abStrategy);
  120.  
  121.  
  122. }
  123.  
  124. private class mineGold implements Task, Condition {
  125.  
  126. @Override
  127. public void run() {
  128. if(SceneEntities.getNearest(goldOreRock).isOnScreen()){
  129.  
  130. status = "Mining Gold Ore...";
  131. if(SceneEntities.getNearest(goldOreRock).validate()){
  132. final SceneObject LS = SceneEntities.getNearest(goldOreRock);
  133. if (LS != null) {
  134. if (Calculations.distance(Players.getLocal().getLocation(),
  135. LS.getLocation()) > 4) {
  136. Walking.walk(getNextPathTile(LS.getLocation().derive(
  137. Random.nextInt(-3, 3), Random.nextInt(-3, 3))));
  138. } else {
  139. interact(LS, "Mine");
  140. Time.sleep(Random.nextInt(5000, 8000));
  141.  
  142. }
  143. }
  144.  
  145. }
  146. }
  147. }
  148.  
  149. @Override
  150. public boolean validate() {
  151. return (Tabs.INVENTORY.open() && Players.getLocal().getAnimation() == -1);
  152. }
  153.  
  154. }
  155.  
  156. private class walkToBank implements Task, Condition {
  157.  
  158. @Override
  159. public void run() {
  160.  
  161. status = "Walking to bank";
  162. walkPath(pathToBank);
  163. }
  164.  
  165.  
  166. @Override
  167. public boolean validate() {
  168. return (Inventory.getCount() >=28 && Players.getLocal().getAnimation() == -1);
  169. }
  170.  
  171. }
  172.  
  173. private class useBank implements Task, Condition {
  174.  
  175. @Override
  176. public void run() {
  177. if(SceneEntities.getNearest(bank).isOnScreen()) {
  178. status = "Opening bank";
  179. final SceneObject LS = SceneEntities.getNearest(bank);
  180. if (LS != null) {
  181. if (Calculations.distance(Players.getLocal().getLocation(),
  182. LS.getLocation()) > 4) {
  183. Walking.walk(getNextPathTile(LS.getLocation().derive(
  184. Random.nextInt(-3, 3), Random.nextInt(-3, 3))));
  185. } else {
  186. interact(LS, "Bank");
  187. Time.sleep(Random.nextInt(2002, 3000));
  188. if(Widgets.get(762, 1).validate() && Inventory.getCount() >= 28) {
  189. Widgets.get(762, 34).click(true);
  190. Time.sleep(Random.nextInt(1200, 2000));
  191. Widgets.get(762, 45).click(true);
  192. Time.sleep(Random.nextInt(1200, 2000));
  193. Tabs.STATS.open();
  194.  
  195. }
  196. }
  197.  
  198. }
  199. }
  200.  
  201. }
  202.  
  203. @Override
  204. public boolean validate() {
  205. return (Inventory.getCount() >= 28 );
  206.  
  207. }
  208.  
  209. }
  210.  
  211.  
  212. private class walkToMine implements Task, Condition {
  213.  
  214. @Override
  215. public void run() {
  216.  
  217. status = "Walking to back to Mine";
  218. walkPath(pathToMine);
  219.  
  220. }
  221.  
  222. @Override
  223. public boolean validate() {
  224. return (Inventory.getCount(goldOre) == 0 && Players.getLocal().getAnimation() == -1 );
  225. }
  226.  
  227. }
  228.  
  229. private class Antiban implements Task, Condition {
  230.  
  231. @Override
  232. public void run() {
  233.  
  234.  
  235. switch (Random.nextInt(1, 588)) {
  236.  
  237. case 0:
  238. status = "Antiban";
  239. Camera.setAngle(Random.nextInt(-180, 180));
  240. case 119:
  241. status = "Antiban";
  242. Camera.setAngle(Random.nextInt(1, 150));
  243. case 289:
  244. status = "Antiban";
  245. Mouse.move(Random.nextInt(1, 500), Random.nextInt(1, 500));
  246. case 500:
  247. status = "Antiban";
  248. Mouse.move(Random.nextInt(1, 500), Random.nextInt(1, 500));
  249. case 3:
  250. status = "Antiban";
  251. Camera.setAngle(Random.nextInt(-180, 180));
  252. case 530:
  253. status = "Antiban";
  254. Mouse.move(Random.nextInt(1, 500), Random.nextInt(1, 500));
  255. }
  256. Time.sleep(Random.nextInt(100, 500));
  257. }
  258.  
  259. @Override
  260. public boolean validate() {
  261. return true;
  262. }
  263.  
  264. }
  265.  
  266. public void walkPath(final Tile... path) {
  267. if (Walking.getEnergy() > Random.nextInt(30, 50)) {
  268. Walking.setRun(true);
  269. }
  270. for (int i = path.length - 1; i >= 0; i--) {
  271. if (Calculations.distanceTo(path[i]) >= 15) {
  272. continue;
  273. }
  274. if (Walking.walk(path[i])) {
  275. break;
  276. }
  277. }
  278. }
  279.  
  280. private Tile getNextPathTile(final Tile tile) {
  281. final Tile pos = Players.getLocal().getLocation();
  282. return new Tile((int) (pos.getX() + (tile.getX() - pos.getX())
  283. * Random.nextDouble(.75D, .9D)),
  284. (int) (pos.getY() + (tile.getY() - pos.getY())
  285. * Random.nextDouble(.75D, .9D)), tile.getPlane());
  286. }
  287.  
  288. private boolean interact(final SceneObject l, final String action) {
  289. final java.awt.geom.Area a = new java.awt.geom.Area();
  290. for (final Polygon p : l.getBounds())
  291. a.add(new java.awt.geom.Area(p));
  292. final Rectangle bounds = a.getBounds();
  293. Point p;
  294. do {
  295. p = new Point(Random.nextGaussian(bounds.x,
  296. bounds.x + bounds.width, 20), Random.nextGaussian(bounds.y,
  297. bounds.y + bounds.height, 20));
  298. } while (!a.contains(p));
  299. Mouse.move(p.x, p.y);
  300. final String[] actions = Menu.getActions();
  301. if (actions.length > 0 && actions[0].contains(action)) {
  302. Mouse.click(true);
  303. return true;
  304. } else {
  305. for (final String item : actions) {
  306. if (item.contains(action)) {
  307. Mouse.click(false);
  308. Time.sleep(Random.nextInt(200, 400));
  309. return Menu.select(item);
  310. }
  311. }
  312. }
  313. return false;
  314. }
  315.  
  316. private Image getImage(String url) {
  317. try {
  318. return ImageIO.read(new URL(url));
  319. } catch(IOException e) {
  320. return null;
  321. }
  322. }
  323.  
  324. private final Color color1 = new Color(255, 255, 255);
  325.  
  326. private final Font font1 = new Font("Gnuolane Free", 0, 20);
  327.  
  328. private final Image img1 = getImage("http://i46.tinypic.com/311rng3.png");
  329.  
  330. public void onRepaint(Graphics g1) {
  331. Graphics2D g = (Graphics2D)g1;
  332. millis = System.currentTimeMillis() - startTime;
  333. hours = millis / (1000 * 60 * 60);
  334. millis -= hours * (1000 * 60 * 60);
  335. minutes = millis / (1000 * 60);
  336. millis -= minutes * (1000 * 60);
  337. seconds = millis / 1000;
  338. Point mLoc = Mouse.getLocation();
  339. g.setColor(Color.black);
  340. g.drawLine(mLoc.x, 0, mLoc.x, 502);
  341. g.drawLine(0, mLoc.y, 764, mLoc.y);
  342. expGained = Skills.getExperience(Skills.MINING) - startExp;
  343. expHour = (int) ((expGained) * 3600000D / (System.currentTimeMillis() - startTime));
  344. g.drawImage(img1, 1, 339, null);
  345. g.setFont(font1);
  346. g.setColor(color1);
  347. g.drawString(" "+ hours + ":" + minutes + ":" + seconds, 119, 430);
  348. g.drawString(" "+ expGained, 132, 448);
  349. g.drawString(" "+ expHour, 107, 469);
  350. g.drawString(" "+ mined, 324, 430);
  351. g.drawString(" "+ gems, 327, 450);
  352. g.drawString(" "+status, 282, 469);
  353. }
  354.  
  355. public void messageReceived(MessageEvent e) {
  356. String svrmsg = e.getMessage();
  357. if (svrmsg.contains("You just found") ) {
  358. gems++;
  359. }
  360. if(svrmsg.contains("You ma")) {
  361. mined++;
  362. }
  363. }
  364.  
  365.  
  366. }
Advertisement
Add Comment
Please, Sign In to add comment