Jump to content

Clay Miner


Aeonx

Recommended Posts

Hey guys, just sharing one script I've made really quick, it Mines clay in West Varrock, then banks it. After x clay, it trades mule standing in West Bank Area.

 

 

Might help someone biggrin.png

import java.awt.*;
import java.lang.String;
import java.text.Normalizer;

import org.osbot.rs07.api.Bank;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Tab;

import javax.swing.*;

@ScriptManifest(author = "YourName", info = "Miner", name = "Miner", version = 0, logo = "")
public class main extends Script {

	// Areas
	private final Area WEST_VARROCK_BANK = new Area(3185, 3439, 3182, 3433);
	private final Area WEST_MINING_ZONE = new Area(3182, 3378, 3184, 3377);
	private final Area TRADING_AREA = new Area(3185, 3437, 3181, 3434);
	
	private enum State {
		CHECK, MINE, BANK, GRAB_LOAD, TRADE, UNLOAD
	}

	private Window window;

	private State state = State.GRAB_LOAD;
	private boolean isRunning = false;

	private int runs, cooldown, clayNum, world;
	private long elapsed;


	private void Check() throws InterruptedException {

		if(worlds.getCurrentWorld() != world) {
			worlds.hop(world); return;
		}


		if(inventory.isFull()) {
			
			if(tabs.getOpen() != Tab.INVENTORY) {
				tabs.open(Tab.INVENTORY);
			}
			
			if(!WEST_VARROCK_BANK.contains(myPlayer())) {
				RandomSleep();
				MoveToZone(WEST_VARROCK_BANK);
			}

			state = State.BANK;
			
		} else {

			if(!WEST_MINING_ZONE.contains(myPlayer())) {
				RandomSleep();
				MoveToZone(WEST_MINING_ZONE);
			}

			state = State.MINE;
		}
	}
	
	private void Mine() throws InterruptedException {


		RS2Object node = objects.closest(WEST_MINING_ZONE, 7454);
		
		if(node != null) {
			
			if(!node.isVisible()) {
				camera.toEntity(node); sleep(450, 850);
			}
			node.hover(); sleep(10, 25);
			
			if(node.interact("Mine")) {
				RandomizeMouse(); sleep(850, 1250);
				
				while(myPlayer().isAnimating() && node.exists()) sleep(50);
				sleep(250, 450);
			}
		}

		state = State.CHECK;
	}
	
	private void Bank() throws InterruptedException {
		
		if(!bank.isOpen()) {
			
			RS2Object bankx = objects.closest("Bank booth");
			
			if(bankx != null) {
				
				if(!bankx.isVisible()) {
					camera.toEntity(bankx); sleep(650, 1250);
				}
				
				if(bankx.interact("Bank")) {
					sleep(2450, 3250); RandomizeMouse(); RandomSleep();
				}
			}

			return;
		}
		else {
			if(!bank.depositAllExcept(1271)) return;

			runs++;
			sleep(450, 650); RandomizeMouse(); RandomSleep();

			if(runs >= cooldown) {
				bank.enableMode(Bank.BankMode.WITHDRAW_NOTE);
				sleep(250, 500); RandomizeMouse();

				sleep(1250, 1850);
				bank.withdrawAll(434); RandomSleep();
			}

			bank.close(); sleep(1250, 1850);
		}

		if(runs >= cooldown) {
			runs = 0;
			cooldown = random(16, 32);

			state = State.TRADE;
		}
		else {
			state = State.CHECK;
		}
	}

	private void GrabLoad() throws InterruptedException {
	log("load");
	}

	private void Trade() throws InterruptedException {

		if(isTrading()) {
			state = State.UNLOAD;
		}
		else {
			if(getWorlds().getCurrentWorld() != 308) {
				worlds.hop(308); sleep(8*1000, 14*1000);
				return;
			}


			if(!TRADING_AREA.contains(myPlayer())) {
				MoveToZone(TRADING_AREA);
				return;
			}


			Player player = players.closest("YourMuleName");

			if(player != null) {
				if(!player.isVisible()) camera.toEntity(player);
				sleep(1850, 3450);

				player.hover(); sleep(100, 350);

				if(player.interact("Trade with")) {
					sleep(450, 650); RandomizeMouse(); sleep(4500, 6500);
				}
			}
		}
	}

