Mining guild rock change

Discussion in 'Archives' started by mitsurugi162, Jan 4, 2009.

Thread Status:
Not open for further replies.
Mining guild rock change
  1. Unread #1 - Jan 4, 2009 at 9:34 PM
  2. mitsurugi162
    Joined:
    Nov 25, 2008
    Posts:
    12
    Referrals:
    0
    Sythe Gold:
    0

    mitsurugi162 Newcomer

    Mining guild rock change

    in the mining guild the rock type has changed and i want a script that can mine coal and bank it please post a script
     
  3. Unread #2 - Jan 5, 2009 at 10:09 AM
  4. gridfun
    Joined:
    Jan 3, 2006
    Posts:
    43
    Referrals:
    0
    Sythe Gold:
    0

    gridfun Member

    Mining guild rock change

    Save as TenacGuildMiner.java to youre scripts folder and then compile. :)
    PHP:
    import java.awt.*;
    import java.util.*;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.net.URLConnection;

    import com.speljohan.rsbot.bot.*;
    import com.speljohan.rsbot.script.*;
    import com.speljohan.rsbot.accessors.*;
    import com.speljohan.rsbot.script.wrappers.*;
    import com.speljohan.rsbot.event.listeners.*;

    public class 
    TenacGuildMiner extends Script implements PaintListener {

        
    int[] bankerID = { 6200 };
        
    int[] bankBoothID = { 11758 };
            
        
    RSTile topLadderObjectTile = new RSTile(30193339);
        
    int[] ladderID = { 30941 };
        
    int[] coalRockID = { 310683106931070 };
        
    int[] mithRockID = { 310863108731088 };

        
    int coalID 453;
        
    int mithrilID 447;
        
    int[] gemID = { 1617161916211623 };
        
    int[] pickaxeHandleID = { 466 };
        
    int[] pickaxeID = { 126512671269127312711275 };
        
    int[] pickaxeHeadID = { 480482484486488490 };
        
    int[] brokenPickaxeID =  { 468470472474476478 };
        
        
    int[] junkItems = { 19171971 }; //beer, kebab
        
    int goldPiecesID 995;

        
    RSTile lumbridgeTile = new RSTile(32213218);

        
    RSTile bankTile = new RSTile(30143356);
        
    RSTile[] betweenBankAndLadderTiles = { new RSTile(30193351), new RSTile(30223351), new RSTile(30243352) };
        
    RSTile ladderTile = new RSTile(30213341);
        
    //RSTile[] topLadderTiles = { new RSTile(3022, 3341), new RSTile(3022, 3337) };
        //RSTile[] bottomLadderTiles = { new RSTile(3021, 9741), new RSTile(3022, 9740) };

        
    RSTile[] coalToLadderPath = { new RSTile(30469752), new RSTile(30449745), new RSTile(30449738),
                                      new 
    RSTile(30379737), new RSTile(30309737), new RSTile(30209739) };

        
    RSTile[] ladderToCoalPath = { new RSTile(30209739), new RSTile(30309737), new RSTile(30379737),
                                      new 
    RSTile(30449738), new RSTile(30449745), new RSTile(30469752) };

        
    RSTile[] lumbridgeToFalidorPath = { new RSTile(32263218), new RSTile(32333220), new RSTile(32333225),
                                            new 
    RSTile(32313230), new RSTile(32283233), new RSTile(32233238),
                                            new 
    RSTile(32213242), new RSTile(32193247), new RSTile(32183251),
                                            new 
    RSTile(32173256), new RSTile(32173257), new RSTile(32173261),
                                            new 
    RSTile(32173266), new RSTile(32163272), new RSTile(32163277),
                                            new 
    RSTile(32103280), new RSTile(32053280), new RSTile(32043279),
                                            new 
    RSTile(31973279), new RSTile(31903282), new RSTile(31843286),
                                            new 
    RSTile(31783287), new RSTile(31723286), new RSTile(31653285),
                                            new 
    RSTile(31583291), new RSTile(31493296), new RSTile(31433294),
                                            new 
    RSTile(31373295), new RSTile(31363295), new RSTile(31303295),
                                            new 
    RSTile(31233299), new RSTile(31183296), new RSTile(31123295),
                                            new 
    RSTile(31063295), new RSTile(30993295), new RSTile(30943292),
                                            new 
    RSTile(30883290), new RSTile(30823289), new RSTile(30763288),
                                            new 
    RSTile(30743284), new RSTile(30743280), new RSTile(30693277),
                                            new 
    RSTile(30633277), new RSTile(30573276), new RSTile(30503276),
                                            new 
    RSTile(30473276), new RSTile(30443274), new RSTile(30373277),
                                            new 
    RSTile(30303278), new RSTile(30243276), new RSTile(30183275),
                                            new 
    RSTile(30133276), new RSTile(30113278), new RSTile(30073284),
                                            new 
    RSTile(30043289), new RSTile(30073294), new RSTile(30063299),
                                            new 
    RSTile(30043304), new RSTile(30063310), new RSTile(30073316),
                                            new 
    RSTile(30073321), new RSTile(30053326), new RSTile(30073331),
                                             new 
    RSTile(30073332), new RSTile(30073337), new RSTile(30073343),
                                             new 
    RSTile(30073349), new RSTile(30053355), new RSTile(30073361),
                                             new 
    RSTile(30123361), new RSTile(30153355) };

        
    long startTime System.currentTimeMillis();
        
    int startingLevel skills.getCurrentSkillLevel(STAT_MINING);
        
    int startingExperience skills.getCurrentSkillExp(STAT_MINING);
        
    int oldExperience 0;
        
    int ranAwayFromCombat 0;
        
    int gemsBanked 0;
        
    int coalBanked 0;
        
    int mithBanked 0;
        
    int gemsDropped 0;
        
    int coalDropped 0;
        
    int mithDropped 0;
        
    int xpPerCoal 50;
        
    int xpPerMithril 80;
        
    int energyToRunAt random(4090);

        
    boolean powermine false;
        
    int invCountToDrop random(1029);
        
    boolean dropping false;
        
        
    boolean walkBack false;
        
    boolean miningMith false;
        
    boolean runAway false;
        
    boolean needNewPick false;

        
    int priceOfCoal getMarketPriceOfItem(coalID);
        
    int priceOfMithril getMarketPriceOfItem(mithrilID);

        public 
    double getVersion() {
            return 
    2.1;
        }

        public 
    String getName() {
            return 
    "Tenac's Guild Miner";
        }

        public 
    String getAuthor() {
            return 
    "Tenac";
        }

        public 
    String getScriptCategory() {
            return 
    "Mining";
        }

        public 
    String getScriptDescription( ) {
            
    String html "";

            
    html += "<html>\n";
            
    html += "<body>\n";

            
    html += "<font size=\"6\">";
            
    html += "<center><h2>" getName() + "</h2></center>\n";
            
    html += "</font>";

            
    html += "<b>Author:</b>" getAuthor() + "<br/>";
            
    html += "<b>Version:</b>" getVersion() + "<br/><br>";

            
    html += "Start anywhere with a pickaxe and at least 60 mining, preferably inside Falidor East bank or Mining Guild.<br>\n<br>";
            
            
    html += "<input type=\"checkbox\" name=\"mineMith\" value=\"yes\">Mine mithril rocks also?\n<br>";
            
    html += "<input type=\"checkbox\" name=\"powermine\" value=\"yes\">Drop ores?\n<br>";
            
            
    html += "</body>\n";
            
    html += "</html\n";

            return 
    html;
        }

        public 
    boolean onStart(Map<StringStringargs) {
            
    startTime System.currentTimeMillis();
            if(
    isLoggedIn()) {
                
    startingLevel skills.getCurrentSkillLevel(STAT_MINING);
                
    startingExperience skills.getCurrentSkillExp(STAT_MINING);
                
    setCameraAltitude(true);
                
    setCameraRotation(random(1359));
            }

            if(
    args.get("mineMith") != null)
                
    miningMith true;

            if(
    args.get("powermine") != null)
                
    powermine true;

            
    Bot.getEventManager().addListener(PaintListener.class, this);
            return 
    true;
        }

        public 
    void onFinish() {
            
    Bot.getEventManager().removeListener(PaintListener.class, this);
        }

        
    int height 1;

        public 
    void onRepaint(Graphics g) {
            if(
    isLoggedIn()) {
                if(
    startTime == 0)
                    
    startTime System.currentTimeMillis();

                if(
    startingLevel == || startingExperience == 0) {
                    
    startingLevel skills.getCurrentSkillLevel(STAT_MINING);
                }

                
    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(3346207100));
                
    //window is (0, 0) (337, 515)
                //my box is (515 - 260, 0) (337, 200)
                
    int x 515 230;
                
    int y 4;
                
    g.fillRoundRect(xy230height2020);
                
    g.setColor(new Color(2636162255));
                
    g.drawRoundRect(xy230height2020);
                
                
    g.setColor(new Color(255255255255));
                
    g.drawString("Tenac's Guild Miner v" getVersion(), 10+= 15);
                
    g.drawString("Running for " hours ":" minutes ":" seconds10+= 15);
                if(
    powermine) {
                    
    g.drawString("Dropped " coalDropped " coal"10+= 15);
                    
    g.drawString("Dropped " mithDropped " mithril"10+= 15);
                    
    g.drawString("Dropped " gemsDropped " gems"10+= 15);
                } else {
                    
    g.drawString("Banked " coalBanked " coal"10+= 15);
                    
    g.drawString("Banked " mithBanked " mithril"10+= 15);
                    
    g.drawString("Banked " gemsBanked " gems"10+= 15);
                }
                if(!
    powermine) {
                    
    g.drawString("Gained " + ((coalBanked priceOfCoal) + (mithBanked priceOfMithril)) + "gp"10+= 15);
                    
    //averaging __gp per hour
                
    }
                
    g.drawString("Currently level " skills.getCurrentSkillLevel(STAT_MINING) + " and " skills.getPercentToNextLevel(STAT_MINING) + "% to next level"10+= 15);
                
    g.drawString("Gained " + (skills.getCurrentSkillLevel(STAT_MINING) - startingLevel) + " levels"10+= 15);
                
    //___ until level (skills.getCurrentSkillLevel(STAT_MINING) + 1)
                
    g.drawString("Gained " + (skills.getCurrentSkillExp(STAT_MINING) - startingExperience) + " experience"10+= 15);
                
    //averaging ____ experience per hour
                
    g.drawString("Ran from combat " ranAwayFromCombat " times"10+= 15);
                
    g.drawString("" + (int)(skills.getXPToNextLevel(STAT_MINING) / xpPerCoal 1) + " more coal until next level"10+= 15);
                
    height 3;
            }
        }

        public 
    void printProgressReport() {
            if(
    startTime == 0)
                
    startTime System.currentTimeMillis();
            if(
    startingLevel == || startingExperience == 0) {
                
    startingLevel skills.getCurrentSkillLevel(STAT_MINING);
                
    startingExperience skills.getCurrentSkillExp(STAT_MINING);
            }
            
    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("Tenac's Guild Miner v" getVersion());
            
    log("Running for " hours ":" minutes ":" seconds);
            if(
    powermine) {
                
    log("Dropped " coalDropped " coal");
                
    log("Dropped " mithDropped " mithril");
                
    log("Dropped " gemsDropped " gems");
            } else {
                
    log("Banked " coalBanked " coal");
                
    log("Banked " mithBanked " mithril");
                
    log("Banked " gemsBanked " gems");
            }
            if(!
    powermine) {
                
    log("Gained " + ((coalBanked priceOfCoal) + (mithBanked priceOfMithril)) + "gp");
                
    //averaging __gp per hour
            
    }
            
    log("Currently level " skills.getCurrentSkillLevel(STAT_MINING) + " and " skills.getPercentToNextLevel(STAT_MINING) + "% to next level");
            
    log("Gained " + (skills.getCurrentSkillLevel(STAT_MINING) - startingLevel) + " levels");
            
    //___ until level (skills.getCurrentSkillLevel(STAT_MINING) + 1)
            
    log("Gained " + (skills.getCurrentSkillExp(STAT_MINING) - startingExperience) + " experience");
            
    //averaging ____ experience per hour
            
    log("Ran from combat " ranAwayFromCombat " times");
            
    log("" + (int)(skills.getXPToNextLevel(STAT_MINING) / xpPerCoal 1) + " more coal until next level");
        }

        public 
    int getMarketPriceOfItem(int id) {
            
    String pageSource "";
            
    int begin 0;
            
    int end 0;
            try {
                
    URL theUrl = new URL("http://itemdb-rs.runescape.com/viewitem.ws?obj=" id);
                
    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""");
                
    begin pageSource.indexOf("<b>Market price:</b> ") + ("<b>Market price:</b> ").length();
                
    end pageSource.indexOf("</span><span><b>Maximum price:</b>");
            } catch (
    Exception e) {
                
    System.out.println("Error obtaining price of http://itemdb-rs.runescape.com/viewitem.ws?obj=" id);
            }
            return (int)new 
    Integer(pageSource.substring(beginend)).intValue();
        }

        public 
    int loop() {
            if(!
    isLoggedIn())
                return 
    random(500800);

            
    //if(getGroundItemByID(17, pickaxeHeadID) != null && (isCarryingItem(pickaxeHandleID)))
            
    if(getGroundItemByID(17pickaxeHeadID) != null)
                return 
    fixPickaxe();
            
            if(
    getEnergy() >= energyToRunAt) {
                
    energyToRunAt random(4090);
                
    setRun(true);
            }
            
            if(
    getMyPlayer().isInCombat())
                
    runAway true;
            
            if(
    runAway)
                return 
    runAway();
            
            if(
    distanceTo(lumbridgeTile) <= 17)
                
    walkBack true;

            if(
    isLost()) {
                if(
    myGetNextTile(lumbridgeToFalidorPath17) == null)
                    return 
    teleportToLumbridge();
                
    walkBack true;
            }

            if(
    walkBack) {
                if(
    myWalkPath(lumbridgeToFalidorPath171)) {
                    
    walkBack false;
                    return 
    depositInventory();
                }
            }

    /*
            //will never be called since the  rsbot equipment interface is fucked up
            if(isCarryingItem(brokenPickaxeID) || isCarryingItem(pickaxeHandleID) || !isCarryingItem(pickaxeID))
                return getNewPick();
    */

            
    if(getInterface(211).isValid())
                if(
    getInterface(211).getChild(1).containsText("You need a Pickaxe") && getGroundItemByID(17pickaxeHeadID) == null)
                    
    needNewPick true;
            
            if(
    needNewPick) {
                if(
    getNewPick() == 99999) {
                    
    needNewPick false;
                    return 
    random(1020);
                } else {
                    return 
    random(1020);
                }
            }

            if(
    isCarryingJunk())
                return 
    dropJunk();

            if(
    canEquipPickaxe())
                return 
    wieldPickaxe();

            if(
    powermine && (getInventoryCount() >= invCountToDrop || isInventoryFull()))
                
    dropping true;

            if(
    dropping)
                return 
    dropInventory();

            if(
    isInventoryFull() && !powermine)
                return 
    depositInventory();

            if(
    isInventoryFull())
                return 
    depositInventory();

            return 
    mineCoal();
        }

        public 
    boolean isLost() {
            if(
    distanceTo(lumbridgeTile) <= 17)
                    return 
    false;
            if(
    distanceTo(bankTile) <= 17)
                return 
    false;
            if(
    distanceTo(ladderTile) <= 17)
                return 
    false;
            for(
    int i 0betweenBankAndLadderTiles.length 1i++)
                if(
    distanceTo(betweenBankAndLadderTiles[i]) <= 17)
                        return 
    false;
            for(
    int i 0coalToLadderPath.length 1i++)
                if(
    distanceTo(coalToLadderPath[i]) <= 17)
                        return 
    false;
            return 
    true;
        }

        public 
    int dropInventory() {
            if(
    atInventoryItem(coalID"Drop")) {
                
    coalDropped++;
                
    wait(random(500700));
                return 
    random(5075);
            } else if(
    atInventoryItem(mithrilID"Drop")) {
                
    mithDropped++;
                
    wait(random(500700));
                return 
    random(5075);
            }
            for(
    int i 0gemID.lengthi++) {
                if(
    atInventoryItem(gemID[i], "Drop")) {
                    
    gemsDropped++;
                    
    wait(random(500700));
                    return 
    random(5075);
                }
            }
            
    dropping false;
            
    invCountToDrop random(1029);
            return 
    random(5075);
        }

        public 
    boolean isCarryingJunk() {
            for(
    int i 0junkItems.lengthi++) {
                if(
    inventoryContainsOneOf(junkItems[i])) {
                    return 
    true;
                }
            }
            
    RSItem item getInventoryItemByID(goldPiecesID);
            if(
    item != null) {
                if(
    item.getStackSize() <= 5000) {
                    return 
    true;
                }
            }
            return 
    false;
        }
        
        public 
    int dropJunk() {
            for(
    int i 0junkItems.lengthi++) {
                if(
    inventoryContainsOneOf(junkItems[i])) {
                    if(
    atInventoryItem(junkItems[i], "Drop"))
                        return 
    random(550700);
                }
            }
            
    RSItem item getInventoryItemByID(goldPiecesID);
            if(
    item != null) {
                if(
    item.getStackSize() <= 5000) {
                    if(
    atInventoryItem(goldPiecesID"Drop"))
                        return 
    random(550700);
                }
            }
            return 
    random(40100);
        }
        
        public 
    void unequipWeapon() {
            
    openTab(TAB_EQUIPMENT);
            
    RSInterface equip RSInterface.getInterface(INTERFACE_TAB_EQUIPMENT);
            
    RSInterfaceChild weapon equip.getChild(16);
            
    atInterface(weapon);
            
    wait(random(400800));
            
    openTab(TAB_INVENTORY);
        }

        public 
    int runAway() {
            
    log("Running away from combat...");
            
    setRun(true);
            if(
    getMyPlayer().getLocation().getY() > 6000) {
                if(!
    myWalkPath(coalToLadderPath172))
                    return 
    random(200300);
                
    waitUntilNotMoving();
                if(!
    climbUpLadder())
                    
    climbUpLadder();
                
    wait(random(22003400));
            } else {
                
    RSTile curentTile getMyPlayer().getLocation();
                
    int xRand random(-1617);
                
    int yRand;
                if(
    random(02) == 0)
                    
    yRand = -(int)(Math.sqrt((16 16) - (xRand xRand)));
                else
                    
    yRand = -(int)(Math.sqrt((16 16)- (xRand xRand)));
                
    RSTile runawayTile = new RSTile(curentTile.getX() + xRandcurentTile.getY() + yRand);
                
    myWalkTile(runawayTile0);
                
    waitUntilNearTile(runawayTile0);
                
    wait(random(22003400));
                
    myWalkTile(curentTile1);
                
    wait(random(50600));
                if(
    random(04) < 3)
                    
    moveMouse(random(100415), random(100237));
                
    waitUntilNotMoving();
            }
            
    runAway false;
            
    ranAwayFromCombat++;
            
    log("Combat evaded.");
            return 
    random(50100);
        }

        
    long upLadderTimer System.currentTimeMillis();

        public 
    boolean climbUpLadder() {
            
    upLadderTimer System.currentTimeMillis();
            
    RSObject object getNearestObjectById(16ladderID);
            if(
    object == null)
                return 
    false;
            if(!
    Calculations.onScreen(Calculations.tileToScreen(object.getLocation()))) {
                
    myWalkTile(object.getLocation(), 2);
                
    wait(random(50600));
                if(
    random(04) < 3)
                    
    moveMouse(random(100415), random(100237));
                
    waitUntilNotMoving();
            }
            if(
    atObject(object"up")) {
                while(
    getMyPlayer().getLocation().getY() > 6000 && System.currentTimeMillis() - upLadderTimer 6000) {
                    if(
    getMyPlayer().getLocation().getY() < 6000)
                        return 
    true;
                    if(
    System.currentTimeMillis() - upLadderTimer >= 6000)
                        return 
    false;
                    
    wait(random(600800));
                }
            } else {
                
    setCameraRotation(random(1359));
                
    //setCameraAltitude(true);
            
    }
            return 
    false;
        }

        public 
    boolean atTileModified(RSTile tileString action) {
            try {
                
    Point location Calculations.tileToScreen(tile);
                if (
    location.== -|| location.== -1) return false;
                
    int xRand 0;
                
    int yRand 0;
                if(
    random(02) == 0)
                    
    xRand random(-26, -16);
                else
                    
    xRand random(1626);
                if(
    random(02) == 0)
                    
    yRand random(-26, -16);
                else
                    
    yRand random(1626);
                
    moveMouse(locationxRandyRand);
                if (
    getMenuItems().get(0).toLowerCase().contains(action.toLowerCase())) {
                    
    clickMouse(true);
                } else {
                    
    clickMouse(false);
                    if(!
    atMenu(action))
                        return 
    false;
                }
                
    waitUntilNotMoving();
                return 
    true;
            } catch (
    Exception e) {
                return 
    false;
            }
        }

        
    long downLadderTimer System.currentTimeMillis();

        public 
    boolean climbDownLadder() {
            
    downLadderTimer System.currentTimeMillis();
            if(!
    Calculations.onScreen(Calculations.tileToScreen(topLadderObjectTile)))
                return 
    false;
            if(
    atTileModified(topLadderObjectTile"down")) {
                while(
    getMyPlayer().getLocation().getY() < 6000 && System.currentTimeMillis() - downLadderTimer 6000) {
                    if(
    getMyPlayer().getLocation().getY() > 6000)
                        return 
    true;
                    if(
    System.currentTimeMillis() - downLadderTimer >= 6000)
                        return 
    false;
                    
    wait(random(600800));
                }
            } else {
                
    //if(distanceTo(ladderTile) > 6)
                //    myWalkTile(ladderTile, 2);
                
    setCameraRotation(random(1359));
                
    //setCameraAltitude(true);
                //waitUntilNearTile(ladderTile, 0);
            
    }
            return 
    false;
        }

        public 
    int getNewPick() {
            if(
    getMyPlayer().getLocation().getY() > 6000) {
                if(
    myWalkPath(coalToLadderPath153)) {
                    
    waitUntilNotMoving();
                    
    climbUpLadder();
                }
                return 
    random(100200);
            }
            if(
    distanceTo(bankTile) > 4) {
                if(
    myWalkTile(bankTile1)) {
                    
    wait(random(50600));
                    if(
    random(04) < 3)
                        
    moveMouse(random(100415), random(100237));
                    
    waitUntilNotMoving();
                } else {
                    
    RSTile theTile betweenBankAndLadderTiles[random(0betweenBankAndLadderTiles.length)];
                    
    myWalkTile(theTile1);
                    if(
    random(02) == 0)
                        
    setCameraAltitude(true);
                    
    waitUntilNearTile(theTile2);
                }
                return 
    random(200300);
            }
            if(!
    RSInterface.getInterface(INTERFACE_BANK).isValid()) {
                
    int r random(02);
                if(
    == 0)
                    if(!
    atObject(getNearestObjectById(15bankBoothID), "uickl"))
                        
    myWalkTile(bankTile2);
                if(
    == 1)
                    if(!
    atNPC(getNearestNPCByID(bankerID), "ank Ba"))
                        
    myWalkTile(bankTile2);
                
    wait(random(200300));
                
    waitUntilNotMoving();
                return 
    random(100300);
            }
            if(
    RSInterface.getInterface(INTERFACE_BANK).isValid()) {
                
    coalBanked += getInventoryCount(coalID);
                
    mithBanked += getInventoryCount(mithrilID);
                
    gemsBanked += getInventoryCount(gemID);
                
    bank.depositAll();

                
    moveMouse(52 random(-1010), 106 random(-1010));
                if(
    getMenuItems().get(0).toLowerCase().contains(("pickaxe").toLowerCase()) && !getMenuItems().get(0).toLowerCase().contains(("Broken").toLowerCase())) {
                    
    clickMouse(true);
                    
    wait(random(11001500));
                } else {
                    
    log("No useable pickaxe, ending script =(");
                    
    bank.close();
                    
    printProgressReport();
                    
    stopAllScripts();
                }
                
    bank.close();
            }
            return 
    99999;
        }

        
    int headAttempts;
        public 
    int fixPickaxe() {
            
    RSItemTile head getGroundItemByID(17pickaxeHeadID);
            if(
    head != null) {
                
    log("Getting pickaxe head...");
                
    myWalkTile(head1);
                
    waitUntilNearTile(head0);
                
    headAttempts 0;
                while(!
    atTile(head"Take") || headAttempts <= 10) {
                    
    setCameraRotation(random(1359));
                    if(
    random(03) == 0)
                        
    atTile(randomizeTile(head11), "Walk");
                    
    headAttempts++;
                    
                }
            }
            
    //if(equipmentContains(pickaxeHandleID) || equipmentContains(brokenPickaxeID))
                
    unequipWeapon();
            
    openTab(TAB_INVENTORY);
            
    wait(random(200300));
            if(
    getInventoryItemByID(pickaxeHeadID) != null && getInventoryItemByID(pickaxeHandleID) != null)
                
    useItem(getInventoryItemByID(pickaxeHeadID), getInventoryItemByID(pickaxeHandleID));

            if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= 40 && inventoryContainsOneOf(pickaxeID[5]))
                
    atInventoryItem(pickaxeID[5], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= 30 && inventoryContainsOneOf(pickaxeID[4]))
                
    atInventoryItem(pickaxeID[4], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= 20 && inventoryContainsOneOf(pickaxeID[3]))
                
    atInventoryItem(pickaxeID[3], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= && inventoryContainsOneOf(pickaxeID[2]))
                
    atInventoryItem(pickaxeID[2], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= && inventoryContainsOneOf(pickaxeID[1]))
                
    atInventoryItem(pickaxeID[1], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= && inventoryContainsOneOf(pickaxeID[0]))
                
    atInventoryItem(pickaxeID[0], "ield");
            return 
    random(200400);
        }

        public 
    boolean canEquipPickaxe() {
            if((
    skills.getCurrentSkillLevel(STAT_ATTACK) >= 40 && inventoryContainsOneOf(pickaxeID[5])) ||
               (
    skills.getCurrentSkillLevel(STAT_ATTACK) >= 30 && inventoryContainsOneOf(pickaxeID[4])) ||
               (
    skills.getCurrentSkillLevel(STAT_ATTACK) >= 20 && inventoryContainsOneOf(pickaxeID[3])) ||
               (
    skills.getCurrentSkillLevel(STAT_ATTACK) >= && inventoryContainsOneOf(pickaxeID[2])) ||
               (
    skills.getCurrentSkillLevel(STAT_ATTACK) >= && inventoryContainsOneOf(pickaxeID[1])) ||
               (
    skills.getCurrentSkillLevel(STAT_ATTACK) >= && inventoryContainsOneOf(pickaxeID[0])))
                return 
    true;
            return 
    false;
        }
        
        public 
    int wieldPickaxe() {
            if(
    RSInterface.getInterface(INTERFACE_BANK).isValid())
                
    bank.close();

            if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= 40 && inventoryContainsOneOf(pickaxeID[5]))
                
    atInventoryItem(pickaxeID[5], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= 30 && inventoryContainsOneOf(pickaxeID[4]))
                
    atInventoryItem(pickaxeID[4], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= 20 && inventoryContainsOneOf(pickaxeID[3]))
                
    atInventoryItem(pickaxeID[3], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= && inventoryContainsOneOf(pickaxeID[2]))
                
    atInventoryItem(pickaxeID[2], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= && inventoryContainsOneOf(pickaxeID[1]))
                
    atInventoryItem(pickaxeID[1], "ield");
            else if(
    skills.getCurrentSkillLevel(STAT_ATTACK) >= && inventoryContainsOneOf(pickaxeID[0]))
                
    atInventoryItem(pickaxeID[0], "ield");
            return 
    random(200400);
        }

        public 
    int depositInventory() {
            if(
    getMyPlayer().getLocation().getY() > 6000) {
                if(
    myWalkPath(coalToLadderPath153)) {
                    
    waitUntilNotMoving();
                    
    climbUpLadder();
                }
                return 
    random(100200);
            }
            if(
    distanceTo(bankTile) > 4) {
                if(
    myWalkTile(bankTile1)) {
                    
    wait(random(50600));
                    if(
    random(04) < 3)
                        
    moveMouse(random(100415), random(100237));
                    
    waitUntilNotMoving();
                } else {
                    
    RSTile theTile betweenBankAndLadderTiles[random(0betweenBankAndLadderTiles.length)];
                    
    myWalkTile(theTile1);
                    if(
    random(02) == 0)
                        
    setCameraAltitude(true);
                    
    waitUntilNearTile(theTile2);
                }
                return 
    random(200300);
            }
            if(!
    RSInterface.getInterface(INTERFACE_BANK).isValid()) {
                
    int r random(02);
                if(
    == 0)
                    if(!
    atObject(getNearestObjectById(15bankBoothID), "uickl"))
                        
    myWalkTile(bankTile2);
                if(
    == 1)
                    if(!
    atNPC(getNearestNPCByID(bankerID), "ank Ba"))
                        
    myWalkTile(bankTile2);
                
    wait(random(200300));
                
    waitUntilNotMoving();
                return 
    random(200300);
            }
            if(
    RSInterface.getInterface(INTERFACE_BANK).isValid()) {
                
    coalBanked += getInventoryCount(coalID);
                
    mithBanked += getInventoryCount(mithrilID);
                
    gemsBanked += getInventoryCount(gemID);
                
    bank.depositAllExcept(pickaxeID);
                if(
    random(05) == 0)
                    
    bank.close();
            }
            return 
    random(25100);
        }

        public 
    void mouseOverMiningSkill() {
            
    openTab(TAB_STATS);
            
    //2 interfaces, one for the pickaxe image, other for the skill text
            
    RSInterfaceChild one RSInterface.getInterface(320).getChild(9);
            
    RSInterfaceChild two RSInterface.getInterface(320).getChild(10);
            if(
    random(02) == 0)
                
    moveMouse(new Point(one.getAbsoluteX() + random(2one.getWidth() - 1), one.getAbsoluteY() + random(2one.getHeight() - 1)));
            else
                
    moveMouse(new Point(two.getAbsoluteX() + random(2two.getWidth() - 1), two.getAbsoluteY() + random(2two.getHeight() - 1)));
        }

        
    //4% chance of doing antiban: 17/425, every 4.8-19.2 seconds doing antiban
        
    public int antiBan() {
            switch(
    random(0425)) {
                case 
    0setCameraRotation(random(1359)); break;
                case 
    1setCameraRotation(random(1359)); break;
                case 
    2setCameraRotation(random(1359)); break;
                case 
    3setCameraRotation(random(1359)); break;
                case 
    4setCameraRotation(random(1359)); break;
                case 
    5setCameraRotation(random(1359)); break;

                case 
    6setRun(true); break;

                case 
    7moveMouse(random(0515), random(0337)); break;
                case 
    8moveMouse(random(0515), random(0337)); break;
                case 
    9moveMouse(random(100415), random(100237)); break;
                case 
    10moveMouse(random(100415), random(100237)); break;
                case 
    11moveMouse(random(100415), random(100237)); break;
                case 
    12moveMouse(random(0764), random(0502)); break;

                case 
    13mouseOverMiningSkill(); break;
                case 
    14mouseOverMiningSkill(); break;

                case 
    15openTab(TAB_INVENTORY); break;
                case 
    16openTab(random(013)); break;

                default: break;
            }
            return 
    random(50200);
        }

        
    RSTile lastRockLocation = new RSTile(00000000);
        
    RSObject rock;
        
    long timeIdle System.currentTimeMillis();

        public 
    boolean mineNewRock() {
            
    RSObject obj getObjectAt(lastRockLocation);
            if(
    obj == null)
                return 
    true;
            for(
    int i 0coalRockID.lengthi++) {
                if(
    obj.getID() == coalRockID[i])
                    return 
    false;
            }
            for(
    int i 0mithRockID.lengthi++) {
                if(
    obj.getID() == mithRockID[i])
                    return 
    false;
            }
            return 
    true;
        }

        public 
    boolean atRock(RSObject obj) {
            try {
                
    Point location Calculations.tileToScreen(obj.getLocation());
                if (
    location.== -|| location.== -1) return false;
                
    moveMouse(location33);
                
    wait(random(4080));
                
    boolean validRock false;
                
    RSObject temp getObjectAt(obj.getLocation());
                if(
    temp != null) {
                    
    int id temp.getID();
                    for(
    int i 0coalRockID.lengthi++) {
                        if(
    id == coalRockID[i])
                            
    validRock true;
                    }
                    if(!
    validRock) {
                        for(
    int i 0mithRockID.lengthi++) {
                            if(
    id == mithRockID[i])
                                
    validRock true;
                        }
                    }
                }
                if(!
    validRock)
                    return 
    false;
                if(!
    getMenuItems().get(0).toLowerCase().contains(("ine R").toLowerCase())) {
                    
    moveMouse(location66);
                    
    wait(random(4080));
                    if(!
    getMenuItems().get(0).toLowerCase().contains(("ine R").toLowerCase())) {
                        
    moveMouse(location66);
                        
    wait(random(4080));
                        if(!
    getMenuItems().get(0).toLowerCase().contains(("ine R").toLowerCase())) {
                            
    moveMouse(location66);
                            
    wait(random(4080));
                        }
                    }
                }
                    
                if(
    getMenuItems().get(0).toLowerCase().contains(("ine R").toLowerCase())) {
                    
    clickMouse(true);
                } else {
                    
    clickMouse(false);
                    if(!
    atMenu("ine R"))
                        return 
    false;
                }
                
    wait(random(5001000));
                
    waitUntilNotMoving();
                return 
    true;
            } catch (
    Exception e) {
                return 
    false;
            }
        }

        private 
    boolean isObjectOccupied(RSObject obj) {
            
    Player[] players Bot.getClient().getPlayerArray();
            
    int[] playerIndex Bot.getClient().getPlayerIndexArray();
            if(
    obj.getLocation() == null)
                return 
    true;
            for(
    int element playerIndex) {
                if(
    players[element] == null)
                    continue;
                
    RSPlayer player = new RSPlayer(players[element]);
                if(!
    player.getName().equals(getMyPlayer().getName()))
                    if(
    distanceBetween(obj.getLocation(), player.getLocation()) < && player.getAnimation() != -1)
                        return 
    true;
            }
            return 
    false;
        }

        private 
    RSObject findNearestUnoccupiedObject(RSObject... objects) {
            
    RSObject nearestObj null;
            for(
    int i 0objects.lengthi++) {
                if(
    isObjectOccupied(objects[i]))
                    continue;
                if(
    nearestObj == null)
                    
    nearestObj objects[i];
                else if(
    distanceTo(objects[i].getLocation()) < distanceTo(nearestObj.getLocation()))
                    
    nearestObj objects[i];
            }
            return 
    nearestObj;
        }

        public 
    int mineCoal() {
            if(
    getMyPlayer().getLocation().getY() < 6000) {
                if(!
    climbDownLadder()) {
                    if(
    Calculations.onScreen(Calculations.tileToScreen(topLadderObjectTile)))
                        return 
    random(2080);
                    if(
    myWalkTile(ladderTile2)) {
                        if(
    random(04) < 3)
                            
    moveMouse(random(100415), random(100237));
                        
    waitUntilNearTile(ladderTile0);
                    } else {
                        
    RSTile theTile betweenBankAndLadderTiles[random(0betweenBankAndLadderTiles.length)];
                        
    myWalkTile(theTile1);
                        if(
    random(02) == 0)
                            
    setCameraAltitude(true);
                        
    waitUntilNearTile(theTile2);
                    }
                    return 
    random(200300);
                }
                return 
    random(200400);
            }

            if(
    getMyPlayer().getAnimation() != -1)
                
    timeIdle System.currentTimeMillis();
            
            if(
    getObjectAt(lastRockLocation) == null)
                
    lastRockLocation = new RSTile(00000000);

            if(
    mineNewRock() || ((getMyPlayer().getAnimation() == -1) && (System.currentTimeMillis() - timeIdle >= 4000) && !getMyPlayer().isMoving())) {
                
    rock null;
                if(
    miningMith && (findNearestUnoccupiedObject(findObjects(16mithRockID)) != null || getNearestObjectById(16mithRockID) != null)) {
                    if(
    findNearestUnoccupiedObject(findObjects(16mithRockID)) != null)
                        
    rock findNearestUnoccupiedObject(findObjects(16mithRockID));
                    else
                        
    rock getNearestObjectById(16mithRockID);
                } else {
                    if(
    findNearestUnoccupiedObject(findObjects(10coalRockID)) != null)
                        
    rock findNearestUnoccupiedObject(findObjects(10coalRockID));
                    else
                        
    rock getNearestObjectById(16coalRockID);
                }
                if(
    rock == null) {
                    if(
    distanceTo(ladderToCoalPath[ladderToCoalPath.length 1]) < 6) {
                        
    myWalkPath(coalToLadderPath153);
                        
    wait(random(50600));
                        if(
    random(04) < 3)
                            
    moveMouse(random(100415), random(100237));
                        
    waitUntilNotMoving();
                        return 
    random(50200);
                    }
                    if(
    distanceTo(coalToLadderPath[coalToLadderPath.length 1]) < 6) {
                        
    myWalkPath(ladderToCoalPath153);
                        
    wait(random(50600));
                        if(
    random(04) < 3)
                            
    moveMouse(random(100415), random(100237));
                        
    waitUntilNotMoving();
                        return 
    random(50200);
                    }
                    if(
    random(02) == 0)
                        
    myWalkPath(ladderToCoalPath173);
                    else
                        
    myWalkPath(coalToLadderPath173);

                    
    wait(random(50600));
                    if(
    random(04) < 3)
                        
    moveMouse(random(100415), random(100237));
                    
    waitUntilNotMoving();
                    return 
    random(50200);
                }
                if(
    rock.getLocation().getY() > 9756) {
                    
    myWalkPath(coalToLadderPath173);
                    
    waitUntilNotMoving();
                    
    lastRockLocation = new RSTile(00000000);
                    return 
    random(50200);
                }
                
    //if(!tileOnScreen(rock.getLocation())) {
                
    if(!Calculations.onScreen(Calculations.tileToScreen(rock.getLocation()))) {
                    if(!
    myWalkTile(rock.getLocation(), 2)) {
                        
    lastRockLocation = new RSTile(00000000);
                        return 
    random(2040);
                    }
                    if(
    random(04) == 0)
                        
    setCameraAltitude(true);
                    
    wait(random(50200));
                    if(
    random(04) < 3)
                        
    moveMouse(random(100415), random(100237));
                    
    waitUntilNotMoving();
                    return 
    random(50200);
                }
                
    lastRockLocation rock.getLocation();
                if(!
    atRock(rock))
                    
    setCameraRotation(random(1359));

                return 
    random(100300);
            }
            return 
    antiBan();
        }

        
    int tries 0;
        public 
    int teleportToLumbridge() {
            if(
    distanceTo(lumbridgeTile) > 17) {
                
    castSpell(1);
                
    wait(random(15002400));
                if(
    getMyPlayer().getAnimation() != -1) {
                    
    wait(random(12500,14000));
                } else {
                    
    tries++;
                    if(
    tries >= 4) {
                        
    log("Unable to teleport to lumbridge, stopping script");
                        
    printProgressReport();
                        
    stopAllScripts();
                    }
                    
    int r random(120000400000);
                    
    log("Unable to teleport to lumbridge, will attempt again in " + (1000) + "seconds");
                    
    printProgressReport();
                    
    logout();
                    
    wait(r);
                    
    login();
                }
            }
            
    myWalkTile(lumbridgeTile1);
            
    setRun(true);
            
    waitUntilNearTile(lumbridgeTile2);
            return 
    random(100600);
        }

        public 
    void waitUntilNotMoving() {
            
    wait(random(7001000));
            while(
    getMyPlayer().isMoving())
                
    wait(random(25100));
        }

        public 
    void waitUntilNearTile(RSTile tileint dist) {
            
    wait(random(7001000));
            while(
    distanceTo(tile) >= dist && getMyPlayer().isMoving())
                
    wait(random(25100));
        }

        public 
    boolean myWalkTile(RSTile theTileint randomness) {
            if(
    theTile == null)
                return 
    false;
            if((
    distanceTo(theTile)) <= 17) {
                
    RSTile newTile;
                if(
    randomness == 0)
                    
    newTile = new RSTile(theTile.getX(), theTile.getY());
                else
                    
    newTile = new RSTile(theTile.getX() + random(-randomnessrandomness 1), theTile.getY() + random(-randomnessrandomness 1));

                if(
    random(030) == 0)
                    
    turnToTile(newTile15);

                if(
    tileOnScreen(newTile) && random(010) == 0) {
                    if(!
    atTile(newTile"Walk")) {
                        if(!
    walkTileMM(newTile)) {
                            
    //log("Failed walking to tile: (" + theTile.getX() + ", " + theTile.getY() + ")");
                            
    return false;
                        } else {
                            return 
    true;
                        }
                    } else {
                        return 
    true;
                    }
                } else {
                    if(!
    walkTileMM(newTile)) {
                        
    //log("Failed walking to tile: (" + theTile.getX() + ", " + theTile.getY() + ")");
                        
    return false;
                    } else {
                        return 
    true;
                    }
                }
            } else {
                
    //log("Tile out of reach: (" + theTile.getX() + ", " + theTile.getY() + ")");
                
    return false;
            }
        }

        public 
    RSTile myGetNextTile(RSTile[] pathint maxDist) {
            for(
    int i path.length 1>= 0i--) {
                if(
    distanceTo(path[i]) <= maxDist) {
                    return 
    path[i];
                }
            }
            return 
    null;
        }

        
    /**
         * Walks to the next reachable tile in the path
         *
         * @param path The path it will walk
         * @param maxDist The max distance it will search for the next tile in the path
         * @param randomness the randomness it will add to clicking the tile
         * @return if you are within 4 tiles of the destination
         */
        
    public boolean myWalkPath(RSTile[] pathint maxDistint randomness) {
            if(
    distanceTo(path[path.length 1]) <= 4) {
                return 
    true;
            } else {
                
    RSTile theTile myGetNextTile(pathmaxDist);
                if(
    theTile != null) {
                    
    myWalkTile(theTilerandomness);
                    
    waitUntilNearTile(theTile2);
                }
                return 
    false;
            }
        }

        public 
    RSObject getNearestObjectById(int rangeint... ids) {
            for(
    int i 0<= rangei++) {
                
    RSObject temp findObject(iids);
                if(
    temp != null) {
                    return 
    temp;
                }
            }
            return 
    null;
        }

        public 
    RSObject[] findObjects(int rangeint... ids) {
            
    ArrayList<RSObjectmatches = new ArrayList<RSObject>();
            
    RSTile pos getMyPlayer().getLocation();
            
    int xBegin pos.getX() - range;
            
    int yBegin pos.getY() - range;
            
    int xEnd pos.getX() + range;
            
    int yEnd pos.getY() + range;
            for (
    int x xBeginxEndx++) {
                for (
    int y yBeginyEndy++) {
                    
    RSTile t = new RSTile(xy);
                    
    RSObject obj getObjectAt(t);
                    if (
    obj == null)
                        continue;
                    for (
    int objType ids) {
                        if (
    objType == obj.getID())
                            
    matches.add(obj);
                    }
                }
            }
            try {
                
    matches.trimToSize();
                return (
    RSObject[]) matches.toArray(new RSObject[matches.size()]);
            } catch (
    Exception e) { }
            return new 
    RSObject[0];
        }

    }
     
< Look! Amazing Mage/range Tank!!!! | Sideshows Free Mm Service® >

Users viewing this thread
1 guest
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site