All pastes #567335 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-06-14 23:07 UTC
rendered paste body
import impsoft.nexus.bots.color.ColorBot;
import impsoft.nexus.bots.color.scriptable.*;
import impsoft.nexus.bots.color.scriptable.components.*;
import impsoft.nexus.bots.color.scriptable.components.bottom.*;
import impsoft.nexus.bots.color.scriptable.components.gamescreen.*;
import impsoft.nexus.bots.color.scriptable.components.minimap.*;
import impsoft.nexus.bots.color.scriptable.components.tab.*;
import impsoft.nexus.bots.color.scriptable.interfaces.*;
import impsoft.nexus.bots.color.scriptable.objects.*;
import impsoft.nexus.bots.color.structures.*;
import impsoft.nexus.bots.color.util.*;
import impsoft.nexus.bots.reflection.objects.*;
import impsoft.nexus.bots.reflection.scriptable.components.*;
import impsoft.nexus.bots.reflection.structures.*;
import java.awt.event.KeyEvent;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

public class MonkCurser extends ColorScript implements AutoPaint
{
	public static String[] commands = new String[] { "Curse" };
	public static String author = "Ainokea";
	public static String description = "zammy monk curser for usa";
	public static double version = 1.1;
	
	//The settings bellow do it every so many minutes.
	//usage - random(minmum, max);
	//How many minute to rotate the screen.
	int rotateScreenEvery = random(25,40);
	//How many minutes to random right click
	int randomRightClickEvery = random(20,35);
	//How many minutes to hoover over a skiil.
	int hoverSkillEvery = random(45,60);
	
	//1000 ms = 1 second
	//Minmum wait between casts.(ms)
	int minWait = 750;
	//Maximum wait between casts.(ms)
	int maxWait = 1250;
	//amount of casts to do
	int CastsToDo = 500;
	
	Rectangle curseRectangle = new Rectangle(666,256,13, 13 );
	AryanTile monkArea = new AryanTile(3214, 3476);
	Curser Curser = new Curser(this);
	Stairs Stairs = new Stairs(this);
	Timer Hover = new Timer(0);
	Timer RClick= new Timer(0);
	Timer Rotate= new Timer(0);
	int casts = 0;
	long startTime = System.currentTimeMillis();
	long Time1= System.currentTimeMillis();
	long Time2= System.currentTimeMillis();
	long Time3= System.currentTimeMillis();
	ColorBot b5;
	
	public MonkCurser(ColorBot b)
	{
		super(b);
		b5 = b;
	}

	public void script() throws InterruptedException
	{
		theCompass.setEast();
		debug("Setting Compass East");
		while(true)
		{
			if(getLocation().distanceTo(monkArea) <= 10)
			{
				if(getLocation().distanceTo(monkArea) <= 2)
				{
					debug(CastsToDo);
					debug(casts);
					if(CastsToDo > casts)
					{
						if(inFight())
						{
							debug("Fight Found");
							if(isFight())
							{
								new AryanPath(new AryanTile(3212,3463),this);
								sleep(random(1500,2500));
								new AryanPath(monkArea,this).walkToEnd();
								sleep(random(1250,2000));
							}
						}
						if(!theTopText.isTopTextContaining("Cast"))
						{
							debug("Top Text Not Containing Cast > Selecting Spell");
							stopRandom("MouseMover");
							curse();
							startRandom("MouseMover");
						}
						if(Curser.attack())
						{
							debug("Attacked Monk");
							casts++;
							debug("Sleeping");
							sleep(random(minWait,maxWait));
							debug("Checking For AntiBan..");
							AntiBan();
						}
					}
					else
					{
						debug("Done");
						theLoggedInTest.logOut();
						stopAllRandoms();
						b5.theScriptManager.stopScript();
						log("Completed "+casts+" Curses");
						
					}
				}
				else
				{
					new AryanPath(monkArea,this).walkToEnd();
				}
			}
		}
	}
	
	public void walkUpStairs() throws InterruptedException
	{
		AryanTile stairs = new AryanTile(3213,3472);
		AryanTile upStairs = new AryanTile(3213,3476);
		new AryanPath(stairs,this).walkToEnd();
		while(getLocation().distanceTo(upStairs) > 1)
		{
			Stairs.upStairs();
			sleep(random(2000,3500));
		}
	}
	
	public void walkDownStairs() throws InterruptedException
	{
		AryanTile downStairs = new AryanTile(3213,3472);
		while(getLocation().distanceTo(downStairs) > 1)
		{
			Stairs.downStairs();
			sleep(random(2000,3500));
		}
		
	}
	
	/*
	* isFight()
	* @author SRL (java convert by Ainokea)
	*/
	public boolean isFight() throws InterruptedException
	{
		if (inFight())
		{
			sleep(random(1000, 1250));
			return inFight();
		}
		return false;
	}
	/*
	 * inFight()
	 * @Ainokea
	 */
	public boolean inFight()throws InterruptedException
	{
		XY[] hpbars = theHPBars.getHPBarsOnGameScreen();
		Rectangle searchZone = new Rectangle(230, 130, 280 - 230, 180 - 130);
		for(int x =0; x<hpbars.length; x++)
		{
			if(searchZone.contains(hpbars[x].x, hpbars[x].y))
			{
				return true;
			}
		}
		return false;
	}
	
	public void paint(Graphics g)
	{
		g.setColor(Color.red);
		g.drawString("Monk Curser For USA!", 9, 30);
		g.setColor(Color.white);
		g.drawString("Time Running "+TimeRunning() , 9, 41);
		g.drawString("Aprox. Cast Done: " + casts+" / "+CastsToDo, 9, 52);
		g.drawString("Aprox. Exp Gained: "+casts * 29, 9, 63);
	}
	//time running in miliseconds
	private int getMili()
	{
		long mili = System.currentTimeMillis() - startTime;
		return (int)mili;
	}

	//return time in seconds
	private int getSeconds()
	{
		int seconds = getMili() / 1000;
		return seconds;
	}

	//return time in minutes
	private int getMinutes(long time)
	{
		long mili = System.currentTimeMillis() - time;
		int seconds = (int) mili / 1000;
		int minutes;
		if (seconds > 59)
		{
			minutes = seconds / 60;
		}
		else
		{
			minutes = 0;
		}
		return minutes;
	}
	
	//return time in minutes
	private int getMinutes()
	{
		int seconds = getSeconds();
		int minutes;
		if (seconds > 59)
		{
			minutes = seconds / 60;
		}
		else
		{
			minutes = 0;
		}
		return minutes;
	}

	//Time running in minutes and seconds
	public String TimeRunning()
	{
		int seconds = getSeconds();
		int minutes = getMinutes();
		if (seconds > 59)
		{
			int remMinutes = seconds % 60;
			return (+minutes + " Minutes and " + remMinutes + " Seconds");
		}
		else
		{
			return ("0 Minutes and " + seconds + " Seconds");
		}
	}
	public void curse() throws InterruptedException
	{
		if(!theTabs.Magic.isSelected())
		{
			theTabs.Magic.setSelected();
			sleep(random(100,200));
		}
		mouseClickLeft(curseRectangle);
		sleep(random(300,400));
	}

	/* AntiBan
	 * Calls HoverSkill, Random Right Click, and Roate Screen. In Timer increments.
	 */
	public void AntiBan()throws InterruptedException
	{
		int ranHover = random(0,11);
		if(getMinutes(Time1) >= hoverSkillEvery)
		{
			debug("[AntiBan]Hover Skill ");
			if(ranHover >= 5)
			{
				HoverSkill("magic");
			}
			else
			{
				HoverSkill("random");
			}
			Time1 = System.currentTimeMillis();
		}
		else if(getMinutes(Time2) >= randomRightClickEvery)
		{
			RandomRClick();
			debug("[AntiBan] Random Right Click");
			Time2 = System.currentTimeMillis();
		}
		else if(getMinutes(Time3) >= rotateScreenEvery)
		{
			RotateScreen();
			debug("[AntiBan] Rotate Screen");
			Time3 = System.currentTimeMillis();
		}
	}
	
	/* HoverSkill
	 * Hovers mouse over the selected skill.
	 * @author SRl (java convert Ainokea)
	 */
	public void HoverSkill(String Skill) throws InterruptedException
	{
		theTabs.Statistics.setSelected();
		stopRandom("MouseMover");
		String skill = Skill.toLowerCase();
		int row = 0;
		int col = 0;
		if(skill.contains("attack"))
		{
			row = 1;
			col = 1;
		}
		else if(skill.contains("strength"))
		{
			row = 2;
			col = 1;
		}
		else if(skill.contains("defence"))
		{
			row = 3;
			col = 1;
		}
		else if(skill.contains("range"))
		{
			row = 4;
			col = 1;
		}
		else if(skill.contains("prayer"))
		{
			row = 5;
			col = 1;
		}
		else if(skill.contains("magic"))
		{
			row = 6;
			col = 1;
		}
		else if(skill.contains("runecraft"))
		{
			row = 7;
			col = 1;
		}
		else if(skill.contains("hitpoints"))
		{
			row = 1;
			col = 2;
		}
		else if(skill.contains("agility"))
		{
			row = 2;
			col = 2;
		}
		else if(skill.contains("herblore"))
		{
			row = 3;
			col = 2;
		}
		else if(skill.contains("thieving"))
		{
			row = 4;
			col = 2;
		}
		else if(skill.contains("crafting"))
		{
			row = 5;
			col = 2;
		}
		else if(skill.contains("fletching"))
		{
			row = 6;
			col = 2;
		}
		else if(skill.contains("slayer"))
		{
			row = 7;
			col = 2;
		}
		else if(skill.contains("smithing"))
		{
			row = 2;
			col = 3;
		}
		else if(skill.contains("mining"))
		{
			row = 1;
			col = 3;
		}
		else if(skill.contains("fishing"))
		{
			row = 3;
			col = 3;
		}
		else if(skill.contains("cooking"))
		{
			row = 4;
			col = 3;
		}
		else if(skill.contains("firemaking"))
		{
			row = 5;
			col = 3;
		}
		else if(skill.contains("woodcutting"))
		{
			row = 6;
			col = 3;
		}
		else if(skill.contains("farming"))
		{
			row = 7;
			col = 3;
		}
		else if(skill.contains("construction"))
		{
			row = 8;
			col = 1;
		}
		else if(skill.contains("hunter"))
		{
			row = 8;
			col = 2;
		}
		else if(skill.contains("random"))
		{
			row = random(0,8) + 1;
			col = random(0,3) + 1;
		}
		else
		{
			row = random(0,8) + 1;
			col = random(0,3) + 1;
		}
		mouseMove(new Rectangle(532 + (64 * col), 191 + (31 * row), 10, 10));
		sleep(random(5000,10000));
		startRandom("MouseMover");
	}
	/* RandomRClick
	 * Randomly right clicks some where on the rs screen
	 * @author SRL (java convert Ainokea)
	 */
	public void RandomRClick() throws InterruptedException
	{
		switch (random(0, 7))
		{
			case 0: mouseClickRight(rectangleFromScar(533, 7, 757, 200));
					sleep(random(600, 900));

			case 1: mouseClickRight(rectangleFromScar(521, 3, 553, 496));
					sleep(random(600, 900));

			case 2: mouseClickRight(rectangleFromScar(743, 3, 764, 497));
					sleep(random(600, 900));

			case 3: mouseClickRight(rectangleFromScar(4, 467, 763, 498));
					sleep(random(600, 900));

			case 4: mouseClickRight(rectangleFromScar(499, 343, 552, 496));
					sleep(random(600, 900));

			case 5: mouseClickRight(rectangleFromScar(3, 343, 521, 355));
					sleep(random(600, 900));

			case 6: mouseClickRight(rectangleFromScar(2, 346, 14, 499));
					sleep(random(600, 900));
		}
	}
	
	/* Rotate Screen
	 * Randomly rotates the camera in one direction.
	 * @author SRL (java convert Ainokea)
	 */
	public void RotateScreen() throws InterruptedException
	{
		int key = random(0, 3);
		stopRandom("MouseMover");
		if (key == 0)
		{
			SendKey(KeyEvent.VK_UP, 500 + random(100, 500));
		}
		else if (key == 1)
		{
			SendKey(KeyEvent.VK_RIGHT, 500 + random(100, 500));
		}
		else if (key == 2)
		{
			SendKey(KeyEvent.VK_LEFT, 500 + random(100, 500));
		}
		sleep(random(200, 500));
		startRandom("MouseMover");
		theCompass.setEast();
		sleep(random(100,200));
	}
	
	public Rectangle rectangleFromScar(int x1, int y1, int x2, int y2)
	{
		return new Rectangle(x1, y1, x1-x2, y2-y1);
	}
	class Stairs extends RGBCluster
	{
		public Stairs(ColorScript c)
		{
			super(new RGB[] {new RGB(107,95,60), new RGB(117,103,67),new RGB(136,121,76)}, c);
		}
		
		public boolean upStairs() throws InterruptedException
		{
			gatherNewPoints(5);
			return 	doTopTextAndMenu("up","up");
		}
		
		public boolean downStairs() throws InterruptedException
		{
			setBounds(new Rectangle(173,179, 100, 75));
			gatherNewPoints(10);
			return 	doTopTextAndMenu("down","down");
		}
	}
	class Curser extends RGBCluster 
	{
		public Curser(ColorScript c)
		{
			super(new RGB[]{new RGB(73,28,26), new RGB(86, 33, 31)}, c);
		}
		public boolean attack() throws InterruptedException 
		{
			gatherNewPoints(5);
			sortPointsByDistanceToXY(new XY(262,190));
			XY[] thePoints = getPoints() ;
			for(int x =0; x< thePoints.length;x++)
			{
				mouseMove(thePoints[x]);
				sleep(random(400,650));
				if(theTopText.isTopTextContaining("Monk"))
				{
					mouseClickLeft(getCurrentMouseXY());
					return true;
				}
			}
			return false;
		}
	}
}