Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.20 KB | None | 0 0
  1. ;
  2. import java.awt.Graphics2D;
  3. import java.awt.Insets;
  4. import java.awt.Point;
  5. import java.awt.Rectangle;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.KeyEvent;
  9. import java.awt.event.MouseEvent;
  10. import java.awt.event.MouseMotionListener;
  11.  
  12. import javax.swing.*;
  13.  
  14. import org.rsbot.event.events.MessageEvent;
  15. import org.rsbot.event.listeners.MessageListener;
  16. import org.rsbot.event.listeners.PaintListener;
  17. import org.rsbot.gui.AccountManager;
  18. import org.rsbot.script.Script;
  19. import org.rsbot.script.ScriptManifest;
  20. import org.rsbot.script.methods.Environment;
  21. import org.rsbot.script.methods.Equipment;
  22. import org.rsbot.script.methods.Game;
  23. import org.rsbot.script.methods.Skills;
  24. import org.rsbot.script.wrappers.RSArea;
  25. import org.rsbot.script.wrappers.RSGroundItem;
  26. import org.rsbot.script.wrappers.RSItem;
  27. import org.rsbot.script.wrappers.RSNPC;
  28. import org.rsbot.script.wrappers.RSObject;
  29. import org.rsbot.script.wrappers.RSPath;
  30. import org.rsbot.script.wrappers.RSTile;
  31.  
  32. /**
  33. * @author jtryba
  34. * @version 1.29 (c)2010-2011 jtryba, No one except jtryba has the right to
  35. * modify and/or spread this script without the permission of jtryba.
  36. * I'm not held responsible for any damage that may occur to your
  37. * property.
  38. */
  39.  
  40. @ScriptManifest(authors = { "jtryba" }, keywords = "cooking", name = "autoCook", version = 1.29, description = ("cooks anything in al-karid"))
  41. public class autoCook extends Script implements PaintListener, MessageListener,
  42. MouseMotionListener {
  43.  
  44. // script constants
  45. public static final RSArea[] area = {
  46. new RSArea(new RSTile(3250, 3150), new RSTile(3281, 3200)), // al-karid
  47. new RSArea(new RSTile(3035, 4960), new RSTile(3060, 4992)), // rouges-den
  48. new RSArea(new RSTile(2790, 3420), new RSTile(2840, 3465)) // catherby
  49. };
  50.  
  51. public static final RSTile[] ntr = { new RSTile(3273, 3180),
  52. new RSTile(3043, 4972), new RSTile(2817, 3443) };
  53.  
  54. public static final RSTile[] ntb = { new RSTile(3269, 3166),
  55. new RSTile(3269, 3167), new RSTile(3269, 3168),
  56. new RSTile(3269, 3169), new RSTile(3043, 4972),
  57. new RSTile(2809, 3441), new RSTile(2810, 3441),
  58. new RSTile(2811, 3441) };
  59.  
  60. /*-Al-Karid-----------------------------------------------------------*/
  61. public static final RSTile alKaridRangeTiles[] = { new RSTile(3271, 3180),
  62. new RSTile(3271, 3181) };
  63. public static final RSTile alKaridBankTiles[] = { new RSTile(3268, 3166),
  64. new RSTile(3268, 3167), new RSTile(3268, 3168),
  65. new RSTile(3268, 3169) };
  66. /*--------------------------------------------------------------------*/
  67.  
  68. /*-Rouges-Den---------------------------------------------------------*/
  69. public static final RSTile rougesDenRangeTiles[] = { new RSTile(3043, 4973) };
  70. public static final int bankerNpcID = 2271;
  71. /*--------------------------------------------------------------------*/
  72.  
  73. /*-Catherby-----------------------------------------------------------*/
  74. public static final RSTile catherbyRangeTiles[] = { new RSTile(2817, 3444),
  75. new RSTile(2818, 3444) };
  76. public static final RSTile catherbyBankTiles[] = { new RSTile(2809, 3442),
  77. new RSTile(2810, 3442), new RSTile(2811, 3442) };
  78. public static final RSTile doorTile = new RSTile(2816, 3438);
  79. /*--------------------------------------------------------------------*/
  80.  
  81. public static final int COOKING_GAUNTLENTS_ID = 775;
  82. public static final int ids[] = { 3132, 2138, 13435, 317, 327, 345, 321,
  83. 353, 335, 341, 349, 331, 359, 377, 363, 371, 7944, 383, 395, 15270,
  84. 2287 };
  85. public static final String names[] = { "Raw beef", "Raw chicken",
  86. "Raw crayfish", "Raw shrimps", "Raw sardine", "Raw herring",
  87. "Raw anchovies", "Raw mackerel", "Raw trout", "Raw cod",
  88. "Raw pike", "Raw salmon", "Raw tuna", "Raw lobster", "Raw bass",
  89. "Raw swordfish", "Raw monkfish", "Raw shark", "Raw sea turtle",
  90. "Raw rocktail", "Uncooked pizza" };
  91. public final static String doorAction = "Open Door";
  92. final private cameraHeight camHeight = new cameraHeight();
  93. final private cameraRotate camRotate = new cameraRotate();
  94.  
  95. private enum State {
  96. ATRANGE, TORANGE, BANKING, TOBANK, LOGOUT, TOLOCATION, WAIT
  97. };
  98.  
  99. /*-rewards box-*/
  100. public static final int boxID = 14664;
  101. public static final int coinID = 995;
  102. public boolean doRewardPickUp = false;
  103. public boolean hadToDrop = false;
  104. public int droppedID = 0;
  105. public String droppedName = "";
  106.  
  107. // script variables
  108. GUI gui;
  109. public int startExp = 0;
  110. public int startExp2 = 0;
  111. public int lastExp = 0;
  112. public int rawExp = 0;
  113. public int rawExp2 = 0;
  114. public int rawID = 0;
  115. public int rawID2 = 0;
  116. public int levelsGained = 0;
  117. public int burnt = 0;
  118. public int cooked = 0;
  119. public int mouseSpeed = 0;
  120. public int currentMouseSpeed = 0;
  121. public long lastCookedTime = 0;
  122. public long lastCheck = 0;
  123. public long startTime = 0;
  124. public long afkTime = 0;
  125. public boolean bankNpc = false;
  126. public boolean cook2ids = false;
  127. public boolean showMouse = true;
  128. public boolean hoverMouse = false;
  129. public boolean clickContinue = false;
  130. public boolean firstRun = true;
  131. public boolean startScript = false;
  132. public boolean outOfRaw = false;
  133. public boolean customID = false;
  134. public boolean customID2 = false;
  135. public boolean dropCoins = false;
  136. public boolean afk = false;
  137. public boolean useafk = false;
  138. public Point mousePoint;
  139. public RSTile nextToBank = null;
  140. public RSTile bankTile = null;
  141. public RSTile nextToRange = null;
  142. public RSTile rangeTile = null;
  143. public RSArea location = null;
  144. public String status = "";
  145. public String rawName = "";
  146. public String rawName2 = "";
  147. public String t = "";
  148.  
  149. private State getState() {
  150. if (game.isLoggedIn()) {
  151. if (outOfRaw) {
  152. return State.LOGOUT;
  153. }
  154. if (atLocation()) {
  155. if (hasRaw()) {
  156. if (atRange()) {
  157. return State.ATRANGE;
  158. } else {
  159. return State.TORANGE;
  160. }
  161. } else {
  162. if (atBank()) {
  163. return State.BANKING;
  164. } else {
  165. return State.TOBANK;
  166. }
  167. }
  168. } else {
  169. if (nearLocation()) {
  170. return State.TOLOCATION;
  171. } else {
  172. return State.LOGOUT;
  173. }
  174. }
  175. }
  176. return State.WAIT;
  177. }
  178.  
  179. @Override
  180. public int loop() {
  181. if (game.isLoggedIn()
  182. && skills.getCurrentLevel(Skills.CONSTITUTION) > 1) {
  183. currentMouseSpeed = mouseSpeed + random(-2, 3);
  184. if (currentMouseSpeed < 0) {
  185. currentMouseSpeed = 0;
  186. } else if (currentMouseSpeed > 10) {
  187. currentMouseSpeed = 10;
  188. }
  189. mouse.setSpeed(currentMouseSpeed);
  190. if (firstRun) {
  191. firstRun();
  192. firstRun = false;
  193. return 50;
  194. }
  195. if (rawExp == 0 && skills.getCurrentExp(Skills.COOKING) > startExp
  196. && startExp2 == 0) {
  197. rawExp = totalExp();
  198. }
  199. if (rawExp == 0 && skills.getCurrentExp(Skills.COOKING) > startExp2
  200. && startExp2 > 0) {
  201. rawExp = skills.getCurrentExp(Skills.COOKING) - startExp2;
  202. }
  203. if (outOfRaw && cook2ids) {
  204. if (rawID != rawID2) {
  205. rawID = rawID2;
  206. rawName = rawName2;
  207. rawExp = 0;
  208. startExp2 = skills.getCurrentExp(Skills.COOKING);
  209. outOfRaw = false;
  210. return 100;
  211. }
  212. }
  213. if (System.currentTimeMillis() < afkTime) {
  214. status = "[AB] - AFK for: "
  215. + formatTime((int) (afkTime - System
  216. .currentTimeMillis()));
  217. return 100;
  218. } else {
  219. if (afk) {
  220. camHeight.pause = false;
  221. camRotate.pause = false;
  222. status = t;
  223. afk = false;
  224. env.setUserInput(Environment.INPUT_KEYBOARD);
  225. return 100;
  226. }
  227. }
  228. checkRun();
  229. if (camera.getPitch() < 75) {
  230. camera.setPitch(true);
  231. return 50;
  232. }
  233. if (clickContinue && interfaces.canContinue()) {
  234. env.saveScreenshot(true);
  235. interfaces.clickContinue();
  236. mouse.moveSlightly();
  237. clickContinue = false;
  238. return random(500, 1000);
  239. }
  240.  
  241. if (doRewardPickUp && itemPresent(boxID, 5)) {
  242. status = "RewardBox";
  243. if (inventory.isFull()) {
  244. hadToDrop = true;
  245. final int randomSpot = random(15, 28);
  246. final RSItem dropped = inventory.getItemAt(randomSpot);
  247. if (dropped != null) {
  248. droppedID = dropped.getID();
  249. droppedName = dropped.getName().substring(12);
  250. log("Dropped ID: " + droppedID);
  251. log("Dropped Name: " + droppedName);
  252. dropped.doAction("Drop " + droppedName);
  253. return random(1750, 2100);
  254. }
  255. return random(10, 50);
  256. } else {
  257. RSGroundItem rewardBox = groundItems.getNearest(boxID);
  258. if (rewardBox != null) {
  259. rewardBox.doAction("Take " + "Random event gift");
  260. log("Picked up reward box");
  261. return random(1750, 2200);
  262. }
  263. return random(10, 50);
  264. }
  265. }
  266.  
  267. if (doRewardPickUp && hadToDrop && dropCoins
  268. && inventory.contains(coinID) && inventory.isFull()) {
  269. RSItem coins = inventory.getItem(coinID);
  270. if (coins != null) {
  271. coins.doAction("Drop");
  272. return random(1000, 1500);
  273. }
  274. }
  275.  
  276. if (doRewardPickUp && hadToDrop && itemPresent(droppedID, 5)
  277. && !inventory.isFull()) {
  278. status = "RewardBox";
  279. final RSGroundItem dropped = groundItems.getNearest(droppedID);
  280. if (dropped != null) {
  281. dropped.doAction("Take " + droppedName);
  282. sleep(random(2500, 3000));
  283. }
  284. if (!itemPresent(droppedID, 5)) {
  285. droppedID = 0;
  286. droppedName = "";
  287. hadToDrop = false;
  288. }
  289. return random(10, 50);
  290. }
  291.  
  292. switch (getState()) {
  293. case ATRANGE:
  294. status = "Cooking";
  295. if (getMyPlayer().getAnimation() != -1) {
  296. if (random(1, 100) < 5) {
  297. switch (random(1, 10)) {
  298. case 1:
  299. mouse.moveSlightly();
  300. sleep(random(250, 500));
  301. break;
  302. case 2:
  303. mouse.moveSlightly();
  304. sleep(random(1250, 1500));
  305. mouse.moveSlightly();
  306. sleep(random(250, 500));
  307. break;
  308. case 3:
  309. if (random(1, 25) < 5) {
  310. t = status;
  311. status = "[AB] - Checking Cooking skill";
  312. if (game.getCurrentTab() != Game.TAB_STATS) {
  313. game.openTab(Game.TAB_STATS);
  314. sleep(1000, 1500);
  315. }
  316. skills.doHover(Skills.INTERFACE_COOKING);
  317. sleep(random(4000, 9000));
  318. status = t;
  319. }
  320. break;
  321. case 4:
  322. mouse.moveSlightly();
  323. sleep(random(250, 500));
  324. break;
  325. case 5:
  326. mouse.moveSlightly();
  327. mouse.moveSlightly();
  328. sleep(random(100, 1100));
  329. mouse.moveSlightly();
  330. sleep(random(250, 500));
  331. break;
  332. case 6:
  333. if (random(1, 100) < 5
  334. && inventory.getCount(rawID) > 7 && useafk) {
  335. camHeight.pause = true;
  336. camRotate.pause = true;
  337. t = status;
  338. afkTime = System.currentTimeMillis()
  339. + random(random(5000, 10000), random(
  340. 60000, 120000));
  341. status = "[AB] - AFK for: "
  342. + formatTime((int) afkTime);
  343. mouse.moveOffScreen();
  344. afk = true;
  345. env.setUserInput(0);
  346. return 100;
  347. }
  348. break;
  349. }
  350. }
  351. lastCookedTime = System.currentTimeMillis();
  352. }
  353. if (interfaces.get(916).isValid()
  354. && interfaces.getComponent(905, 14).isValid()) {
  355. interfaces.getComponent(905, 14).doClick();
  356. mouse.moveSlightly();
  357. lastCookedTime = System.currentTimeMillis();
  358. return random(1000, 2000);
  359. } else {
  360. if ((System.currentTimeMillis() - lastCookedTime) > 4000) {
  361. if (bank.isOpen()) {
  362. bank.close();
  363. return random(100, 500);
  364. }
  365. if (inventory.isItemSelected()) {
  366. RSObject range = objects.getTopAt(rangeTile);
  367. if (range != null) {
  368. if (bankNpc) {
  369. if (range.doAction("Use " + rawName
  370. + " -> Fire")) {
  371. mouse.move(201, 368, 66, 38);
  372. return random(1000, 2000);
  373. }
  374. } else {
  375. if (range.doAction("Use " + rawName
  376. + " -> Range")) {
  377. mouse.move(201, 368, 66, 38);
  378. return random(1000, 2000);
  379. }
  380. }
  381. return random(100, 500);
  382. }
  383. } else {
  384. RSItem raw = inventory.getItem(rawID);
  385. if (raw != null) {
  386. if (raw.doAction("Use " + rawName)) {
  387. return random(500, 1000);
  388. }
  389. return random(100, 500);
  390. }
  391. }
  392. }
  393. return 100;
  394. }
  395. case TORANGE:
  396. camRotate.pause = true;
  397. if (!getMyPlayer().isMoving() && !cameraIsMoving()) {
  398. if (location.contains(ntb[5])) { // catherby
  399. if (doorOpen()) {
  400. status = "Walking to range";
  401. walking.walkTo(nextToRange);
  402. } else {
  403. if (atDoor()) {
  404. camera.setCompass('s');
  405. if (camera.getPitch() > 50) {
  406. camera.setPitch(25);
  407. }
  408. Point p = calc.tileToScreen(doorTile);
  409. if (p != null) {
  410. status = "Opening door";
  411. mouse.move(p, 5, 5);
  412. sleep(random(250, 500));
  413. if (menu.contains(doorAction)) {
  414. if (menu.getIndex(doorAction) > 0) {
  415. mouse.click(false);
  416. sleep(random(250, 500));
  417. if (menu.contains(doorAction)) {
  418. menu.doAction(doorAction);
  419. } else {
  420. mouse.moveSlightly();
  421. }
  422. } else {
  423. mouse.click(true);
  424. }
  425. }
  426. }
  427. } else {
  428. status = "Walking to door";
  429. walking.walkTo(new RSTile(doorTile.getX(),
  430. doorTile.getY() - 1));
  431. }
  432. }
  433. } else {
  434. status = "Walking to range";
  435. walking.walkTo(nextToRange);
  436. }
  437. }
  438. camRotate.pause = false;
  439. return random(500, 1000);
  440. case TOBANK:
  441. camRotate.pause = true;
  442. if (!getMyPlayer().isMoving() && !cameraIsMoving()) {
  443. if (location.contains(ntb[5])) { // catherby
  444. if (doorOpen()) {
  445. status = "Walking to bank";
  446. walking.walkTo(nextToBank);
  447. } else {
  448. camera.setCompass('s');
  449. if (camera.getPitch() > 50) {
  450. camera.setPitch(25);
  451. }
  452. Point p = calc.tileToScreen(doorTile);
  453. if (p != null) {
  454. status = "Opening door";
  455. mouse.move(p, 5, 5);
  456. sleep(random(250, 500));
  457. if (menu.contains(doorAction)) {
  458. if (menu.getIndex(doorAction) > 0) {
  459. mouse.click(false);
  460. sleep(random(250, 500));
  461. if (menu.contains(doorAction)) {
  462. menu.doAction(doorAction);
  463. } else {
  464. mouse.moveSlightly();
  465. }
  466. } else {
  467. mouse.click(true);
  468. }
  469. }
  470. }
  471. }
  472. } else {
  473. status = "Walking to bank";
  474. walking.walkTo(nextToBank);
  475. }
  476. }
  477. camRotate.pause = false;
  478. return random(500, 1000);
  479. case BANKING:
  480. if (bank.isOpen()) {
  481. if (inventory.getCount() >= 1) {
  482. status = "Depositing all";
  483. bank.depositAll();
  484. return random(1000, 1500);
  485. } else {
  486. status = "Withdrawing raw";
  487. if (bank.getCount(rawID) > 0) {
  488. if (bank.withdraw(rawID, 0)) {
  489. mouse.moveSlightly();
  490. return random(500, 1000);
  491. }
  492. return 100;
  493. } else {
  494. outOfRaw = true;
  495. return 100;
  496. }
  497. }
  498. } else {
  499. status = "Opening bank";
  500. if (bankNpc) {
  501. RSNPC banker = npcs.getNearest(bankerNpcID);
  502. if (banker != null) {
  503. if (calc.pointOnScreen(banker.getScreenLocation())) {
  504. if (banker.doAction("Bank Emerald Benedict")) {
  505. mouse.moveSlightly();
  506. return random(2000, 2500);
  507. }
  508. return 100;
  509. } else {
  510. RSTile tile = banker.getLocation();
  511. if (tile != null) {
  512. int a1 = camera.getAngle();
  513. int at1 = camera.getTileAngle(tile);
  514. if (a1 < (at1 - 25) || a1 > (at1 + 25)) {
  515. camera.turnTo(bankTile, 10);
  516. }
  517. }
  518. return 100;
  519. }
  520. }
  521. return 100;
  522. } else {
  523. if (calc.tileOnScreen(bankTile)) {
  524. RSObject bankBooth = objects.getTopAt(bankTile);
  525. if (bankBooth != null) {
  526. if (bankBooth.doAction("Use-quickly")) {
  527. mouse.moveSlightly();
  528. return random(2000, 2500);
  529. }
  530. return 100;
  531. }
  532. return 100;
  533. } else {
  534. int a1 = camera.getAngle();
  535. int at1 = camera.getTileAngle(bankTile);
  536. if (a1 < (at1 - 25) || a1 > (at1 + 25)) {
  537. camera.turnTo(bankTile, 10);
  538. return 100;
  539. }
  540. return 100;
  541. }
  542. }
  543. }
  544. case LOGOUT:
  545. status = "Stoping script";
  546. game.logout(true);
  547. return -1;
  548. case TOLOCATION:
  549. camRotate.pause = true;
  550. status = "Walking to cooking area.";
  551. if (!cameraIsMoving()) {
  552. RSPath gPath = walking.getPath(location.getCentralTile());
  553. if (gPath.isValid()) {
  554. if (gPath.traverse()) {
  555. camRotate.pause = false;
  556. return random(1500, 2000);
  557. }
  558. }
  559. }
  560. camRotate.pause = false;
  561. return random(250, 500);
  562. case WAIT:
  563. return 100;
  564. }
  565. }
  566. return 100;
  567. }
  568.  
  569. private boolean atDoor() {
  570. return calc.tileOnScreen(doorTile) && calc.distanceTo(doorTile) < 3;
  571. }
  572.  
  573. private boolean doorOpen() {
  574. return objects.getTopAt(doorTile) == null;
  575. }
  576.  
  577. private boolean cameraIsMoving() {
  578. int ca1 = 0, ca2 = 0;
  579. ca1 = camera.getAngle();
  580. sleep(50);
  581. ca2 = camera.getAngle();
  582. if (ca1 != ca2) {
  583. return true;
  584. }
  585. return false;
  586. }
  587.  
  588. private void checkRun() {
  589. if (!walking.isRunEnabled() && walking.getEnergy() > random(15, 30)) {
  590. status = "Setting run";
  591. walking.setRun(true);
  592. sleep(random(500, 750));
  593. }
  594. }
  595.  
  596. private boolean atLocation() {
  597. return location.contains(getMyPlayer().getLocation());
  598. }
  599.  
  600. private boolean nearLocation() {
  601. return calc.distanceTo(location.getCentralTile()) < 35;
  602. }
  603.  
  604. private boolean atBank() {
  605. if (location.contains(ntr[0])) {
  606. return calc.tileOnScreen(bankTile) && calc.distanceTo(bankTile) < 5
  607. && getMyPlayer().getLocation().getX() >= bankTile.getX();
  608. } else if (location.contains(ntr[1])) {
  609. RSNPC banker = npcs.getNearest(bankerNpcID);
  610. if (banker != null) {
  611. RSTile t = banker.getLocation();
  612. if (t != null)
  613. return calc.tileOnScreen(t) && calc.distanceTo(t) < 3;
  614. }
  615. return false;
  616. } else {
  617. return calc.tileOnScreen(bankTile) && calc.distanceTo(bankTile) < 5
  618. && getMyPlayer().getLocation().getY() <= bankTile.getY();
  619. }
  620. }
  621.  
  622. private boolean atRange() {
  623. if (location.contains(ntr[0])) {
  624. return calc.tileOnScreen(rangeTile)
  625. && calc.distanceTo(rangeTile) < 5
  626. && getMyPlayer().getLocation().getX() >= rangeTile.getX();
  627. } else if (location.contains(ntr[1])) {
  628. return calc.tileOnScreen(rangeTile)
  629. && calc.distanceTo(rangeTile) < 5;
  630. } else {
  631. return calc.tileOnScreen(rangeTile)
  632. && calc.distanceTo(rangeTile) < 3
  633. && getMyPlayer().getLocation().getY() <= rangeTile.getY();
  634. }
  635. }
  636.  
  637. private boolean hasRaw() {
  638. return inventory.contains(rawID);
  639. }
  640.  
  641. private double getVersion() {
  642. return getClass().getAnnotation(ScriptManifest.class).version();
  643. }
  644.  
  645. private int totalExp() {
  646. return skills.getCurrentExp(Skills.COOKING) - startExp;
  647. }
  648.  
  649. private int expPerHour() {
  650. if (runTime() / 1000 > 0) {
  651. return (int) (3600000.0 / runTime() * totalExp());
  652. }
  653. return 0;
  654. }
  655.  
  656. private int cookedPerHour() {
  657. if (runTime() / 1000 > 0) {
  658. return (int) (3600000.0 / runTime() * cooked);
  659. }
  660. return 0;
  661. }
  662.  
  663. private int burntPerHour() {
  664. if (runTime() / 1000 > 0) {
  665. return (int) (3600000.0 / runTime() * burnt);
  666. }
  667. return 0;
  668. }
  669.  
  670. private int rawTNL() {
  671. if (rawExp == 0) {
  672. return 0;
  673. }
  674. return (int) skills.getExpToNextLevel(Skills.COOKING) / rawExp;
  675. }
  676.  
  677. private int rawTNN() {
  678. if (rawExp == 0) {
  679. return 0;
  680. }
  681. int currentExp = skills.getCurrentExp(Skills.COOKING);
  682. if (currentExp < 13034431) {
  683. return (int) (13034431 - currentExp) / rawExp;
  684. }
  685. return 0;
  686. }
  687.  
  688. private long runTime() {
  689. return System.currentTimeMillis() - startTime;
  690. }
  691.  
  692. private String runTimeString() {
  693. return formatTime((int) runTime());
  694. }
  695.  
  696. private String formatTime(int time) { // credits to Ahmedbasil1
  697. final StringBuilder stringAppend = new StringBuilder();
  698. final long TSec = time / 1000;
  699. final long TMin = TSec / 60;
  700. final long THour = TMin / 60;
  701. final int s = (int) TSec % 60;
  702. final int m = (int) TMin % 60;
  703. final int h = (int) THour;
  704. if (time <= 0) {
  705. return "00:00:00";
  706. }
  707. if (h < 10) {
  708. stringAppend.append("0");
  709. }
  710. stringAppend.append(h);
  711. stringAppend.append(":");
  712. if (m < 10) {
  713. stringAppend.append("0");
  714. }
  715. stringAppend.append(m);
  716. stringAppend.append(":");
  717. if (s < 10) {
  718. stringAppend.append("0");
  719. }
  720. stringAppend.append(s);
  721. return stringAppend.toString();
  722. }
  723.  
  724. private void firstRun() {
  725. while (skills.getCurrentExp(Skills.COOKING) == 0) {
  726. sleep(100);
  727. }
  728. status = "setup";
  729. startExp = skills.getCurrentExp(Skills.COOKING);
  730. if (isMember()) {
  731. status = "Checking for gauntlents";
  732. if (equipment.getItem(Equipment.HANDS).getID() != COOKING_GAUNTLENTS_ID) {
  733. if (!inventory.contains(COOKING_GAUNTLENTS_ID)) {
  734. log("You could be burning a lot less food if you had 'Cooking gauntlets'");
  735. log("You can get these by completing the 'Family Crest' quest.");
  736. } else {
  737. RSItem gloves = inventory.getItem(COOKING_GAUNTLENTS_ID);
  738. if (gloves != null) {
  739. String n = gloves.getName();
  740. if (n != null) {
  741. gloves.doAction("Wield " + n);
  742. }
  743. }
  744. }
  745. }
  746. }
  747. camRotate.isAlive = true;
  748. camRotate.start();
  749. camHeight.isAlive = true;
  750. camHeight.start();
  751. }
  752.  
  753. public boolean isMember() {
  754. return AccountManager.isMember(account.getName());
  755. }
  756.  
  757. @Override
  758. public boolean onStart() {
  759. gui = new GUI();
  760. while (gui.isVisible()) {
  761. sleep(100);
  762. }
  763. status = "loading";
  764. if (customID) {
  765. log("Loading name from ge");
  766. rawName = grandExchange.getItemName(rawID);
  767. }
  768. if (cook2ids) {
  769. if (customID2) {
  770. log("Loading second name from ge");
  771. rawName2 = grandExchange.getItemName(rawID2);
  772. }
  773. log("We will cook " + rawName + " ID: " + rawID + " and "
  774. + rawName2 + " ID: " + rawID2);
  775. } else {
  776. log("We will cook " + rawName + " ID: " + rawID);
  777. }
  778. startTime = System.currentTimeMillis();
  779. return startScript;
  780. }
  781.  
  782. @Override
  783. public void onFinish() {
  784. camHeight.isAlive = false;
  785. camRotate.isAlive = false;
  786. log("Cooked " + cooked + " " + rawName + " in " + runTimeString()
  787. + " (" + cookedPerHour() + " p/hr)");
  788. log("Burnt " + burnt + " " + rawName);
  789. log("Exp gained: " + totalExp() + " (" + expPerHour() + " p/hr)");
  790. log("Levels gained: " + levelsGained);
  791. log("autoCook v" + getVersion());
  792. }
  793.  
  794. @Override
  795. public void onRepaint(Graphics render) {
  796. Graphics2D g = (Graphics2D) render;
  797. if (showMouse) {
  798. g.setStroke(new BasicStroke(2));
  799. drawMouse(g);
  800. }
  801. if (afk) {
  802. g.setColor(new Color(0, 0, 0, 150));
  803. g.fillRect(0, 0, 768, 510);
  804. }
  805. if (game.isLoggedIn()
  806. && skills.getCurrentLevel(Skills.CONSTITUTION) > 1
  807. && !isHover(528, 203, 756, 466)) {
  808. g.setColor(new Color(0, 0, 0, 150));
  809. g.fillRoundRect(528, 203, 228, 263, 16, 16);
  810. g.setFont(new Font("Arial", 1, 16));
  811. g.setColor(Color.GREEN);
  812. g.drawString("autoCook v" + getVersion(), 584, 221);
  813. g.setFont(new Font("Arial", 1, 12));
  814. g.drawString("Runtime: " + runTimeString(), 533, 240);
  815. g.drawString("Status: " + status, 533, 256);
  816. g.drawString("Total raw: " + (cooked + burnt), 533, 272);
  817. g.drawString("Cooked: " + cooked + " (" + cookedPerHour()
  818. + " p/hr)", 533, 288);
  819. g.drawString("Burnt: " + burnt + " (" + burntPerHour() + " p/hr)",
  820. 533, 304);
  821. g.drawString("Total exp: " + totalExp(), 533, 320);
  822. g.drawString("Exp p/hr: " + expPerHour(), 533, 336);
  823. if (skills.getCurrentLevel(Skills.COOKING) < 99) {
  824. g.drawString("Exp TNL: "
  825. + skills.getExpToNextLevel(Skills.COOKING) + " ("
  826. + skills.getPercentToNextLevel(Skills.COOKING) + "%)",
  827. 533, 352);
  828. try {
  829. if (expPerHour() > 0) {
  830. long sTNL = skills.getExpToNextLevel(Skills.COOKING)
  831. / (expPerHour() / 3600);
  832. long hTNL = sTNL / (60 * 60);
  833. sTNL -= hTNL * (60 * 60);
  834. long mTNL = sTNL / 60;
  835. sTNL -= mTNL * 60;
  836. g.drawString("Level in: " + hTNL + ":" + mTNL + ":"
  837. + sTNL, 533, 368);
  838. } else {
  839. g.drawString("Level in: 0:0:0 ", 533, 368);
  840. }
  841. } catch (Exception e) {
  842. g.drawString("Level in: -1:-1:-1", 533, 368);
  843. }
  844. g.drawString("Cooked TNL: " + rawTNL(), 533, 416);
  845. } else {
  846. g.drawString("Exp TNL: 0 (0%)", 533, 352);
  847. g.drawString("Level in: 0:0:0 ", 533, 368);
  848. g.drawString("Cooked TNL: 0", 533, 416);
  849. }
  850. g.drawString("Total levels: " + levelsGained, 533, 384);
  851. g.drawString("Exp per raw: " + rawExp, 533, 400);
  852. g.drawString("Cooked till 99: " + rawTNN(), 533, 432);
  853. if (skills.getCurrentLevel(Skills.COOKING) < 99) {
  854. try {
  855. if (expPerHour() > 0) {
  856. long sTNN = (13034431 - skills
  857. .getCurrentExp(Skills.COOKING))
  858. / (expPerHour() / 3600);
  859. long hTNN = sTNN / (60 * 60);
  860. sTNN -= hTNN * (60 * 60);
  861. long mTNN = sTNN / 60;
  862. sTNN -= mTNN * 60;
  863. g.drawString(
  864. "99 in: " + hTNN + ":" + mTNN + ":" + sTNN,
  865. 533, 448);
  866. } else {
  867. g.drawString("99 in: 0:0:0 ", 533, 448);
  868. }
  869. } catch (Exception e) {
  870. g.drawString("99 in: -1:-1:-1", 533, 448);
  871. }
  872. } else {
  873. g.drawString("99 in: 0:0:0 ", 533, 448);
  874. }
  875. }
  876. }
  877.  
  878. public void drawMouse(final Graphics g) {
  879. final Point loc = mouse.getLocation();
  880. g.setColor(Color.RED);
  881. g.drawLine(0, loc.y, 766, loc.y);
  882. g.drawLine(loc.x, 0, loc.x, 505);
  883. }
  884.  
  885. @Override
  886. public void messageReceived(MessageEvent e) {
  887. String s = e.getMessage().toLowerCase();
  888. if (s.contains("accidentally burn") || s.contains("accidentally burnt")) {
  889. burnt++;
  890. }
  891. if (s.contains("successfully cook") || s.contains("manage to cook")
  892. || s.contains("roast") || s.contains("bake")) {
  893. cooked++;
  894. }
  895. if (s.contains("you've just advanced")) {
  896. if (s.contains("cooking level")) {
  897. levelsGained++;
  898. }
  899. log("Gratz you just gained a level !");
  900. clickContinue = true;
  901. }
  902. }
  903.  
  904. @Override
  905. public void mouseDragged(MouseEvent arg0) {
  906. // Auto-generated method stub
  907. // Not used
  908. }
  909.  
  910. @Override
  911. public void mouseMoved(MouseEvent e) {
  912. mousePoint = e.getPoint();
  913. }
  914.  
  915. public boolean isHover(int x1, int y1, int x2, int y2) { // credits to
  916. // Ahmedbasil1
  917. if (mousePoint != null) {
  918. if (mousePoint.getX() >= x1 && mousePoint.getY() >= y1
  919. && mousePoint.getX() <= x2 && mousePoint.getY() <= y2) {
  920. return true;
  921. } else {
  922. return false;
  923. }
  924. } else {
  925. return false;
  926. }
  927. }
  928.  
  929. public boolean itemPresent(int itemID, int dist) {
  930. RSGroundItem item = groundItems.getNearest(itemID);
  931. RSTile playerTile = getMyPlayer().getLocation();
  932. if (item != null) {
  933. RSTile itemTile = item.getLocation();
  934. return (playerTile.getX() - dist) <= itemTile.getX()
  935. && itemTile.getX() <= (playerTile.getX() + dist)
  936. && (playerTile.getY() + dist) >= itemTile.getY()
  937. && itemTile.getY() >= (playerTile.getY() - dist);
  938. }
  939. return false;
  940. }
  941.  
  942. public class cameraHeight extends Thread {
  943. // credits to Aion
  944. private boolean isAlive = false;
  945. private boolean pause = false;
  946.  
  947. @Override
  948. public void run() {
  949. while (this.isAlive) {
  950. if (random(1, 15000) == 342) {
  951. try {
  952. if (this.pause) {
  953. while (this.pause) {
  954. Thread.sleep(3000, 7000);
  955. }
  956. }
  957. char key = KeyEvent.VK_UP;
  958. if (camera.getPitch() >= random(50, 100)) {
  959. key = KeyEvent.VK_DOWN;
  960. }
  961. keyboard.pressKey(key);
  962. Thread.sleep(random(75, 300));
  963. keyboard.releaseKey(key);
  964. } catch (Exception e) {
  965. }
  966. try {
  967. Thread.sleep(random(random(1000, 5000), random(11000,
  968. 17000)));
  969. } catch (Exception e) {
  970. camera.setPitch(random(0, 100));
  971. }
  972. }
  973. }
  974. }
  975. }
  976.  
  977. public class cameraRotate extends Thread {
  978. // credits to Aion
  979. private boolean isAlive = false;
  980. private boolean pause = false;
  981.  
  982. @Override
  983. public void run() {
  984. while (this.isAlive) {
  985. if (random(1, 15000) == 342) {
  986. try {
  987. if (this.pause) {
  988. while (this.pause) {
  989. Thread.sleep(3000, 7000);
  990. }
  991. }
  992. char key = KeyEvent.VK_RIGHT;
  993. if (random(1, 5) == 2) {
  994. key = KeyEvent.VK_LEFT;
  995. }
  996. keyboard.pressKey(key);
  997. Thread.sleep(random(350, 1200));
  998. keyboard.releaseKey(key);
  999. } catch (Exception e) {
  1000. camera.setAngle(random(0, 360));
  1001. }
  1002. try {
  1003. Thread.sleep(random(random(1000, 5000), random(11000,
  1004. 17000)));
  1005. } catch (Exception e) {
  1006. }
  1007. }
  1008. }
  1009. }
  1010. }
  1011.  
  1012. public class GUI extends JFrame {
  1013.  
  1014. private static final long serialVersionUID = -7758110133437943043L;
  1015.  
  1016. public GUI() {
  1017. initComponents();
  1018. }
  1019.  
  1020. private void buttonStartActionPerformed(ActionEvent e) {
  1021. if (checkBoxCustomID.isSelected()) {
  1022. customID = true;
  1023. try {
  1024. rawID = Integer.parseInt(textFieldCustomID.getText());
  1025. } catch (NumberFormatException nfe) {
  1026. log
  1027. .severe("You MUST enter a valid nuber in the custom ID text field");
  1028. setVisible(false);
  1029. dispose();
  1030. }
  1031. } else {
  1032. rawID = ids[comboBoxPreSetID.getSelectedIndex()];
  1033. rawName = names[comboBoxPreSetID.getSelectedIndex()];
  1034. }
  1035. if (checkBoxCookSecondItem.isSelected()) {
  1036. cook2ids = true;
  1037. if (checkBoxCustomID2.isSelected()) {
  1038. customID2 = true;
  1039. try {
  1040. rawID2 = Integer.parseInt(textFieldCustomID2.getText());
  1041. } catch (NumberFormatException nfe) {
  1042. log
  1043. .severe("You MUST enter a valid nuber in the 2nd custom ID text field");
  1044. setVisible(false);
  1045. dispose();
  1046. }
  1047. } else {
  1048. rawID2 = ids[comboBoxPreSetID2.getSelectedIndex()];
  1049. rawName2 = names[comboBoxPreSetID2.getSelectedIndex()];
  1050. }
  1051. }
  1052. if (checkBoxRewards.isSelected()) {
  1053. doRewardPickUp = true;
  1054. }
  1055. if (checkBoxAFK.isSelected()) {
  1056. useafk = true;
  1057. }
  1058.  
  1059. int l = comboBoxLocation.getSelectedIndex();
  1060. location = area[l];
  1061. nextToRange = ntr[l];
  1062. switch (l) {
  1063. case 0:
  1064. rangeTile = alKaridRangeTiles[random(0,
  1065. alKaridRangeTiles.length)];
  1066. nextToBank = ntb[random(0, alKaridBankTiles.length)];
  1067. bankTile = alKaridBankTiles[random(0, alKaridBankTiles.length)];
  1068. break;
  1069. case 1:
  1070. rangeTile = rougesDenRangeTiles[random(0,
  1071. rougesDenRangeTiles.length)];
  1072. nextToBank = ntb[4];
  1073. bankTile = null;
  1074. bankNpc = true;
  1075. break;
  1076. case 2:
  1077. rangeTile = catherbyRangeTiles[random(0,
  1078. catherbyRangeTiles.length)];
  1079. nextToBank = ntb[random(5, ntb.length)];
  1080. bankTile = catherbyBankTiles[random(0, catherbyBankTiles.length)];
  1081. break;
  1082. }
  1083. mouseSpeed = sliderMouseSpeed.getValue();
  1084. /* Write settings
  1085. try {
  1086. final BufferedWriter out = new BufferedWriter(new FileWriter(
  1087. settingsFile));
  1088. out.write((checkBoxCustomID.isSelected() ? "true" : "false")
  1089. + ":" // 0
  1090. + rawID
  1091. + ":" // 1
  1092. + comboBoxPreSetID.getSelectedIndex()
  1093. + ":" // 2
  1094. + (checkBoxRewards.isSelected() ? "true" : "false")
  1095. + ":" // 3
  1096. + (checkBoxDropCoins.isSelected() ? "true" : "false")
  1097. + ":" // 4
  1098. + (checkBoxCookSecondItem.isSelected() ? "true"
  1099. : "false")
  1100. + ":" // 5
  1101. + rawID2
  1102. + ":" // 6
  1103. + comboBoxPreSetID2.getSelectedIndex()
  1104. + ":" // 7
  1105. + (checkBoxCustomID2.isSelected() ? "true" : "false")
  1106. + ":" // 8
  1107. + (checkBoxAFK.isSelected() ? "true" : "false") + ":" // 9
  1108. + comboBoxLocation.getSelectedIndex() + ":" // 10
  1109. + sliderMouseSpeed.getValue()); // 11
  1110. out.close();
  1111. } catch (final Exception e1) {
  1112. log.warning("Error saving setting.");
  1113. }
  1114. // End write settings */
  1115. startScript = true;
  1116. setVisible(false);
  1117. dispose();
  1118. }
  1119.  
  1120. private void buttonExitActionPerformed(ActionEvent e) {
  1121. final int exit = JOptionPane.showConfirmDialog(null,
  1122. "Are you sure you want to exit the script?", "Exiting",
  1123. JOptionPane.YES_NO_OPTION);
  1124. if (exit == 0) {
  1125. setVisible(false);
  1126. dispose();
  1127. }
  1128. }
  1129.  
  1130. private void checkBoxCustomIDActionPerformed(ActionEvent e) {
  1131. if (checkBoxCustomID.isSelected()) {
  1132. comboBoxPreSetID.setEnabled(false);
  1133. textFieldCustomID.setEnabled(true);
  1134. } else {
  1135. textFieldCustomID.setEnabled(false);
  1136. comboBoxPreSetID.setEnabled(true);
  1137. }
  1138. }
  1139.  
  1140. private void buttonVisitThreadActionPerformed(ActionEvent e) {
  1141. JOptionPane.showConfirmDialog(null,
  1142. "RSBot no longer allows this option..",
  1143. "Sorry", JOptionPane.OK_OPTION);
  1144. }
  1145.  
  1146. private void checkBoxRewardsActionPerformed(ActionEvent e) {
  1147. if (checkBoxRewards.isSelected()) {
  1148. checkBoxDropCoins.setEnabled(true);
  1149. } else {
  1150. checkBoxDropCoins.setEnabled(false);
  1151. checkBoxDropCoins.setSelected(false);
  1152. }
  1153. }
  1154.  
  1155. private void checkBoxCustomID2ActionPerformed(ActionEvent e) {
  1156. if (checkBoxCustomID2.isSelected()) {
  1157. comboBoxPreSetID2.setEnabled(false);
  1158. textFieldCustomID2.setEnabled(true);
  1159. } else {
  1160. comboBoxPreSetID2.setEnabled(true);
  1161. textFieldCustomID2.setEnabled(false);
  1162. }
  1163. }
  1164.  
  1165. private void checkBoxCookSecondItemActionPerformed(ActionEvent e) {
  1166. if (checkBoxCookSecondItem.isSelected()) {
  1167. comboBoxPreSetID2.setEnabled(true);
  1168. checkBoxCustomID2.setEnabled(true);
  1169. } else {
  1170. comboBoxPreSetID2.setEnabled(false);
  1171. checkBoxCustomID2.setEnabled(false);
  1172. textFieldCustomID2.setEnabled(false);
  1173. }
  1174. }
  1175.  
  1176. private void initComponents() {
  1177. // GEN-BEGIN:initComponents
  1178. panelMain = new JPanel();
  1179. comboBoxPreSetID = new JComboBox();
  1180. label1 = new JLabel();
  1181. buttonStart = new JButton();
  1182. buttonExit = new JButton();
  1183. checkBoxCustomID = new JCheckBox();
  1184. textFieldCustomID = new JTextField();
  1185. label2 = new JLabel();
  1186. buttonVisitThread = new JButton();
  1187. checkBoxRewards = new JCheckBox();
  1188. checkBoxDropCoins = new JCheckBox();
  1189. comboBoxPreSetID2 = new JComboBox();
  1190. checkBoxCustomID2 = new JCheckBox();
  1191. textFieldCustomID2 = new JTextField();
  1192. checkBoxCookSecondItem = new JCheckBox();
  1193. checkBoxAFK = new JCheckBox();
  1194. sliderMouseSpeed = new JSlider();
  1195. label3 = new JLabel();
  1196. label4 = new JLabel();
  1197. label5 = new JLabel();
  1198. label6 = new JLabel();
  1199. comboBoxLocation = new JComboBox();
  1200.  
  1201. // ======== this ========
  1202. setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  1203. setTitle("autoCook v" + getVersion());
  1204. setVisible(true);
  1205. setResizable(false);
  1206. Container contentPane = getContentPane();
  1207. contentPane.setLayout(null);
  1208.  
  1209. // ======== panelMain ========
  1210. {
  1211. panelMain.setLayout(null);
  1212.  
  1213. // ---- comboBoxPreSetID ----
  1214. comboBoxPreSetID.setModel(new DefaultComboBoxModel(
  1215. new String[] { "Raw beef", "Raw chicken",
  1216. "Raw crayfish", "Raw shrimps", "Raw sardine",
  1217. "Raw herring", "Raw anchovies", "Raw mackerel",
  1218. "Raw trout", "Raw cod", "Raw pike",
  1219. "Raw salmon", "Raw tuna", "Raw lobster",
  1220. "Raw bass", "Raw swordfish", "Raw monkfish",
  1221. "Raw shark", "Raw sea turtle", "Raw rocktail",
  1222. "Uncooked pizza" }));
  1223. comboBoxPreSetID.setSelectedIndex(12);
  1224. panelMain.add(comboBoxPreSetID);
  1225. comboBoxPreSetID.setBounds(110, 35, 100, comboBoxPreSetID
  1226. .getPreferredSize().height);
  1227.  
  1228. // ---- label1 ----
  1229. label1.setText("autoCook v" + getVersion() + " Settings");
  1230. label1.setHorizontalAlignment(SwingConstants.CENTER);
  1231. label1.setFont(new Font("Tahoma", Font.BOLD, 16));
  1232. panelMain.add(label1);
  1233. label1.setBounds(0, 0, 435, 30);
  1234.  
  1235. // ---- buttonStart ----
  1236. buttonStart.setText("START");
  1237. buttonStart.setFont(buttonStart.getFont().deriveFont(
  1238. buttonStart.getFont().getStyle() | Font.BOLD));
  1239. buttonStart.addActionListener(new ActionListener() {
  1240. @Override
  1241. public void actionPerformed(ActionEvent e) {
  1242. buttonStartActionPerformed(e);
  1243. }
  1244. });
  1245. panelMain.add(buttonStart);
  1246. buttonStart.setBounds(5, 155, 135, 30);
  1247.  
  1248. // ---- buttonExit ----
  1249. buttonExit.setText("EXIT");
  1250. buttonExit.addActionListener(new ActionListener() {
  1251. @Override
  1252. public void actionPerformed(ActionEvent e) {
  1253. buttonExitActionPerformed(e);
  1254. }
  1255. });
  1256. panelMain.add(buttonExit);
  1257. buttonExit.setBounds(290, 155, 135, 30);
  1258.  
  1259. // ---- checkBoxCustomID ----
  1260. checkBoxCustomID.setText("Custom ID?");
  1261. checkBoxCustomID.addActionListener(new ActionListener() {
  1262. @Override
  1263. public void actionPerformed(ActionEvent e) {
  1264. checkBoxCustomIDActionPerformed(e);
  1265. }
  1266. });
  1267. panelMain.add(checkBoxCustomID);
  1268. checkBoxCustomID.setBounds(5, 65, 100, 20);
  1269.  
  1270. // ---- textFieldCustomID ----
  1271. textFieldCustomID.setEnabled(false);
  1272. panelMain.add(textFieldCustomID);
  1273. textFieldCustomID.setBounds(110, 65, 100, 20);
  1274.  
  1275. // ---- label2 ----
  1276. label2.setText("Pre-set ID:");
  1277. panelMain.add(label2);
  1278. label2.setBounds(10, 35, 95, 20);
  1279.  
  1280. // ---- buttonVisitThread ----
  1281. buttonVisitThread.setText("Visit Thread");
  1282. buttonVisitThread.addActionListener(new ActionListener() {
  1283. @Override
  1284. public void actionPerformed(ActionEvent e) {
  1285. buttonVisitThreadActionPerformed(e);
  1286. }
  1287. });
  1288. panelMain.add(buttonVisitThread);
  1289. buttonVisitThread.setBounds(145, 155, 140, 30);
  1290.  
  1291. // ---- checkBoxRewards ----
  1292. checkBoxRewards.setText("Pick up rewards?");
  1293. checkBoxRewards.setSelected(true);
  1294. checkBoxRewards.addActionListener(new ActionListener() {
  1295. @Override
  1296. public void actionPerformed(ActionEvent e) {
  1297. checkBoxRewardsActionPerformed(e);
  1298. }
  1299. });
  1300. panelMain.add(checkBoxRewards);
  1301. checkBoxRewards.setBounds(new Rectangle(new Point(5, 95),
  1302. checkBoxRewards.getPreferredSize()));
  1303.  
  1304. // ---- checkBoxDropCoins ----
  1305. checkBoxDropCoins.setText("Drop coins?");
  1306. checkBoxDropCoins.setSelected(true);
  1307. panelMain.add(checkBoxDropCoins);
  1308. checkBoxDropCoins.setBounds(new Rectangle(new Point(110, 95),
  1309. checkBoxDropCoins.getPreferredSize()));
  1310.  
  1311. // ---- comboBoxPreSetID2 ----
  1312. comboBoxPreSetID2.setModel(new DefaultComboBoxModel(
  1313. new String[] { "Raw beef", "Raw chicken",
  1314. "Raw crayfish", "Raw shrimps", "Raw sardine",
  1315. "Raw herring", "Raw anchovies", "Raw mackerel",
  1316. "Raw trout", "Raw cod", "Raw pike",
  1317. "Raw salmon", "Raw tuna", "Raw lobster",
  1318. "Raw bass", "Raw swordfish", "Raw monkfish",
  1319. "Raw shark", "Raw sea turtle", "Raw rocktail",
  1320. "Uncooked pizza" }));
  1321. comboBoxPreSetID2.setEnabled(false);
  1322. comboBoxPreSetID2.setSelectedIndex(15);
  1323. panelMain.add(comboBoxPreSetID2);
  1324. comboBoxPreSetID2.setBounds(325, 35, 100, 22);
  1325.  
  1326. // ---- checkBoxCustomID2 ----
  1327. checkBoxCustomID2.setText("Custom ID?");
  1328. checkBoxCustomID2.setEnabled(false);
  1329. checkBoxCustomID2.addActionListener(new ActionListener() {
  1330. @Override
  1331. public void actionPerformed(ActionEvent e) {
  1332. checkBoxCustomID2ActionPerformed(e);
  1333. }
  1334. });
  1335. panelMain.add(checkBoxCustomID2);
  1336. checkBoxCustomID2.setBounds(220, 65, 100, 20);
  1337.  
  1338. // ---- textFieldCustomID2 ----
  1339. textFieldCustomID2.setEnabled(false);
  1340. panelMain.add(textFieldCustomID2);
  1341. textFieldCustomID2.setBounds(325, 65, 100, 20);
  1342.  
  1343. // ---- checkBoxCookSecondItem ----
  1344. checkBoxCookSecondItem.setText("Second ID? ID:");
  1345. checkBoxCookSecondItem.addActionListener(new ActionListener() {
  1346. @Override
  1347. public void actionPerformed(ActionEvent e) {
  1348. checkBoxCookSecondItemActionPerformed(e);
  1349. }
  1350. });
  1351. panelMain.add(checkBoxCookSecondItem);
  1352. checkBoxCookSecondItem.setBounds(new Rectangle(new Point(220,
  1353. 35), checkBoxCookSecondItem.getPreferredSize()));
  1354.  
  1355. // ---- checkBoxAFK ----
  1356. checkBoxAFK.setText("AFK?");
  1357. checkBoxAFK.setSelected(true);
  1358. panelMain.add(checkBoxAFK);
  1359. checkBoxAFK.setBounds(new Rectangle(new Point(190, 95),
  1360. checkBoxAFK.getPreferredSize()));
  1361.  
  1362. // ---- sliderMouseSpeed ----
  1363. sliderMouseSpeed.setMaximum(10);
  1364. sliderMouseSpeed.setMinimum(1);
  1365. sliderMouseSpeed.setPaintLabels(true);
  1366. sliderMouseSpeed.setPaintTicks(true);
  1367. sliderMouseSpeed.setSnapToTicks(true);
  1368. sliderMouseSpeed.setValue(7);
  1369. sliderMouseSpeed.setMinorTickSpacing(1);
  1370. panelMain.add(sliderMouseSpeed);
  1371. sliderMouseSpeed.setBounds(325, 105, 100, 17);
  1372.  
  1373. // ---- label3 ----
  1374. label3.setText("Mouse speed:");
  1375. panelMain.add(label3);
  1376. label3.setBounds(255, 95, label3.getPreferredSize().width, 20);
  1377.  
  1378. // ---- label4 ----
  1379. label4.setText("fast");
  1380. panelMain.add(label4);
  1381. label4.setBounds(new Rectangle(new Point(330, 90), label4
  1382. .getPreferredSize()));
  1383.  
  1384. // ---- label5 ----
  1385. label5.setText("slow");
  1386. panelMain.add(label5);
  1387. label5.setBounds(new Rectangle(new Point(405, 90), label5
  1388. .getPreferredSize()));
  1389.  
  1390. // ---- label6 ----
  1391. label6.setText("Location:");
  1392. panelMain.add(label6);
  1393. label6.setBounds(10, 125, label6.getPreferredSize().width, 20);
  1394.  
  1395. // ---- comboBoxLocation ----
  1396. comboBoxLocation
  1397. .setModel(new DefaultComboBoxModel(new String[] {
  1398. "Al-karid", "Rouge's den", "Catherby" }));
  1399. panelMain.add(comboBoxLocation);
  1400. comboBoxLocation.setBounds(110, 125, 100, comboBoxLocation
  1401. .getPreferredSize().height);
  1402.  
  1403. { // compute preferred size
  1404. Dimension preferredSize = new Dimension();
  1405. for (int i = 0; i < panelMain.getComponentCount(); i++) {
  1406. Rectangle bounds = panelMain.getComponent(i)
  1407. .getBounds();
  1408. preferredSize.width = Math.max(bounds.x + bounds.width,
  1409. preferredSize.width);
  1410. preferredSize.height = Math.max(bounds.y
  1411. + bounds.height, preferredSize.height);
  1412. }
  1413. Insets insets = panelMain.getInsets();
  1414. preferredSize.width += insets.right;
  1415. preferredSize.height += insets.bottom;
  1416. panelMain.setMinimumSize(preferredSize);
  1417. panelMain.setPreferredSize(preferredSize);
  1418. }
  1419. }
  1420. contentPane.add(panelMain);
  1421. panelMain.setBounds(0, 0, 435, 195);
  1422.  
  1423. { // compute preferred size
  1424. Dimension preferredSize = new Dimension();
  1425. for (int i = 0; i < contentPane.getComponentCount(); i++) {
  1426. Rectangle bounds = contentPane.getComponent(i).getBounds();
  1427. preferredSize.width = Math.max(bounds.x + bounds.width,
  1428. preferredSize.width);
  1429. preferredSize.height = Math.max(bounds.y + bounds.height,
  1430. preferredSize.height);
  1431. }
  1432. Insets insets = contentPane.getInsets();
  1433. preferredSize.width += insets.right;
  1434. preferredSize.height += insets.bottom;
  1435. contentPane.setMinimumSize(preferredSize);
  1436. contentPane.setPreferredSize(preferredSize);
  1437. }
  1438. pack();
  1439. setLocationRelativeTo(getOwner());
  1440. // GEN-END:initComponents
  1441. /* LOAD SAVED SELECTION INFO
  1442. try {
  1443. final BufferedReader in = new BufferedReader(new FileReader(
  1444. settingsFile));
  1445. String line;
  1446. String[] opts = {};
  1447. while ((line = in.readLine()) != null) {
  1448. if (line.contains(":")) {
  1449. opts = line.split(":");
  1450. }
  1451. }
  1452. in.close();
  1453. if (opts.length > 10) {
  1454. if (opts[0].equals("true")) {
  1455. checkBoxCustomID.setSelected(true);
  1456. textFieldCustomID.setEnabled(true);
  1457. textFieldCustomID.setText(opts[1]);
  1458. }
  1459. comboBoxPreSetID
  1460. .setSelectedIndex(Integer.parseInt(opts[2]));
  1461. if (opts[3].equals("true")) {
  1462. checkBoxRewards.setSelected(true);
  1463. checkBoxDropCoins.setEnabled(true);
  1464. if (opts[4].equals("true")) {
  1465. checkBoxDropCoins.setSelected(true);
  1466. }
  1467. }
  1468. if (opts[5].equals("true")) {
  1469. checkBoxCookSecondItem.setSelected(true);
  1470. comboBoxPreSetID2.setEnabled(true);
  1471. checkBoxCustomID2.setEnabled(true);
  1472. if (opts[8].equals("true")) {
  1473. checkBoxCustomID2.setSelected(true);
  1474. textFieldCustomID2.setEnabled(true);
  1475. textFieldCustomID2.setText(opts[6]);
  1476. }
  1477. }
  1478. comboBoxPreSetID2.setSelectedIndex(Integer
  1479. .parseInt(opts[7]));
  1480. if (opts[9].equals("false")) {
  1481. checkBoxAFK.setSelected(false);
  1482. }
  1483. comboBoxLocation.setSelectedIndex(Integer
  1484. .parseInt(opts[10]));
  1485. sliderMouseSpeed.setValue(Integer.parseInt(opts[11]));
  1486. }
  1487. } catch (final Exception e2) {
  1488. log.warning("Error loading settings.");
  1489. }
  1490. // END LOAD SAVED SELECTION INFO */
  1491. }
  1492.  
  1493. // GEN-BEGIN:variables
  1494. private JPanel panelMain;
  1495. private JComboBox comboBoxPreSetID;
  1496. private JLabel label1;
  1497. private JButton buttonStart;
  1498. private JButton buttonExit;
  1499. private JCheckBox checkBoxCustomID;
  1500. private JTextField textFieldCustomID;
  1501. private JLabel label2;
  1502. private JButton buttonVisitThread;
  1503. private JCheckBox checkBoxRewards;
  1504. private JCheckBox checkBoxDropCoins;
  1505. private JComboBox comboBoxPreSetID2;
  1506. private JCheckBox checkBoxCustomID2;
  1507. private JTextField textFieldCustomID2;
  1508. private JCheckBox checkBoxCookSecondItem;
  1509. private JCheckBox checkBoxAFK;
  1510. private JSlider sliderMouseSpeed;
  1511. private JLabel label3;
  1512. private JLabel label4;
  1513. private JLabel label5;
  1514. private JLabel label6;
  1515. private JComboBox comboBoxLocation;
  1516. // GEN-END:variables
  1517. }
  1518.  
  1519. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement