All pastes #372629 Raw Edit

Untitled

public java v1 · immutable
#372629 ·published 2007-02-26 05:38 UTC
rendered paste body
//PowerMiner v2.0 for Nexus 7.7 - by Solarwind//www.impwiki.org - the best RuneScape cheating wiki on the planet.//Name this file "SolarwindPowerMiner.java"import impsoft.nexus.bots.color.constants.*;import impsoft.nexus.bots.color.methods.*;import impsoft.nexus.bots.color.scriptobjects.*;//import impsoft.nexus.storage.*; //In this script, we don't need it, but just keep it commented.import java.awt.Rectangle;//import java.awt.event.KeyEvent; //In this script, we don't need it, but just keep it commented.//import org.apache.log4j.rule.ExistsRule; //In this script, we don't need it, but just keep it commented. public class SolarwindPowerMiner extends ColorScript{    //Declare standard variables.    public static double version = 2.0;    public static String[] commands = new String[] {"This mines normal copper ore only."};    public String author = "Solarwind v2.0";    public String description = "Copper powerminer. Banking + walking soon to come.";        //Declare game variables.    public int mx = 240; //Areas.GAME middle x point.    public int my = 160; //Areas.GAME middle y point.            public boolean doStart(String cmd, String[] args) throws InterruptedException {    	log("Starting script...");        return true;    }        public void walkToBank() throws InterruptedException {    	//This walks to the bank. (it screws up cuz it doesn't have failsafes)    	followARoadOnMM(40,-54,new RGB(102,94,94));    	followARoadOnMM(66,22,new RGB(69,63,63));    	followARoadOnMM(61,-2,new RGB(69,63,63));    	followARoadOnMM(62,12,new RGB(95,88,88));    	walkTowardARoadOnMM(23,57,new RGB(95,88,88));    	walkTowardARoadOnMM(5,68,new RGB(95,88,88));    	CoordinateWalk(-33,4);    }        public void walkFromBank() throws InterruptedException {    	//This walks from the bank back to the mining spot. (it screws up cuz it doesn't have failsafes)    	walkTowardARoadOnMM(33,-4,new RGB(98,91,89));    	walkTowardARoadOnMM(-10,-60,new RGB(98,91,89));    	walkTowardARoadOnMM(-3,-43,new RGB(98,91,89));    	walkTowardARoadOnMM(-52,-20,new RGB(98,91,89));    	walkTowardARoadOnMM(-43,-9,new RGB(100,93,92));    	followARoadOnMM(-65,9,new RGB(100,93,92));    	followARoadOnMM(-43,-12,new RGB(100,93,92));    	CoordinateWalk(-32,35);    	CoordinateWalk(-36,4);    }        //sBubbleSort by Solarwind    public static void sBubbleSort(int[] x, int[] y) {        int n = x.length;        for (int pass = 1; pass < n; pass++) {            for (int i=0; i < n-pass; i++) {                if (x[i] > x[i+1]) {                    int temp = x[i];                      x[i] = x[i+1];                      x[i+1] = temp;                                        int temp2 = y[i];                      y[i] = y[i+1];                      y[i+1] = temp2;                }            }        }    }        /* Usage example of sBubbleSort    public static void main(String[] args) {        int[] distances = new int[] {50, 40, 10, 30, 20};        int[] positions = new int[] {0, 1, 2, 3, 4};                sBubbleSort(distances, positions);                for(int p = 0; p < distances.length; p++) {            System.out.println("Distance: " + distances[p] + " Position: " + positions[p]);        }    }    */        public void declareThreads() throws InterruptedException {    	log("Fighting antirandom started.");	    while(isLoggedin()) {	    	try {	    		sleep(500);	    	} catch(InterruptedException ex) {	    		log(ex);	    	}	    				    	if(1 == 1 /* is dead */) {				    		Rectangle HitBox = new Rectangle(210, 110, 300, 175);	    		XY GreenHealthBar = findXY(getColorArray2d(), new RGB(0, 255, 0), HitBox);	    		if(GreenHealthBar != null) {	    			log("Fight detected, run!");	    			//Place run functions here...	    		} else {	    			//log("No fight detected.");	    		}	    	} else {	    		//We are dead.	    		log("We are dead. Terminate script.");	    		log("--- Terminate script ---");	    		theBot.destroy();	    	}	    }      } //End function.            public void dropAllOres(String OreName) throws InterruptedException {        doActionAtInventory(OreName, "Drop", 28);    }        //This one returns the distance from x1, y1 to x2, y2.    public int pDistance(int x1, int y1, int x2, int y2) {    	int dx = x1 - x2;		int dy = y1 - y2;		int result = (int)Math.sqrt(dx*dx + dy*dy);    	return result;    }        //This one returns the distance from the middle of Areas.GAME to x1, y1.    public int pDistance(int x1, int y1) {    	int dx = x1 - mx;		int dy = y1 - my;		int result = (int)Math.sqrt(dx*dx + dy*dy);    	return result;    }                public void findOre(String OreType) throws InterruptedException {        int CurrentInventory = inventoryCount(); //Get an initial count of the inventory.        int Sleepcount = 0;        int[] distances = new int[] {0, 0, 0, 0, 0}; //Array of distances between match and game middle.        int[] positions = new int[] {0, 1, 2, 3, 4}; //Array of the corresponding position.        String TopText = "";                log("Preparing to find ore...");               if(OreType == "Copper") {                     //doActionAtRGBCluster(new RGB[] { new RGB(157, 113, 72), new  RGB(157, 113, 72) }, "Mine", "Mine Rocks");        	log("Finding ore...");        	XY[] FoundArray = findRGBCluster(new RGB(111, 80, 51), Areas.GAME, 5); //Working copper colours.        	        	        	if(FoundArray.length > 0) {        		log("Length: " + FoundArray.length);        		        		for(int i = 0; i < FoundArray.length; i++) {        			log("Found colour at " + FoundArray[i] + " at pos: " + i + ".");        		}        		        		//Find closest ore to the player.       		    	        		//Calculate distances.        		log("Finding all distances of matches.");        		for(int p = 0; p < FoundArray.length; p++) {        			distances[p] = pDistance(FoundArray[p].x, FoundArray[p].y);        		}        		        		//Sort distances.        		sBubbleSort(distances, positions);        		       	        		//Print out distances in order (closes to furthest) and their position in FoundArray.        		log("Printing sorted distances.");        		log("----------");        		for(int p = 0; p < FoundArray.length; p++) {        			log("D: #" + p + " (" + distances[p] + "px) xy: " + FoundArray[positions[p]] +  " pos: "  + positions[p] + ".");        			        		}   	        		log("----------");        		        		//Check top text and click.        	    log("Clicking #" + positions[0]); 		        		       		        		mouseMove(FoundArray[positions[0]]);        		TopText = getTopText();        		        		if(TopText.contains("ine")) {        			log("Rock found, mining...");        			mouseClickLeft(FoundArray[positions[0]]);        		} else {        			log("Uptext is false, searching again for ore...");        		}        		        		        	}         	//What to do if no colours were found.        	if(FoundArray.length <= 0) {        		log("No RGBs found. Searching again.");        	}        }                //Wait until the player mines the ore, or wait until a timeout occurs, then start finding and mining again.        while(inventoryCount() <= CurrentInventory) {            sleep(1000);            Sleepcount++;            log("Waiting to finish mining..." + Sleepcount);            if(Sleepcount > random(2, 12)) {                log("Timeout occured, break...");                break; //Break out of the loop and try to mine another rock.                            }        }    }       public void closeBank() throws InterruptedException {       	    	int X = random(474, 496);    	int Y = random(31, 51);    	XY myXY = new XY(X, Y);    	mouseMove(myXY);    	mouseClickLeft(myXY);    }        public void store() throws InterruptedException {    	log("Using bank.");    	doActionAtRGBCluster(new RGB(91, 68, 9), "booth", "quickly");    	sleep(random(1000, 3000));    	log("Storing ores.");    	doActionAtInventory("Copper ore", "All", 2);    	log("Closing bank booth.");    	closeBank();    	sleep(1000);    }     public void script() throws InterruptedException {             log("Start script...");                log("running....");                if(inventoryCount() < 28) {        	setRun(true);        }                //Start a never ending loop of mining and dropping.        while(true) {        	//While the inventory is NOT full, keep mining ores.            while(inventoryCount() < 28) {            	log("Mining ore.");            	findOre("Copper");             }            //If the inventory is full, drop all of the ores.            if(inventoryCount() >= 28) {                log("Inventory is full, dropping all ores.");                //dropAllOres("Copper"); //Drop all ores.                //dropAllOres("Copper"); //Drop again just in case the bot misses a few ores.                setRun(false);                walkToBank();                store();                setRun(true);                walkFromBank();                     }        }            } }