All pastes #368434 Raw Edit

Anonymous

public java v1 · immutable
#368434 ·published 2007-02-23 02:06 UTC
rendered paste body
import java.awt.Rectangle;import java.io.IOException;import impsoft.nexus.botbase.methods.interfaces.CoreRandom;import impsoft.nexus.bots.color.constants.Areas;import impsoft.nexus.bots.color.constants.Info;import impsoft.nexus.bots.color.managers.BitMapManger;import impsoft.nexus.bots.color.methods.ColorRandom;import impsoft.nexus.bots.color.methods.Timer;import impsoft.nexus.bots.color.scriptobjects.Menu;import impsoft.nexus.bots.color.scriptobjects.NPCChat;import impsoft.nexus.bots.color.scriptobjects.RGB;import impsoft.nexus.bots.color.scriptobjects.XY;import impsoft.nexus.storage.SettingsManager;public class StrangeBox extends ColorRandom {	private short[][][] box;	private XY matches[];	public String author = "ruler, pups";//417,314	public Rectangle boxBounds = new Rectangle(116,0,417-116,314-0);	public boolean startUp() {		if (theBot.loggedIn) {			if (box == null) {				box = loadBitmap("bitmaps/strangebox.bmp");			}			if (getTab() == Info.TAB_INVENTORY) {				matches = findXYs(getColorArray2d(), Areas.INVENTORY, null,						box, null, 30, 5, 5, 5);				if (matches.length > 0) {					return true;				}			}			NPCChat chat = null;			try {				chat = getNPCChat(0);			} catch (InterruptedException e) {			}			if (chat != null					&& chat.options.length == 3					&& chat.options[0]							.contains("You have been given a Mysterious box")) {				return true;			}		}		setNextCheck(3000);		return false;	}	public XY findText(String text) {		return findGameScreenText(text, Areas.GAME, new RGB(187, 185, 73), 3,				3, 3);	}	public String shapes[] = { "Pentagon", "Circle", "Square", "Star",			"Triangle" };	public void random() throws InterruptedException {		NPCChat chat = null;		try {			chat = getNPCChat(0);		} catch (InterruptedException e) {		}		if (chat != null				&& chat.options.length == 3				&& chat.options[0]						.contains("You have been given a Mysterious box")) {			chat.selectContains("Click Here");			sleep(1000);		}		setTab(Info.TAB_INVENTORY);		if (getTab() == Info.TAB_INVENTORY) {			matches = findXYs(getColorArray2d(), 28, box, Areas.INVENTORY, 5,					5, 5);		}		for (int i = 0; i < matches.length; i++) {			mouseClickRight(new Rectangle(matches[i].x, matches[i].y,					box.length, box[0].length));			Menu menu = getMenu(Areas.INVENTORY, 2000);			if (menu != null) {				if (menu.selectContains("Open")) {					doCube();				}			}		}	}	public void doCube() throws InterruptedException {		while (true) {			sleep(3000);			// What question			if (findText("What") != null) {				whatQuestion();			}			// Which question			else if (findText("Which") != null) {				whichQuestion();			}		}	}	public void whatQuestion() throws InterruptedException {		int shapeIndex = -1;		for (int shp = 0; shp < shapes.length; shp++) {			if (findText("" + shapes[shp]) != null) {				shapeIndex = shp;				break;			}		}		if (shapeIndex != -1) {			int options[] = new int[3];			int found = 0;			for (int num = 0; num < 10; num++) {				if (findText("" + num) != null) {					options[found] = num;					found++;					if (found == 3)						break;				}			}			if (found == 3) {				log("Which number is the " + shapes[shapeIndex]);				for (int option = 0; option < options.length; option++) {					log("     " + options[option]);				}				Timer t = new Timer(10000);				short[][][] colorMap = getValidGrab();				log("Took " + t.timePassed()						+ " ms to complete pup's pre-function ");				paintColorMap(colorMap, boxBounds.width+boxBounds.x, 0, 6000);				sleep(2000);			}		} else {			log("Could not determine the shape to find");		}	}	public short[][][] getValidGrab() throws InterruptedException {		while (true) {			sleep(defaultmaxAgeInMillisecs);			short[][][] colorMap = getColorArray2d();			// array			if (findRGBXYs(colorMap, 1, new RGB(16579837, RGB.COLOR_TYPE_SCAR),					new Rectangle(182, 45, 1, 180), 5, 5, 5).length > 0) {				continue;			}			if (findRGBXYs(colorMap, 1, new RGB(16579837, RGB.COLOR_TYPE_SCAR),					new Rectangle(342, 45, 1, 180), 5, 5, 5).length > 0) {				continue;			}			if (findRGBXYs(colorMap, 1, new RGB(16579837, RGB.COLOR_TYPE_SCAR),					new Rectangle(172, 55, 177, 1), null, 5, 5, 5).length > 0) {				continue;			}			if (findRGBXYs(colorMap, 1, new RGB(16579837, RGB.COLOR_TYPE_SCAR),					new Rectangle(172, 215, 177, 1), 5, 5, 5).length > 0) {				continue;			}			if (findRGBXYs(colorMap, 1, new RGB(12764106, RGB.COLOR_TYPE_SCAR),					new Rectangle(182, 45, 1, 180), 5, 5, 5).length > 0) {				continue;			}			if (findRGBXYs(colorMap, 1, new RGB(12764106, RGB.COLOR_TYPE_SCAR),					new Rectangle(342, 45, 1, 180), 5, 5, 5).length > 0) {				continue;			}			if (findRGBXYs(colorMap, 1, new RGB(12764106, RGB.COLOR_TYPE_SCAR),					new Rectangle(172, 55, 177, 1), 5, 5, 5).length > 0) {				continue;			}			if (findRGBXYs(colorMap, 1, new RGB(12764106, RGB.COLOR_TYPE_SCAR),					new Rectangle(172, 215, 1, 180), 5, 5, 5).length > 0) {				continue;			}			int width = boxBounds.width;			int length = boxBounds.height;			short[][][] result = new short[width][length][3];						for (int x = 0; x < width; x++) {				short[][] srcSlice = colorMap[x+boxBounds.x];				short[][] destSlice = result[x];				for (int y = 0; y < length; y++) {					destSlice[y][0] = srcSlice[y][0];					destSlice[y][1] = srcSlice[y][1];					destSlice[y][2] = srcSlice[y][2];				}			}			return result;		}	}	public void whichQuestion() throws InterruptedException {		int numerToFind = -1;		for (int num = 0; num < 10; num++) {			if (findText("" + num) != null) {				numerToFind = num;				break;			}		}		if (numerToFind != -1) {			int options[] = new int[3];			int found = 0;			for (int shp = 0; shp < shapes.length; shp++) {				if (findText("" + shapes[shp]) != null) {					options[found] = shp;					found++;					if (found == 3)						break;				}			}			if (found == 3) {				log("Which shape has a " + numerToFind);				for (int option = 0; option < options.length; option++) {					log("      " + shapes[options[option]]);				}				Timer t = new Timer(10000);				short[][][] colorMap = getValidGrab();				log("Took " + t.timePassed()						+ " ms to complete pup's pre-function ");				paintColorMap(colorMap, boxBounds.width+boxBounds.x, 0, 6000);				sleep(2000);			}		} else {			log("Could not determine the number to find");		}	}	public void findMatched(int x, int y, boolean bools[][],			short colors[][][], RGB color) {		if (!bools[x][y]) {			if (colors[x][y][0] == color.r && colors[x][y][1] == color.g					&& colors[x][y][2] == color.b) {				bools[x][y] = true;				findMatched(x + 1, y, bools, colors, color);				findMatched(x - 1, y, bools, colors, color);				findMatched(x, y + 1, bools, colors, color);				findMatched(x, y - 1, bools, colors, color);			}		}	}}