Guest User

Untitled

a guest
Jun 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.92 KB | None | 0 0
  1. //
  2. // Created by [ ampzZ_ ] on 6/15/09
  3. //
  4.  
  5. package com.scripts;
  6.  
  7. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  8. import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
  9. import com.kbot2.scriptable.Script;
  10. import com.kbot2.scriptable.methods.wrappers.*;
  11. import com.kbot2.scriptable.methods.data.Skills;
  12. import com.kbot2.scriptable.methods.data.GameScreen;
  13. import com.kbot2.scriptable.methods.data.Bank;
  14.  
  15. import java.awt.*;
  16. import java.text.DecimalFormat;
  17. import java.awt.event.KeyEvent;
  18.  
  19. public class MonkFisher extends Script implements PaintListener, ServerMessageListener {
  20.  
  21. //-------------------
  22. // Variables
  23. //-----------------------------
  24. boolean runnable = true;
  25. final Tile bankTile = new Tile(2329, 3690);
  26. final Tile fishTile = new Tile(2340,3700);
  27. final Tile[] pathToFish = new Tile[]{new Tile(2329,3690), new Tile(2334,3691), new Tile(2336,3696), new Tile(2340,3700) };
  28. int catches = 0;
  29. long startTime = 0;
  30. int origExp = 0;
  31. int origLvl = 0;
  32. long antibanTimer = 0;
  33. String statusMsg = "";
  34.  
  35. //-------------------
  36. // Starting methods
  37. //------------------------------
  38. public boolean active() { return runnable; }
  39.  
  40. public String getName() { return "Monk Fisher"; }
  41.  
  42. public String getAuthor() { return "ampzZ_"; }
  43.  
  44. public double getVersion() { return 1.0; }
  45.  
  46. public String getDescription() { return "Please refer to\nforum post."; }
  47.  
  48. public String[] getTags() { return new String[]{"ampzz", "Fishing", "Monk fish" }; }
  49.  
  50. public boolean onStart() {
  51. origExp = skills.getExperience(Skills.SKILL_FISHING);
  52. origLvl = skills.getLevel(Skills.SKILL_FISHING);
  53. camera.setAltitude(true);
  54. setMouseSpeed(2.0);
  55. startTime = System.currentTimeMillis();
  56. antibanTimer = System.currentTimeMillis() + random(15000, 30000);
  57. return true;
  58. }
  59.  
  60. //-----------------------
  61. // Antiban
  62. //-----------------------
  63. public void antiban() {
  64.  
  65. int r = random(0, 8);
  66.  
  67. if(r == 0){
  68. gameScreen.openTab(GameScreen.TAB_INVENTORY);
  69. sleep(800, 1500);
  70. }
  71. if(r == 1) { // Open friends tab
  72. gameScreen.openTab(GameScreen.TAB_FRIENDS);
  73. sleep(800, 1500);
  74. }
  75. if(r == 2 && !getMyPlayer().isMoving()) { // Open skills tab + highlight Fishing
  76. gameScreen.openTab(GameScreen.TAB_STATS);
  77. int xx = 666;
  78. int yy = 297;
  79. moveMouse(new Point(xx, yy), 43, 17);
  80. sleep(2000, 4000);
  81. }
  82. if(r == 3) { // Move mouse random position
  83. mouse.moveMouse(random(5, 420), random(5, 420));
  84. sleep(300, 700);
  85. }
  86. if(r == 4 && random(1, 2) == 2 && !getMyPlayer().isMoving()) { // Randomly click on players near - 1% chance of this :P
  87. if(players.getPlayers().length == 0)
  88. return;
  89. int randPlayer = random(0, players.getPlayers().length-1);
  90. Point onePoint = getCalculations().tileToScreen(players.getPlayers()[randPlayer].getLocation());
  91. clickMouse(onePoint, 1, 1, false);
  92. sleep(2000);
  93. atMenu("Cancel");
  94. }
  95. if(r == 5 || r == 6) { // Move camera up and down
  96. char k = (random(0, 1) == 0 ? (char)KeyEvent.VK_DOWN : (char)KeyEvent.VK_UP);
  97. keyboard.pressKey(k);
  98. sleep(random(10, 400));
  99. keyboard.releaseKey(k);
  100. }
  101. if(r == 7 || r == 8) // Rotate camera
  102. camera.setAngle(camera.getAngle() + random(-90, 90));
  103.  
  104. gameScreen.openTab(GameScreen.TAB_INVENTORY);
  105. antibanTimer = System.currentTimeMillis() + random(15000, 30000);
  106.  
  107. }
  108.  
  109. //-------------------
  110. // Loop
  111. //------------------------------
  112. public int loop() {
  113. try {
  114. if(!(inventory.contains(303))) {
  115. log("No net - Stopping;");
  116. runnable = false;
  117. return 1;
  118. }
  119.  
  120. if(getMyPlayer().getAnimation() != -1 || getMyPlayer().isMoving()) {
  121. if(System.currentTimeMillis() > antibanTimer)
  122. antiban();
  123. return 100;
  124. }
  125.  
  126. if(walking.getEnergy() > 40) walking.setRunning(true);
  127.  
  128. if(inventory.isFull()) {
  129. if(getMyPlayer().getLocation().distanceTo(bankTile) > 8) {
  130. statusMsg = "Walking to bank";
  131. walking.walkPath(walking.randomizePath(walking.reversePath(pathToFish), 3, 1));
  132. return 100;
  133. } else {
  134. // Bank
  135. statusMsg = "Banking";
  136. if(!bank.isOpen()) {
  137. NPC bankNPC = npcs.getClosest(10, 3824);
  138. if(bankNPC == null)
  139. bankNPC = npcs.getClosest(10, "Arnold Lydspor");
  140. if(bankNPC != null)
  141. bankNPC.doAction("Bank Arnold Lydspor");
  142. return random(500, 800);
  143. } else {
  144. statusMsg = "Depositing";
  145. bank.deposit(7944, Bank.MENU_ALL);
  146. sleep(500, 1000);
  147. bank.deposit(7944, Bank.MENU_ALL);
  148. }
  149. }
  150. } else {
  151. if(getMyPlayer().getLocation().distanceTo(fishTile) > 12 && getMyPlayer().getLocation().getY() < 3701) {
  152. statusMsg = "Walking to fishing spot";
  153. walking.walkPath(walking.randomizePath(pathToFish, 3, 1));
  154. return 100;
  155. } else {
  156. // Fishing
  157. NPC fishSpot = npcs.getClosest(15, 3848);
  158. if(fishSpot == null) {
  159. log("Couldnt find fishing spot.");
  160. return 1000;
  161. } else {
  162. if(!getCalculations().onScreen(getCalculations().tileToScreen(fishSpot.getLocation()))) {
  163. statusMsg = "Fixing location";
  164. walking.walkToMM(new Tile(fishSpot.getLocation().getX(), fishSpot.getLocation().getY()-1));
  165. return 100;
  166. } else {
  167. statusMsg = "Fishing";
  168. fishSpot.doAction("Net Fish");
  169. sleep(1500, 2500);
  170. }
  171. }
  172. }
  173. }
  174.  
  175. return random(350, 500);
  176. } catch (Exception e) {
  177. return 100;
  178. }
  179. }
  180.  
  181. //-------------------
  182. // Server messages
  183. //------------------------------
  184. public void onServerMessage(String m) {
  185. if(m.contains("catch a")) {
  186. catches++;
  187. }
  188. }
  189.  
  190. //-------------------
  191. // Paint
  192. //------------------------------
  193. public void onRepaint(Graphics g) {
  194. long runTime = System.currentTimeMillis() - startTime;
  195.  
  196. int secs = ((int) ((runTime / 1000) % 60));
  197. int mins = ((int) (((runTime / 1000) / 60) % 60));
  198. int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
  199.  
  200. int x = 43;
  201. int y = 43;
  202.  
  203. DecimalFormat d = new DecimalFormat("#,#00");
  204. d.setMaximumFractionDigits(0);
  205.  
  206. g.setFont(new Font("Lucida", Font.BOLD, 12));
  207. g.setColor(Color.WHITE);
  208. g.drawString(getName() + " " + getVersion() + " | Created By: " + getAuthor(), x-18, y);
  209.  
  210. g.setFont(new Font("Lucida", Font.PLAIN, 12));
  211. y += 20;
  212. g.drawString("Status: " + statusMsg, x, y);
  213. y += 13;
  214. g.drawString("Run time: " + d.format(hours) + ":" + d.format(mins) + ":" + d.format(secs), x, y); // Yes alo, I took this from you :)
  215. y += 13;
  216. g.drawString("Monkfish caught: " + catches, x, y);
  217. y += 13;
  218. g.drawString("Experience gained: " + (skills.getExperience(Skills.SKILL_FISHING) - origExp), x, y);
  219. y += 13;
  220. g.drawString("Experience to next level: " + skills.getExperienceToNextLevel(Skills.SKILL_FISHING), x, y);
  221. y += 13;
  222. g.drawString("Levels gained: " + (skills.getLevel(Skills.SKILL_FISHING) - origLvl), x, y);
  223. }
  224.  
  225. }
Add Comment
Please, Sign In to add comment