Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.RenderingHints;
- import java.util.Map;
- import org.rsbot.bot.Bot;
- import org.rsbot.bot.input.Mouse;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Constants;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.util.ScreenshotUtil;
- @ScriptManifest(authors = { "Script Dude" }, category = "Woodcutting", name = "SrcYews", version = 1.00, description = "<html>"
- + "<center><h2>Script Dude's Yew Chopper</h2></center>"
- + "<centerStart this scipr near yew trees, bank or anywhere between them<center"
- + "<center>Location: "
- + "<select name='location'>"
- + "<option>Grand Exchange"
- + "<option>Rimmington"
- + "<option>Seers village"
- + "</select>"
- + "</center>"
- + "<center>Show Paint: "
- + "<select name='showpaint'>"
- + "<option>Yes"
- + "<option>No" + "</select>" + "</center>" + "</html>")
- public class SrcYews extends Script implements PaintListener,
- ServerMessageListener {
- public String status = "";
- public String location = "";
- public int treeID = 1309;
- public int[] hatchetID = { 1351, 1349, 1353, 1361, 1355, 1357, 1359, 4031,
- 6739, 13470, 14108 };
- public int[] bankBoothID = { 11758, 11402, 34752, 35647, 2213, 25808, 2213,
- 26972, 27663, 4483, 14367, 19230, 29085, 12759, 6084, 24914 };
- public int logs = 0;
- public int levels = 0;
- public int yewID = 1515;
- public int bankerID = 6533;
- public int profit;
- public int startexp;
- public int yewCost = grandExchange.loadItemInfo(yewID).getMarketPrice();
- public long startTime;
- public boolean showPaint, showAveraging, showGained, end = false;
- public RSTile midTree1 = new RSTile(2935, 3226);
- public RSTile midTree2 = new RSTile(2936, 3230);
- public RSTile midTree3 = new RSTile(2934, 3234);
- public RSTile midTree4 = new RSTile(2941, 3233);
- public RSTile midTree5 = new RSTile(3205, 3504);
- public RSTile midTree6 = new RSTile(3210, 3504);
- public RSTile midTree7 = new RSTile(3222, 3503);
- public RSTile midTree8 = new RSTile(2715, 3460);
- public RSTile midTree9 = new RSTile(2706, 3460);
- public RSTile midTree10 = new RSTile(2706, 3465);
- public RSTile banktileR = new RSTile(3014, 3355);
- public RSTile treetileR = new RSTile(2938, 3231);
- public RSTile banktileGE = new RSTile(3168, 3489);
- public RSTile treetileGE = new RSTile(3215, 3500);
- public RSTile banktileS = new RSTile(2726, 3491);
- public RSTile treetileS = new RSTile(2710, 3462);
- public RSTile[] bankToYewsR = { new RSTile(3013, 3358),
- new RSTile(3008, 3349), new RSTile(3006, 3334),
- new RSTile(3005, 3319), new RSTile(2996, 3308),
- new RSTile(2986, 3296), new RSTile(2977, 3284),
- new RSTile(2972, 3270), new RSTile(2964, 3260),
- new RSTile(2958, 3247), new RSTile(2945, 3238),
- new RSTile(2938, 3232) };
- public RSTile[] yewsToBankR = reversePath(bankToYewsR);
- public RSTile[] bankToYewsGE = { new RSTile(3167, 3489),
- new RSTile(3174, 3489), new RSTile(3185, 3489),
- new RSTile(3195, 3491), new RSTile(3197, 3501),
- new RSTile(3206, 3502) };
- public RSTile[] yewsToBankGE = reversePath(bankToYewsGE);
- public RSTile[] yewsToBankS = { new RSTile(2715, 3463),
- new RSTile(2722, 3474), new RSTile(2724, 3485),
- new RSTile(2726, 3491) };
- public RSTile[] bankToYewsS = reversePath(yewsToBankS);
- @Override
- protected int getMouseSpeed() {
- return random(4, 6);
- }
- public boolean onStart(Map<String, String> args) {
- startTime = System.currentTimeMillis();
- final String paint = args.get("showpaint");
- if (paint.equals("Yes")) {
- showPaint = true;
- } else if (paint.equals("No")) {
- showPaint = false;
- }
- final String place = args.get("location");
- if (place.equals("Grand Exchange")) {
- location = "GE";
- } else if (place.equals("Rimmington")) {
- location = "R";
- } else if (place.equals("Seers village")) {
- location = "S";
- }
- return true;
- }
- public void onFinish() {
- end = true;
- showGained = true;
- ScreenshotUtil.takeScreenshot(true);
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- log("Thank You for using Script Dude's Yew Chopper!");
- log("Time ran " + hours + ":" +minutes + ":" + seconds);
- log("Logs cut: " + logs);
- log("Levels Gained: " + levels);
- log("Profit got: " + profit);
- }
- @Override
- public int loop() {
- setCameraAltitude(true);
- antiBan();
- if (isInventoryFull()) {
- if (atBank()) {
- bank();
- } else {
- toBank();
- }
- }
- if (!isInventoryFull()) {
- if (atTrees()) {
- chop();
- } else {
- toTrees();
- }
- }
- return random(100, 250);
- }
- // METHODS
- public boolean atBank() {
- if (location == "R") {
- return distanceTo(banktileR) <= 7;
- }
- if (location == "GE") {
- return distanceTo(banktileGE) <= 7;
- }
- if (location == "S") {
- return distanceTo(banktileS) <= 7;
- }
- return false;
- }
- public boolean atTrees() {
- if (location == "R") {
- return distanceTo(treetileR) <= 10;
- }
- if (location == "GE") {
- return distanceTo(treetileGE) <= 15;
- }
- if (location == "S") {
- return distanceTo(treetileS) <= 10;
- }
- return false;
- }
- public void antiBan() {
- int randomNumber = random(1, 50);
- if (randomNumber <= 4) {
- status = "Antiban";
- if (randomNumber == 1) {
- setCameraRotation(random(1, 360));
- }
- if (randomNumber == 2) {
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- if (randomNumber == 3) {
- setCameraRotation(random(1, 360));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- if (randomNumber == 4) {
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- setCameraRotation(random(1, 360));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- }
- int randomnumber2 = random(1, 500);
- if (randomnumber2 == 1) {
- if (getCurrentTab() != TAB_STATS) {
- openTab(TAB_STATS);
- wait(random(100, 200));
- moveMouse(random(664, 713), random(392, 419), 2, 2);
- wait(random(750, 1000));
- openTab(TAB_INVENTORY);
- }
- }
- }
- public boolean atTree(final String action) {
- try {
- final RSObject yew = getNearestObjectByID(treeID);
- if (location == "R") {
- if (distanceBetween(yew.getLocation(), midTree1) <= 1) {
- if (distanceTo(midTree1) >= 6) {
- setRun(true);
- walkTo(midTree1);
- }
- atTile(midTree1, action);
- return false;
- }
- if (distanceBetween(yew.getLocation(), midTree2) <= 1) {
- if (distanceTo(midTree2) >= 6) {
- setRun(true);
- walkTo(midTree2);
- }
- atTile(midTree2, action);
- return false;
- }
- if (distanceBetween(yew.getLocation(), midTree3) <= 1) {
- if (distanceTo(midTree3) >= 6) {
- setRun(true);
- walkTo(midTree3);
- }
- atTile(midTree3, action);
- return false;
- }
- if (distanceBetween(yew.getLocation(), midTree4) <= 1) {
- if (distanceTo(midTree4) >= 6) {
- setRun(true);
- walkTo(midTree4);
- }
- atTile(midTree4, action);
- return false;
- }
- }
- if (location == "GE") {
- if (distanceBetween(yew.getLocation(), midTree5) <= 1) {
- if (distanceTo(midTree5) >= 6) {
- setRun(true);
- walkTo(midTree5);
- }
- atTile(midTree5, action);
- return false;
- }
- if (distanceBetween(yew.getLocation(), midTree6) <= 1) {
- if (distanceTo(midTree6) >= 6) {
- setRun(true);
- walkTo(midTree6);
- }
- atTile(midTree6, action);
- return false;
- }
- if (distanceBetween(yew.getLocation(), midTree7) <= 1) {
- if (distanceTo(midTree7) >= 6) {
- setRun(true);
- walkTo(midTree7);
- }
- atTile(midTree7, action);
- return false;
- }
- }
- if (location == "S") {
- if (distanceBetween(yew.getLocation(), midTree8) <= 1) {
- if (distanceTo(midTree8) >= 6) {
- setRun(true);
- walkTo(midTree8);
- }
- atTile(midTree8, action);
- return false;
- }
- if (distanceBetween(yew.getLocation(), midTree9) <= 1) {
- if (distanceTo(midTree9) >= 6) {
- setRun(true);
- walkTo(midTree9);
- }
- atTile(midTree9, action);
- return false;
- }
- if (distanceBetween(yew.getLocation(), midTree10) <= 1) {
- if (distanceTo(midTree10) >= 6) {
- setRun(true);
- walkTo(midTree10);
- }
- atTile(midTree10, action);
- return false;
- }
- }
- } catch (Exception e) {
- log("Something went wrong, but it didn't stop the script");
- }
- return true;
- }
- public boolean chop() {
- if (getMyPlayer().getAnimation() == 867) {
- status = "Chopping";
- wait(random(500, 1000));
- }
- if (getMyPlayer().getAnimation() != 867) {
- status = "Waiting";
- if (location == "GE") {
- final RSObject yew = getNearestObjectByID(treeID);
- if (yew == null) {
- if (distanceTo(new RSTile(3213, 3501)) > 2) {
- walkTo(new RSTile(3213, 3501));
- }
- }
- }
- wait(random(500, 1000));
- }
- if (!(getMyPlayer().getAnimation() == 867)) {
- final RSObject yew = getNearestObjectByID(treeID);
- if (yew != null) {
- atTree("Chop down Yew");
- wait(random(300, 700));
- }
- }
- return true;
- }
- public int toBank() {
- status = ("Walking to bank");
- if (getEnergy() >= 65) {
- setRun(true);
- }
- if (location == "R") {
- if (distanceTo(getDestination()) < random(5, 12)
- || distanceTo(getDestination()) > 40) {
- if (!walkPathMM(yewsToBankR)) {
- walkToClosestTile(randomizePath(yewsToBankR, 2, 2));
- return random(400, 600);
- }
- }
- }
- if (location == "GE") {
- if (distanceTo(getDestination()) < random(5, 12)
- || distanceTo(getDestination()) > 40) {
- if (!walkPathMM(yewsToBankGE)) {
- walkToClosestTile(randomizePath(yewsToBankGE, 2, 2));
- return random(400, 600);
- }
- }
- }
- if (location == "S") {
- if (distanceTo(getDestination()) < random(5, 12)
- || distanceTo(getDestination()) > 40) {
- if (!walkPathMM(yewsToBankS)) {
- walkToClosestTile(randomizePath(yewsToBankS, 2, 2));
- return random(400, 600);
- }
- }
- }
- return random(100, 250);
- }
- public int toTrees() {
- status = ("Walking to yews");
- if (getEnergy() >= 65) {
- setRun(true);
- }
- if (location == "R") {
- if (distanceTo(getDestination()) < random(5, 12)
- || distanceTo(getDestination()) > 40) {
- if (!walkPathMM(randomizePath(bankToYewsR, 2, 2))) {
- walkToClosestTile(randomizePath(bankToYewsR, 2, 2));
- return random(400, 600);
- }
- }
- }
- if (location == "GE") {
- if (distanceTo(getDestination()) < random(5, 12)
- || distanceTo(getDestination()) > 40) {
- if (!walkPathMM(randomizePath(bankToYewsGE, 2, 2))) {
- walkToClosestTile(randomizePath(bankToYewsGE, 2, 2));
- return random(400, 600);
- }
- }
- }
- if (location == "S") {
- if (distanceTo(getDestination()) < random(5, 12)
- || distanceTo(getDestination()) > 40) {
- if (!walkPathMM(randomizePath(bankToYewsS, 2, 2))) {
- walkToClosestTile(randomizePath(bankToYewsS, 2, 2));
- return random(400, 600);
- }
- }
- }
- return random(100, 250);
- }
- public int bank() {
- status = "Banking";
- if (bank.isOpen()) {
- bank.depositAllExcept(hatchetID);
- wait(random(800, 1000));
- }
- if (!(bank.isOpen())) {
- if (location == "R") {
- final RSObject bankBooth = getNearestObjectByID(bankBoothID);
- if (bankBooth != null) {
- atObject(bankBooth, "Use-Quickly");
- wait(random(200, 300));
- }
- if (bankBooth == null) {
- return random(100, 200);
- }
- }
- if (location == "GE") {
- final RSNPC bankNPC = getNearestNPCByID(bankerID);
- if (bankNPC != null) {
- atNPC(bankNPC, "Bank Banker");
- wait(random(200, 300));
- }
- if (bankNPC == null) {
- return random(100, 200);
- }
- }
- if (location == "S") {
- final RSObject bankBooth = getNearestObjectByID(bankBoothID);
- if (bankBooth != null) {
- atObject(bankBooth, "Use-Quickly");
- wait(random(200, 300));
- }
- if (bankBooth == null) {
- return random(100, 200);
- }
- }
- }
- return random(150, 350);
- }
- // METHODS
- @Override
- public void onRepaint(Graphics g) {
- ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- if (showPaint == true) {
- if (isLoggedIn()) {
- int xpGained = 0;
- if (startexp == 0) {
- startexp = skills
- .getCurrentSkillExp(Constants.STAT_WOODCUTTING);
- }
- profit = (logs * yewCost);
- xpGained = skills
- .getCurrentSkillExp(Constants.STAT_WOODCUTTING)
- - startexp;
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- float xpsec = 0;
- if ((minutes > 0 || hours > 0 || seconds > 0) && xpGained > 0) {
- xpsec = ((float) xpGained)
- / (float) (seconds + (minutes * 60) + (hours * 60 * 60));
- }
- float xpmin = xpsec * 60;
- float xphour = xpmin * 60;
- final int yewHour = (int) ((logs) * 3600000D / (System
- .currentTimeMillis() - startTime));
- final int profitHour = (int) ((profit) * 3600000D / (System
- .currentTimeMillis() - startTime));
- g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
- if (showGained == true) {
- g.setColor(new Color(0, 0, 0, 150));
- g.fillRoundRect(200, 213 + 18, 150, 100 - 18, 0, 0);
- g.setColor(Color.white);
- g.drawString("XP Gained: " + xpGained, 208, 230 + 18);
- g.drawString("Levels Gained: " + levels, 208, 248 + 18);
- g.drawString("Logs chopped: " + logs, 208, 284);
- g.drawString("Profit: " + profit + "gp", 208, 284 + 18);
- }
- if (showAveraging == true) {
- g.setColor(new Color(0, 0, 0, 150));
- g.fillRoundRect(286, 213 + 18, 200, 100 - 18, 0, 0);
- g.setColor(Color.white);
- g.drawString("Time running: " + hours + ":" + minutes + ":"
- + seconds, 294, 230 + 18);
- g
- .drawString("XP Hour: " + (int) xphour, 294,
- 230 + 18 + 18);
- g.drawString("Logs/Hour: " + yewHour, 294, 266 + 18);
- g.drawString("Profit/Hour: " + profitHour + "gp", 294,
- 284 + 18);
- }
- final int percent = skills
- .getPercentToNextLevel(Constants.STAT_WOODCUTTING);
- g.setColor(new Color(0, 0, 0, 150));
- g.fillRoundRect(4, 313, 511, 24, 0, 0);
- g.setColor(Color.white);
- g.draw3DRect(4, 313, 511, 24, true);
- g.setColor(new Color(149, 7, 17, 200));
- g.fillRoundRect(7, 315, 100, 20, 0, 0);
- g.setColor(new Color(0, 79, 0, 200));
- g.fillRoundRect(7, 315, percent, 20, 0, 0);
- g.setColor(Color.black);
- g.drawRect(7, 315, 100, 20);
- g.setColor(Color.white);
- g.drawString(percent + "% Done", 117, 330);
- g.draw3DRect(200, 313, 1, 24, true);
- g.drawString("Gained", 220, 330);
- g.draw3DRect(285, 313, 1, 24, true);
- g.drawString("Averaging", 305, 330);
- g.draw3DRect(390, 313, 1, 24, true);
- g.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
- g.drawString("" + status, 400, 330);
- }
- Mouse m = Bot.getClient().getMouse();
- if (m.x >= 200 && m.x < 200 + 85 && m.y >= 313 && m.y < 313 + 24) {
- showGained = true;
- } else {
- if (end == false){
- showGained = false;
- }
- }
- if (m.x >= 286 && m.x < 286 + 105 && m.y >= 313 && m.y < 313 + 24) {
- showAveraging = true;
- } else {
- showAveraging = false;
- }
- }
- }
- @Override
- public void serverMessageRecieved(final ServerMessageEvent e) {
- final String serverString = e.getMessage();
- if (serverString.contains("logs.")) {
- logs++;
- }
- if (serverString.contains("You've just advanced")) {
- levels++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement