rendered paste bodyimport java.awt.*;import java.util.*;import java.awt.event.*;import com.speljohan.rsbot.script.*;import com.speljohan.rsbot.bot.*;import com.speljohan.rsbot.script.wrappers.*;import com.speljohan.rsbot.event.listeners.*;import com.speljohan.rsbot.accessors.*;import com.speljohan.rsbot.event.events.*;import java.awt.event.KeyEvent;public class SmartWC extends Script implements PaintListener, ServerMessageListener { public String getName() { return "SmartWC"; } public double getVersion() { return 0.2; } Color BG = new Color(123, 123, 123, 100); Color GREEN = new Color(0, 255, 0, 255); Color RED = new Color(255, 0, 0, 255); long startTime=0; boolean proggy=false; boolean finish=false; int logsSold=0; int[] axes = { 1351, 1349, 1353, 1355, 1357, 1359, 6739 }; RSTile[] tree = { new RSTile(3197,3245), new RSTile(3194,3246), new RSTile(3193,3244), new RSTile(3196,3242), new RSTile(3190,3241), new RSTile(3192,3238), new RSTile(3197,3235), new RSTile(3229,3245), new RSTile(3225,3246), new RSTile(3223,3247), new RSTile(3226,3248), new RSTile(3219,3252), new RSTile(3181,3237), new RSTile(3183,3238), new RSTile(3177,3237), new RSTile(3180,3250), new RSTile(3175,3250), new RSTile(3176,3254), new RSTile(3179,3255), new RSTile(3182,3257), new RSTile(3185,3259), new RSTile(3188,3260), new RSTile(3190,3255), new RSTile(3191,3252)}; int[] treeType = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; RSTile[] willow = { new RSTile(2966,3200), new RSTile(2967,3192), new RSTile(2968,3193), new RSTile(2970,3193), new RSTile(2972,3195) }; int[] willowType = {0}; public String getAuthor() { return "Mike"; } public String getScriptCategory() { return "Mike's Scripts/BotArmy"; } public static RSTile getStartingTile() { return new RSTile(3221,3218); } public void onFinish() { Bot.getEventManager().removeListener(PaintListener.class, this); Bot.getEventManager().removeListener(ServerMessageListener.class, this); proggy=false; } public void serverMessageRecieved(ServerMessageEvent t) { if(t.getMessage().toLowerCase().contains("an axe to chop down this tree")) finish=true; } public String getTopText() { ArrayList<String> items = getMenuItems(); if (items.size() <= 1) return " "; return items.get(0).toLowerCase(); } public String getScriptDescription() { return "<html>\n" + "<head></head>\n" + "<body>\n" + "<center>" + "<h2>" + getName() + "</h2>" + "</center>\n" + "<b>Author:</b> " + getAuthor() + "<br/>\n" + "<b>Version:</b> " + getVersion() + "<br/>\n" + "<br/>\n" + "<b>Starting Location:</b> Tutorial island/Lumbridge<br/>" + "<b>Function:</b> Will train woodcutting from any level at the best spot possible." + "<br/>" + "<b>Version Notes:</b> " + "<ul>" + "<li>" + "<b>V1</b>" + "<li>" + "<b>1.0</b> <i> First release. Does normal trees if you are lower than level 30." + "Otherwise it will do rimmington willows." + "</li>" + "</li>" + "<li>" + "<b>0.*:</b> Beta Versions" + "</li>" + "</ul>" + "</body>\n" + "</html>"; } public boolean onStart(String[] args) { startTime=0; logsSold=0; Bot.getEventManager().addListener(PaintListener.class, this); Bot.getEventManager().addListener(ServerMessageListener.class, this); proggy=true; finish=false; return true; } public Point treeToScreen(RSTile t,int type) { Point p = Calculations.tileToScreen(t.getX(), t.getY(), 1, 1, random(10,70)); if(distanceTo(t) > 7 || p == null || p.getX() < 0 || p.getY() < 0) { turnToTile(t); p = Calculations.tileToScreen(t.getX(), t.getY(), 1, 1, random(10,70)); if(distanceTo(t) > 7 || p == null || p.getX() < 0 || p.getY() < 0) { walkPathMM2(randomizePath(fixPath(generateProperPath(t)),2,4),17); return null; } } return p; } public boolean chopTree(RSTile t,int i) throws Exception { Point p=treeToScreen(t,0); if(p==null) return false; String treeType = " Tree"; if(skills.getCurrentSkillLevel(STAT_WOODCUTTING) >=30) treeType=" Willow"; moveMouse(p, 3, 3); if(getTopText().contains("hop down"+treeType)) { clickMouse(true); return true; } ArrayList<String> items = getMenuItems(); if (items.size() <= 1) return false; for(int o=0;o<items.size();o++) if(items.get(o).contains("Chop down"+treeType)) { return atMenu("Chop down"+treeType); } if(isMenuOpen()) atMenu("cancel"); return false; } public boolean canReach(RSTile t) { return Calculations.canReach(t, false); } public boolean dropAllItemsExcept(int[] except) { if (getCurrentTab() != TAB_INVENTORY && !interfaceExists(INTERFACE_BANK) && !interfaceExists(INTERFACE_STORE)) { openTab(TAB_INVENTORY); } int[] items = getInventoryArray(); for (int i = 0; i < items.length; i++) { boolean exception = false; for(int e=0; e<except.length;e++) if(except[e] == items[i]) exception = true; if (!exception) { Point t = getInventoryItemPoint(i); clickMouse(t, 5, 5, false); atMenu("Drop"); wait(random(0,150)); } } return true; } public void sellLogs() { if(distanceTo(new RSTile(2949,3215)) > 2) if(!walkPathMM2(randomizePath(generatePath(new RSTile(2948,3215)),2,4),15)) return; if(!RSInterface.getInterface(620).isValid()) { RSNPC shopK = getNearestNPCByName("Shopkeeper"); RSNPC shopA = getNearestNPCByName("Shop assistant"); if(distanceTo(shopK) > distanceTo(shopA)) { if(!atNPC(shopA,"Trade")) turnToTile(shopA.getLocation()); } else { if(!atNPC(shopK,"Trade")) turnToTile(shopK.getLocation()); } return; } int inventoryCount = getInventoryCount(); int[] inventoryArray = getInventoryArray(); int temp=getInventoryCount(1519); for (int off = 0; off < inventoryArray.length; off++) { int t = inventoryArray[off]; if(t==995 || t == 1351 || t == 1349 || t == 1353 || t == 1355 || t == 1357 || t == 1359 || t == 6739) continue; if(inventoryContains(inventoryArray[off])) atInventoryItem(inventoryArray[off], "Sell 50"); } logsSold+=temp-getInventoryCount(1519); } RSTile entTile=null; public int loop() { if(entTile != null && getNPCAt(entTile) == null) entTile=null; if(finish) return -1; if(isMenuOpen()) atMenu("cancel"); //just incase; try { RSCharacter temp = getMyPlayer().getInteracting(); RSNPC interacting=null; if(temp!=null) interacting=getNPCAt(temp.getLocation()); if(interacting != null) { if(interacting.getName() == "Tree" || interacting.getName() == "Oak" || interacting.getName() == "Willow") { log(interacting.getName()); atTile(getMyPlayer().getLocation(), "alk here"); entTile=interacting.getLocation(); } } for(int i=0; i<=10;i++) if(getMyPlayer().getAnimation() != -1 || (getMyPlayer().isMoving() && distanceTo(getDestination()) >5)) return random(50,100); else wait(random(75,125)); if(getEnergy() >= random(random(random(50,99),99),99)) //triple random for chance of higher number setRun(true); if(getInventoryCount() == 28) { if(skills.getCurrentSkillLevel(STAT_WOODCUTTING) > 30) sellLogs(); else dropAllItemsExcept(axes); return random(50,100); } if(RSInterface.getInterface(620).isValid()) atInterface(620,7); RSTile nearest=null; RSTile[] treeType = treeType(); if(treeType==null)//wtf return random(50,100); for(int i=0;i<treeType.length;i++) { if(entTile != null && distanceBetween(treeType[i],entTile) <=2) continue; RSObject t = getObjectAt(treeType[i]); if(t==null) continue; if(!isTree(t.getID())) continue; if(nearest == null || distanceTo(t) < distanceTo(nearest)) nearest=treeType[i]; } if(nearest != null) chopTree(nearest,0); } catch(Exception e) { e.printStackTrace(); } return random(50,100); } public RSTile[] treeType() { if(skills.getCurrentSkillLevel(STAT_WOODCUTTING) >= 30) { if(distanceTo(willow[0]) >= 15) if(!walkPathMM2(randomizePath(fixPath(generateProperPath(willow[0])),2,4),15)) return null; if(startTime==0) startTime=System.currentTimeMillis(); return willow; } if(distanceTo(tree[0]) >= 50) if(!walkPathMM2(randomizePath(fixPath(generateProperPath(tree[0])),2,4),15)) return null; return tree; } public boolean isTree(int id) { if(id == 1278 || id == 1276 || id == 5551 || id == 5552 || id == 5553) return true; return false; } public RSTile[] fixPath(RSTile[] path) { ArrayList<RSTile> newPath = new ArrayList<RSTile>(); for(int i=0; i<path.length-1;i++) { RSTile[] temp1 = generatePath(path[i],path[i+1]); for(int l=0;l<temp1.length;l++) newPath.add(temp1[l]); } return newPath.toArray(new RSTile[newPath.size()]); } public RSTile[] generatePath(RSTile tile) { return generatePath(getMyPlayer().getLocation().getX(),getMyPlayer().getLocation().getY(), tile.getX(), tile.getY()); } public RSTile[] generatePath(RSTile tile, RSTile tile2) { return generatePath(tile.getX(), tile.getY(), tile2.getX(), tile2.getY()); } public RSTile[] generatePath(int startX, int startY, int destinationX, int destinationY) { //most credits to aftermath double dx, dy; ArrayList<RSTile> list = new ArrayList<RSTile>(); list.add(new RSTile(startX, startY)); while(Math.hypot(destinationY - startY, destinationX - startX) > 8) { dx = destinationX - startX; dy = destinationY - startY; int gamble = random(14,17); while(Math.hypot(dx, dy) > gamble) { dx *= .95; dy *= .95; } startX += (int) dx; startY += (int) dy; list.add(new RSTile(startX, startY)); } list.add(new RSTile(destinationX, destinationY)); return list.toArray(new RSTile[list.size()]); } public boolean walkPathMM2(RSTile[] path, int maxDist) { try { RSTile next = nextTile(path, maxDist); RSTile current=getDestination(); if(current==null) walkTileMM(next); else if(distanceBetween(current,next)<=4 && getMyPlayer().isMoving()) return false; else walkTileMM(next); if(distanceBetween(path[path.length],getMyPlayer().getLocation())<=4) return true; } catch (Exception e) { } return false; } public RSNPC getNPCAt(RSTile t) { int Dist = 20; RSNPC closest = null; int[] validNPCs = Bot.getClient().getNPCIndexArray(); NPC[] npcs = Bot.getClient().getNPCArray(); for (int element : validNPCs) { if (npcs[element] == null) { continue; } RSNPC Monster = new RSNPC(npcs[element]); try { if(Monster.getLocation().equals(t)) return Monster; } catch (Exception e) { e.printStackTrace(); } } log("NpcAt: None"); return null; } public int antiban() { int gamble = random(0,50); if(gamble==49) { openTab(TAB_STATS); wait(random(100,200)); hoverInterface(320,146); wait(random(500,3000)); openTab(TAB_INVENTORY); return random(500,600); } return random(50,100); } public void hoverInterface(int iface, int child) { hoverInterface(RSInterface.getChildInterface(iface, child)); } public void hoverInterface(RSInterfaceChild i) { if (!i.isValid()) return; Rectangle pos = i.getArea(); moveMouse((int) random(pos.getMinX(), pos.getMaxX()), (int) random(pos.getMinY(), pos.getMaxY())); } public void onRepaint(Graphics g) { // stole transparent box from ~alex~'s if(skills.getCurrentSkillLevel(STAT_WOODCUTTING) < 30) return; if (isLoggedIn() && proggy == true && startTime != 0) { int logs = getInventoryCount(1519)+logsSold; long millis = System.currentTimeMillis() - startTime; long seconds2 = millis / 1000; long hours = millis / (1000 * 60 * 60); millis -= hours * 1000 * 60 * 60; long minutes = millis / (1000 * 60); millis -= minutes * 1000 * 60; long seconds = millis / 1000; String hoursString = ""; String minutesString = ""; String secondsString = seconds + ""; String type = "seconds"; if (minutes > 0) { minutesString = minutes + ":"; type = "minutes"; } if (hours > 0) { hoursString = hours + ":"; type = "hours"; } if (minutesString.length() == 1) { minutesString = "0" + minutesString; } if (hoursString.length() == 1) { hoursString = "0" + hoursString; } if (secondsString.length() == 1) { secondsString = "0" + secondsString; } int x = 18; int y = 18; g.setColor(BG); g.fill3DRect(14, 25, 210, 165, true); g.setColor(GREEN); g.drawString(getName() + " v" + getVersion() + " by " + getAuthor(), x, y += 20); g.drawString("Running for " + hoursString + minutesString + secondsString + " " + type + ".", x, y += 20); g.setColor(RED); g.drawString("Chopped " + (logs+getInventoryCount(1953)) + " willows.", x, y += 20); if (seconds2 != 0) { g.drawString("Averaging " + ((logs+getInventoryCount(1953)) * 3600 / seconds2) + " willows per hour.", x, y += 20); g.drawString("Averaging " + ((logs+getInventoryCount(1953)) * 3600 / seconds2)*67.5 + " xp per hour.", x, y += 20); } } }}