Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.RenderingHints;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.methods.GrandExchange.GEItem;
- import org.rsbot.script.wrappers.Web;
- @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")
- public class VassdaGrape extends Script implements PaintListener {
- private int grapeID = 1987;
- private int stairsDownID[] = { 24074, 24075 };
- private int stairsUpID[] = { 24073, 24074 };
- private int bankerID = 11402;
- // Paint
- public String status;
- public long startTime = System.currentTimeMillis();
- public int grapesHour = 0;
- public int profit = 0;
- public int price = 0;
- public float secGrapes = 0.0F;
- public float hourGrapes = 0.0F;
- public int profitHour = 0;
- long Runtime;
- RSTile doorTileID = new RSTile(3143, 3443);
- RSTile stairsTileID = new RSTile(3144, 3448);
- RSTile grapeTileID = new RSTile(3143, 3450);
- RSTile insideGuildTile = new RSTile(3143, 3444);
- RSTile onGrapeTile = new RSTile(3144, 3450);
- // Objects
- RSObject stairs;
- RSObject door;
- RSObject table;
- RSObject walkObj;
- GEItem grapeGE;
- // GroundItems
- RSGroundItem grapes;
- private static Web web = null;
- private int invCount = 1337;
- private int grapeTaken = 0;
- // Areas
- RSArea bankArea = new RSArea(new RSTile(3182, 3433), new RSTile(3189, 3446));
- RSArea grapeArea = new RSArea(new RSTile(3140, 3446),
- new RSTile(3146, 3453));
- RSArea outGuildArea = new RSArea(new RSTile(3147, 3439), new RSTile(3139,
- 3443));
- RSArea guildLevel1 = new RSArea(new RSTile(3142, 3444), new RSTile(3146,
- 3452));
- RSArea guildLevel2 = new RSArea(new RSTile(3140, 3446), new RSTile(3148,
- 3452));
- public enum states {
- 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;
- }
- public states getState() {
- if (inventory.isFull()) {
- if (atBank()) {
- return states.BANK;
- } else {
- return states.GO_TO_BANK;
- }
- } else {
- if (!atGrapes()) {
- return states.GO_TO_GRAPES;
- } else {
- return states.TAKE;
- }
- }
- }
- public states getLocationStateBank() {
- if (atGrapes() || atFloorTwo()) {
- return states.CLIMB_STAIRS_DOWN;
- } else if (calc.distanceTo(doorTileID) <= 5 && atFloorOne()) {
- return states.OPEN_DOOR;
- } else if (!atFloorOne() && !atFloorTwo() && !atGrapes()) {
- return states.WALK_TO_BANK;
- } else {
- return states.WALK_TO_DOOR;
- }
- }
- public states getLocationStateGrapes() {
- if (calc.distanceTo(doorTileID) >= 5 && !atFloorOne() && !atFloorTwo()
- && !atGrapes()) {
- return states.WALK_TO_GUILD;
- } else if (calc.distanceTo(stairsTileID) >= 5 && atFloorOne()) {
- return states.WALK_TO_STAIRS;
- } else if (atFloorOne() || atFloorTwo()) {
- return states.CLIMB_STAIRS_UP;
- } else {
- return states.OPEN_DOOR;
- }
- }
- public boolean onStart() {
- startTime = System.currentTimeMillis();
- grapeGE = grandExchange.lookup(grapeID);
- price = grapeGE.getGuidePrice();
- return true;
- }
- public int loop() {
- try {
- switch (getState()) {
- case BANK:
- status = "Banking";
- RSObject bankbooth = objects.getNearest(bankerID);
- if ((!bank.isOpen()) && (bankbooth != null)) {
- bankbooth.doAction("Use-Quickly");
- return random(250, 500);
- }
- if (bank.isOpen()) {
- bank.depositAll();
- }
- bank.close();
- break;
- case TAKE:
- status = "Taking grapes";
- if (calc.distanceTo(grapeTileID) >= 2) {
- walking.walkTo(grapeTileID);
- }
- RSGroundItem grapes = groundItems.getNearest(grapeID);
- if (grapes != null) {
- mouse.click(calc
- .tileToScreen(groundItems.getNearest(grapeID)
- .getLocation(), -500), true);
- if (invCount != inventory.getCount(grapeID)) {
- grapeTaken++;
- invCount = inventory.getCount(grapeID);
- }
- sleep(1000, 1500);
- }
- int rdm2 = random(1, 1000);
- if (rdm2 <= 5) {
- status = "Move Mouse Offscreen";mouse.moveOffScreen();
- } else if (rdm2 >= 51 && rdm2 <= 58) {
- status = "Move mouse slightly";
- mouse.moveSlightly();
- }
- break;
- case GO_TO_BANK:
- switch (getLocationStateBank()) {
- case WALK_TO_BANK:
- status = "Walking To Bank";
- RSTile[] pathToBank = { new RSTile(3143, 3443),
- new RSTile(3149, 3443), new RSTile(3159, 3451),
- new RSTile(3169, 3450), new RSTile(3181, 3450),
- new RSTile(3185, 3445), new RSTile(3182, 3444) };
- RSTile[] randomizedPath = walking.randomizePath(pathToBank,
- 2, 2);
- walking.walkPathMM(randomizedPath, 15);
- break;
- case OPEN_DOOR:
- status = "Opening Door";
- door = objects.getTopAt(doorTileID);
- if (door != null) {
- door.doAction("Open");
- }
- break;
- case CLIMB_STAIRS_DOWN:
- status = "Climbing Down Stairs";
- if (calc.distanceTo(stairsTileID) >= 5) {
- walking.walkTileMM(stairsTileID);
- }
- stairs = objects.getNearest(stairsDownID);
- if (stairs != null) {
- stairs.doAction("Climb-down");
- }
- break;
- case WALK_TO_DOOR:
- status = "Walking to Door";
- walking.walkTileMM(doorTileID);
- break;
- }
- break;
- case GO_TO_GRAPES:
- switch (getLocationStateGrapes()) {
- case WALK_TO_GUILD:
- status = "Walking To grapes";
- RSTile[] pathToGrapes = { new RSTile(3174, 3448),
- new RSTile(3166, 3450), new RSTile(3156, 3449),
- new RSTile(3149, 3445), new RSTile(3143, 3443) };
- RSTile[] randomizedPath = walking.randomizePath(
- pathToGrapes, 2, 2);
- walking.walkPathMM(randomizedPath, 15);
- break;
- case OPEN_DOOR:
- status = "Opening Door";
- walking.walkTo(doorTileID);
- door = objects.getTopAt(doorTileID);
- if (door != null) {
- door.doAction("Open");
- }
- break;
- case CLIMB_STAIRS_UP:
- status = "Climbing Up Stairs";
- stairs = objects.getNearest(stairsUpID);
- if (stairs != null) {
- stairs.doAction("Climb-Up");
- }
- break;
- case WALK_TO_STAIRS:
- status = "Walking to Stairs";
- walking.walkTileMM(stairsTileID);
- break;
- }
- break;
- }
- } catch (Exception e) {
- log("Ooops! Something went wrong. Heres the error:");
- log(e.toString());
- }
- while (getMyPlayer().isMoving()) {
- sleep(500, 600);
- }
- runControl();
- antiban();
- return random(10, 50);
- }
- private boolean atGrapes() {
- return grapeArea.contains(getMyPlayer().getLocation())
- && game.getPlane() == 2;
- }
- private boolean atBank() {
- return bankArea.contains(getMyPlayer().getLocation())
- && game.getPlane() == 0;
- }
- private boolean atFloorTwo() {
- return guildLevel2.contains(getMyPlayer().getLocation())
- && game.getPlane() == 1;
- }
- private boolean atFloorOne() {
- return guildLevel1.contains(getMyPlayer().getLocation())
- && game.getPlane() == 0;
- }
- private void walk(RSTile tile) {
- if (web == null) {
- web = walking.getWebPath(tile);
- } else {
- if (!web.traverse()) {
- web = null;
- }
- sleep(50);// So it doesn't burn out your CPU.
- }
- if (web.atDestination()) {
- web = null;
- }
- }
- public void antiban() {
- int randomNum = random(1, 50);
- int r = random(1, 100);
- if (randomNum == 6) {
- if (r == 2) {
- this.status = "Using AntiBan|Open Random Tab";
- this.game.openTab(random(1, 14));
- }
- if (r == 3) {
- this.status = "Using AntiBan|Move Mouse";
- this.mouse.moveRandomly(50, 300);
- }
- if (r == 4) {
- this.status = "Using AntiBan|Move Mouse";
- this.mouse.moveRandomly(70, 380);
- }
- if (r == 5) {
- this.status = "Using AntiBan|Rotate Camera";
- this.camera.setAngle(random(25, 49));
- }
- if (r == 6) {
- this.status = "Using AntiBan|Rotate Camera";
- this.camera.setAngle(random(50, 100));
- }
- if (r == 7) {
- this.status = "Using AntiBan|Rotate Camera";
- this.camera.setAngle(random(100, 120));
- }
- if (r == 8) {
- this.status = "Using AntiBan|Rotate Camera";
- this.camera.setAngle(random(190, 230));
- }
- if (r == 9) {
- this.status = "Using AntiBan|Rotate Camera";
- this.camera.setAngle(random(150, 180));
- }
- if (r == 10) {
- this.status = "Using AntiBan|Rotate Camera";
- this.camera.setAngle(random(250, 260));
- }
- if (r == 11) {
- this.status = "Using AntiBan|Open Skill Tab";
- if (this.game.getCurrentTab() != 4)
- this.game.openTab(4);
- else
- return;
- }
- if (r == 35) {
- this.status = "Using AntiBan|Move Mouse To Woodutting Skill";
- if (this.game.getCurrentTab() != 1) {
- this.game.openTab(1);
- sleep(random(500, 700));
- this.mouse.move(random(680, 730), random(355, 370));
- sleep(random(1500, 5000));
- }
- }
- }
- }
- int runControl() {
- if ((!walking.isRunEnabled()) && (walking.getEnergy() > random(20, 30))) {
- walking.setRun(true);
- return 500;
- }
- if (walking.getEnergy() < random(20, 30)) {
- status = "Resting";
- walking.rest();
- }
- return 10;
- }
- private final RenderingHints antialiasing = new RenderingHints(
- RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- private final Color color1 = new Color(0, 255, 255, 110);
- private final Color color2 = new Color(0, 255, 255);
- private final Color color3 = new Color(0, 255, 255, 100);
- private final Color color4 = new Color(255, 255, 0);
- private final Color color5 = new Color(0, 0, 0);
- private final Color color6 = new Color(0, 0, 0, 103);
- private final Color color7 = new Color(255, 255, 51);
- private final Color colorgreen = new Color(0, 255, 0, 100);
- private final Color colorred = new Color(255, 0, 0, 100);
- private final BasicStroke stroke1 = new BasicStroke(1.0F);
- private final Font font1 = new Font("Comic Sans MS", 0, 10);
- public void onRepaint(Graphics g1) {
- if (game.isLoggedIn()) {
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(antialiasing);
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / 3600000L;
- millis -= hours * 3600000L;
- long minutes = millis / 60000L;
- millis -= minutes * 60000L;
- long seconds = millis / 1000L;
- long minutes2 = (int) (minutes + hours * 60);
- if (((minutes > 0L) || (hours > 0L) || (seconds > 0L))
- && (grapeTaken > 0)) {
- secGrapes = (grapeTaken / (float) (seconds + minutes * 60L + hours * 60L * 60L));
- }
- hourGrapes = (secGrapes * 3600.0F);
- profitHour = (price * (int) Math.abs(hourGrapes));
- profitHour = (Math.abs(profitHour) / 1000);
- profit = (price * grapeTaken);
- g.setColor(color1);
- g.fillRect(18, 15, 170, 18);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(18, 15, 170, 18);
- g.setColor(color3);
- g.fillRect(18, 38, 170, 103);
- g.setColor(color2);
- g.drawRect(18, 38, 170, 103);
- g.setColor(color3);
- g.fillRect(18, 145, 170, 50);
- g.setColor(color2);
- g.drawRect(18, 145, 170, 50);
- g.setFont(font1);
- g.setColor(color4);
- g.drawString("Runtime : " + hours + ":" + minutes + ":" + seconds,
- 23, 55);
- g.drawString("Grapes Taken : " + grapeTaken, 23, 71);
- g.drawString("Grapes/Hour : " + hourGrapes, 23, 87);
- g.drawString("Profit : " + profit, 23, 103);
- g.drawString("Profit/Hour : " + profitHour + "k", 23, 119);
- g.drawString("VassdaGrape 0.1 by Dandan Boy ", 21, 29);
- g.drawString("Status : " + status, 23, 135);
- g.drawLine(mouse.getLocation().x - 5, mouse.getLocation().y,
- mouse.getLocation().x + 5, mouse.getLocation().y);
- g.drawLine(mouse.getLocation().x, mouse.getLocation().y - 5,
- mouse.getLocation().x, mouse.getLocation().y + 5);
- }
- }
- }
Add Comment
Please, Sign In to add comment