All pastes #416380 Raw Edit

Anonymous

public java v1 · immutable
#416380 ·published 2007-03-30 07:02 UTC
rendered paste body
import impsoft.nexus.bots.color.constants.Areas;import impsoft.nexus.bots.color.methods.ColorRandom;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.bots.core.interfaces.CoreRandom;import java.awt.Rectangle;public class Yellowtext extends ColorRandom {	public static double version = 1;	public String author = "GenoDemoN, ruler";	public String description = "finds yellow text with you name and talks to NPC centered underneath";	private String formatedUserName;	private XY userNameOnScreen;	@Override	public boolean startUp() {		if (!theBot.loggedIn) {			formatedUserName = null;			setNextCheck(3000);			return false;		} else {			if (formatedUserName == null) {				if (theBot.theHandler.getUsername().length() < 5) {					error("STOP player username not found, please enter it in user/pass tab");					deActivateRandom();				}				formatedUserName = formatword(theBot.theHandler.getUsername());			}			userNameOnScreen = findGameScreenText(formatedUserName, Areas.GAME,					new RGB(255, 255, 1), 1, 1, 1);			if (userNameOnScreen != null) {				warn("found name onscreen!");				return true;			}			setNextCheck(600);			return false;		}	}	private String formatword(String username) {		username = username.toLowerCase();		int index = 0;		index = username.indexOf(" ", index);		while (index != -1) {			String front = username.substring(0, index);			String middle = username.substring(index, index + 2);			String back = username.substring(index + 2, username.length());			username = (front + middle.toUpperCase() + back);			index = username.indexOf(" ", index + 2);		}		if (username.length() > 1) {			String front = username.substring(0, 1);			String back = username.substring(1, username.length());			username = front.toUpperCase() + back;		}		return username.replaceAll(" ", "   ").replaceAll(".", " ");	}	@Override	public void random() throws InterruptedException {		Rectangle textLine = new Rectangle(Areas.GAME.x,				userNameOnScreen.y - 1, Areas.GAME.width, 20);		short[][][] currentGame = getColorArray2d(1000);		XY startOfTextOnScreen = findXYspiral(currentGame,				new RGB(255, 255, 1), textLine, textLine.x, textLine.y, 1,				1, 1);		XY endOfTextOnScreen = findXYspiral(currentGame,				new RGB(255, 255, 1), textLine, textLine.x+textLine.width, textLine.y, 1,				1, 1);		if (startOfTextOnScreen != null && endOfTextOnScreen != null) {			String textTheNPCSaid = getGameScreenText(0, userNameOnScreen.y, 1,					new RGB(255, 255, 1));			if (textTheNPCSaid != null) {				log("NPC said: " + textTheNPCSaid);				if (textTheNPCSaid.toLowerCase().indexOf(						"think I forgot about you") != -1) {					log("Molly found");					for (CoreRandom cr : getColorBot().getCoreRandomManager()							.getRandomHandlers()) {						if (cr.getClass().getName().contains("Sand")) {							cr.random();						}					}					return;				}			}			XY CenterOfText = new XY(startOfTextOnScreen.x					+ (endOfTextOnScreen.x - startOfTextOnScreen.x) / 2,					userNameOnScreen.y);			for (int i = 0; i < 10; i++) {				for (int y = CenterOfText.y; y < (Areas.GAME.y + Areas.GAME.height); y += random(						7, 16)) {					mouseMove(CenterOfText.x + random(-10, 10), y, 500);					sleep(defaultmaxAgeInMillisecs);					if (getTopText().contains("alk")) {						mouseClickRight(currentMouseX(), currentMouseY());						Menu menu = getMenu(Areas.GAME, 2000);						if(menu!=null){							if(!menu.selectContains("alk")){								menu.exit();							}						}						sleep(950);						log("Found NPC and iniciated talking");						NPCChat chat;						while ((chat = getNPCChat(2000)) != null) {							mouseClickLeft(chat.locations[chat.locations.length - 1]);							sleep(1000);						}						return;					}				}			}		}	}}