Guest User

Untitled

a guest
Jul 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.08 KB | None | 0 0
  1. /* ProCooker by Myr
  2. * Do not reproduce this script in any way.
  3. *
  4. * Enjoy cooking!
  5. */
  6.  
  7. /* REVISIONS:
  8. * V1.0: Release of script
  9. * ...
  10. */
  11.  
  12. /* UPDATES TO COME:
  13. * Rouge's Den support.
  14. * Disable auto-cooker, add whatever you want to cook.
  15. ...
  16. */
  17.  
  18. import java.awt.*;
  19. import java.util.*;
  20. import java.util.logging.*;
  21. import javax.accessibility.*;
  22. import javax.swing.*;
  23.  
  24. import org.rsbot.bot.*;
  25. import org.rsbot.bot.input.*;
  26. import org.rsbot.script.*;
  27. import org.rsbot.script.wrappers.*;
  28. import org.rsbot.event.listeners.*;
  29. import org.rsbot.event.events.*;
  30.  
  31. @ScriptManifest(authors = { "Myr" }, category = "Cooking", name = "ProCooker", version = 1.0, description = "<html><center>"
  32. + "<h2>ProCooker</h2><br />"
  33. + "<b>Author:</b> Myr<br />"
  34. + "<b>Version:</b> 1.0<br>"
  35. + "<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>"
  36. + "<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>")
  37. public class ProCooker extends Script implements PaintListener, ServerMessageListener {
  38.  
  39. ///////////////////////////////////
  40. ////////////INTEGERS///////////////
  41. ///////////////////////////////////
  42.  
  43. public int rawID = 0;
  44. public int cookedID = 0;
  45. public int rangeID = 25730;
  46. public long startTime = System.currentTimeMillis();
  47. public int antiban;
  48.  
  49. private String Status = "Loading";
  50. private int status = 0;
  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 bank = new RSTile (3273,3176);
  68. RSTile range = 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. log("ProCooker terminated");
  191. return;
  192. }
  193.  
  194.  
  195. ///////////////////////////////////
  196. //////////////METHODS//////////////
  197. ///////////////////////////////////
  198.  
  199. public boolean isWithinBounds(Point p, int x, int y, int w, int h) {
  200. if (p.x > x && p.x < x+w && p.y > y && p.y < y+h) {
  201. return true;
  202. } else {
  203. return false;
  204. }
  205. }
  206.  
  207. public void serverMessageRecieved(final ServerMessageEvent arg0) {
  208. final String msg = arg0.getMessage();
  209. if (msg.contains("I should try")) {
  210. hasShark = true;
  211. hasMonkfish = true;
  212. } else {
  213. hasShark = false;
  214. hasMonkfish = false;
  215. bank.close();
  216. }
  217. }
  218.  
  219. public boolean hasShark() {
  220. openBank();
  221. if (bank == null) return false;
  222. return bank.atItem(383, "Examine");
  223. }
  224.  
  225. public boolean hasMonkfish() {
  226. openBank();
  227. if (bank == null) return false;
  228. return bank.atItem(7944, "Examine");
  229. }
  230.  
  231. public boolean openBank() {
  232. RSObject bank = findObject(35647);
  233. status = "Opening bank";
  234. if(bank == null) return false;
  235. return atObject(bank, "Use-quickly");
  236. }
  237.  
  238. public boolean deposit() {
  239. if(!bank.isOpen()) return false;
  240. status = "Depositing";
  241. bank.depositAllExcept(rawID);
  242. bank.close();
  243. return true;
  244. }
  245.  
  246. public boolean withdraw() {
  247. if(!bank.isOpen()) return false;
  248. status = "Withdrawing";
  249. bank.atItem(rawID, "Withdraw-All");
  250. bank.close();
  251. return true;
  252. }
  253.  
  254. public void antiBan() {
  255. antiban = random(0, 60);
  256. if(antiban == 12) {
  257. setCameraRotation(random(1,360));
  258. }
  259.  
  260. if(antiban == 2) {
  261. moveMouseRandomly(20);
  262. }
  263.  
  264. if(antiban == 17) {
  265. setCameraAltitude(random(1, 100));
  266. }
  267.  
  268. if(antiban == 6) {
  269. moveMouseRandomly(750);
  270. }
  271.  
  272. if(antiban == 31) {
  273. setCameraRotation(random(1,176));
  274. setCameraAltitude(random(1, 168));
  275. }
  276.  
  277. if(antiban == 38) {
  278. if (getCurrentTab() != TAB_INVENTORY) {
  279. openTab(TAB_INVENTORY);
  280. }
  281. }
  282. }
  283.  
  284. ///////////////////////////////////
  285. ////////////////LOOP///////////////
  286. ///////////////////////////////////
  287.  
  288. public int loop() {
  289.  
  290. if (skills.getCurrentSkillLevel(7) >= 94 && hasShark) {
  291. int rawID = 383;
  292. int cookedID = 385;
  293. } else if (skills.getCurrentSkillLevel(7) >= 80 && hasMonkfish) {
  294. int rawID = 7944;
  295. int cookedID = 7946;
  296. } else if (skills.getCurrentSkillLevel(7) >= 68 && hasLobster) {
  297. int rawID = 377;
  298. int cookedID = 379;
  299. } else if (skills.getCurrentSkillLevel(7) >= 30 && hasTuna) {
  300. int rawID = 359;
  301. int cookedID = 361;
  302. } else if (skills.getCurrentSkillLevel(7) >= 25 && hasSalmon) {
  303. int rawID = 331;
  304. int cookedID = 329;
  305. } else if (skills.getCurrentSkillLevel(7) >= 15 && hasTrout) {
  306. int rawID = 335;
  307. int cookedID = 333;
  308. } else if (skills.getCurrentSkillLevel(7) >= 25 && hasMackerel) {
  309. int rawID = 353;
  310. int cookedID = 355;
  311. } else if (skills.getCurrentSkillLevel(7) >= 25 && hasHerring) {
  312. int rawID = 345;
  313. int cookedID = 347;
  314. } else if (skills.getCurrentSkillLevel(7) >= 25 && hasAnchovies) {
  315. int rawID = 321;
  316. int cookedID = 319;
  317. }
  318.  
  319. if(getInventoryCount(rawID) == 0) {
  320. if(distanceTo(bank) >= 4) {
  321. if (getMyPlayer().getInteracting() == null) {
  322. if (getMyPlayer().isMoving()) {
  323. return 500;
  324. } else { if(!getMyPlayer().isMoving()) {
  325. rangeToBank = randomizePath (rangeToBank, 2, 2);
  326. walkPathMM(rangeToBank, 25);
  327. return random(500, 1000);
  328. openBank();
  329. deposit();
  330. withdraw();
  331. }
  332. }
  333. }
  334. } else {
  335. openBank();
  336. deposit();
  337. withdraw();
  338. }
  339. }
  340.  
  341. if(getInventoryCount(rawID) == 28) {
  342. if(distanceTo(range) >= 4) {
  343. if (getMyPlayer().getInteracting() == null) {
  344. if (getMyPlayer().isMoving()) {
  345. return 500;
  346. } else { if(!getMyPlayer().isMoving()) {
  347. bankToRange = randomizePath (bankToRange, 2, 2);
  348. walkPathMM(bankToRange, 25);
  349. return random(500,1000);
  350. clickItem();
  351. clickRange();
  352. return 50;
  353. }
  354. return 50;
  355. }
  356. }
  357. }
  358. }
  359. }
  360. }
  361. return -1;
  362. }
Add Comment
Please, Sign In to add comment