Guest User

Untitled

a guest
Jul 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.20 KB | None | 0 0
  1. /* ProCooker by Myr
  2. * Do not reproduce this script in any way.
  3. * Thanks to Epic_ for the idea!
  4. *
  5. * Enjoy cooking!
  6. */
  7.  
  8. /* REVISIONS:
  9. * V1.0: Release of script
  10. * ...
  11. */
  12.  
  13. /* UPDATES TO COME:
  14. * Rouge's Den support.
  15. *
  16. ...
  17. */
  18.  
  19. import java.awt.*;
  20. import java.util.*;
  21. import java.util.logging.*;
  22. import javax.accessibility.*;
  23. import javax.swing.*;
  24.  
  25. import org.rsbot.bot.*;
  26. import org.rsbot.bot.input.*;
  27. import org.rsbot.script.*;
  28. import org.rsbot.script.wrappers.*;
  29. import org.rsbot.event.listeners.*;
  30. import org.rsbot.event.events.*;
  31.  
  32. @ScriptManifest(authors = { "Myr" }, category = "Cooking", name = "MuDkIpZ C00kur", version = 1.0, description = "<html><center>"
  33. + "<h2>ProCooker</h2><br />"
  34. + "<b>Author:</b> Myr<br />"
  35. + "<b>Version:</b> 1.0<br>"
  36. + "<b>Instructions:</b> Start in the Al-Kharid bank with bank scrolled all the way up with raw food clearly visible. This script will detect your level and cook the best food for your level. If you do not have the required food it will try and search for the next type.<br><br>"
  37. + "<center><b>1-5:</b> Anchovies<br><b>5-10:</b> Herring<br><b>10-15:</b> Mackerel<br><b>15-25:</b> Trout<br><b>25-30:</b> Salmon<br><b>30-68:</b> Tuna<br><b>68-80:</b> Lobsters<br><b>80-94:</b> Monkfish<br><b>94-99:</b> Sharks<br>")
  38. public class ProCooker extends Script implements PaintListener {
  39.  
  40. ///////////////////////////////////
  41. ////////////INTEGERS///////////////
  42. ///////////////////////////////////
  43.  
  44. public int rawID = 0;
  45. public int cookedID = 0;
  46. public int rangeID = 25730;
  47. public long startTime = System.currentTimeMillis();
  48. public int antiban;
  49.  
  50. private String status = "Loading";
  51. public String type = " ";
  52. public int cooked;
  53. public int startexp;
  54. public int expgained;
  55. public int paintSelection = 1;
  56.  
  57. public boolean hasShark;
  58. public boolean hasMonkfish;
  59. public boolean hasLobster;
  60. public boolean hasTuna;
  61. public boolean hasSalmon;
  62. public boolean hasTrout;
  63. public boolean hasMackerel;
  64. public boolean hasHerring;
  65. public boolean hasAnchovies;
  66.  
  67. RSTile banktile = new RSTile (3273,3176);
  68. RSTile rangetile = new RSTile (3273, 3180);
  69. RSTile[] bankToRange = { new RSTile (3272, 3167), new RSTile (3275, 3167), new RSTile(3276, 3172), new RSTile (3277, 3177), new RSTile (3275, 3180), new RSTile (3272, 3180) };
  70. RSTile[] rangeToBank = reversePath(bankToRange);
  71.  
  72. public int statIndex = 0;
  73.  
  74. private final Color background = new Color(0,0,0,200),
  75. blue = new Color(51, 204, 255, 200),
  76. black = new Color(0, 0, 0, 200),
  77. white = new Color(255,255,255,200),
  78. green = new Color(30,255,30,200);
  79.  
  80. ///////////////////////////////////
  81. /////////////PAINT/////////////////
  82. ///////////////////////////////////
  83.  
  84. public void onRepaint(Graphics g) {
  85. if (isLoggedIn()) {
  86.  
  87. int expgained = 0;
  88. if ( startexp == 0) {
  89. startexp = skills.getCurrentSkillExp(7);
  90. statIndex = STAT_ATTACK;
  91. }
  92. expgained = skills.getCurrentSkillExp(7) - startexp;
  93. }
  94.  
  95. long millis = System.currentTimeMillis() - startTime;
  96. long hours = millis / (1000 * 60 * 60);
  97. millis -= hours * (1000 * 60 * 60);
  98. long minutes = millis / (1000 * 60);
  99. millis -= minutes * (1000 * 60);
  100. long seconds = millis / 1000;
  101.  
  102.  
  103.  
  104. long totalSeconds = ((System.currentTimeMillis() - startTime) / 1000);
  105.  
  106. int EXPGained = skills.getCurrentSkillExp(statIndex) - startexp;
  107. long EXPPerHour;
  108. if (totalSeconds == 0) {
  109. EXPPerHour = 0;
  110. } else {
  111. EXPPerHour = (EXPGained * 3600) / totalSeconds;
  112. }
  113.  
  114. long secondsToLvl;
  115.  
  116. if (EXPPerHour == 0) {
  117. secondsToLvl = 0;
  118. } else {
  119. secondsToLvl = (skills.getXPToNextLevel(statIndex) * 3600) / EXPPerHour;
  120. }
  121. ;
  122. long hoursToLvl = secondsToLvl / (60 * 60);
  123. secondsToLvl -= hoursToLvl * (60 * 60);
  124. long minutesToLvl = secondsToLvl / (60);
  125. secondsToLvl -= minutesToLvl * (60);
  126.  
  127.  
  128.  
  129. Mouse m = Bot.getClient().getMouse();
  130. Point p = new Point(m.x,m.y);
  131.  
  132. if (isWithinBounds(p,350,350,70,20)) {
  133. paintSelection = 0;
  134. }
  135. if (isWithinBounds(p,420,350,70,20)) {
  136. paintSelection = 1;
  137. }
  138.  
  139. g.setColor(background);
  140. g.fillRoundRect(350,350,140,20,5,5);
  141. g.fillRoundRect(350,374,140,82,5,5);
  142.  
  143. g.setFont(new Font("sans serif", Font.PLAIN, 16));
  144. g.setColor(white);
  145. g.drawString("EXP", 373, 365);
  146. g.drawString("INFO", 437, 365);
  147. g.fillRect(420,350,1,20);
  148.  
  149.  
  150. g.setFont(new Font("sans serif", Font.PLAIN, 12));
  151. int y = 375;
  152. if (paintSelection == 0) {
  153. g.setColor(blue);
  154. g.drawString("Cooking Level: ", 355, y += 14); //Fix cooking level.
  155. g.drawString("EXP Gained: " + expgained, 355, y += 14);
  156. g.drawString("EXP Per Hour: " + EXPPerHour, 355, y += 14);
  157. g.drawString("Level in: " + hoursToLvl + ":" + minutesToLvl + ":" + secondsToLvl, 355, y += 14);
  158.  
  159. g.setColor(white);
  160. g.drawString("" + skills.getPercentToNextLevel(statIndex)+"%", 355, y += 20);
  161. g.setColor(green);
  162. g.fillRoundRect(385, y -= 10, skills.getPercentToNextLevel(statIndex), 10, 5, 10);
  163. }
  164.  
  165. if (paintSelection == 1) {
  166. g.setColor(white);
  167. g.drawString("ProCooker", 355, y += 14);
  168. g.setColor(blue);
  169. g.drawString("Cooked: " + cooked + " fish", 355, y += 14);
  170. g.drawString("Time Running: " + hours + ":" + minutes + ":" + seconds , 355, y += 14);
  171. g.drawString("Status: " + status, 355, y += 14);
  172. g.setColor(white);
  173. g.drawString("Created by Myr", 355, y += 20);
  174. }
  175. }
  176.  
  177.  
  178. ///////////////////////////////////
  179. //////onStart and onFinish/////////
  180. ///////////////////////////////////
  181. @SuppressWarnings("deprecation")
  182. public boolean onStart(Map<String, String> args) {
  183. Bot.getEventManager().addListener(PaintListener.class, this);
  184. log("ProCooker initiated");
  185. return true;
  186. }
  187.  
  188. public void onFinish() {
  189. Bot.getEventManager().removeListener(PaintListener.class, this); // Make onFinish log more detailed (levels gained, exp gained, time running etc.)
  190.  
  191. long millis = System.currentTimeMillis() - startTime;
  192. long hours = millis / (1000 * 60 * 60);
  193. millis -= hours * (1000 * 60 * 60);
  194. long minutes = millis / (1000 * 60);
  195. millis -= minutes * (1000 * 60);
  196. long seconds = millis / 1000;
  197.  
  198. log("ProCooker terminated");
  199. log("You cooked: " + cooked + " fish");
  200. log("You gained: " + expgained + " exp");
  201. log("ProCooker was running for: " + hours + ":" + minutes + ":" + seconds);
  202. return;
  203. }
  204.  
  205.  
  206. ///////////////////////////////////
  207. //////////////METHODS//////////////
  208. ///////////////////////////////////
  209.  
  210. public boolean isWithinBounds(Point p, int x, int y, int w, int h) {
  211. if (p.x > x && p.x < x+w && p.y > y && p.y < y+h) {
  212. return true;
  213. } else {
  214. return false;
  215. }
  216. }
  217.  
  218. public boolean hasShark() {
  219. RSObject bankbooth = getNearestObjectByID(35647);
  220. if (bank == null) {
  221. log("hasShark(bank nulled)");
  222. rangeToBank = randomizePath (rangeToBank, 2, 2);
  223. walkPathMM(rangeToBank, 25);
  224. wait (random (50, 500));
  225. antiBan();
  226. status = "Finding a bank";
  227. openBank();
  228. } else {
  229. if (bank != null) {
  230. log("hasShark(bank not nulled)");
  231. openBank();
  232. wait (random (2000, 5000));
  233. if(bank.getItemByID(383) != null) {
  234. wait (random(5000,6000));
  235. log("Attempting to cook Sharks");
  236. return true;
  237. } else {
  238. log("No Sharks found. Searching for Monkfish");
  239. return false;
  240. }
  241. }
  242. }
  243. return false;
  244. }
  245.  
  246. public boolean openBank() {
  247. RSObject bankbooth = getNearestObjectByID(35647);
  248. status = "Opening bank";
  249. if(bankbooth == null) {
  250. setCameraRotation(random(1,360));
  251. return false; }
  252. return atObject(bankbooth, "Use-quickly");
  253. }
  254.  
  255. public boolean deposit() {
  256. if(!bank.isOpen()) return false;
  257. status = "Depositing";
  258. bank.depositAllExcept(rawID);
  259. bank.close();
  260. return true;
  261. }
  262.  
  263. public boolean withdraw() {
  264. if(!bank.isOpen()) return false;
  265. status = "Withdrawing";
  266. bank.atItem(rawID, "Withdraw-All");
  267. bank.close();
  268. return true;
  269. }
  270.  
  271. public void doInterface() {
  272. if (RSInterface.getInterface(513).isValid()) {
  273. clickMouse(random(220,300), random(385,460), false);
  274. atMenu("Cook All");
  275. wait(random(2700,3900));
  276. }
  277. }
  278.  
  279. public void antiBan() {
  280. antiban = random(0, 60);
  281. if(antiban == 12) {
  282. setCameraRotation(random(1,360));
  283. }
  284.  
  285. if(antiban == 2) {
  286. moveMouseRandomly(20);
  287. }
  288.  
  289. if(antiban == 17) {
  290. setCameraAltitude(random(1, 100));
  291. }
  292.  
  293. if(antiban == 6) {
  294. moveMouseRandomly(750);
  295. }
  296.  
  297. if(antiban == 31) {
  298. setCameraRotation(random(1,176));
  299. setCameraAltitude(random(1, 168));
  300. }
  301.  
  302. if(antiban == 38) {
  303. if (getCurrentTab() != TAB_INVENTORY) {
  304. openTab(TAB_INVENTORY);
  305. }
  306. }
  307. }
  308.  
  309. ///////////////////////////////////
  310. ////////////////LOOP///////////////
  311. ///////////////////////////////////
  312.  
  313. public int loop() {
  314.  
  315. if (skills.getCurrentSkillLevel(7) >= 69 && (!hasShark)) {
  316. hasShark();
  317. wait (random (50, 500));
  318. }
  319. if (skills.getCurrentSkillLevel(7) >= 69 && hasShark) {
  320. int rawID = 383;
  321. int cookedID = 385;
  322. }
  323.  
  324. if(getInventoryCount(rawID) == 0) {
  325. if(distanceTo(banktile) >= 4) {
  326. if (getMyPlayer().getInteracting() == null) {
  327. if (getMyPlayer().isMoving()) {
  328. return 500;
  329. } else if(!getMyPlayer().isMoving()) {
  330. rangeToBank = randomizePath (rangeToBank, 2, 2);
  331. walkPathMM(rangeToBank, 25);
  332. antiBan();
  333. status = "Walking to bank";
  334. wait (random(50, 200));
  335. openBank();
  336. deposit();
  337. withdraw();
  338. return random(500, 1000);
  339. }
  340. }
  341. }
  342. }
  343.  
  344. if(getInventoryCount(rawID) == 28) {
  345. if(distanceTo(rangetile) >= 4) {
  346. if (getMyPlayer().getInteracting() == null) {
  347. if (getMyPlayer().isMoving()) {
  348. return 500;
  349. } else { if(!getMyPlayer().isMoving()) {
  350. bankToRange = randomizePath (bankToRange, 2, 2);
  351. walkPathMM(bankToRange, 25);
  352. antiBan();
  353. wait (random(50, 200));
  354. //clickItem();
  355. //clickRange();
  356. doInterface();
  357. return random(500,1000);
  358. }
  359. return 50;
  360. }
  361. }
  362. }
  363. }
  364. return -1;
  365. }
  366. }
Add Comment
Please, Sign In to add comment