Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.Color;
  2. import java.awt.Point;
  3. import java.awt.Graphics;
  4. import java.awt.*;
  5. import java.awt.event.KeyEvent;
  6. import java.util.List;
  7. import java.util.Map;
  8.  
  9. import org.rsbot.accessors.Model;
  10. import org.rsbot.accessors.RSAnimable;
  11. import org.rsbot.bot.Bot;
  12. import org.rsbot.event.events.ServerMessageEvent;
  13. import org.rsbot.event.listeners.PaintListener;
  14. import org.rsbot.event.listeners.ServerMessageListener;
  15. import org.rsbot.script.Calculations;
  16. import org.rsbot.script.Script;
  17. import org.rsbot.script.ScriptManifest;
  18. import org.rsbot.script.wrappers.RSNPC;
  19. import org.rsbot.script.wrappers.RSObject;
  20. import org.rsbot.script.wrappers.RSTile;
  21. // /code
  22. @ScriptManifest(authors = { "harnum" }, category = "Fishing", name = "HBarbBanker", version = 2.0,
  23.  
  24. description =
  25. "<html>" +
  26. "<body>" +
  27. "<h2><center>HBarbBanker v2.1</center></h2>" +
  28. "<br>" +
  29. "<center>By harnum</center>" +
  30. "<p>" +
  31. "<br><center> Drop fish?</center>" +
  32. "<br><center><select name='dropping'><option>True<option>False</select></center>" +
  33. "</body>" +
  34. "</html>"
  35. )
  36. public class HBarbBanker extends Script implements PaintListener, ServerMessageListener{
  37. final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
  38.  
  39. // Ints
  40. public int[] need = { 314, 309 }; // feathers and pole IDs
  41. public int mang = 328; // fishing spot id
  42. public int bankID = 26972;
  43. public int runEnergy = random(15, 40);
  44. public int amntcaught;
  45. public int xpg;
  46. public int startlevel, levelsgained;
  47.  
  48. public boolean drop;
  49.  
  50. // For paint
  51. public long startTime = System.currentTimeMillis();
  52.  
  53. // Tiles n such
  54. RSTile bankTile = new RSTile(3093, 3489);
  55. RSTile fishTile = new RSTile(3104, 3431);
  56. RSTile[] toBank = {new RSTile(3104,3431),new RSTile(3099,3434),new RSTile(3094,3439),new RSTile
  57.  
  58. (3091,3445),new RSTile(3090,3451),new RSTile(3090,3457),new RSTile(3087,3463),new RSTile(3093,3464),new
  59.  
  60. RSTile(3098,3468),new RSTile(3099,3474),new RSTile(3099,3480),new RSTile(3093,3484),new RSTile
  61.  
  62. (3090,3490),new RSTile(3094,3491)};
  63. RSTile[] toFish = reversePath(toBank);
  64.  
  65. public void onFinish(){
  66. return;
  67. }
  68.  
  69. public boolean onStart(Map<String, String> args){
  70. startlevel = skills.getCurrentSkillLevel(STAT_FISHING);
  71. if (args.get("dropping").equals("True")) {
  72. drop = true;
  73. log("Dropping fish.");
  74. } else {
  75. drop = false;
  76. log("Banking fish.");
  77. }
  78. return true;
  79. }
  80.  
  81. public int loop() {
  82. if (!inventoryContains(need)) {
  83. log("No rod/feathers, logging out!");
  84. logout();
  85. stopScript();
  86. }
  87. if (!isRunning() && getEnergy() >= runEnergy) {
  88. runEnergy = random(15, 40);
  89. setRun(true);
  90. wait(random(300, 700));
  91. }
  92. switch (getState()) {
  93. case BANK:
  94. bank.depositAllExcept(need);
  95. break;
  96. case OPEN_BANK:
  97. RSObject banky = getNearestObjectByID(bankID);
  98. if (banky != null) {
  99. RSTile loc = banky.getLocation();
  100. if (distanceTo(loc) >= 4) {
  101. walkTileMM(loc);
  102. wait(random(1000,1500));
  103. }
  104. if (!tileOnScreen(banky.getLocation()))
  105. turnToTile(banky.getLocation());
  106. atBank(banky);
  107. }
  108. wait(random(1800,2000));
  109. break;
  110. case WALK_TO_BANK:
  111. walkPathMM2(toBank,13);
  112. return random(1000,2000);
  113. //break;
  114. case WALK_TO_FISHING_AREA:
  115. walkPathMM2(toFish,13);
  116. return random(1000,2000);
  117. //break;
  118. case FISH:
  119. RSNPC mayne = getNearestNPCByID(mang);
  120. if (mayne != null) {
  121. RSTile mloc = mayne.getLocation();
  122. if (distanceTo(mloc) >= 4) {
  123. walkTileMM(mloc);
  124. wait(random(2000,3000));
  125. }
  126. if (!tileOnScreen(mloc))
  127. turnToTile(mloc);
  128. clickNPC(mayne, "Lure");
  129. wait(random(2000,3000));
  130. }
  131. break;
  132. case WAIT:
  133. wait(random(1000, 2000));
  134. antiBan();
  135. break;
  136. case DROP:
  137. dropAllExcept(need);
  138. break;
  139. }
  140. return random(300, 400);
  141. }
  142. //PAINT:
  143. private final Color color1 = new Color(0, 0, 0, 222);
  144. private final Color color2 = new Color(0, 0, 0);
  145. private final Color color3 = new Color(255, 255, 255);
  146. private final Color color4 = new Color(0, 0, 0, 143);
  147. private final Color color5 = new Color(153, 153, 153);
  148.  
  149. private final BasicStroke stroke1 = new BasicStroke(1);
  150.  
  151. private final Font font1 = new Font("Traditional Arabic", 0, 30);
  152. private final Font font2 = new Font("Arial", 0, 15);
  153. private final Font font3 = new Font("Arial", 0, 16);
  154. private final Font font4 = new Font("Tunga", 1, 22);
  155.  
  156. public void onRepaint(Graphics g1) {
  157. Graphics2D g = (Graphics2D)g1;
  158. long millis = System.currentTimeMillis() - startTime;
  159. long hours = millis / (1000 * 60 * 60);
  160. millis -= hours * (1000 * 60 * 60);
  161. long minutes = millis / (1000 * 60);
  162. millis -= minutes * (1000 * 60);
  163. long seconds = millis / 1000;
  164. levelsgained = skills.getCurrentSkillLevel(STAT_FISHING) - startlevel;
  165. float xpsec = 0;
  166. if ((minutes > 0 || hours > 0 || seconds > 0) && xpg > 0) {
  167. }
  168. g.setColor(color1);
  169. g.fillRect(6, 345, 504, 112);
  170. g.setColor(color2);
  171. g.setStroke(stroke1);
  172. g.drawRect(6, 345, 504, 112);
  173. g.setColor(color3);
  174. g.fillRect(7, 457, 96, 16);
  175. g.setColor(color2);
  176. g.drawRect(7, 457, 96, 16);
  177. g.setColor(color4);
  178. g.fillRoundRect(546, 411, 192, 55, 16, 16);
  179. g.setFont(font1);
  180. g.setColor(color3);
  181. g.drawString("H barb fisher", 9, 373);
  182. g.setFont(font2);
  183. g.setColor(color2);
  184. g.drawString("*********", 26, 474);
  185. g.setFont(font3);
  186. g.setColor(color5);
  187. g.drawString("visit: rune-site.webs.com", 556, 454);
  188. g.setFont(font4);
  189. g.drawString("made by harnum", 564, 436);
  190. g.drawString("Time running: " + hours + ":" + minutes + ":" + seconds + "." , 14, 398);
  191. g.drawString("Caught: " + amntcaught + ".", 14, 416);
  192. g.drawString("Exp gained: " + xpg + ".", 14, 438);
  193. g.drawString("Lvls gained: " + levelsgained + ".", 260, 416);
  194.  
  195. }
  196.  
  197. public void serverMessageRecieved(ServerMessageEvent e) {
  198. String message = e.getMessage();
  199. if (message.contains("You catch"))
  200. amntcaught++;
  201. if (message.contains("trout"))
  202. xpg += 50;
  203. if (message.contains("salmon"))
  204. xpg += 70;
  205. }
  206.  
  207. private enum State {
  208. BANK, FISH, WALK_TO_FISHING_AREA, WALK_TO_BANK, OPEN_BANK, WAIT, DROP
  209. }
  210.  
  211. private State getState() {
  212. if (isInventoryFull() && drop == true) {
  213. return State.DROP;
  214. }
  215. if (isInventoryFull()) {
  216. if (bank.isOpen()) {
  217. return State.BANK;
  218. } else if (distanceTo(bankTile) <= 8 && !getMyPlayer().isMoving()) {
  219. return State.OPEN_BANK;
  220. } else {
  221. return State.WALK_TO_BANK;
  222. }
  223. } else {
  224. if (checkSpot()) {
  225. return State.WAIT;
  226. } else if (distanceTo(fishTile) <= 8) {
  227. return State.FISH;
  228. } else {
  229. return State.WALK_TO_FISHING_AREA;
  230. }
  231. }
  232. }
  233.  
  234. private void antiBan() {
  235. if (random(0, 15) == 0) {
  236. final char[] LR = new char[] { KeyEvent.VK_LEFT,
  237. KeyEvent.VK_RIGHT };
  238. final char[] UD = new char[] { KeyEvent.VK_DOWN,
  239. KeyEvent.VK_UP };
  240. final char[] LRUD = new char[] { KeyEvent.VK_LEFT,
  241. KeyEvent.VK_RIGHT, KeyEvent.VK_UP,
  242. KeyEvent.VK_UP };
  243. final int random2 = random(0, 2);
  244. final int random1 = random(0, 2);
  245. final int random4 = random(0, 4);
  246.  
  247. if (random(0, 3) == 0) {
  248. Bot.getInputManager().pressKey(LR[random1]);
  249. wait(random(100, 400));
  250. Bot.getInputManager().pressKey(UD[random2]);
  251. wait(random(300, 600));
  252. Bot.getInputManager().releaseKey(UD[random2]);
  253. wait(random(100, 400));
  254. Bot.getInputManager().releaseKey(LR[random1]);
  255. } else {
  256. Bot.getInputManager().pressKey(LRUD[random4]);
  257. if (random4 > 1) {
  258. wait(random(300, 600));
  259. } else {
  260. wait(random(500, 900));
  261. }
  262. Bot.getInputManager().releaseKey(LRUD[random4]);
  263. }
  264.  
  265. if(random(0, 1) == 0)
  266. {
  267. int x = random(0, 750);
  268. int y = random(0, 500);
  269. moveMouse(x, y);
  270. }
  271. } else {
  272. wait(random(200, 2000));
  273. }
  274. }
  275.  
  276. private boolean clickNPC(final RSNPC npc, final String action) {
  277. // THANKS TO RUSKI
  278. try {
  279. int a;
  280. final StringBuffer npcCommandBuf = new StringBuffer();
  281. npcCommandBuf.append(action);
  282. npcCommandBuf.append(" ");
  283. npcCommandBuf.append(npc.getName());
  284. final String npcCommand = npcCommandBuf.toString();
  285. for (a = 10; a-- >= 0;) {
  286. final List<String> menuItems = getMenuItems();
  287. if (menuItems.size() > 1) {
  288. if (listContainsString(menuItems, npcCommand)) {
  289. if (menuItems.get(0).contains(npcCommand)) {
  290. clickMouse(true);
  291. return true;
  292. } else {
  293. // clickMouse(false);
  294. wait(random(50, 200));
  295. return atMenu(npcCommand);
  296. }
  297. }
  298. }
  299. final Point screenLoc = npc.getScreenLocation();
  300. if (!pointOnScreen(screenLoc)) {
  301. return false;
  302. }
  303. final Point randomP = new Point(random(screenLoc.x - 10,
  304. screenLoc.x + 10), random(screenLoc.y - 10,
  305. screenLoc.y + 10));
  306. if (randomP.x >= 0 && randomP.y >= 0) {
  307. moveMouse(randomP);
  308. }
  309. }
  310. return false;
  311. } catch (final Exception e) {
  312. return false;
  313. }
  314. }
  315.  
  316. private boolean listContainsString(final List<String> list,
  317. final String string) {
  318. // THANKS TO RUSKI
  319. try {
  320. int a;
  321. for (a = list.size() - 1; a-- >= 0;) {
  322. if (list.get(a).contains(string)) {
  323. return true;
  324. }
  325. }
  326. } catch (final Exception e) {
  327. }
  328. return false;
  329. }
  330.  
  331. public boolean atBank(RSObject bank) {
  332. if (!(bank.getObject() instanceof RSAnimable)) {
  333. return atTree(bank, "uickly");
  334. }
  335. RSAnimable anim = (RSAnimable) bank.getObject();
  336. Model model = bank.getModel();
  337. int index = random(0, model.getXPoints().length);
  338. int xoff = model.getXPoints()[index];
  339. int yoff = model.getZPoints()[index];
  340. int zoff = model.getYPoints()[index];
  341. Point p = Calculations.worldToScreen(anim.getX() + xoff, anim.getY() + zoff, -yoff);
  342. if (p.x == -1)
  343. return false;
  344. moveMouse(p, 3, 3);
  345. return atMenu("uickly");
  346. }
  347.  
  348. public boolean checkSpot() {
  349. RSNPC check = (RSNPC) getMyPlayer().getInteracting();
  350. if (check != null
  351. && getMyPlayer().getAnimation() != -1)
  352. return true;
  353. return false;
  354. }
  355.  
  356. public boolean walkPathMM2(final RSTile[] path, final int maxDist) {
  357. try {
  358. final RSTile next = nextTile(path, maxDist);
  359. if (next != null) {
  360. walkTileMM2(next);
  361. current = next;
  362. wait(random(1000,2000));
  363. return false;
  364. } else if (next != null && next.equals(current)) {
  365. return false;
  366. }
  367. } catch (final Exception e) {
  368. return false;
  369. }
  370. return true;
  371. }
  372.  
  373. public boolean walkTileMM2(final RSTile t)
  374. {
  375. final Point p = tileToMinimap(t);
  376. if (p.x == -1 || p.y == -1) {
  377. return false;
  378. }
  379. clickMouse(p, 0, 0, true);
  380. return true;
  381. }
  382. private static RSTile current = new RSTile(0, 0);
  383. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement