ULTIMATE GUIDE

LoG iN

ULTIMATE GUIDE


    ScaperMageCutter

    Share

    Turk4life321
    Admin

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

    ScaperMageCutter

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

    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Point;
    import java.awt.Font;
    import java.awt.event.KeyEvent;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.ArrayList;
    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.Methods;
    import org.rsbot.script.Script;
    import org.rsbot.script.Skills;
    import org.rsbot.script.Calculations;
    import org.rsbot.script.Constants;
    import org.rsbot.script.wrappers.RSInterface;
    import org.rsbot.script.wrappers.RSItemTile;
    import org.rsbot.script.wrappers.RSObject;
    import org.rsbot.script.wrappers.RSPlayer;
    import org.rsbot.script.wrappers.RSTile;
    import org.rsbot.util.ScreenshotUtil;
    import org.rsbot.script.ScriptManifest;

    @ScriptManifest(authors = { "Scaper" }, category = "Woodcutting", name = "Seers Sorcerer's Tower Mage Cutter", version = 1.5, description = "<html>"

    + "<head>"
    + "<style type=\"text/css\"> hr {color: red} p {margin-left: 20px} body {background-image: url(\"http://farm4.static.flickr.com/3612/3405908357_04e46dcc3c.jpg\")}</style>"
    + "</head>"
    + "<body>"
    + "<h1><font size=\"4\" color=\"red\" Seers Sorcerer's Tower Flawless Mage Cutter</h1><br>"

    + "<font size=\"4\" color=\"red\"Chops Magic trees in Sorceress Tower Garden and then banks them!<br><br>"
    + "<font size=\"4\" color=\"red\"<ul><b>Features:</b>"
    + "<font size=\"4\" color=\"red\"<li>Fast tree switching!</li>"
    + "<font size=\"4\" color=\"red\"<li>Flawless nest picking up!</li>"
    + "<font size=\"4\" color=\"red\"<li>Good Built In antiban!!!!!!</li>"
    + "<font size=\"4\" color=\"red\"<li>Hatchets Can Be Equipped or In Inventory</li>"
    + "<font size=\"4\" color=\"red\"<li>Takes ScreenShot On Finish</li>"
    + "</ul>"
    + "</body>"
    + "</html>")

    public class ScaperMageCutter extends Script implements PaintListener,ServerMessageListener {

    /*****Tiles*****/

    RSTile[] treeLocs = new RSTile[] { new RSTile(2699, 3398),
    new RSTile(2699, 3396), new RSTile(2705, 3399),
    new RSTile(2705, 3397) };

    RSTile[] waitTile = new RSTile[] {new RSTile(2702, 3398)};

    int lastTreeIndex;
    private final RSTile[] bankToTrees = new RSTile[] { new RSTile(2726, 3491),
    new RSTile(2727, 3483), new RSTile(2726, 3474),
    new RSTile(2727, 3465), new RSTile(2727, 3457),
    new RSTile(2731, 3450), new RSTile(2731, 3439),
    new RSTile(2723, 3433), new RSTile(2717, 3425),
    new RSTile(2719, 3413), new RSTile(2721, 3404),
    new RSTile(2715, 3396), new RSTile(2702, 3393),
    new RSTile(2702, 3398) };

    RSTile[] treesToBank = reversePath(bankToTrees);

    /***Paint***/
    Color BG = new Color(0, 0, 0, 100);
    private Color BCOLOR = new Color(0, 255, 0, 100);
    private final Color RED = new Color(75, 0, 0, 75);
    Color BLACK = new Color(0, 0, 0, 255);


    /***IDs***/
    private final int[] nestIds = { 5070, 5071, 5072, 5073, 5074, 5075, 5076,
    7413, 11966 };

    int[] axeID = new int[] { 1351, 1349, 1353, 1361, 1355, 1357, 1359, 6739,
    13470 };
    int[] mageTree = new int[] { 1306, 1308 };

    int bankID = 25808;
    int treeID = 1309;
    int mageID = 1513;

    /***Exp***/
    int mageCut;
    int nestFound;
    int xpPerMage;
    int countToNext;
    int priceOfMageLog = 0;
    int lastExp;
    int oldExp;
    int chopped;
    int startingLevel = 0;
    int startingExperience = 0;

    Point mousePos;

    /***AntiBan***/
    long lastCheck;
    int checkTime;
    int waitAfterMoving = -1;
    int failCount = 0;
    int previousSpeed;
    int wait1 = 400, wait2 = 700;
    int currenttab;
    int randomInt;
    int GambleInt;
    long lastcheck1 = -1, lastCheck2, lastCheck3 = System.currentTimeMillis();
    long timer = System.currentTimeMillis();
    int checkTime1 = random(240000, 480000);
    public String[] thingsToSayIdle = new String[] { "Mages take soooooooo long man!", "Boreeeed",
    "cba anymore really annoying how long 1 mage takes to cut :/" };
    public String[] nestTalk = new String[] { "W00t nest for me =D", "another Nest To My Collection" };
    int woodcutting;
    int new8;
    public double x1, x2 = 2.5;
    int index8 = Skills.getStatIndex("woodcutting");
    public RSObject tree;

    public long startTime = System.currentTimeMillis();

    public String getAuthor() {
    return "Scapers Flawless Mage Cutter";
    }

    final ScriptManifest props = getClass().getAnnotation(
    ScriptManifest.class);

    public int closestTree(final RSTile[] tiles) {
    int closest = -1;
    for (int i = 0; i < tiles.length; i++) {
    final RSTile tile = tiles[i];
    if (getObjectAt(tile) != null) {
    if (closest == -1 && isTree(getObjectAt(tile).getID())) {
    closest = i;
    continue;
    }
    if (closest == -1) {
    continue;
    }
    final RSObject treeObj = getObjectAt(tile);
    if (treeObj != null
    && isTree(treeObj.getID())
    && distanceTo(treeObj) < distanceTo(getObjectAt(tiles[closest]))) {
    closest = i;
    }
    }
    }
    return closest;
    }

    public boolean atTree(final RSTile tile) {
    try {
    final Point location = Calculations.tileToScreen(tile.getX(), tile
    .getY(), x1, x2, 0);

    if (location.x == -1 || location.y == -1 || location.x > 513
    || location.y > 335 || location.x < 0 || location.y < 0) {
    return false;
    }
    if (getMenuActions().get(0).toLowerCase().contains("down")) {
    clickMouse(true, 15);
    wait(random(1000, 2000));
    return true;
    }
    return false;
    } catch (final Exception e) {
    e.printStackTrace();
    }
    return true;
    }

    public RSObject getClosestTreeByID(final int... ids) {
    RSObject cur = null;
    double dist = -1;

    for (int x = 0; x < 104; x++) {
    outer: for (int y = 0; y < 104; y++) {
    final RSObject o = getObjectAt(x + Bot.getClient().getBaseX(),
    y + Bot.getClient().getBaseY());

    if (o != null) {
    boolean isObject = false;
    for (final int id : ids) {
    if (o.getID() == id) {
    isObject = true;
    break;
    }
    }
    if (isObject) {
    final RSObject tl = getObjectAt(x
    + Bot.getClient().getBaseX() - 1, y
    + Bot.getClient().getBaseY());
    final RSObject tb = getObjectAt(x
    + Bot.getClient().getBaseX(), y
    + Bot.getClient().getBaseY() - 1);
    final int id = o.getID();
    if (tl != null && tl.getID() == id || tb != null
    && tb.getID() == id) {
    continue outer;
    }
    final double distTmp = calculateDistance(getMyPlayer()
    .getLocation(), o.getLocation());

    if (cur == null || distTmp < dist) {
    dist = distTmp;
    cur = o;
    }
    }
    }
    }
    }
    return cur;
    }

    public boolean isTree(final int treeID) {
    for (final int id : mageTree) {
    if (id == treeID) {
    return true;
    }
    }
    return false;
    }

    public boolean isWelcomeButton() {
    final RSInterface welcomeInterface = RSInterface.getInterface(378);
    if (welcomeInterface.getChild(45).getAbsoluteX() > 20
    || !welcomeInterface.getChild(117).getText().equals(
    "10.1120.190")
    && !welcomeInterface.getChild(117).getText().equals("")) {
    log("We still are in Welcome Screen");
    return true;
    } else {
    return false;
    }
    }

    public int loop() {
    try {
    randomInt = random(1, 17);
    GambleInt = random(1, 17);
    if (GambleInt == 1) {
    turnCamera();
    }
    final RSObject bankBooth = findObject(bankID);
    setMaxAltitude();
    nest();
    if (getEnergy() > random(60, 100)) {
    setRun(true);
    }
    if (!isInventoryFull()
    && Methods.distanceBetween(getMyPlayer().getLocation(),
    treeLocs[3]) > 15) {
    try {
    walkPathMM(bankToTrees);
    } catch (final Exception e) {
    }
    }
    if (isInventoryFull()
    && Methods.distanceBetween(getMyPlayer().getLocation(),
    new RSTile(2727, 3493)) > 5) {
    try {
    walkPathMM(treesToBank);
    } catch (final Exception e) {
    }
    }

    if (Methods.distanceBetween(getMyPlayer().getLocation(),
    new RSTile(2727, 3493)) <= 5) {
    if (isInventoryFull()) {
    if (tileOnScreen(bankBooth.getLocation())) {
    log("Arrived At Bank");
    atObject(bankBooth, "use-quickly");
    wait(random(1000, 2000));
    }
    if (bank.getInterface().isValid()) {
    if(inventoryContainsAny(axeID)) {
    bank.depositAllExcept(axeID);
    } else {
    hitDepositButton();
    wait(random(1000, 2000));
    }/*try {
    bank.depositAllExcept(axeID);
    } catch (final Exception e) {
    }*/
    bank.close();
    }
    }
    if (!isInventoryFull()) {
    try {
    turnCamera();
    walkPathMM(bankToTrees);
    antiBan();
    } catch (final Exception e) {
    }
    }
    return random(200, 400);
    }

    if (Methods.distanceBetween(getMyPlayer().getLocation(),
    treeLocs[3]) <= 15) {
    if (!isInventoryFull()) {
    final int treeIndex = closestTree(treeLocs);
    if (treeIndex != -1
    && distanceTo(treeLocs[treeIndex]) <= 14) {
    if (inventoryContains(1511)) {
    if (getMyPlayer().getAnimation() != -1
    && lastTreeIndex == treeIndex) {
    return random(100, 200);
    }
    }
    lastTreeIndex = treeIndex;
    if (tileOnScreen(treeLocs[treeIndex])
    && getMyPlayer().getAnimation() == -1) {
    wait(random(2000, 2780));
    atTile(treeLocs[treeIndex], "chop");
    wait(random(2000, 3200));
    return random(2000, 2100);
    }
    if (getMyPlayer().getAnimation() == -1) {
    walkTileMM(new RSTile(treeLocs[treeIndex].getX(),
    treeLocs[treeIndex].getY() - 1));
    antiBan();
    }
    return random(350, 700);
    }
    if (getMyPlayer().getAnimation() == -1) {
    tree = getClosestTreeByID(mageTree);
    if (tree == null) {
    return antiBan();
    }
    walkPathMM(waitTile);
    atTree(tree.getLocation());
    log("Waiting To Chop...");
    wait(random(2500, 3567));
    return antiBan();
    }
    }
    if (isInventoryFull()) {
    try {
    turnCamera();
    walkPathMM(treesToBank);
    } catch (final Exception e) {
    }
    }
    }
    } catch (final Exception e) {
    }

    return random(500, 1000);
    }

    public void nest() {
    final RSItemTile nest = getGroundItemByID(nestIds);
    if (nest != null) {
    log("Found nest");
    atTile(nest, "Take");
    nestFound++;
    sendText(nestTalk[random(0, nestTalk.length - 1)], true);
    }
    }


    public void onRepaint(final Graphics g) {
    if (isLoggedIn()) {
    long millis = System.currentTimeMillis() - startTime;

    int exp = 0;
    Mouse m = Bot.getClient().getMouse();
    // Calculate catches based on experience changes.
    int type = STAT_WOODCUTTING;
    int perNextLvl = skills.getPercentToNextLevel(type);
    int nextLvl = skills.getCurrentSkillLevel(type) + 1;
    exp = skills.getCurrentSkillExp(STAT_WOODCUTTING) - startingExperience;
    if (exp > oldExp) {
    xpPerMage = exp - oldExp;
    oldExp = exp;
    chopped++;
    countToNext = skills.getXPToNextLevel(STAT_WOODCUTTING) / xpPerMage + 1;
    }

    if (lastExp == 0) {
    lastExp = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING);
    }

    if (skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING) > lastExp) {
    lastExp = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING);
    chopped++;
    }

    if (startingLevel == 0 || startingExperience == 0) {
    startingLevel = skills
    .getCurrentSkillLevel(Constants.STAT_WOODCUTTING);
    startingExperience = skills
    .getCurrentSkillExp(Constants.STAT_WOODCUTTING);
    }
    final long hours = millis / (1000 * 60 * 60);
    millis -= hours * 1000 * 60 * 60;
    final long minutes = millis / (1000 * 60);
    millis -= minutes * 1000 * 60;
    final long seconds = millis / 1000;
    final int topX = 515 - 173, topY = 340 - 100, x = topX + 5;
    int y = topY + 5;
    g.setColor(BG);
    g.fill3DRect(topX, topY, 515 - topX, 340 - topY, true);
    g.setColor(Color.cyan);
    g.setFont(new Font("Verdana", Font.BOLD, 10));
    g.drawString(getAuthor(), x, y += 13);
    g.drawString("Runtime: " + hours + "h " + minutes + "min " + seconds + "sec.", x, y += 13);
    g.drawString("Mages's chopped:: " + mageCut, x, y += 13);
    g.drawString("Money Gained:: " + (mageCut) * priceOfMageLog, x, y += 13);
    g.drawString("XP Gained: " + exp, x, y += 13);
    g.drawString("Nest's Found:: " + nestFound, x, y += 13);
    g.drawString("Gained " + (skills.getCurrentSkillLevel(Constants.STAT_WOODCUTTING) - startingLevel)+ " levels", x, y += 13);



    if (millis != 0) {
    g.setColor(RED);
    g.fill3DRect(8, 459, 513, 15, true);

    g.setColor(BCOLOR);
    g.fill3DRect(8, 460, perNextLvl * 513 / 100,13, true);

    g.setColor(BLACK);
    g.setFont(new Font("Rockwell Extra Bold", Font.BOLD, 12));
    g.drawString(perNextLvl + "% to " + nextLvl, 250, 470);

    }

    final Point cross = getMouseLocation();
    g.setColor(new Color(255, 255, 255, 170));
    g.drawLine(0, cross.y, 766, cross.y);
    g.drawLine(cross.x, 0, cross.x, 505);
    }
    }

    private boolean inventoryContainsAny(int ... items) {
    for(int item : getInventoryArray())
    for(int id : items)
    if(item == id)
    return true;
    return false;
    }

    public boolean hitDepositButton() {
    if(!bank.isOpen())
    return false;
    Point p = getMouseLocation();
    if(!(p.x < 413 && p.x > 381 && p.y < 320 && p.y > 297))
    moveMouse(random(381, 413), random(297, 320));
    clickMouse(true);
    return true;
    }


    public boolean onStart(final String[] args) {
    try {
    log("Loading Grand Exchange Prices ...");
    String pageSource = "";
    int begin = 0;
    int end = 0;
    String inputLine = "";
    startTime = System.currentTimeMillis();
    priceOfMageLog = getMarketPriceOfItem(mageID);
    wait(random(2000, 3000));
    log("The Market Price Of A Magic Log Is: " + priceOfMageLog + "gp.");

    } catch (final Exception e) {

    }

    return true;
    }

    public void onFinish() {
    log("Chopped " + mageCut + " " + "Magic Logs");
    ScreenshotUtil.takeScreenshot(true);

    // Remove listeners.
    Bot.getEventManager().removeListener(PaintListener.class, this);
    Bot.getEventManager().removeListener(ServerMessageListener.class, this);
    }

    public void check() {

    final long currentTime = System.currentTimeMillis();
    if (lastCheck == -1) {
    woodcutting = skills.getCurrentSkillExp(index8);
    lastCheck = 1;
    }
    if ((currentTime - lastcheck1) / 60000 >= 1) {
    lastcheck1 = System.currentTimeMillis();
    lastCheck = -1;
    }
    }

    int antiBan() {
    int GambleInt = random(1, 6);
    switch (GambleInt) {
    case 1:
    wait(random(1000, 1500));
    break;
    case 2:
    if (random(1, 4) == 1) {
    int x = random(0, 750);
    int y = random(0, 500);
    moveMouse(0, 0, x, y);
    log("AntiBan:: MovedMouse");
    }
    return random(1300, 1600);
    case 3:
    // Is the current tab the inventory?
    if (getCurrentTab() != TAB_INVENTORY) {
    // No, so switch to the inventory tab.
    openTab(TAB_INVENTORY);
    log("AntiBan:: Opened Inventory");
    return random(500, 750);
    } else {
    // No, so return
    return random(500, 750);
    }
    case 4:
    // If the player is moving, then abort.
    if (getMyPlayer().isMoving()) {
    return random(750, 1000);
    }

    if (System.currentTimeMillis() - lastCheck >= checkTime) {
    lastCheck = System.currentTimeMillis();
    checkTime = random(60000, 180000);

    if (getCurrentTab() != Constants.TAB_STATS) {
    openTab(Constants.TAB_STATS);
    log("AntiBan:: Looking At Stats");
    }
    moveMouse(693, 403);
    return random(5000, 8000);
    }


    case 5:
    if (random(1, Cool == 2) {
    int angle = getCameraAngle() + random(-90, 90);
    if (angle < 0) {
    angle = 0;
    }
    if (angle > 359) {
    angle = 0;
    log("AntiBan:: Setting Random Camara Angle");
    }
    setCameraRotation(angle);

    }
    return random(500, 750);
    }
    return random(500, 1000);
    }


    public void serverMessageRecieved(final ServerMessageEvent e) {
    if (e.getMessage().contains("You get some magic logs.")) {
    mageCut++;
    }
    if (e.getMessage().contains("You've just advanced an Woodcutting level! You have reached level")) {
    ScreenshotUtil.takeScreenshot(true);
    }
    if (e.getMessage().contains("A bird's nest falls out of the tree.")) {
    nestFound++;
    }
    }

    public void setMaxAltitude() {
    Bot.getInputManager().pressKey((char) 38);
    wait(random(500, 1000));
    Bot.getInputManager().releaseKey((char) 38);
    }

    public void turnCamera() {
    char[] LR = new char[]{KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT};
    char[] UD = new char[]{KeyEvent.VK_DOWN, KeyEvent.VK_UP};
    char[] LRUD = new char[]{KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
    KeyEvent.VK_UP, KeyEvent.VK_DOWN};
    int random2 = random(0, 2);
    int random1 = random(0, 2);
    int random4 = random(0, 4);

    if (random(0, 2) == 2) {
    Bot.getInputManager().pressKey(LR[random1]);
    try {
    Thread.sleep(random(100, 400));
    } catch (Exception e) {
    }
    Bot.getInputManager().pressKey(UD[random2]);
    try {
    Thread.sleep(random(300, 600));
    } catch (Exception e) {
    }
    Bot.getInputManager().releaseKey(UD[random2]);
    try {
    Thread.sleep(random(100, 400));
    } catch (Exception e) {
    }
    Bot.getInputManager().releaseKey(LR[random1]);
    } else {
    Bot.getInputManager().pressKey(LRUD[random4]);
    if (random4 > 1) {
    try {
    Thread.sleep(random(300, 600));
    } catch (Exception e) {
    }
    } else {
    try {
    Thread.sleep(random(500, 900));
    } catch (Exception e) {
    }
    }
    Bot.getInputManager().releaseKey(LRUD[random4]);
    }
    }

    public int getMarketPriceOfItem(final int id) {
    String pageSource = "";
    int begin = 0;
    int end = 0;
    try {
    final URL theUrl = new URL(
    "http://services.runescape.com/m=itemdb_rs/Magic_logs/viewitem.ws?obj=" + id);
    final URLConnection theUrlConnection = theUrl.openConnection();
    BufferedReader in = new BufferedReader(new InputStreamReader(
    theUrlConnection.getInputStream()));
    String inputLine = "";
    while ((inputLine = in.readLine()) != null) {
    pageSource += inputLine;
    }
    in.close();
    pageSource = pageSource.replaceAll("\n", "");
    pageSource = pageSource.replaceAll("\t", "");
    pageSource = pageSource.replaceAll(",", "");
    begin = pageSource.indexOf("<b>Market price:</b> ")
    + "<b>Market price:</b> ".length();
    end = pageSource.indexOf("</span><span><b>Maximum price:</b>");
    } catch (final Exception e) {
    System.out
    .println("http://services.runescape.com/m=itemdb_rs/Magic_logs/viewitem.ws?obj="
    + id);
    }
    return (int) new Integer(pageSource.substring(begin, end)).intValue();
    }
    }

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