Anda di halaman 1dari 23

import import import import import import import import import import import import import import import

import import import import import import import import import import import import import import import import

java.awt.Color; java.awt.Font; java.awt.Graphics; java.awt.Point; java.util.Map; java.io.*; java.net.*; org.rsbot.event.listeners.PaintListener; org.rsbot.script.Script; org.rsbot.script.ScriptManifest; org.rsbot.script.wrappers.RSInterface; org.rsbot.script.wrappers.RSItem; org.rsbot.script.wrappers.RSObject; org.rsbot.script.wrappers.RSTile; org.rsbot.bot.Bot; java.awt.event.ActionEvent; java.awt.event.ActionListener; java.awt.event.MouseEvent; java.awt.event.MouseListener; java.awt.*; javax.swing.*; java.io.BufferedReader; java.io.BufferedWriter; java.io.FileWriter; java.io.InputStreamReader; java.net.URLConnection; java.awt.image.BufferedImage; javax.imageio.ImageIO; java.io.IOException; java.net.MalformedURLException; java.net.URL;

@org.rsbot.script.ScriptManifest(authors = { "Epic_, MeryXmas" }, keywords = "Wo odcutting", name = "XWoodcutter", version = 1.0, description = "Flawless.") public class XWoodCutter extends Script implements PaintListener, MouseListener { // ////////////////// // VARIABLES // // ////////////////// XWoodCutterGUI gui; private boolean waitGUI = true; BufferedImage normal = null; BufferedImage clicked = null; public double version = 1.0; public double latestVersion = 0; public Point m; public int startLevel; public int startEXP; public long EXPGained; public int levelsGained; public long EXPPerHour; public String status = "Starting up"; public String logType = "logs"; public boolean getRuneAxe = false; public boolean getAdamantAxe = false; public boolean getMithrilAxe = false;

public public public public }; public public public public

boolean cutYews = false; int cutYewsAt = 100; int YEWLOGID = 1515; int yewPrice = 0;

public int[] axeTypes = { 1349, 1351, 1353, 1355, 1357, 1359, 1361, 6739 int runeAxe = 1359; int adamantAxe = 1357; int mithrilAxe = 1355; long startTime = 0;

28, 34, 04, 74, };

