All pastes #348526 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-02-10 05:52 UTC
rendered paste body
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.io.File;

import javax.swing.JOptionPane;

import impsoft.nexus.bots.color.constants.Areas;
import impsoft.nexus.bots.color.constants.Info;
import impsoft.nexus.bots.color.methods.ColorScript;
import impsoft.nexus.bots.color.scriptobjects.RGB;
import impsoft.nexus.components.paint.PaintJob;

public class lardMiner extends ColorScript {
	rsObject rock;

	@Override
	public String getAuthor() {
		return "Lardmaster";
	}

	@Override
	public String getDescription() {
		return "A very advanced Powerminer that you hopefully bought. \n";
	}

	public boolean bugme = true; // **do you want to ensure the script

	// works?**

	private long time;

	private int mineTime;

	@SuppressWarnings("unused")
	private boolean paintDebug;

	private bitmapMask oreMask;

	// startup?

	@Override
	public boolean doStart(String arg0, String[] arg1)
			throws InterruptedException {
		time = System.currentTimeMillis();
		if (bugme)
			mineTime = Integer
					.parseInt(JOptionPane
							.showInputDialog("Max wait time after clicking without getting ore?"));
		else
			mineTime = random(3000, 4000);
		if (bugme)
			paintDebug = (JOptionPane.showConfirmDialog(null,
					"Show debug rectangles? (interferes if on  ibot lite)",
					"Debug Q", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION);
		else
			paintDebug = false;
		PaintJob pj = new PaintJob() {
			private long start = System.currentTimeMillis();

			@Override
			public boolean timeUp() {
				return start + 10000 < System.currentTimeMillis();
			}

			@Override
			public void paint(Graphics g) {
				Rectangle r = rock.findOne();
				g.setColor(new Color(255, 255, 255));
				g.drawRect(r.x, r.y, r.width, r.height);
			}

		};
		RGB[][] picture = LardMethods.convertShort(loadBitmap("bitmaps/iron1.bmp"));
		rock = new rsObject(this, "Rock", picture, new Rectangle(0, 0,
				picture.length - 10, picture[0].length - 10), new Rectangle(0,
				0, picture.length + 10, picture[0].length + 10));
		picture = LardMethods.convertShort(loadBitmap("bitmaps/iron2.bmp"));
		rock.add(picture);
		LardMethods.convertShort(loadBitmap("bitmaps/iron3.bmp"));
		rock.add(picture);
		oreMask = new bitmapMask(LardMethods.convertShort(loadBitmap("bitmaps/oremask.bmp")));
		if (!rock.clickOne("mine")) {
			log("Rock finding method not working, quitting");
			log("this is where i thought the rock was:");
			addPaintJob(pj);
			mouseClickLeft(Areas.MINI_MAP_CENTER);
			return false;
		} else {
			mouseClickLeft(Areas.MINI_MAP_CENTER);
			log("we located a rock at this location:");
			addPaintJob(pj);
			if (bugme)
				if (JOptionPane.showConfirmDialog(null,
						"Is the Drawn rectangle a rock?",
						"Checking Rockfinding", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
					log("couldnt find rock at startup... according to you...");
					return false;
				}
			log("Script started, and ready to go!");
			return true;
		}
	}

	@Override
	public void script() throws InterruptedException {
		int invcount;
		while (time + 7200 < System.currentTimeMillis()) {
			while (inventoryCount() < 28) {
				if (messups > 10) {
					log("***messing up too many times, exiting to avoid bannage***");
					return;
				}
				invcount = inventoryCount();
				mine();
				long marker = System.currentTimeMillis();
				while (inventoryCount() == invcount
						&& marker + mineTime < System.currentTimeMillis())
					sleep(random(250, 1200));

			}
			dropOres();
		}
	}

	PaintJob pj2 = new PaintJob() {
		private long start = System.currentTimeMillis();

		@Override
		public boolean timeUp() {
			return start + 1000 < System.currentTimeMillis();
		}

		@Override
		public void paint(Graphics g) {
			Rectangle r = rock.findOne(4);
			g.setColor(new Color(255, 255, 255));
			g.drawRect(r.x, r.y, r.width, r.height);
		}

	};

	private int messups = 0;

	private void mine() {
		if (rock.clickOne("Mine")) {
			addPaintJob(pj2);
			log("clicked a rock");
			messups = 0;
			return;
		} else {
			log("rock click falure");
			addPaintJob(pj2);
			messups++;
		}
	}

	public void dropOres() throws InterruptedException {
		for (int i = 0; i < 28; i++)
			if (itemExist(i))
				if (oreMask.find(getColorArray2d(), Info
						.getInventoryRectangle(i)) != null) {
					mouseMove(Info.getInventoryRectangle(i));
					if (getTopText().contains("ore")) {
						mouseClickRight(theBot.mouse_x, theBot.mouse_y);
						if (!getMenu(Areas.INVENTORY, random(300, 400))
								.selectContains("Drop"))
							getMenu(Areas.INVENTORY, random(300, 400))
									.selectContains("xit");
					}
				}
	}
}