Advertisement
deww1

fixed-should work.. search for "the script writer"

Jun 30th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.78 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.imageio.ImageIO;
  3. import java.io.IOException;
  4. import java.net.URL;
  5. import org.rsbot.event.listeners.PaintListener;
  6. import org.rsbot.script.Script;
  7. import org.rsbot.script.ScriptManifest;
  8. import org.rsbot.script.methods.GrandExchange.GEItem;
  9. import org.rsbot.script.wrappers.*;
  10.  
  11. @ScriptManifest(authors = {"Furion"}, keywords = {"money, make, maker, furion"}, name = "Furion's Guild Looter", description = "Loots valuable things from the cooking guild.", version = 1.0)
  12.  
  13. public class FurionsGuildLooter extends Script implements PaintListener {
  14.  
  15. int chocolateID = 1973;
  16. int appleID = 1955;
  17. int grapesID = 1987;
  18. int doorID = 2712;
  19. int bankID = 782;
  20. int appleIndicationID = 24212;
  21. int grapesIndicationID = 24067;
  22. int runEnergy = random(55, 100);
  23. int stairsID[] = { 24073, 24074, 24075 };
  24. int chocolatePrice;
  25. int applesPrice;
  26. int grapesPrice;
  27. int chocolatePicked;
  28. int applesPicked;
  29. int grapesPicked;
  30. int chocoInInv;
  31. int applesInInv;
  32. int grapesInInv;
  33. int lootPerHour;
  34. boolean grapesCollected = false;
  35. boolean applesCollected = false;
  36. int collected = 0;
  37. long millis = 0;
  38. long hours = 0;
  39. long minutes = 0;
  40. long seconds = 0;
  41. long startTime = 0;
  42. long nextRun;
  43. String botStatus = "null";
  44. GEItem chocolate;
  45. GEItem grapes;
  46. GEItem apples;
  47. RSTile bankTile = new RSTile(3185, 3442);
  48. RSTile guildTile = new RSTile(3143, 3443);
  49. RSTile guildTile2 = new RSTile(3143, 3445);
  50. RSTile chocolatePickUp = new RSTile(3143, 3453);
  51. RSTile chocolatePickUpID = new RSTile(3143, 3452);
  52. RSTile applePickUp = new RSTile(3140, 3447, 1);
  53. RSTile applePickUp2 = new RSTile(3141, 3447, 1);
  54. RSTile applePickUp3 = new RSTile(3141, 3447, 2);
  55. RSTile applePickUpID = new RSTile(3141, 3448, 1);
  56. RSTile applePickUpID2 = new RSTile(3141, 3446, 2);
  57. RSTile grapesPickUp = new RSTile(3144, 3450, 2);
  58. RSTile grapesPickUpID = new RSTile(3143, 3450);
  59. RSArea doorArea = new RSArea(new RSTile(3136, 3443), new RSTile(3148, 3438));
  60. RSArea chocolateArea = new RSArea(new RSTile(3140, 3444), new RSTile(3144,3453));
  61. RSArea bankArea = new RSArea(new RSTile(3178, 3447), new RSTile(3195, 3431));
  62. //RSArea appleArea = new RSArea(new RSTile(3148, 3152, 1), new RSTile(3138, 3446, 1));
  63. //RSArea grapesArea = new RSArea(new RSTile(3146, 3446, 2), new RSTile(3138,3454, 2));
  64.  
  65.  
  66. private enum lootingStates {walkToGuild, collectChocolate, collectApples, collectGrapes, leaveGuild, walkToBank, bankLoot, unknownState };
  67.  
  68. public boolean onStart() {
  69. log("Loading Prices.. please wait.");
  70. chocolate = grandExchange.lookup(chocolateID);
  71. apples = grandExchange.lookup(appleID);
  72. grapes = grandExchange.lookup(grapesID);
  73. chocolatePrice = chocolate.getGuidePrice();
  74. applesPrice = apples.getGuidePrice();
  75. grapesPrice = grapes.getGuidePrice();
  76. startTime = System.currentTimeMillis();
  77. nextRun = System.currentTimeMillis();
  78. botStatus = "Initializing...";
  79. return true;
  80. }
  81.  
  82.  
  83. /*
  84. * For the script writer.
  85. * All I did to this script, is add three RSGroundItems.
  86. * added a null check to each of the three collecting states,
  87. * and check if they were on screen.
  88. * If they were on screen OR if the areas/indicators are right.
  89. */
  90. private lootingStates mainStates() {
  91. RSGroundItem Grape = groundItems.getNearest(grapesID);
  92. RSGroundItem Choco = groundItems.getNearest(chocolateID);
  93. RSGroundItem Apple = groundItems.getNearest(appleID);
  94. if (!inventory.isFull() && chocolateArea.contains(getMyPlayer().getLocation()) || !inventory.isFull() && Choco != null && Choco.isOnScreen() /* && !getMyPlayer().isMoving()*/) {
  95. botStatus = "Collecting chocolate...";
  96. return lootingStates.collectChocolate;
  97. }
  98. if (!inventory.isFull() && indicateApple() || !inventory.isFull() && Apple != null && Apple.isOnScreen()) {
  99. botStatus = "Collecting apples...";
  100. return lootingStates.collectApples;
  101. }
  102. if (!inventory.isFull() && indicateGrapes() || !inventory.isFull() && Grape != null && Grape.isOnScreen()) {
  103. botStatus = "Collecting grapes...";
  104. return lootingStates.collectGrapes;
  105. }
  106. if (inventory.isFull() && indicateApple() || inventory.isFull() && indicateGrapes()) {
  107. botStatus = "Leaving guild...";
  108. return lootingStates.leaveGuild;
  109. }
  110. if (doorArea.contains(getMyPlayer().getLocation()) && inventory.isFull()) {
  111. botStatus = "Walking to bank...";
  112. return lootingStates.walkToBank;
  113. }
  114. if (!chocolateArea.contains(getMyPlayer().getLocation()) && inventory.isFull() && !bankArea.contains(getMyPlayer().getLocation())) {
  115. botStatus = "Walking to bank...";
  116. return lootingStates.walkToBank;
  117. }
  118. if (inventory.isFull() && bankArea.contains(getMyPlayer().getLocation())) {
  119. botStatus = "Banking...";
  120. return lootingStates.bankLoot;
  121. } else if (!inventory.isFull()) {
  122. botStatus = "Walking to guild...";
  123. return lootingStates.walkToGuild;
  124. }
  125. if (!chocolateArea.contains(getMyPlayer().getLocation()) && !bankArea.contains(getMyPlayer().getLocation()) && !inventory.isFull()) {
  126. botStatus = "Walking to guild...";
  127. return lootingStates.walkToGuild;
  128. }
  129. botStatus = "null";
  130. return lootingStates.unknownState;
  131. }
  132.  
  133. public boolean indicateApple() {
  134. RSObject appleIndicate = objects.getNearest(appleIndicationID);
  135. if(appleIndicate != null && appleIndicate.isOnScreen()) {
  136. return true;
  137. } else {
  138. return false;
  139. }
  140. }
  141.  
  142. public boolean indicateGrapes() {
  143. RSObject grapesIndicate = objects.getNearest(grapesIndicationID);
  144. if(grapesIndicate != null && grapesIndicate.isOnScreen()) {
  145. return true;
  146. } else {
  147. return false;
  148. }
  149.  
  150.  
  151. }
  152.  
  153. public void startRunning(final int energy) {
  154. if (nextRun < System.currentTimeMillis() && walking.getEnergy() >= energy && !walking.isRunEnabled()) {
  155. nextRun = System.currentTimeMillis() + 7000;
  156. runEnergy = random(40, 100);
  157. walking.setRun(true);
  158. sleep(random(400, 600));
  159. }
  160. }
  161.  
  162. public void climbUp() {
  163. RSObject stairsObject = objects.getNearest(stairsID);
  164. camera.turnTo(stairsObject);
  165. stairsObject.interact("Climb-Up");
  166. sleep(random(400, 600));
  167. }
  168.  
  169. public void climbDown() {
  170. RSObject stairsObject = objects.getNearest(stairsID);
  171. camera.turnTo(stairsObject);
  172. stairsObject.interact("Climb-Down");
  173. sleep(random(400, 600));
  174. }
  175.  
  176. private void openBank() {
  177. RSObject bankObject = objects.getNearest(bankID);
  178. if (bankObject != null && bankObject.isOnScreen() && !getMyPlayer().isMoving()) {
  179. bank.open();
  180. sleep(random(350, 500));
  181. if (bank.isOpen()) {
  182. bank.depositAll();
  183. sleep(random(350, 500));
  184. bank.close();
  185. sleep(random(250, 400));
  186. }
  187. }
  188. }
  189. public void openDoor() {
  190. RSObject doorObject = objects.getNearest(doorID);
  191. if (doorObject != null && doorObject.isOnScreen() && !getMyPlayer().isMoving()) {
  192. camera.turnTo(doorObject);
  193. doorObject.interact("Open");
  194. sleep(random(1000, 1200));
  195. }
  196. }
  197.  
  198. @Override
  199. public int loop() {
  200. if (game.isLoggedIn()) {
  201. if(inventory.isFull() && chocolateArea.contains(getMyPlayer().getLocation())) {
  202. walking.walkTo(guildTile2);
  203. sleep(random(350, 500));
  204. openDoor();
  205. sleep(random(350, 500));
  206. }
  207. if(!inventory.isFull() && doorArea.contains(getMyPlayer().getLocation())) {
  208. openDoor();
  209. sleep(random(350, 500));
  210. }
  211. switch (mainStates()) {
  212.  
  213. case collectChocolate:
  214. RSGroundItem chocolateItem = groundItems.getNearest(chocolateID);
  215. if (chocolateItem != null && chocolateItem.isOnScreen() && !getMyPlayer().isMoving()) {
  216. camera.turnTo(chocolatePickUp);
  217. sleep(random(500, 1000));
  218. mouse.move(calc.tileToScreen(chocolatePickUp, -500));
  219. String[] actions = menu.getActions();
  220. for(String act : actions) {
  221. if(act.contains("Take")) {
  222. mouse.click(calc.tileToScreen(chocolateItem.getLocation(), -500), true);
  223. sleep(random(500, 550));
  224. if (chocoInInv < inventory.getCount(chocolateID)) {
  225. chocolatePicked++;
  226. }
  227. chocoInInv = inventory.getCount(chocolateID);
  228. }
  229. }
  230. } else {
  231. climbUp();
  232. sleep(random(1500, 2000));
  233. }
  234.  
  235. return 50;
  236.  
  237. case collectApples:
  238. // <editor-fold defaultstate="collapsed" desc="comment">
  239. // RSGroundItem appleItem = groundItems.getNearest(appleID);
  240. // if (appleItem != null && appleItem.isOnScreen() && !getMyPlayer().isMoving()) {
  241. // walking.walkTo(applePickUpID);
  242. // sleep(random(250, 500));
  243. // mouse.move(calc.tileToScreen(applePickUp, -500));
  244. // String[] actions = menu.getActions();
  245. // for(String act : actions) {
  246. // if(act.contains("Take")) {
  247. // mouse.click(calc.tileToScreen(appleItem.getLocation(), -500), true);
  248. // if (applesInInv < inventory.getCount(appleID)) {
  249. // applesPicked++;
  250. // }
  251. // applesInInv = inventory.getCount(appleID);
  252. // }
  253. // }
  254. // }
  255. // sleep(random(500, 1000));
  256. // if (appleItem != null && appleItem.isOnScreen() && !getMyPlayer().isMoving()) {
  257. // camera.turnTo(applePickUp2);
  258. // mouse.move(calc.tileToScreen(applePickUp2, -500));
  259. // String[] actions = menu.getActions();
  260. // for(String act : actions) {
  261. // if(act.contains("Take")) {
  262. // mouse.click(calc.tileToScreen(appleItem.getLocation(), -500), true);
  263. // if (applesInInv < inventory.getCount(appleID)) {
  264. // applesPicked++;
  265. // }
  266. // applesInInv = inventory.getCount(appleID);
  267. // }
  268. // }
  269. // } else {
  270. // climbUp();
  271. // sleep(random(1000, 2000));
  272. // }// </editor-fold>
  273. if (collectingApples()) {
  274. collectingApples();
  275. }
  276. return 50;
  277.  
  278. case leaveGuild:
  279. if(inventory.isFull() && indicateGrapes()) {
  280. climbDown();
  281. sleep(random(1200, 2000));
  282. climbDown();
  283. sleep(random(1200, 2000));
  284. }
  285. if(inventory.isFull() && indicateApple()) {
  286. climbDown();
  287. sleep(random(1200, 2000));
  288. }
  289. if(inventory.isFull() && chocolateArea.contains(getMyPlayer().getLocation())) {
  290. openDoor();
  291. sleep(random(500, 550));
  292. }
  293.  
  294. return 50;
  295.  
  296. case walkToBank:
  297. final RSWeb walkBank = web.getWeb(getMyPlayer().getLocation(), bankTile);
  298. final RSObject bankBooth = objects.getNearest(bankID);
  299. if (walkBank != null) {
  300. if(!walkBank.finished()) {
  301. if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) < 4) {
  302. try {
  303. walkBank.step();
  304. sleep(1000, 1200);
  305. while(getMyPlayer().isMoving()){
  306. sleep(1000, 1200);
  307. }
  308. } catch (Exception ignored) {
  309. sleep(300, 500);
  310. }
  311. }
  312. }
  313. if(calc.distanceTo(bankTile) >= 6){
  314. walking.walkTileMM(bankTile);
  315. sleep(random(350, 400));
  316. camera.turnTo(bankBooth);
  317. }
  318. }
  319. return 50;
  320.  
  321. case walkToGuild:
  322. final RSWeb walkGuild = web.getWeb(getMyPlayer().getLocation(), guildTile);
  323. if (walkGuild != null) {
  324. if (!walkGuild.finished()) {
  325. if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) < 4) {
  326. try {
  327. walkGuild.step();
  328. sleep(1000, 1200);
  329. while(getMyPlayer().isMoving()){
  330. sleep(1000, 1200);
  331. }
  332. } catch (Exception ignored) {
  333. sleep(300, 500);
  334. }
  335. }
  336. }
  337. if(calc.distanceTo(guildTile) >= 6){
  338. walking.walkTileMM(guildTile);
  339. sleep(random(300, 350));
  340. }
  341. openDoor();
  342. sleep(random(500, 550));
  343. walking.walkTo(chocolatePickUpID);
  344. sleep(random(750, 800));
  345. }
  346.  
  347. return 50;
  348.  
  349. case bankLoot:
  350. openBank();
  351. sleep(random(1500, 2000));
  352. return 50;
  353.  
  354. case collectGrapes:
  355. // <editor-fold defaultstate="collapsed" desc="comment">
  356. // RSGroundItem appleItem11 = groundItems.getNearest(appleID);
  357. // if (appleItem11 != null && appleItem11.isOnScreen() && !getMyPlayer().isMoving()) {
  358. // walking.walkTo(applePickUpID2);
  359. // sleep(random(350, 500));
  360. // camera.turnTo(applePickUp3);
  361. // sleep(random(500, 550));
  362. // mouse.move(calc.tileToScreen(applePickUp3, -500));
  363. // String[] actions = menu.getActions();
  364. // for(String act : actions) {
  365. // if(act.contains("Take")) {
  366. // mouse.click(calc.tileToScreen(appleItem11.getLocation(), -500), true);
  367. // if (grapesInInv < inventory.getCount(grapesID)) {
  368. // grapesPicked++;
  369. // }
  370. // grapesInInv = inventory.getCount(grapesID);
  371. // }
  372. // }
  373. // }
  374. // sleep(random(1500, 2000));
  375. // RSGroundItem grapesItem = groundItems.getNearest(grapesID);
  376. // if (grapesItem != null && grapesItem.isOnScreen() && !getMyPlayer().isMoving()) {
  377. // walking.walkTo(grapesPickUpID);
  378. // sleep(random(350, 500));
  379. // camera.turnTo(grapesPickUp);
  380. // sleep(random(500, 1000));
  381. // mouse.move(calc.tileToScreen(grapesPickUp, -500));
  382. // String[] actions1 = menu.getActions();
  383. // for(String act : actions1) {
  384. // if(act.contains("Take")) {
  385. // mouse.click(calc.tileToScreen(grapesItem.getLocation(), -500), true);
  386. // }
  387. // }
  388. // } else {
  389. // climbDown();
  390. // sleep(random(1500, 2000));
  391. // }// </editor-fold>
  392. if (collectingGrapes()) {
  393. sleep(1000,2000);
  394. collectingGrapes();
  395. }
  396. return 50;
  397.  
  398. }
  399. }
  400. return random(50, 100);
  401. }
  402.  
  403. private boolean collectingGrapes() {
  404.  
  405. RSGroundItem appleItem11 = groundItems.getNearest(appleID);
  406. if (appleItem11 != null && appleItem11.isOnScreen() && !getMyPlayer().isMoving()) {
  407. walking.walkTo(applePickUpID2);
  408. sleep(random(350, 500));
  409. camera.turnTo(applePickUp3);
  410. sleep(random(500, 550));
  411. mouse.move(calc.tileToScreen(applePickUp3, -500));
  412. String[] actions = menu.getActions();
  413. for(String act : actions) {
  414. if(act.contains("Take")) {
  415. mouse.click(calc.tileToScreen(appleItem11.getLocation(), -500), true);
  416. if (grapesInInv < inventory.getCount(grapesID)) {
  417. grapesPicked++;
  418. }
  419. grapesInInv = inventory.getCount(grapesID);
  420. return true;
  421. }
  422. }
  423. }
  424. sleep(random(1500, 2000));
  425. RSGroundItem grapesItem = groundItems.getNearest(grapesID);
  426. if (grapesItem != null && grapesItem.isOnScreen() && !getMyPlayer().isMoving()) {
  427. walking.walkTo(grapesPickUpID);
  428. sleep(random(350, 500));
  429. camera.turnTo(grapesPickUp);
  430. sleep(random(500, 1000));
  431. mouse.move(calc.tileToScreen(grapesPickUp, -500));
  432. String[] actions1 = menu.getActions();
  433. for(String act : actions1) {
  434. if(act.contains("Take")) {
  435. mouse.click(calc.tileToScreen(grapesItem.getLocation(), -500), true);
  436. return true;
  437. }
  438. }
  439. } else if (appleItem11 == null && grapesItem == null || !appleItem11.isOnScreen() && !grapesItem.isOnScreen() || grapesItem == null && appleItem11 == null && !grapesItem.isOnScreen() && !appleItem11.isOnScreen()) {
  440. climbDown();
  441. sleep(random(1500, 2000));
  442. }
  443.  
  444. return false;
  445. }
  446.  
  447. private boolean collectingApples() {
  448.  
  449. RSGroundItem appleItem = groundItems.getNearest(appleID);
  450. if (appleItem != null && appleItem.isOnScreen() && !getMyPlayer().isMoving()) {
  451. walking.walkTo(applePickUpID);
  452. sleep(random(250, 500));
  453. mouse.move(calc.tileToScreen(applePickUp, -500));
  454. String[] actions = menu.getActions();
  455. for(String act : actions) {
  456. if(act.contains("Take")) {
  457. mouse.click(calc.tileToScreen(appleItem.getLocation(), -500), true);
  458. sleep(400, 1500);
  459. if (applesInInv < inventory.getCount(appleID)) {
  460. applesPicked++;
  461. }
  462. applesInInv = inventory.getCount(appleID);
  463. //collected = true;
  464. collected++;
  465. log("collected = "+collected);
  466. return true;
  467. }
  468. }
  469. }
  470. sleep(random(500, 1000));
  471. if (appleItem != null && appleItem.isOnScreen() && !getMyPlayer().isMoving()) {
  472. camera.turnTo(applePickUp2);
  473. mouse.move(calc.tileToScreen(applePickUp2, -500));
  474. String[] actions = menu.getActions();
  475. for(String act : actions) {
  476. if(act.contains("Take")) {
  477. mouse.click(calc.tileToScreen(appleItem.getLocation(), -500), true);
  478. sleep(400, 1500);
  479. if (applesInInv < inventory.getCount(appleID)) {
  480. applesPicked++;
  481. }
  482. applesInInv = inventory.getCount(appleID);
  483. sleep(400,1500);
  484. //collected = false;
  485. collected++;
  486. log("collected = "+collected);
  487. return true;
  488. }
  489. }
  490. } else if (appleItem == null || !appleItem.isOnScreen() || appleItem == null && !appleItem.isOnScreen()) {
  491. climbUp();
  492. log("collected = "+collected);
  493. sleep(random(1000, 2000));
  494. }
  495.  
  496. return false;
  497. }
  498.  
  499. private final RenderingHints antialiasing = new RenderingHints(
  500. RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  501.  
  502. private Image getImage(String url) {
  503. try {
  504. return ImageIO.read(new URL(url));
  505. } catch(IOException e) {
  506. return null;
  507. }
  508. }
  509.  
  510. private final Color color1 = new Color(203, 181, 141);
  511. private final Color color2 = new Color(255, 255, 255);
  512. private final Color color3 = new Color(0, 0, 0);
  513.  
  514. private final BasicStroke stroke1 = new BasicStroke(1);
  515.  
  516. private final Font font1 = new Font("Tahoma", 0, 13);
  517. private final Font font2 = new Font("Tahoma", 0, 12);
  518. private final Font font3 = new Font("Tahoma", 0, 11);
  519.  
  520. private final Image img1 = getImage("http://i55.tinypic.com/6h16l4.png");
  521.  
  522. public void onRepaint(Graphics g1) {
  523. millis = System.currentTimeMillis() - startTime;
  524. hours = millis / (1000 * 60 * 60);
  525. millis -= hours * (1000 * 60 * 60);
  526. minutes = millis / (1000 * 60);
  527. millis -= minutes * (1000 * 60);
  528. seconds = millis / 1000;
  529. lootPerHour = (int) ((chocolatePrice * chocolatePicked) + (applesPrice * applesPicked) + (grapesPrice * grapesPicked) * 3600000D / (System.currentTimeMillis() - startTime));
  530.  
  531. Graphics2D g = (Graphics2D)g1;
  532. g.setRenderingHints(antialiasing);
  533.  
  534. g.setColor(color1);
  535. g.fillRoundRect(8, 346, 487, 111, 16, 16);
  536. g.setColor(color2);
  537. g.setStroke(stroke1);
  538. g.drawRoundRect(8, 346, 487, 111, 16, 16);
  539. g.setFont(font1);
  540. g.setColor(color3);
  541. g.drawString("Loot: " + (chocolatePrice * chocolatePicked) + (grapesPrice * grapesPicked) + (applesPrice * applesPicked), 329, 411);
  542. g.setColor(color2);
  543. //g.drawString("Loot: " + (chocolatePrice * chocolatePicked) + (grapesPrice * grapesPicked) + (applesPrice * applesPicked), 328, 410);
  544. g.setColor(color3);
  545. g.drawString("Status: " + botStatus, 128, 411);
  546. g.setColor(color2);
  547. //g.drawString("Status: " + botStatus, 127, 410);
  548. g.setFont(font2);
  549. g.setColor(color3);
  550. g.drawString("AntiBan: Idle", 129, 443);
  551. g.setColor(color2);
  552. //g.drawString("AntiBan: Idle", 128, 442);
  553. g.setColor(color3);
  554. g.drawString("Loot / Hr: " + lootPerHour, 329, 443);
  555. g.setColor(color2);
  556. //g.drawString("Loot / Hr: " + lootPerHour, 328, 442);
  557. g.setColor(color3);
  558. g.drawString("Welcome to Furion's Guild Looter!", 171, 369);
  559. g.setColor(color2);
  560. //g.drawString("Welcome to Furion's Guild Looter!", 170, 368);
  561. g.drawImage(img1, 28, 382, null);
  562. g.setFont(font3);
  563. g.setColor(color3);
  564. g.drawString("Made by Furion", 226, 387);
  565. g.setColor(color2);
  566. //g.drawString("Made by Furion", 225, 386);
  567. g.setColor(color3);
  568. g.drawString("Time running: " + +hours + ":" + minutes + ":" + seconds, 14, 368);
  569. g.setColor(color2);
  570. //g.drawString("Time running:", 13, 367);
  571. }
  572. @Override
  573. public void onFinish() {
  574. log("Thanks for using!");
  575. }
  576. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement