Guest User

Untitled

a guest
Jan 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.99 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.RenderingHints;
  7.  
  8. import org.rsbot.event.listeners.PaintListener;
  9. import org.rsbot.script.Script;
  10. import org.rsbot.script.ScriptManifest;
  11. import org.rsbot.script.wrappers.RSArea;
  12. import org.rsbot.script.wrappers.RSGroundItem;
  13. import org.rsbot.script.wrappers.RSObject;
  14. import org.rsbot.script.wrappers.RSTile;
  15. import org.rsbot.script.methods.GrandExchange.GEItem;
  16. import org.rsbot.script.wrappers.Web;
  17.  
  18. @ScriptManifest(authors = { "Dandan Boy" }, keywords = { "Grape, Vassda, Money, Misc" }, name = "VassdaGrape", version = 0.1, description = "Start at Varrock west bank. Collects grapes. REQ: LVL 32 Cooking and chef's hat")
  19. public class VassdaGrape extends Script implements PaintListener {
  20.  
  21. private int grapeID = 1987;
  22. private int stairsDownID[] = { 24074, 24075 };
  23. private int stairsUpID[] = { 24073, 24074 };
  24. private int bankerID = 11402;
  25.  
  26. // Paint
  27. public String status;
  28. public long startTime = System.currentTimeMillis();
  29. public int grapesHour = 0;
  30. public int profit = 0;
  31. public int price = 0;
  32. public float secGrapes = 0.0F;
  33. public float hourGrapes = 0.0F;
  34. public int profitHour = 0;
  35. long Runtime;
  36.  
  37. RSTile doorTileID = new RSTile(3143, 3443);
  38. RSTile stairsTileID = new RSTile(3144, 3448);
  39. RSTile grapeTileID = new RSTile(3143, 3450);
  40. RSTile insideGuildTile = new RSTile(3143, 3444);
  41. RSTile onGrapeTile = new RSTile(3144, 3450);
  42.  
  43. // Objects
  44. RSObject stairs;
  45. RSObject door;
  46. RSObject table;
  47. RSObject walkObj;
  48. GEItem grapeGE;
  49.  
  50. // GroundItems
  51. RSGroundItem grapes;
  52.  
  53. private static Web web = null;
  54.  
  55. private int invCount = 1337;
  56. private int grapeTaken = 0;
  57.  
  58. // Areas
  59. RSArea bankArea = new RSArea(new RSTile(3182, 3433), new RSTile(3189, 3446));
  60. RSArea grapeArea = new RSArea(new RSTile(3140, 3446),
  61. new RSTile(3146, 3453));
  62. RSArea outGuildArea = new RSArea(new RSTile(3147, 3439), new RSTile(3139,
  63. 3443));
  64. RSArea guildLevel1 = new RSArea(new RSTile(3142, 3444), new RSTile(3146,
  65. 3452));
  66. RSArea guildLevel2 = new RSArea(new RSTile(3140, 3446), new RSTile(3148,
  67. 3452));
  68.  
  69. public enum states {
  70. GO_TO_BANK, GO_TO_GRAPES, OPEN_DOOR, BANK, TAKE, CLIMB_STAIRS_DOWN, CLIMB_STAIRS_UP, WALK_TO_BANK, WALK_TO_GUILD, WALK_TO_DOOR, WALK_TO_STAIRS;
  71. }
  72.  
  73. public states getState() {
  74.  
  75. if (inventory.isFull()) {
  76. if (atBank()) {
  77. return states.BANK;
  78. } else {
  79. return states.GO_TO_BANK;
  80. }
  81. } else {
  82. if (!atGrapes()) {
  83. return states.GO_TO_GRAPES;
  84. } else {
  85. return states.TAKE;
  86. }
  87. }
  88.  
  89. }
  90.  
  91. public states getLocationStateBank() {
  92. if (atGrapes() || atFloorTwo()) {
  93. return states.CLIMB_STAIRS_DOWN;
  94. } else if (calc.distanceTo(doorTileID) <= 5 && atFloorOne()) {
  95. return states.OPEN_DOOR;
  96. } else if (!atFloorOne() && !atFloorTwo() && !atGrapes()) {
  97. return states.WALK_TO_BANK;
  98. } else {
  99. return states.WALK_TO_DOOR;
  100. }
  101. }
  102.  
  103. public states getLocationStateGrapes() {
  104. if (calc.distanceTo(doorTileID) >= 5 && !atFloorOne() && !atFloorTwo()
  105. && !atGrapes()) {
  106. return states.WALK_TO_GUILD;
  107. } else if (calc.distanceTo(stairsTileID) >= 5 && atFloorOne()) {
  108. return states.WALK_TO_STAIRS;
  109. } else if (atFloorOne() || atFloorTwo()) {
  110. return states.CLIMB_STAIRS_UP;
  111. } else {
  112. return states.OPEN_DOOR;
  113. }
  114. }
  115.  
  116. public boolean onStart() {
  117.  
  118. startTime = System.currentTimeMillis();
  119. grapeGE = grandExchange.lookup(grapeID);
  120. price = grapeGE.getGuidePrice();
  121. return true;
  122. }
  123.  
  124. public int loop() {
  125. try {
  126. switch (getState()) {
  127. case BANK:
  128. status = "Banking";
  129. RSObject bankbooth = objects.getNearest(bankerID);
  130. if ((!bank.isOpen()) && (bankbooth != null)) {
  131. bankbooth.doAction("Use-Quickly");
  132. return random(250, 500);
  133. }
  134.  
  135. if (bank.isOpen()) {
  136. bank.depositAll();
  137. }
  138.  
  139. bank.close();
  140.  
  141. break;
  142.  
  143. case TAKE:
  144. status = "Taking grapes";
  145. if (calc.distanceTo(grapeTileID) >= 2) {
  146. walking.walkTo(grapeTileID);
  147. }
  148. RSGroundItem grapes = groundItems.getNearest(grapeID);
  149. if (grapes != null) {
  150.  
  151. mouse.click(calc
  152. .tileToScreen(groundItems.getNearest(grapeID)
  153. .getLocation(), -500), true);
  154. if (invCount != inventory.getCount(grapeID)) {
  155. grapeTaken++;
  156. invCount = inventory.getCount(grapeID);
  157. }
  158. sleep(1000, 1500);
  159.  
  160.  
  161. }
  162. int rdm2 = random(1, 1000);
  163. if (rdm2 <= 5) {
  164. status = "Move Mouse Offscreen";mouse.moveOffScreen();
  165. } else if (rdm2 >= 51 && rdm2 <= 58) {
  166. status = "Move mouse slightly";
  167. mouse.moveSlightly();
  168. }
  169. break;
  170.  
  171. case GO_TO_BANK:
  172. switch (getLocationStateBank()) {
  173. case WALK_TO_BANK:
  174. status = "Walking To Bank";
  175. RSTile[] pathToBank = { new RSTile(3143, 3443),
  176. new RSTile(3149, 3443), new RSTile(3159, 3451),
  177. new RSTile(3169, 3450), new RSTile(3181, 3450),
  178. new RSTile(3185, 3445), new RSTile(3182, 3444) };
  179. RSTile[] randomizedPath = walking.randomizePath(pathToBank,
  180. 2, 2);
  181. walking.walkPathMM(randomizedPath, 15);
  182. break;
  183.  
  184. case OPEN_DOOR:
  185. status = "Opening Door";
  186. door = objects.getTopAt(doorTileID);
  187. if (door != null) {
  188. door.doAction("Open");
  189. }
  190. break;
  191.  
  192. case CLIMB_STAIRS_DOWN:
  193. status = "Climbing Down Stairs";
  194. if (calc.distanceTo(stairsTileID) >= 5) {
  195. walking.walkTileMM(stairsTileID);
  196. }
  197. stairs = objects.getNearest(stairsDownID);
  198. if (stairs != null) {
  199. stairs.doAction("Climb-down");
  200. }
  201. break;
  202.  
  203. case WALK_TO_DOOR:
  204. status = "Walking to Door";
  205. walking.walkTileMM(doorTileID);
  206. break;
  207.  
  208. }
  209. break;
  210. case GO_TO_GRAPES:
  211. switch (getLocationStateGrapes()) {
  212. case WALK_TO_GUILD:
  213. status = "Walking To grapes";
  214. RSTile[] pathToGrapes = { new RSTile(3174, 3448),
  215. new RSTile(3166, 3450), new RSTile(3156, 3449),
  216. new RSTile(3149, 3445), new RSTile(3143, 3443) };
  217. RSTile[] randomizedPath = walking.randomizePath(
  218. pathToGrapes, 2, 2);
  219. walking.walkPathMM(randomizedPath, 15);
  220.  
  221. break;
  222.  
  223. case OPEN_DOOR:
  224. status = "Opening Door";
  225. walking.walkTo(doorTileID);
  226. door = objects.getTopAt(doorTileID);
  227. if (door != null) {
  228. door.doAction("Open");
  229. }
  230. break;
  231.  
  232. case CLIMB_STAIRS_UP:
  233. status = "Climbing Up Stairs";
  234. stairs = objects.getNearest(stairsUpID);
  235. if (stairs != null) {
  236. stairs.doAction("Climb-Up");
  237. }
  238. break;
  239. case WALK_TO_STAIRS:
  240. status = "Walking to Stairs";
  241. walking.walkTileMM(stairsTileID);
  242. break;
  243. }
  244. break;
  245.  
  246. }
  247.  
  248. } catch (Exception e) {
  249. log("Ooops! Something went wrong. Heres the error:");
  250. log(e.toString());
  251. }
  252. while (getMyPlayer().isMoving()) {
  253. sleep(500, 600);
  254. }
  255. runControl();
  256. antiban();
  257.  
  258. return random(10, 50);
  259. }
  260.  
  261. private boolean atGrapes() {
  262. return grapeArea.contains(getMyPlayer().getLocation())
  263. && game.getPlane() == 2;
  264. }
  265.  
  266. private boolean atBank() {
  267. return bankArea.contains(getMyPlayer().getLocation())
  268. && game.getPlane() == 0;
  269. }
  270.  
  271. private boolean atFloorTwo() {
  272. return guildLevel2.contains(getMyPlayer().getLocation())
  273. && game.getPlane() == 1;
  274. }
  275.  
  276. private boolean atFloorOne() {
  277. return guildLevel1.contains(getMyPlayer().getLocation())
  278. && game.getPlane() == 0;
  279. }
  280.  
  281. private void walk(RSTile tile) {
  282. if (web == null) {
  283. web = walking.getWebPath(tile);
  284. } else {
  285. if (!web.traverse()) {
  286. web = null;
  287. }
  288. sleep(50);// So it doesn't burn out your CPU.
  289. }
  290. if (web.atDestination()) {
  291. web = null;
  292. }
  293. }
  294.  
  295. public void antiban() {
  296. int randomNum = random(1, 50);
  297. int r = random(1, 100);
  298. if (randomNum == 6) {
  299. if (r == 2) {
  300. this.status = "Using AntiBan|Open Random Tab";
  301. this.game.openTab(random(1, 14));
  302. }
  303. if (r == 3) {
  304. this.status = "Using AntiBan|Move Mouse";
  305. this.mouse.moveRandomly(50, 300);
  306. }
  307. if (r == 4) {
  308. this.status = "Using AntiBan|Move Mouse";
  309. this.mouse.moveRandomly(70, 380);
  310. }
  311. if (r == 5) {
  312. this.status = "Using AntiBan|Rotate Camera";
  313. this.camera.setAngle(random(25, 49));
  314. }
  315. if (r == 6) {
  316. this.status = "Using AntiBan|Rotate Camera";
  317. this.camera.setAngle(random(50, 100));
  318. }
  319. if (r == 7) {
  320. this.status = "Using AntiBan|Rotate Camera";
  321. this.camera.setAngle(random(100, 120));
  322. }
  323. if (r == 8) {
  324. this.status = "Using AntiBan|Rotate Camera";
  325. this.camera.setAngle(random(190, 230));
  326. }
  327. if (r == 9) {
  328. this.status = "Using AntiBan|Rotate Camera";
  329. this.camera.setAngle(random(150, 180));
  330. }
  331. if (r == 10) {
  332. this.status = "Using AntiBan|Rotate Camera";
  333. this.camera.setAngle(random(250, 260));
  334. }
  335. if (r == 11) {
  336. this.status = "Using AntiBan|Open Skill Tab";
  337. if (this.game.getCurrentTab() != 4)
  338. this.game.openTab(4);
  339. else
  340. return;
  341. }
  342. if (r == 35) {
  343. this.status = "Using AntiBan|Move Mouse To Woodutting Skill";
  344. if (this.game.getCurrentTab() != 1) {
  345. this.game.openTab(1);
  346. sleep(random(500, 700));
  347. this.mouse.move(random(680, 730), random(355, 370));
  348. sleep(random(1500, 5000));
  349. }
  350. }
  351. }
  352. }
  353.  
  354. int runControl() {
  355. if ((!walking.isRunEnabled()) && (walking.getEnergy() > random(20, 30))) {
  356. walking.setRun(true);
  357. return 500;
  358. }
  359. if (walking.getEnergy() < random(20, 30)) {
  360. status = "Resting";
  361. walking.rest();
  362. }
  363. return 10;
  364. }
  365.  
  366. private final RenderingHints antialiasing = new RenderingHints(
  367. RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  368.  
  369. private final Color color1 = new Color(0, 255, 255, 110);
  370. private final Color color2 = new Color(0, 255, 255);
  371. private final Color color3 = new Color(0, 255, 255, 100);
  372. private final Color color4 = new Color(255, 255, 0);
  373. private final Color color5 = new Color(0, 0, 0);
  374. private final Color color6 = new Color(0, 0, 0, 103);
  375. private final Color color7 = new Color(255, 255, 51);
  376. private final Color colorgreen = new Color(0, 255, 0, 100);
  377. private final Color colorred = new Color(255, 0, 0, 100);
  378.  
  379. private final BasicStroke stroke1 = new BasicStroke(1.0F);
  380.  
  381. private final Font font1 = new Font("Comic Sans MS", 0, 10);
  382.  
  383. public void onRepaint(Graphics g1) {
  384. if (game.isLoggedIn()) {
  385. Graphics2D g = (Graphics2D) g1;
  386. g.setRenderingHints(antialiasing);
  387.  
  388. long millis = System.currentTimeMillis() - startTime;
  389. long hours = millis / 3600000L;
  390. millis -= hours * 3600000L;
  391. long minutes = millis / 60000L;
  392. millis -= minutes * 60000L;
  393. long seconds = millis / 1000L;
  394. long minutes2 = (int) (minutes + hours * 60);
  395.  
  396. if (((minutes > 0L) || (hours > 0L) || (seconds > 0L))
  397. && (grapeTaken > 0)) {
  398. secGrapes = (grapeTaken / (float) (seconds + minutes * 60L + hours * 60L * 60L));
  399. }
  400. hourGrapes = (secGrapes * 3600.0F);
  401.  
  402. profitHour = (price * (int) Math.abs(hourGrapes));
  403. profitHour = (Math.abs(profitHour) / 1000);
  404. profit = (price * grapeTaken);
  405.  
  406. g.setColor(color1);
  407. g.fillRect(18, 15, 170, 18);
  408. g.setColor(color2);
  409. g.setStroke(stroke1);
  410. g.drawRect(18, 15, 170, 18);
  411. g.setColor(color3);
  412. g.fillRect(18, 38, 170, 103);
  413. g.setColor(color2);
  414. g.drawRect(18, 38, 170, 103);
  415. g.setColor(color3);
  416. g.fillRect(18, 145, 170, 50);
  417. g.setColor(color2);
  418. g.drawRect(18, 145, 170, 50);
  419. g.setFont(font1);
  420. g.setColor(color4);
  421. g.drawString("Runtime : " + hours + ":" + minutes + ":" + seconds,
  422. 23, 55);
  423. g.drawString("Grapes Taken : " + grapeTaken, 23, 71);
  424. g.drawString("Grapes/Hour : " + hourGrapes, 23, 87);
  425. g.drawString("Profit : " + profit, 23, 103);
  426. g.drawString("Profit/Hour : " + profitHour + "k", 23, 119);
  427. g.drawString("VassdaGrape 0.1 by Dandan Boy ", 21, 29);
  428. g.drawString("Status : " + status, 23, 135);
  429. g.drawLine(mouse.getLocation().x - 5, mouse.getLocation().y,
  430. mouse.getLocation().x + 5, mouse.getLocation().y);
  431. g.drawLine(mouse.getLocation().x, mouse.getLocation().y - 5,
  432. mouse.getLocation().x, mouse.getLocation().y + 5);
  433. }
  434.  
  435. }
  436. }
Add Comment
Please, Sign In to add comment