ULTIMATE GUIDE

LoG iN

ULTIMATE GUIDE


    QckYews AWSOME SCRIPT

    Share

    Turk4life321
    Admin

    Posts : 41
    Join date : 2009-08-09
    Location : In Saims Room *cough*

    QckYews AWSOME SCRIPT

    Post  Turk4life321 on Fri Jan 01, 2010 4:48 am

    import java.io.*;
    import java.net.*;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Point;
    import java.awt.Polygon;
    import java.awt.event.KeyEvent;
    import java.lang.reflect.Method;
    import java.util.Map;
    import java.util.Random;

    import javax.swing.JOptionPane;
    import org.rsbot.bot.Bot;
    import org.rsbot.script.Calculations;
    import org.rsbot.script.GEItemInfo;
    import org.rsbot.script.ScriptManifest;
    import org.rsbot.event.events.ServerMessageEvent;
    import org.rsbot.event.listeners.PaintListener;
    import org.rsbot.event.listeners.ServerMessageListener;
    import org.rsbot.script.wrappers.RSObject;
    import org.rsbot.script.wrappers.RSTile;
    import org.rsbot.script.Script;


    //Credits
    //Antiban structure based off Garrett's antiban, however the actions are all my own.
    // atTree method used courtesy of Epic_ with permission.
    // Multi-threaded anti-ban (QckYewsAntiBan class) courtesy of Taha's tutorial. (http://itaha.com/?p=96)
    //Paint progress bar courtesy of purefocus (http://www.rsbot.org/vb/showthread.php?p=2089956)

    @ScriptManifest(authors = { "Qckdrw777" }, category = "Woodcutting", name = "QckYews", version = 2.03, description = "<html><head>"
    + "</head><body>"
    + "<center>"
    + "<b><font size=\"5\" color=\"Black\">"
    + "QckYews"
    + " V2.03"
    + "</font></b>"
    + "<br></br>"
    + "<i><font size=\"4\" color=\"black\">Cuts and banks yews.</font></i>"
    + "<br></br>"
    + "<br></br>"
    + "<br></br>"
    + "Please start the script at the East Varrock bank."
    + "<br></br>" + "</body></html>"
    )

    public class QckYews extends Script implements PaintListener, ServerMessageListener {

    public int bankBooth = 11402;
    public int yewTree = 1309;
    public int [] axes = {1349, 1351, 1353, 1355, 1357, 1359, 1361, 6739};
    public long startTime = System.currentTimeMillis();
    private String status = "";
    public int startexp;
    public int logsChopped;
    public int levelsGained;
    public int xpPerHour;
    public int logsPerHour;
    public int yewValue;
    public int moneyMade;
    public int percentToNextLevel;
    private boolean Banked;
    QckYewsAntiBan antiban;
    Thread t;

    //Bank To Yew
    RSTile[] bankToYew1 = {
    new RSTile (3265, 3429),
    new RSTile (3280, 3429),
    new RSTile (3285, 3444),
    new RSTile (3288, 3460),
    new RSTile (3298, 3468),
    new RSTile (3305, 3472),
    };
    RSTile[] bankToYew2 = {
    new RSTile (3260, 3429),
    new RSTile (3268, 3429),
    new RSTile (3279, 3429),
    new RSTile (3284, 3443),
    new RSTile (3287, 3458),
    new RSTile (3278, 3464),
    new RSTile (3272, 3469),
    };
    RSTile[] bankToYew3 = {
    new RSTile (3260, 3429),
    new RSTile (3268, 3429),
    new RSTile (3279, 3429),
    new RSTile (3284, 3443),
    new RSTile (3287, 3458),
    new RSTile (3278, 3464),
    new RSTile (3272, 3469),
    new RSTile (3268, 3479),
    new RSTile (3266, 3488),
    new RSTile (3267, 3491),

    };

    // Yew To Bank
    RSTile[] yew1ToBank = {
    new RSTile (3299, 3463),
    new RSTile (3290, 3460),
    new RSTile (3286, 3449),
    new RSTile (3285, 3439),
    new RSTile (3284, 3432),
    new RSTile (3277, 3429),
    new RSTile (3264, 3430),
    new RSTile (3253, 3421),
    };
    RSTile[] yew2ToBank = {
    new RSTile (3277, 3461),
    new RSTile (3284, 3453),
    new RSTile (3284, 3442),
    new RSTile (3284, 3434),
    new RSTile (3277, 3428),
    new RSTile (3261, 3428),
    new RSTile (3253, 3421),
    };
    RSTile[] yew3ToBank = {
    new RSTile (3269, 3485),
    new RSTile (3276, 3474),
    new RSTile (3278, 3464),
    new RSTile (3282, 3454),
    new RSTile (3284, 3444),
    new RSTile (3286, 3437),
    new RSTile (3277, 3429),
    new RSTile (3264, 3429),
    new RSTile (3253, 3421),
    };

    //Yew Tiles
    RSTile yewTile1 = new RSTile(3305, 3472);
    RSTile yewTile2 = new RSTile(3271, 3473);
    RSTile yewTile3 = new RSTile (3267, 3491);

    //Yew To Yew
    RSTile[] yew1toyew2 = {
    new RSTile(3290, 3475),
    new RSTile(3277, 3472),
    new RSTile(3271, 3473),
    };
    RSTile[] yew1toyew3 = {
    new RSTile(3295, 3468),
    new RSTile(3290, 3475),
    new RSTile(3280, 3480),
    new RSTile(3271, 3482),
    new RSTile(3267, 3488),
    new RSTile(3267, 3491),
    };
    RSTile[] yew2toyew1 = {
    new RSTile(3277, 3464),
    new RSTile(3285, 3462),
    new RSTile(3294, 3468),
    new RSTile(3305, 3472),
    };
    RSTile[] yew2toyew3 = {
    new RSTile(3271, 3478),
    new RSTile(3268, 3484),
    new RSTile(3266, 3490),
    new RSTile(3267, 3491),
    };
    RSTile[] yew3toyew1 = {
    new RSTile(3268, 3487),
    new RSTile(3280, 3478),
    new RSTile(3294, 3478),
    new RSTile(3300, 3468),
    new RSTile(3305, 3472),
    };
    RSTile[] yew3toyew2 = {new RSTile(3268, 3485),
    new RSTile(3267, 3479),
    new RSTile(3271, 3473),
    };

    // Tile/Path Variables
    public RSTile yewTile;
    public RSTile[] yewpath;
    public RSTile[] bankpath;
    public RSTile[] bankToYew;

    //Areas
    final int[] BANK_AREA = {3256, 3423, 3250, 3419};


    public boolean onStart(Map<String, String> args) {
    startTime = System.currentTimeMillis();
    log("QckYews Started");

    URLConnection url = null;
    BufferedReader in = null;
    try{
    //Open the version text file
    url = new URL("http://www.qckdrw777.webs.com/Scripts/QckYewsVERSION.txt").openConnection();
    //Create an input stream for it
    in = new BufferedReader(new InputStreamReader(url.getInputStream()));
    //Check if the current version is outdated
    if(Double.parseDouble(in.readLine()) > getVersion()) {
    //If it is, check if the user would like to update.
    if(JOptionPane.showConfirmDialog(null, "Update found. Do you want to update?") == 0){
    openURL("http://www.qckdrw777.webs.com/qckyews.htm");
    }
    }
    }
    catch (final Exception e) {
    e.printStackTrace();
    }

    //yewTile = yewTile1;
    //bankpath = yew1ToBank;
    //yewpath = yew2toyew1;
    if (isLoggedIn()) {
    setCameraAltitude(true);
    }

    final GEItemInfo yew = grandExchange.loadItemInfo(1515);
    yewValue = yew.getMarketPrice();

    antiban = new QckYewsAntiBan();
    t = new Thread(antiban);
    return true;
    }

    public double getVersion() {
    return (2.03);
    }


    public void onFinish(){
    Bot.getEventManager().removeListener(PaintListener.class, this);
    antiban.stopThread = true;
    log("QckYews Stopped");
    log("Thanks for using");
    return;
    }

    public void onRepaint(Graphics render) {
    if (isLoggedIn()) {
    int xpGained = 0;
    if ( startexp == 0) {
    startexp = skills.getCurrentSkillExp(STAT_WOODCUTTING);
    }
    xpGained = skills.getCurrentSkillExp(STAT_WOODCUTTING) - startexp;
    long runTime = 0;
    runTime = System.currentTimeMillis() - startTime;
    if ((runTime / 1000) > 0) {
    logsPerHour = (int) ((3600000.0 / (double) runTime) * logsChopped);
    xpPerHour = (int) ((3600000.0 / (double) runTime) * xpGained);
    }
    moneyMade = yewValue * logsChopped;
    percentToNextLevel = skills.getPercentToNextLevel(STAT_WOODCUTTING);
    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;
    render.setColor(Color.gray);
    render.fill3DRect(0, 0, 155, 160, true);
    render.setColor(Color.white);
    render.drawString("QckYews V" + getVersion(), 5, 15);
    render.drawString("Status : " + status , 5, 30);
    render.drawString("Time Running: " + hours + ":" + minutes + ":" + seconds, 5, 45);
    render.drawString("XP Gained: " + xpGained, 5, 60);
    render.drawString("XP/Hour: " + xpPerHour, 5, 75);
    render.drawString("Levels Gained: " + levelsGained, 5, 90);
    render.drawString("LogsChopped: " + logsChopped, 5, 105);
    render.drawString("Logs/Hour: " + logsPerHour, 5, 120);
    render.drawString("Money Made: " + moneyMade +"gp", 5, 135);
    ProgBar(render, 5, 142, 145, 12, percentToNextLevel, Color.red, Color.green, Color.white);
    }
    }

    /**
    *
    * @param g
    * graphics
    * @param posX
    * position x for the bar
    * @param posY
    * position y for the bar
    * @param width
    * width of the bar
    * @param height
    * height of the bar
    * @param Progress
    * progress variable
    * @param color1
    * primary color
    * @param color2
    * secondary color
    * @param text
    * Text color
    */

    public void ProgBar(Graphics g,int posX, int posY, int width, int height, int Progress, Color color1, Color color2, Color text){



    int[] c1 = {color1.getRed() , color1.getGreen() , color1.getBlue() , 150};
    int[] c2 = {color2.getRed() , color2.getGreen() , color2.getBlue() , 150};
    if(c1[0]>230){c1[0]=230;}if(c1[1]>230){c1[1]=230;}if(c1[2]>230){c1[2]=230;}
    if(c2[0]>230){c2[0]=230;}if(c2[1]>230){c2[1]=230;}if(c2[2]>230){c2[2]=230;}

    g.setColor(new Color(c1[0],c1[1],c1[2],200));
    g.fillRoundRect(posX, posY, width, height, 5, 12);
    g.setColor(new Color(c1[0]+25,c1[1]+25,c1[2]+25,200));
    g.fillRoundRect(posX, posY, width, height/2, 5, 12);

    g.setColor(new Color(c2[0],c2[1],c2[2],200));
    g.fillRoundRect(posX, posY, (Progress*width)/100, height, 5, 12);
    g.setColor(new Color(c2[0]+25,c2[1]+25,c2[2]+25,150));
    g.fillRoundRect(posX, posY, (Progress*width)/100, height/2, 5, 12);

    g.setColor(Color.LIGHT_GRAY);
    g.drawRoundRect(posX, posY, width, height, 5, 12);

    g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, height));
    g.setColor(text);
    g.drawString(""+Progress+"% To Next Level", posX+(width/6), posY+(height+height/20));

    }

    public int antiBan() {
    int random = random(1, 24);
    switch (random) {
    case 1:
    if (random(1, 5) == 3)
    {
    int x = (int) getMouseLocation().getX();
    int y = (int) getMouseLocation().getY();
    moveMouse(x + random(-100, 100), y + random(-50, 50));
    return random(100, 350);
    }
    case 2:
    if (random(1, 10) == 5)
    {
    openTab(random(1, 6));
    return(random(1152, 2543));
    }
    case 3:
    if (random(1, 100) == 50)
    {
    openTab(TAB_STATS);
    moveMouse(random(664, 710), random(297, 322));
    return(random(731, 2313));
    }
    case 4:
    if (random(1, 147) == 75)
    {
    openTab(random(0, Cool);
    return random(1000, 3673);
    }
    case 5:
    if (random(1, 10) == 9)
    {
    moveMouseRandomly(77);
    return random(105, 435);
    }
    case 6:
    if (random(1, 10) == 7)
    {
    openTab(random(9, 13));
    return random(993, 5435);
    }
    }
    return random(100, 200);
    }

    public void run() {
    if (getEnergy() > random(60, 100) && getSetting(173) != 1)
    setRun(true);
    }

    public void openURL(final String url) { // Credits to Dave who gave credits
    // to
    // some guy who made this.
    final String osName = System.getProperty("os.name");
    try {
    if (osName.startsWith("Mac OS")) {
    final Class<?> fileMgr = Class
    .forName("com.apple.eio.FileManager");
    final Method openURL = fileMgr.getDeclaredMethod("openURL",
    new Class[] { String.class });
    openURL.invoke(null, new Object[] { url });
    } else if (osName.startsWith("Windows")) {
    Runtime.getRuntime().exec(
    "rundll32 url.dll,FileProtocolHandler " + url);
    } else { // assume Unix or Linux
    final String[] browsers = { "firefox", "opera", "konqueror",
    "epiphany", "mozilla", "netscape" };
    String browser = null;
    for (int count = 0; count < browsers.length && browser == null; count++) {
    if (Runtime.getRuntime().exec(
    new String[] { "which", browsers[count] })
    .waitFor() == 0) {
    browser = browsers[count];
    }
    }
    if (browser == null) {
    throw new Exception("Could not find web browser");
    } else {
    Runtime.getRuntime().exec(new String[] { browser, url });
    }
    }
    } catch (final Exception e) {
    }
    }

    public boolean walkToBank() {
    status = "Walking To Bank";
    try{
    walkPathMM(randomizePath(bankpath,2 ,2 ));
    return true;
    }catch (final Exception e) {
    e.printStackTrace();
    }
    return false;
    }

    public boolean bankToYew() {
    status = "Walking To Yew";
    try{
    walkPathMM(randomizePath(bankToYew,2 ,2 ));
    return true;
    }catch (final Exception e) {
    e.printStackTrace();
    }
    return false;
    }

    public boolean walk() {
    status = "Walking to Yew";
    try{
    walkPathMM(randomizePath(yewpath,2 ,2 ));
    return true;
    } catch (final Exception e) {
    e.printStackTrace();}
    return false;
    }

    public boolean playerInArea(int maxX, int maxY, int minX, int minY) {
    int x = getMyPlayer().getLocation().getX();
    int y = getMyPlayer().getLocation().getY();
    if (x >= minX && x <= maxX && y >= minY && y <= maxY)
    return true;
    return false;
    }

    public boolean playerInArea(final int[] area) {
    final int x = getMyPlayer().getLocation().getX();
    final int y = getMyPlayer().getLocation().getY();
    if (x >= area[2] && x <= area[0] && y >= area[3] && y <= area[1])
    return true;
    return false;
    }

    public boolean playerInArea(Polygon area)
    {
    return area.contains(new Point(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY()));
    }


    public boolean openBank() {
    final RSObject bank = getNearestObjectByID(bankBooth); // search for bank.
    if (bank == null) {
    return false; // did not find the bank.
    }if(!tileOnScreen(bank.getLocation())) {
    turnToTile(bank.getLocation(), 15);
    }
    return atTile(bank.getLocation(), "Use-quickly");
    }

    public void bank() {
    wait (random(2000,3000));
    if(bank.isOpen()) {
    if(inventoryContainsOneOf(axes)){
    bank.depositAllExcept(axes);
    }else{
    bank.depositAll();
    }
    Banked = true;
    bank.close();
    wait (random(500, 1000));
    }
    }

    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 = Calculations.tileToScreen(loc4.getX(), loc4.getY(), 10);
    if (screenLoc.x == -1 || screenLoc.y == -1) {
    return false;
    }

    moveMouse(screenLoc, 3, 3);
    wait(random(200, 300));
    return atMenu(action);
    } catch (final Exception e) {
    log("Small problem encountered, meltdown averted =P");
    return false;
    }
    }

    public void serverMessageRecieved(final ServerMessageEvent e) {
    final String word = e.getMessage().toLowerCase();
    if (word.contains("you get some yew logs")) {
    logsChopped++;
    }
    if (word.contains("just advanced a")) {
    levelsGained++;
    }
    }

    private enum Series {BANK, WALK_FROM_BANK, YEW1, YEW2, YEW3, WALK_TO_BANK, error;};
    private Series getSeries() {
    try {
    if(playerInArea(BANK_AREA)){
    Banked = true;
    if(isInventoryFull()) {
    return Series.BANK;
    }
    return Series.WALK_FROM_BANK;
    }

    if(distanceTo(yewTile) > 2 && !isInventoryFull()){
    walkTo(yewTile);
    }

    if(distanceTo(yewTile1) < 3) {
    if(isInventoryFull()){
    bankpath = yew1ToBank;
    return Series.WALK_TO_BANK;
    }
    return Series.YEW1;
    }
    if(distanceTo(yewTile2) < 3) {
    if(isInventoryFull()){
    bankpath = yew2ToBank;
    return Series.WALK_TO_BANK;
    }
    return Series.YEW2;
    }
    if(distanceTo(yewTile3) < 3) {
    if(isInventoryFull()){
    return Series.WALK_TO_BANK;
    }
    return Series.YEW3;
    }
    if(isInventoryFull()){
    return Series.WALK_TO_BANK;
    }
    } catch(Exception e) { }
    return Series.error;
    }


    public int loop() {
    antiBan();
    if (!t.isAlive()) {
    t.start();
    log("AntiBan initialized!");
    }
    run();

    if(getMyPlayer().getAnimation() != -1) {
    return random(703, 980);
    }

    try{
    switch (getSeries()) {
    case BANK:
    status = "Banking";
    openBank();
    bank();
    break;
    case WALK_FROM_BANK:
    int random = random(1, 4);
    switch(random){
    case 1:
    yewTile = yewTile1;
    bankToYew = bankToYew1;
    log("Walking to Yew 1");
    bankToYew();
    wait(random(7000, 8000));
    break;
    case 2:
    yewTile = yewTile2;
    bankToYew = bankToYew2;
    log("Walking to Yew 2");
    bankToYew();
    wait(random(7000, 8000));
    break;
    case 3:
    yewTile = yewTile3;
    bankToYew = bankToYew3;
    log("Walking to Yew 3");
    bankToYew();
    wait(random(7000, 8000));
    break;
    }
    break;
    case YEW1:
    bankpath = yew1ToBank;
    Banked = false;
    setCameraAltitude(true);
    RSObject YEW1 = findObject(6, yewTree);

    if(YEW1 != null) {
    if(!tileOnScreen(YEW1.getLocation())) {
    turnToTile(YEW1.getLocation(), 15);
    }
    if (distanceTo(yewTile) > 2) {
    walkTo(YEW1.getLocation());
    status = "Need to be Closer";
    }

    status = "Cutting Yews";
    atTreeEpic33(YEW1, "Chop");
    wait(random(500, 700));
    }else{
    log("Tree is Null");
    int treechooser = random(1, 3);
    switch(treechooser){
    case 1:
    yewTile = yewTile2;
    yewpath = yew1toyew2;
    log("Walking to Yew 2");
    walk();
    wait(random(7000, 8000));
    break;
    case 2:
    yewTile = yewTile3;
    yewpath = yew1toyew3;
    log("Walking to Yew 3");
    walk();
    wait(random(7000, 8000));
    break;
    }
    }
    break;
    case YEW2:
    bankpath = yew2ToBank;
    Banked = false;
    setCameraAltitude(true);
    RSObject YEW2 = findObject(6, yewTree);
    if(YEW2 != null) {
    if(!tileOnScreen(YEW2.getLocation())) {
    turnToTile(YEW2.getLocation(), 15);
    }
    if (distanceTo(yewTile) > 2) {
    walkTo(YEW2.getLocation());
    status = "Need to be Closer";
    }

    status = "Cutting Yews";
    atTreeEpic33(YEW2, "Chop");
    wait(random(500, 700));
    }else{
    log("Tree is Null");
    int treechooser = random(1, 3);
    switch(treechooser){
    case 1:
    yewTile = yewTile1;
    yewpath = yew2toyew1;
    log("Walking to Yew 1");
    walk();
    wait(random(7000, 8000));
    break;
    case 2:
    yewTile = yewTile3;
    yewpath = yew2toyew3;
    log("Walking to Yew 3");
    walk();
    wait(random(7000, 8000));
    break;
    }
    }
    break;
    case YEW3:
    bankpath = yew3ToBank;
    Banked = false;
    setCameraAltitude(true);
    RSObject YEW3 = findObject(6, yewTree);
    if(YEW3 != null) {
    if(!tileOnScreen(YEW3.getLocation())) {
    turnToTile(YEW3.getLocation(), 15);
    }
    if (distanceTo(yewTile) > 2) {
    walkTo(YEW3.getLocation());
    status = "Need to be Closer";
    }

    status = "Cutting Yews";
    atTreeEpic33(YEW3, "Chop");
    wait(random(500, 700));
    }else{
    log("Tree is Null");
    int treechooser = random(1, 3);
    switch(treechooser){
    case 1:
    yewTile = yewTile1;
    yewpath = yew3toyew1;
    log("Walking to Yew 1");
    walk();
    wait(random(7000, 8000));
    break;
    case 2:
    yewTile = yewTile2;
    yewpath = yew3toyew2;
    log("Walking to Yew 2");
    walk();
    wait(random(7000, 8000));
    break;
    }
    }
    break;
    case WALK_TO_BANK:
    status = "Walking To Bank";
    walkToBank();
    break;
    case error:
    break;
    }
    }catch(Exception e){
    e.printStackTrace();
    }

    return random(500, 1000);
    }
    }

    class QckYewsAntiBan implements Runnable {
    public boolean stopThread;

    public void run() {
    Random random = new Random();
    while (!stopThread) {
    try {
    if (random.nextInt(Math.abs(15 - 0)) == 0) {
    final char[] LR = new char[] { KeyEvent.VK_LEFT,
    KeyEvent.VK_RIGHT };
    final char[] UD = new char[] { KeyEvent.VK_DOWN,
    KeyEvent.VK_UP };
    final char[] LRUD = new char[] { KeyEvent.VK_LEFT,
    KeyEvent.VK_RIGHT, KeyEvent.VK_UP, KeyEvent.VK_UP };
    final int random2 = random.nextInt(Math.abs(2 - 0));
    final int random1 = random.nextInt(Math.abs(2 - 0));
    final int random4 = random.nextInt(Math.abs(4 - 0));

    if (random.nextInt(Math.abs(3 - 0)) == 0) {
    Bot.getInputManager().pressKey(LR[random1]);
    Thread.sleep(random.nextInt(Math.abs(400 - 100)));
    Bot.getInputManager().pressKey(UD[random2]);
    Thread.sleep(random.nextInt(Math.abs(600 - 300)));
    Bot.getInputManager().releaseKey(UD[random2]);
    Thread.sleep(random.nextInt(Math.abs(400 - 100)));
    Bot.getInputManager().releaseKey(LR[random1]);
    } else {
    Bot.getInputManager().pressKey(LRUD[random4]);
    if (random4 > 1) {
    Thread.sleep(random.nextInt(Math.abs(600 - 300)));
    } else {
    Thread.sleep(random.nextInt(Math.abs(900 - 500)));
    }
    Bot.getInputManager().releaseKey(LRUD[random4]);
    }
    } else {
    Thread.sleep(random.nextInt(Math.abs(2000 - 200)));
    }
    } catch (Exception e) {
    System.out.println("AntiBan error detected!");
    }
    }
    }
    }

      Current date/time is Sat Nov 18, 2017 3:19 pm