public int[] NORMALTREES = { 5004, 5005, 5045, 3879, 3881, 3882, 3883, 3885, 3886, 3887, 3888, 3889, 3890, 3891, 3892, 3893, 39 3967, 3968, 4048, 4049, 4050, 4051, 4052, 4053, 4054, 3033, 30 3035, 3036, 2409, 2447, 2448, 1330, 1331, 1332, 1310, 1305, 13 1303, 1301, 1276, 1277, 1278, 1279, 1280, 8742, 8743, 8973, 89 1315, 1316 }; public int[] OAKTREES = { 1281, 3037, 8462, 8463, 8464, 8465, 8466, 8467 public int[] WILLOWTREES = { 1308, 5551, 5552, 5553, 8481, 8482, 8483, 8484, 8485, 8486, 8487, 8488 }; public int[] YEWTREES = { 1309, 8503, 8504, 8505, 8506, 8507, 8508, 8509

, 8510, 8511, 8512, 8513 }; public int[] currentTrees; public int bankBooth = 11758; // RSTiles public RSTile normalTreesLocation = new RSTile(2996, 3228); // new // RSTile(2990,3206); // new // RSTile(2995,3252); public RSTile oakTreesLocation = new RSTile(2984, 3205); public RSTile willowTreesLocation = new RSTile(2989, 3187); // new // RSTile(2970,3195); // new // RSTile(2997,3167); public RSTile yewTreesLocation = new RSTile(2938, 3232); public RSTile halfWayWalkPoint = new RSTile(3070, 3276); public RSTile faladorEastBank = new RSTile(3012, 3355); public RSTile lumbridge = new RSTile(3222, 3218); public RSTile[] bankToYews = new new RSTile(3005, new RSTile(2958, public RSTile[] yewsToBank = new new RSTile(2958, new RSTile(3005, RSTile[] { 3318), new 3241), new RSTile[] { 3241), new 3318), new new RSTile(3012, 3355), RSTile(2968, 3284), RSTile(2938, 3232) }; new RSTile(2938, 3232), RSTile(2968, 3284), RSTile(3012, 3355) };

private final Color backgroundTop = new Color(255, 255, 255, 30), backgroundBottom = new Color(52, 42, 31, 200), title = n ew Color( 252, 180, 72, 200), text = new Color(180

, 150, 90, 200), black = new Color(0, 0, 0, 160), white = new Color(255, 255, 255, 160), green = new Color(30, 255, 30, 200 ), red = new Color( 255, 30, 30, 200); public boolean atWelcomButton() { RSInterface welcomeInterface = interfaces.get(378); if (welcomeInterface.getComponent(45).getAbsoluteX() > 20 (!welcomeInterface.getComponent(117).getText( ).equals( "10.1120.190") && !welcomeInterf ace.getComponent(117) .getText().equals(""))) { status = "Welcome Screen"; mouse.click(random(215, 555), random(420, 440), true); return true; } else { return false; } } public boolean onStart() { gui = new XWoodCutterGUI(); gui.setVisible(true); while (waitGUI) { sleep(100); } if (cutYews == true) { yewPrice = grandExchange.getMarketPrice(YEWLOGID); } try { final URL cursorURL = new URL("http://imgur.com/i7nMG.pn g"); final URL cursor80URL = new URL("http://imgur.com/8k9op. png"); normal = ImageIO.read(cursorURL); clicked = ImageIO.read(cursor80URL); } catch (MalformedURLException e) { log.info("Unable to buffer cursor."); } catch (IOException e) { log.info("Unable to open cursor image."); } log.info("Welcome to XWoodCutter!"); return true; } /*public void onFinish() { log.info("Please sleep, updating information..."); URLConnection url = null; BufferedReader in = null; long totalSeconds = ((System.currentTimeMillis() - startTime) / 1000); EXPGained = skills.getCurrentExp(8) - startEXP;

levelsGained = skills.getCurrentLevel(8) - startLevel; if (latestVersion != 0 && totalSeconds < 360000) { try { String urlToLoad = ("http://www.epic-scripting.n et63.net/updateinfo.php?time=" + totalSeconds + "&exp=" + EXPGained + "&gp=" + (EXPGained / 175 * yewPrice) + "&lvls=" + levelsGained); url = new URL(urlToLoad).openConnection(); in = new BufferedReader(new InputStreamReader(ur l .getInputStream())); } catch (final Exception e) { log("Update Failed =("); } } log("Update complete!"); return; }*/ //Credit to rawr for the mouse public void drawMouse(final Graphics g) { if (normal != null) { final double mouseX = mouse.getLocation().getX() - 8, mo useY = mouse .getLocation().getY() - 8; final double mousePressX = mouse.getPressLocation().getX () - 8, mousePressY = mouse .getPressLocation().getY() - 8; if (System.currentTimeMillis() - mouse.getPressTime() < 400) { g .drawImage(clicked, (int) mouseP ressX, (int) mousePress Y, null); } g.drawImage(normal, (int) mouseX, (int) mouseY, null); } } public void onRepaint(Graphics g) { if (game.isLoggedIn()) { drawMouse(g); 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; /* * g.setColor(new Color(0, 0, 0, 100)); g.fillRoundRect( 10, 209, * 110, 123, 10, 10); */

long totalSeconds = ((System.currentTimeMillis() - start Time) / 1000); EXPGained = skills.getCurrentExp(8) - startEXP; levelsGained = skills.getCurrentLevel(8) - startLevel; if (totalSeconds == 0) { EXPPerHour = 0; } else { EXPPerHour = (EXPGained * 3600) / totalSeconds; } long secondsToLvl; if (EXPPerHour == 0) { secondsToLvl = 0; } else { secondsToLvl = (skills.getExpToNextLevel(8) * 36 00) / EXPPerHour; } ; long hoursToLvl = secondsToLvl / (60 * 60); secondsToLvl -= hoursToLvl * (60 * 60); long minutesToLvl = secondsToLvl / (60); secondsToLvl -= minutesToLvl * (60); g.setColor(backgroundBottom); g.fillRect(0, 319, 519, 20); g.setColor(new Color(255, 30, 30, 200)); g.fillRoundRect(15, 324, 100, 10, 5, 10); g.setColor(new Color(30, 255, 30, 200)); g .fillRoundRect(15, 324, skills.getPercen tToNextLevel(8), 10, 5, 10); g.setColor(new Color(200, 200, 200, 200)); g.drawRoundRect(15, 324, 100, 10, 5, 10); g.setFont(new Font("Calibri", Font.BOLD, 14)); g.setColor(white); drawStringWithShadow("" + skills.getPercentToNextLevel(8 ) + "%", 125, 333, g); g.drawRect(517, g.drawRect(417, g.drawRect(317, g.drawRect(217, 319, 319, 319, 319, 1, 1, 1, 1, 19); 19); 19); 19);

g.setFont(new Font("Calibri", Font.BOLD, 16)); g.setColor(title); drawStringWithShadow("Status", 245, 334, g); drawStringWithShadow("Experience", 332, 334, g); drawStringWithShadow("Profit", 450, 334, g); g.setColor(backgroundTop); g.fillRect(0, 319, 519, 10);

int y = 220; int x; int spacing = 15; g.setFont(new Font("Calibri", Font.BOLD, 12)); Point p = new Point(m.x, m.y); if (isWithinBounds(p, 217, 319, 100, 20)) { g.setColor(backgroundBottom); g.fillRect(217, 235, 102, 84); x = 222; y = 235; g.setColor(green); drawStringWithShadow("" + status, x, y += spacin g, g); g.setColor(title); drawStringWithShadow("Runtime: " + hours + ":" + minutes + ":" + seconds, x, y += spacing, g); drawStringWithShadow("Version: " + version, x, y += spacing, g); if (version < latestVersion) { g.setColor(red); drawStringWithShadow("***Outdated***", x , y += spacing, g); drawStringWithShadow( "v" + latestVersion + " is available!", x, y += spacing, g); g.setColor(title); } else { drawStringWithShadow("Fully updated", x, y += spacing, g); drawStringWithShadow("Latest version", x , y += spacing, g); } } if (isWithinBounds(p, 317, 319, 100, 20)) { g.setColor(backgroundBottom); g.fillRect(317, 235, 102, 84); x = 322; y = 235; g.setColor(title); drawStringWithShadow("Current Level: " + skills.getCurrentLevel(8), x, y += spacing, g); drawStringWithShadow("Levels Gained: " + levelsG ained, x, y += spacing, g); drawStringWithShadow("EXP Gain: " + EXPGained, x , y += spacing, g); drawStringWithShadow("EXP/Hour: " + EXPPerHour, x, y += spacing, g); drawStringWithShadow("Level in: " + hoursToLvl + ":"

+ minutesToLvl + ":" + secondsTo Lvl, x, y += spacing, g); } if (isWithinBounds(p, 417, 319, 100, 20)) { g.setColor(backgroundBottom); g.fillRect(417, 235, 102, 84); x = 422; y = 235; g.setColor(title); if (logType == "yews") { drawStringWithShadow("Log Type: Yews", x , y += spacing, g); drawStringWithShadow("Log Price: " + yew Price + "gp", x, y += spacing, g); drawStringWithShadow("Logs Banked: " + E XPGained / 175, x, y += spacing, g); drawStringWithShadow("Profit: " + EXPGai ned / 175 * yewPrice + "gp", x, y += spacing, g); drawStringWithShadow("GP/Hour: " + (EXPP erHour * yewPrice) / 175, x, y += spacing, g); } else { drawStringWithShadow("Log Type: " + logT ype, x, y += spacing, g); drawStringWithShadow("Log Price: N/A", x , y += spacing, g); drawStringWithShadow("Logs Banked: N/A", x, y += spacing, g); drawStringWithShadow("Profit: N/A", x, y += spacing, g); drawStringWithShadow("GP/Hour: N/A", x, y += spacing, g); } } } } public void mouseExited(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseClicked(MouseEvent e) { m = e.getPoint(); } /*

* public void getLatestVersion() { URLConnection url = null; BufferedRe ader * * * * if * the current version is outdated latestVersion = * Double.parseDouble(in.readLine()); } catch (final Exception e) { * log("Error loading version data."); } } */ public boolean isWithinBounds(Point p, int x, int y, int w, int h) { if (p.x > x && p.x < x + w && p.y > y && p.y < y + h) { return true; } else { return false; } } public void drawStringWithShadow(String text, int x, int y, Graphics g) { Color col = g.getColor(); g.setColor(black); g.drawString(text, x + 1, y + 1); g.setColor(col); g.drawString(text, x, y); } public int loop() { if (atWelcomButton()) { return 500; } if (game.isLoggedIn() && skills.getCurrentLevel(8) != 0) { camera.setPitch(true); if (walking.getEnergy() > random(30, 60)) { walking.setRun(true); } if (startTime == 0 && skills.getCurrentLevel(8) != 0) { startTime = System.currentTimeMillis(); startLevel = skills.getCurrentLevel(8); startEXP = skills.getCurrentExp(8); } if (getRuneAxe == true) { if ((skills.getCurrentLevel(8) >= 41) && !inventory.contains(runeAxe)) { status = "Walking to bank"; walkToTile(faladorEastBank); sleep(random(1000, 2000)); swapAxe(runeAxe); return random(500, 800); } } if (getAdamantAxe == true) { in = null; try { // Open the version text file url = new URL("http://epic-scripting.webs.com/EpicWoodcutterV.txt") .openConnection(); // Create an input stream for it in = new BufferedReader(new InputStreamReader(url.getInputStream())); // Check

if ((skills.getCurrentLevel(8) >= 31) && (skills.getCurrentLevel(8) < 41) && !inventory.contains(adamantAx e)) { status = "Walking to bank"; walkToTile(faladorEastBank); sleep(random(1000, 2000)); swapAxe(adamantAxe); return random(500, 800); } } if (getMithrilAxe == true) { if ((skills.getCurrentLevel(8) >= 21) && (skills.getCurrentLevel(8) < 31) && !inventory.contains(mithrilAx e)) { status = "Walking to bank"; walkToTile(faladorEastBank); sleep(random(1000, 2000)); swapAxe(mithrilAxe); return random(500, 800); } } if (getMyPlayer().getLocation().getX() > halfWayWalkPoin t.getX() + 5) { status = "Walking"; walkToTile(halfWayWalkPoint); return random(200, 500); } if (skills.getCurrentLevel(8) < 20) { logType = "logs"; } else if (skills.getCurrentLevel(8) < 35) { logType = "oaks"; } else if (skills.getCurrentLevel(8) < cutYewsAt cutYews == false) { logType = "willows"; } else { logType = "yews"; } if (inventory.isFull() (bank.getInterface().isValid() && inv entory.getCount() == 14)) { if (logType == "yews") { status = "Walking to bank"; walkPathEpic(yewsToBank); if (calc.distanceTo(faladorEastBank) < r andom(2, 5)) { status = "Banking yews"; depositYews(); } else { walking.walkTileMM(faladorEastBa nk); } return random(300, 800); } else {

status = "Dropping " + logType; inventory.dropAllExcept(axeTypes); } } if (skills.getCurrentLevel(8) < 20) { currentTrees = NORMALTREES; if (calc.distanceTo(normalTreesLocation) > 12) { status = "Walking to trees"; walkToTile(normalTreesLocation); // status = "Return"; return random(500, 800); } } else if (skills.getCurrentLevel(8) < 35) { currentTrees = OAKTREES; if (calc.distanceTo(oakTreesLocation) > 12) { status = "Walking to oaks"; walkToTile(oakTreesLocation); // status = "Return"; return random(500, 800); } } else if (skills.getCurrentLevel(8) < cutYewsAt cutYews == false) { currentTrees = WILLOWTREES; if (calc.distanceTo(willowTreesLocation) > 12) { status = "Walking to willows"; walkToTile(willowTreesLocation); // status = "Return"; return random(500, 800); } } else { currentTrees = YEWTREES; if (calc.distanceTo(yewTreesLocation) > 12 && !inventory.isFull()) { status = "Walking to yews"; walkPathEpic(bankToYews); // status = "Return"; return random(500, 800); } } if ((getMyPlayer().getAnimation() != -1 ) .isMoving()))) { return antiBan(); } else { status = "Cutting " + logType; chopTree(currentTrees); return random(500, 800); } } return (random(500, 800)); } // /////////////////////// // FUNCTIONS // // /////////////////////// public RSObject getLowestCorner(final RSObject testObj) { RSObject cur = null; (getMyPlayer(

int int int int

testID = testObj.getID(); lowestX = -1; lowestY = -1; x, y;

for (x = 0; x < 5; x++) { final RSObject o = objects.getTopAt(testObj.getLocation( )); if (o != null) { if (o.getID() != testID && lowestX == -1) { lowestX = testObj.getLocation().getX() x + 1; } } else if (lowestX == -1) { lowestX = testObj.getLocation().getX() - x + 1; } } for (y = 0; y < 5; y++) { final RSObject o = objects.getTopAt(testObj.getLocation( )); if (o != null) { if (o.getID() != testID && lowestY == -1) { lowestY = testObj.getLocation().getY() y + 1; } } else if (lowestY == -1) { lowestY = testObj.getLocation().getY() - y + 1; } } cur = objects.getTopAt(testObj.getLocation()); return cur; } public boolean chopTree(int treeIds[]) { RSObject Tree = objects.getNearest(treeIds); if (Tree == null) return false; final RSTile treeLoc = Tree.getLocation(); /* * if (distanceTo(treeLoc) == 5) { turnToTile(treeLoc); sleep(ra ndom(300, * 500)); } */ if (calc.distanceTo(treeLoc) > random(4, 5)) { walking.walkTileMM(treeLoc); sleep(random(200, 500)); } if (random(1, 20) == 10) { walking.walkTileMM(treeLoc); sleep(random(200, 500)); } RSObject finalTree = getLowestCorner(Tree); if (logType == "oaks" logType == "yews") { return finalTree.doAction("Chop down");

} else { return finalTree.doAction("Chop down"); } } /* * public boolean atTreeEpic33(final RSObject tree, final String action) { * try { final RSTile loc1 = tree.getLocation(); final RSTile loc4 = new * RSTile(loc1.getX() + 1, loc1.getY() + 1); * * final Point screenLoc = calc.tileToScreen(loc4.getX(), loc4.getY(), 1 0); * * * * * } } * * /*public boolean atTreeEpic(final RSObject tree, final String action) { * try { final RSTile loc1 = tree.getLocation(); * * @SuppressWarnings("unused") final RSTile loc2 = new RSTile(loc1.getX( ) + * 1, loc1.getY()); * * @SuppressWarnings("unused") final RSTile loc3 = new RSTile(loc1.getX( ), * loc1.getY() + 1); final RSTile loc4 = new RSTile(loc1.getX() + 1, * loc1.getY() + 1); * * //final Point sloc1 = calc.tileOnScreen(loc1.getX(), loc1.getY(), 10) ; * //final Point sloc2 = calc.tileToScreen(loc4.getX(), loc4.getY(), 10) ; * * * * * * * } } */ public void swapAxe(int axeID) { try { if (calc.distanceTo(faladorEastBank) < random(2, 4) && !bank.getInterface().isValid()) { walking.walkTileMM(faladorEastBank); sleep(random(200, 500)); } final RSObject bankbooth = objects.getNearest(bankBooth) ; if (bankbooth != null && !bank.getInterface().isValid()) { bankbooth.doAction("Use-quickly"); final Point screenLoc = new Point((sloc1.x + sloc2.x) / 2, (sloc1.y + sloc2.y) / 2); if (screenLoc.x == -1 screenLoc.y == -1) { return false; } mouse.move(screenLoc, 3, 3); sleep(random(200, 300)); return atMenu(action); } catch (final Exception e) { log("Small problem encountered, meltdown averted =P"); return false; if (screenLoc.x == -1 screenLoc.y == -1) { return false; } mouse.move(screenLoc, 3, 3); sleep(random(200, 300)); return atMenu(action); } catch (final Exception e) { log("Small problem encountered, meltdown averted =P"); return false;

} sleep(random(800, 1600)); if (bank.getInterface().isValid()) { if (bank.getCount(axeID) == 0) { if (axeID == runeAxe) { getRuneAxe = false; log("Could not find rune hatchet in bank. Next time don't select it at the start!"); } if (axeID == adamantAxe) { getAdamantAxe = false; log("Could not find adamant hatc het in bank. Next time don't select it at the start!"); } if (axeID == mithrilAxe) { getMithrilAxe = false; log("Could not find mithril hatc het in bank. Next time don't select it at the start!"); } sleep(500); bank.close(); return; } bank.depositAll(); sleep(random(400, 800)); bank.withdraw(axeID, 1); sleep(random(1500, 2100)); bank.close(); } } catch (final Exception e) { } return; } public void depositYews() { try { final RSObject bankbooth = objects.getNearest(bankBooth) ; if (bankbooth != null && !bank.getInterface().isValid()) { bankbooth.doAction("Use-quickly"); } sleep(random(800, 1000)); // RSInterface bankInterface= // RSInterface.getInterface(Constants.INTERFACE_BANK); if (bank.getInterface().isValid()) { bank.deposit(YEWLOGID, 0); sleep(random(400, 800)); } } catch (final Exception e) { } return; } /* * public boolean atObjectEpic(final RSObject object, final String actio

n) { * return objects.getAt(object.getLocation(), action); } * * /*public boolean atTileEpic(final RSTile tile, final String action) { try * { final Point location = calc.tileToScreen(tile); if (location.x == 1 * location.y == -1) { return false; } mouse.move(location, 3, 3); * mouse.click(false); return atMenuEpic(action); } catch (final Excepti on * * * * * * n * true; } else { if (idx == -1) { while (isMenuOpen()) { * mouse.moveRandomly(750); sleep(random(100, 500)); } return false; } e lse { * atMenuItem(idx); return true; } } } * * public void dropAllExcept_(final int... items) { try { boolean canDro p = * * * * * * * * * * * * * * * * * * + j * * * * * oing to do * * * e; * * * * * * * * 4] == k) { canDrop = false; } } } if (canDrop) { RSItem q = inventory.getItem(items); q.doAction("Drop"); } } } } } catch (final Exception e) {log( "Small problem encountered, meltdown averted =P (not sure what it's g now =S)" ); } return; } public void depositAllExceptEpic(int items[]) { boolean canBank = tru int i = 0; int j = 0; int[] inventoryArray = null; Point inventoryItemPoint = null; for (i = 0; i < 4; i++) { for (j = 0; j < 7; j++) { inventoryArray = null; inventoryItemPoint = null; inventoryArray = getInventoryArray(); canBank = true; if true; int i = 0; int j = 0; int[] inventoryArray = null; Point inventoryItemPoint = null; if (game.getCurrentTab() != game.TAB_INVENTORY) { game.openTab(game.TAB_INVENTORY); } for (i = 0; i < 4; i++) { for (j = 0; j < 7; j++) { inventoryArray = null; inventoryItemPoint = null; inventoryArray = getInventoryArray(); canDrop = true; if (inventoryArray[i + j * 4] != 0) { if (items != null) { for (final int k : items) { if (inventoryArray[i e) { return false; } } /*public boolean atMenuEpic(final String optionContains) { int idx = getMenuIndex(optionContains); if (!menu.isOpen()) { if (idx == -1) { return false; } if (idx == 0) { mouse.click(true); } else { mouse.click(false); sleep(random(200, 400)); atMenuItem(idx); } retur

* (inventoryArray[j + i * 4] != 0) { if (items != null) { for (final in t k * : items) { if (inventoryArray[j + i * 4] == k) { canBank = false; } } } * if (inventoryArray[j + i * 4] <= 0) { canBank = false; } * * if (canBank) { bank.depositAllExcept(); } } } } return; } */ public int antiBan() { final int ranNo = random(0, 20); int angle; if (ranNo == 2) { if (game.getCurrentTab() != (game.TAB_STATS)) { game.openTab(game.TAB_STATS); mouse.moveRandomly(random(670, 690), random(400, 410)); sleep(random(500, 750)); return random(100, 200); } } else if (ranNo == 3) { game.openTab(game.TAB_INVENTORY); return random(200, 400); } else if (ranNo == 4) { mouse.moveRandomly(random(0, 700), random(0, 500)); return random(200, 400); } else if (ranNo == 5) { mouse.moveRandomly(random(0, 450), random(0, 400)); return random(200, 400); } return random(200, 450); } public void walkPathEpic(RSTile tilePath[]) { int nearest = 0; int distance = 999; for (int i = 0; i < tilePath.length; i++) { if (calc.distanceTo(tilePath[i]) < distance) { nearest = i; distance = calc.distanceTo(tilePath[i]); } } for (int j = nearest; j < tilePath.length; j++) { if (walkToTile(tilePath[j]) == false) { return; } } } public boolean walkToTile(RSTile tile) { int failsRemaining = 6; int locationFailsRemaining = 5; RSTile lastLocation = getMyPlayer().getLocation(); while (calc.distanceTo(tile) > 8) { if (walking.getEnergy() > random(30, 60)) { walking.setRun(true);

} if (walking .walkTileMM(tileOnMap2(walking.randomize Tile(tile, 2, 2))) == false) { failsRemaining -= 1; if (failsRemaining <= 0) { status = "Walking failed"; log("Walking failed (invalid location), checking for randoms"); if (random(1, 3) == 2) { walking.walkTileMM(new RSTile(ge tMyPlayer() .getLocation().g etX() + 2, getMyPlayer() .getLocation().g etY() + 2)); } return false; } sleep(random(300, 800)); } else { failsRemaining = 5; } if (getMyPlayer().getLocation().getX() == lastLocation.g etX() && getMyPlayer().getLocation().getY() == lastLocation .getY()) { locationFailsRemaining -= 1; if (locationFailsRemaining <= 0) { status = "Walking failed"; log("Walking failed (not moving), checki ng for randoms"); return false; } sleep(random(300, 800)); } else { lastLocation = getMyPlayer().getLocation(); locationFailsRemaining = 5; } int countDown = 100; while (calc.distanceTo(walking.getDestination()) > 8 && getMyPlayer().isMoving()) { sleep(200); countDown -= 1; if (countDown <= 0) { if (calc.distanceTo(lumbridge) > 40) { return false; } } } } if (calc.distanceTo(tile) > 5) { walking.walkTileMM(tile); } return true; } public RSTile tileOnMap2(RSTile tile) { if (calc.distanceTo(tile) < 15) {

return tile; } for (int i = 0; i < 100; i++) { RSTile tileLoc = getMyPlayer().getLocation(); RSTile tile2 = new RSTile((tile.getX() * 2 + tileLoc.get X()) / 3, (tile.getY() * 2 + tileLoc.getY()) / 3); if (calc.distanceTo(tile2) < 15) { return tile2; } tile = tile2; } return tile; } public class XWoodCutterGUI extends JFrame { public XWoodCutterGUI() { initComponents(); } private void button1ActionPerformed(ActionEvent e) { if (checkBox1.isSelected()) { getMithrilAxe = true; } else if (checkBox2.isSelected()) { getAdamantAxe = true; } else if (checkBox3.isSelected()) { getRuneAxe = true; } else { log.severe("No hatchet retrieval"); } if (comboBox1.getSelectedItem() == "Yews from 65") { cutYewsAt = 65; cutYews = true; } else if (comboBox1.getSelectedItem() == "Yews from 60" ) { cutYewsAt = 60; cutYews = true; } else if (comboBox1.getSelectedItem() == "Yews from 70" ) { cutYewsAt = 70; cutYews = true; } else if (comboBox1.getSelectedItem() == "never") { cutYewsAt = 100; cutYews = false; } if (comboBox2.getSelectedItem() == "Trees 1") { normalTreesLocation = new RSTile(2996, 3228); } else if (comboBox2.getSelectedItem() == "Trees 2") { normalTreesLocation = new RSTile(2995, 3252); } else if (comboBox2.getSelectedItem() == "Trees 3") { normalTreesLocation = new RSTile(2990, 3206); } if (comboBox3.getSelectedItem() == "Oaks 1") { oakTreesLocation = new RSTile(2984, 3205); }

if (comboBox2.getSelectedItem() == "Willows 1") { willowTreesLocation = new RSTile(2989, 3187); } else if (comboBox2.getSelectedItem() == "Willows 2") { willowTreesLocation = new RSTile(2998, 3166); } else if (comboBox2.getSelectedItem() == "Willows 3") { willowTreesLocation = new RSTile(2970, 3195); } waitGUI = false; dispose(); } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MOD IFY // //GEN-BEGIN:initComponents tabbedPane1 = new JTabbedPane(); panel1 = new JPanel(); comboBox1 = new JComboBox(); textPane1 = new JTextPane(); button1 = new JButton(); panel2 = new JPanel(); checkBox1 = new JCheckBox(); checkBox2 = new JCheckBox(); checkBox3 = new JCheckBox(); panel3 = new JPanel(); label1 = new JLabel(); label2 = new JLabel(); label3 = new JLabel(); comboBox2 = new JComboBox(); comboBox3 = new JComboBox(); comboBox4 = new JComboBox(); // ======== this ======== setTitle("XWoodCutter"); Container contentPane = getContentPane(); contentPane.setLayout(null); // ======== tabbedPane1 ======== { // ======== panel1 ======== { panel1.setLayout(null); // ---- comboBox1 ---comboBox1.setModel(new DefaultComboBoxMo del(new String[] { "Yews from 65", "Yews fr om 60", "Yews from 70", "never" })); panel1.add(comboBox1); comboBox1.setBounds(new Rectangle(new Po int(140, 130), comboBox1.getPreferredSi ze())); // ---- textPane1 ---textPane1

.setText("This script is a woodcutter that trains around Rimmington. It has a built in deathwalk and wil l find its way to the trees wherever you start it. It is intended for training y our woodcutting from 1 to yews as fast as possible, and trains in the most effic ient way to get there. Locations are ranked in order best to worst, so only use other locations if the first ones are full."); textPane1.setEditable(false); panel1.add(textPane1); textPane1.setBounds(20, 15, 341, 90); // ---- button1 ---button1.setText("START"); panel1.add(button1); button1.setBounds(new Rectangle(new Poin t(155, 160), button1.getPreferredSize ())); button1.addActionListener(new ActionList ener() { public void actionPerformed(Acti onEvent e) { button1ActionPerformed(e ); } }); { // compute preferred size Dimension preferredSize = new Di mension(); for (int i = 0; i < panel1.getCo mponentCount(); i++) { Rectangle bounds = panel 1.getComponent(i) .getBoun ds(); preferredSize.width = Ma th.max(bounds.x + bounds .width, preferredSize.width); preferredSize.height = M ath.max(bounds.y + bounds .height, preferredSize.height); } Insets insets = panel1.getInsets (); preferredSize.width += insets.ri ght; preferredSize.height += insets.b ottom; panel1.setMinimumSize(preferredS ize); panel1.setPreferredSize(preferre dSize); } } tabbedPane1.addTab("Main", panel1); // ======== panel2 ======== {

panel2.setLayout(null); // ---- checkBox1 ---checkBox1.setText("Get Mithril Axe"); panel2.add(checkBox1); checkBox1.setBounds(new Rectangle(new Po int(130, 45), checkBox1.getPreferredSi ze())); // ---- checkBox2 ---checkBox2.setText("Get Adamant Axe"); panel2.add(checkBox2); checkBox2.setBounds(new Rectangle(new Po int(130, 70), checkBox2.getPreferredSi ze())); // ---- checkBox3 ---checkBox3.setText("Get Rune Axe"); panel2.add(checkBox3); checkBox3.setBounds(new Rectangle(new Po int(130, 95), checkBox3.getPreferredSi ze())); { // compute preferred size Dimension preferredSize = new Di mension(); for (int i = 0; i < panel2.getCo mponentCount(); i++) { Rectangle bounds = panel 2.getComponent(i) .getBoun ds(); preferredSize.width = Ma th.max(bounds.x + bounds .width, preferredSize.width); preferredSize.height = M ath.max(bounds.y + bounds .height, preferredSize.height); } Insets insets = panel2.getInsets (); preferredSize.width += insets.ri ght; preferredSize.height += insets.b ottom; panel2.setMinimumSize(preferredS ize); panel2.setPreferredSize(preferre dSize); } } tabbedPane1.addTab("Hatchet Retrieval", panel2); // ======== panel3 ======== {

panel3.setLayout(null); // ---- label1 ---label1.setText(" Trees"); panel3.add(label1); label1.setBounds(new Rectangle(new Point (55, 65), label1 .getPreferredSize())); // ---- label2 ---label2.setText("Oaks"); panel3.add(label2); label2.setBounds(new Rectangle(new Point (175, 65), label2 .getPreferredSize())); // ---- label3 ---label3.setText("Willows"); panel3.add(label3); label3.setBounds(new Rectangle(new Point (275, 65), label3 .getPreferredSize())); // ---- comboBox2 ---comboBox2.setModel(new DefaultComboBoxMo del(new String[] { "Trees 1", "Trees 2", "T rees 3" })); panel3.add(comboBox2); comboBox2.setBounds(new Rectangle(new Po int(40, 85), comboBox2.getPreferredSi ze())); // ---- comboBox3 ---comboBox3.setModel(new DefaultComboBoxMo del( new String[] { "Oaks 1" })); panel3.add(comboBox3); comboBox3.setBounds(new Rectangle(new Po int(160, 85), comboBox3.getPreferredSi ze())); // ---- comboBox4 ---comboBox4.setModel(new DefaultComboBoxMo del(new String[] { "Willows 1", "Willows 2" , "Willows 3" })); panel3.add(comboBox4); comboBox4.setBounds(new Rectangle(new Po int(260, 85), comboBox4.getPreferredSi ze())); { // compute preferred size Dimension preferredSize = new Di mension(); for (int i = 0; i < panel3.getCo

mponentCount(); i++) { Rectangle bounds = panel 3.getComponent(i) .getBoun ds(); preferredSize.width = Ma th.max(bounds.x + bounds .width, preferredSize.width); preferredSize.height = M ath.max(bounds.y + bounds .height, preferredSize.height); } Insets insets = panel3.getInsets (); preferredSize.width += insets.ri ght; preferredSize.height += insets.b ottom; panel3.setMinimumSize(preferredS ize); panel3.setPreferredSize(preferre dSize); } } tabbedPane1.addTab("Tree Location", panel3); } contentPane.add(tabbedPane1); tabbedPane1.setBounds(0, 0, 385, 265); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < contentPane.getComponentCoun t(); i++) { Rectangle bounds = contentPane.getCompon ent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = contentPane.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; contentPane.setMinimumSize(preferredSize); contentPane.setPreferredSize(preferredSize); } pack(); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization // //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY // //GEN-BEGIN:variables private JTabbedPane tabbedPane1;

private JPanel panel1; private JComboBox comboBox1; private JTextPane textPane1; private JButton button1; private JPanel panel2; private JCheckBox checkBox1; private JCheckBox checkBox2; private JCheckBox checkBox3; private JPanel panel3; private JLabel label1; private JLabel label2; private JLabel label3; private JComboBox comboBox2; private JComboBox comboBox3; private JComboBox comboBox4; // JFormDesigner - End of variables declaration //GEN-END:variab les } }

Anda mungkin juga menyukai