	private void Unload() throws InterruptedException {

		if(isTrading()) {

			if(trade.isFirstInterfaceOpen()) {
				if(!trade.offer(435, inventory.getItem(435).getAmount())) return;

				sleep(450, 850);
				RandomizeMouse(); RandomSleep();

				trade.acceptTrade(); sleep(150, 300); RandomizeMouse();
				while(isTrading() && !trade.didOtherAcceptTrade());
			}

			if(trade.isSecondInterfaceOpen()) {
				RandomSleep();

				trade.acceptTrade(); sleep(150, 300); RandomizeMouse();
				while(isTrading() && !trade.didOtherAcceptTrade());
			}


			return;
		}

		state = State.CHECK;
	}

	
	
    @Override
    public int onLoop() throws InterruptedException {

    	switch(state) {
    		
	    	case CHECK:
	    		log("State: Check");
	    		Check();
	    		break;
	    		
	    	case MINE:
	    		log("State: Mine");
	    		Mine();
	    		break;
	    		
	    	case BANK:
	    		log("State: Bank");
	    		Bank();
	    		break;

			case GRAB_LOAD:
				log("State: Grab Load");
				GrabLoad();
				break;

			case TRADE:
				log("State: Trade");
				Trade();
				break;

	    	case UNLOAD:
				log("State: Unload");
	    		Unload();
	    		break;
    	}
    	
        return random(150, 200);
    }
 
    @Override
    public void onStart() {
		//String input = getClass().getResource("talk").getFile();
		//File file = new File(input);
		isRunning = true;

    	cooldown = random(18, 32);
		world = worlds.getCurrentWorld();




		Thread runTimeThread = new Thread() {

			@Override
			public void run() {
				try {
					RunTime();
				}
				catch (Exception e) {
					log(e.getMessage());
				}
			}
		};

		runTimeThread.start();
    }
    
    @Override
    public void onExit() {
		isRunning = false;
    }

    @Override
    public void onPaint(Graphics2D g) {
    	
    	int x = getMouse().getPosition().x;
    	int y = getMouse().getPosition().y;
    			 
    	g.drawLine(0, y, 765, y);
    	g.drawLine(x, 0, x, 503);

		DrawUpdate(g);
	}


	private void DrawUpdate(Graphics2D g) {

		g.setColor(new Color(0, 0, 0, 80));
		g.fillRect(4, 280, 512, 58);

		g.setColor(Color.white);
		g.setFont(new Font("Consolas", Font.PLAIN, 12));
		g.drawString("RunTime: " + GetRunTime(), 14, 300);

		g.drawString("Clay collected: " + clayNum, 170, 300);
	}

	private void RunTime() throws InterruptedException {

		long startTime = System.currentTimeMillis();

		while(isRunning) {
			elapsed = (System.currentTimeMillis() - startTime);
			sleep(1000);
		}
	}

	private void LaunchGUI() {

	}

	private void CloseGUI() {

	}



	private void sleep(int min, int max) throws InterruptedException {
		sleep(random(min, max));
	}

	private String GetRunTime() {

		long hours = (elapsed / (1000 * 60 * 60)) % 24;
		long minutes = (elapsed / (1000 * 60)) % 60;
		long seconds = (elapsed / 1000) % 60;

		return String.format("%02d:%02d:%02d", hours, minutes, seconds);
	}




	@SuppressWarnings("deprecation")
	private void MoveToZone(Area zone) throws InterruptedException {

		walking.webWalk(zone.getRandomPosition());
	}

	private boolean isTrading() {
		return trade.isCurrentlyTrading();
	}

    private boolean isInRadius(NPC npc) {
    	Player me = myPlayer();
    	
    	int x = me.getX(),
    		y = me.getY();
    	
    	return new Area(x + 1, y + 1, x - 1, y - 1).contains(npc);
    }
    
    private void RandomizeMouse() {
    	switch(random(0, 5)) {
    	case 0:
    		mouse.moveRandomly();
    		break;
    	case 1:
    		mouse.moveOutsideScreen();
    		break;
    	case 2:
    		mouse.moveSlightly();
    		break;
    	}
    }
    
    private void RandomSleep() throws InterruptedException {

    	switch(random(0, 5)) {
    	case 0:
    		sleep(650, 1250);
    		break;
    		
    	case 1:  
    		sleep(1450, 2050);
    		break;
    		
    	case 2: 
    		sleep(2250, 2850);
    		break;
    		
    	case 3:
    		sleep(3050, 3850);
    		break;
    	}
    }
}
Edited by Aeonx
  • Like 1
Link to comment
Share on other sites

Very nice, I like the whole mule idea so that you can just mass farm and try to keep it all hidden and let the accounts just get banned.

Good job!

Thanks man! Yeah it's great, just make an army of accounts that way and bans have no much meaning, profit biggrin.png

Edited by Aeonx
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...