Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Iron Powerminer

Featured Replies

hi dis my 1st script ever so if anything is wrong let me know (you can change the rock id to copper/tin aswell)

credits to @Vilius and @Keven for helping

 

also this does not have antiban or gui , only paint

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.concurrent.TimeUnit;

import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "assnerd", info = "mines iron ore and drops em for you", name = "ironore powerminer for leechers", version = 69, logo = "")
public class PowerMiner extends Script {
	private long timeBegan;
	private long timeRan;

	String state = "IdleIdle"; // first state

	@Override
	public void onStart() {
		timeBegan = System.currentTimeMillis();
		getExperienceTracker().startAll();
		log("enjoy this you leecher");
	}

	private enum State {
		MINEMINE, DROPDROP, SLEEPSLEEP // the 3 states
	};

	private State getState() {
		RS2Object rock = getObjects().closest(13446); // gets nearest objects of the ID (change them if they get updated)
		if (inventory.isFull()) // checks if inventory is full
			return State.DROPDROP;
		if (rock != null && !myPlayer().isAnimating()) // checks if rock is visible and if character (your player) is not animating
			return State.MINEMINE;
		return State.SLEEPSLEEP;
	}

	@Override
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		case MINEMINE:
			state = "MineMine"; // changes state to MineMine
			log("mine mine motherfucker"); // rofl
			RS2Object rock = getObjects().closest(13446); // gets nearest objects of the ID (change them if they get updated)
			if (rock != null) { // checks if rock is visible
				rock.interact("Mine"); // mines the rock 
				sleep(random(1000, 3000));
			}
			break;
		case DROPDROP:
			state = "DropDrop"; // changes state to DropDrop
			log("drop drop motherfucker"); // rofl
			inventory.dropAllExcept(getInventory().filter(item -> item.getName().contains("pickaxe"))); // will drop everything in the inventory except pickaxes
			break;
		case SLEEPSLEEP:
			state = "SleepSleep"; // changes state to SleepSleep
			log("sleep sleep motherfucker"); // rofl
			sleep(random(500, 1500));

			break;
		}
		return random(400, 600);
	}

	@Override
	public void onExit() {
		log("perish you degenerate");
	}

	@Override
	public void onPaint(Graphics2D g) {
		timeRan = System.currentTimeMillis() - this.timeBegan;
		g.setColor(Color.GREEN); // this makes the paint text green
		g.drawString("RUNTIME: " + (ft(timeRan)), 15, 50); // this prints out runtime
		g.drawString("XP/HR(" + getExperienceTracker().getGainedXPPerHour(Skill.MINING) + ")", 15, 65); // this prints out xp/hr
		g.drawString("STATE: " + state, 15, 80); // this prints out state

	}

	private String ft(long duration) {
		String res = "";
		long days = TimeUnit.MILLISECONDS.toDays(duration);
		long hours = TimeUnit.MILLISECONDS.toHours(duration)
				- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
		long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
				- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration));
		long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
				- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration));
		if (days == 0) {
			res = (hours + ":" + minutes + ":" + seconds);
		} else {
			res = (days + ":" + hours + ":" + minutes + ":" + seconds);
		}
		return res;
	}
}

Edited by Assnerd

vouch for acerd

 

 

doesn't seen to be filled with pesky rats

ran this on my almost 2277 account, banned nearly instantly. thx a lot fgt emote3.png

Simpler time formatting -

	/**
	 * Gets the accumulated session time.
	 * 
	 * @return
	 * 		Formated session time.
	 */
	public String getAccumulatedTime() {
		final long cachedTime = (System.currentTimeMillis() - startTime);
		
		return String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(cachedTime), (TimeUnit.MILLISECONDS.toMinutes(cachedTime) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(cachedTime))), (TimeUnit.MILLISECONDS.toSeconds(cachedTime) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(cachedTime))));
	}

If you want a decent Antiban implementation here's one I wrote -

package org.osb.fishing.antiban;

import org.osb.fishing.Greyfish;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.input.mouse.EntityDestination;
import org.osbot.rs07.script.MethodProvider;

import static org.osbot.rs07.script.MethodProvider.random;

import java.util.Collections;
import java.util.List;

/**
 * Enumerated type holding Antiban pattern functions.
 * 
 * @author Dustin Greyfield
 */
public enum AntibanFunction implements PolicyExecutor {

	SELECT_RANDOM_TAB {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getTabs().open(Tab.values()[random(Tab.values().length)]);
			Greyfish.sleep(random(600, 1000));
			
		}
	},
	
	SELECT_SKILL_TAB_HOVER {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getTabs().open(Tab.SKILLS);
			Greyfish.sleep(random(1200, 2000));
			greyfish.getWidgets().get(320, SkillWidget.getRandomChildId());
			
		}
	},
	
	SELECT_MAGIC_TAB_HOVER {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getTabs().open(Tab.MAGIC);
			Greyfish.sleep(random(1200, 2000));
			greyfish.getWidgets().get(218, MethodProvider.random(64)).hover();
			
		}
	}, 
	
	TOGGLE_EXP_COUNTER {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			if (!greyfish.getWidgets().interact(160, 1, "Show"))
				greyfish.getWidgets().interact(160, 1, "Hide");
				
		}
	},
	
	EXAMINE_RANDOM_NPC {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			if (!greyfish.getNpcs().getAll().isEmpty()) {
				final List<NPC> arrayCopy = greyfish.getNpcs().getAll();
				Collections.shuffle(arrayCopy);
				
				for (final NPC npc : arrayCopy) {

					if (npc.getPosition().distance(greyfish.myPosition()) > 4)
						continue;
					
					npc.examine();
					return;
				}
			}
		}
	},
	
	MOUSE_RANDOM_NPC {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			if (!greyfish.getNpcs().getAll().isEmpty()) {
				final List<NPC> arrayCopy = greyfish.getNpcs().getAll();
				Collections.shuffle(arrayCopy);
				
				for (final NPC npc : arrayCopy) {

					if (npc.getPosition().distance(greyfish.myPosition()) > 4)
						continue;
					
					final EntityDestination dest = new EntityDestination(greyfish.getBot(), arrayCopy.get(0));
					greyfish.getMouse().move(dest);
					return;
				}
			}
		}
	},
	
	MOVE_MOUSE_RANDOMLY {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getMouse().moveRandomly();
			
		}
	},
	
	EXAMINE_RANDOM_OBJECT {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			if (!greyfish.getObjects().getAll().isEmpty()) {
				final List<RS2Object> arrayCopy = greyfish.getObjects().getAll();
				Collections.shuffle(arrayCopy);
				
				for (final RS2Object obj : arrayCopy) {

					if (obj.getPosition().distance(greyfish.myPosition()) > 4)
						continue;
					
					obj.examine();
					return;
				}
			}
		}
	},
	
	MOUSE_RANDOM_OBJECT {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			if (!greyfish.getObjects().getAll().isEmpty()) {
				final List<RS2Object> arrayCopy = greyfish.getObjects().getAll();
				Collections.shuffle(arrayCopy);
				
				for (final RS2Object obj : arrayCopy) {

					if (obj.getPosition().distance(greyfish.myPosition()) > 4)
						continue;
					
					final EntityDestination dest = new EntityDestination(greyfish.getBot(), arrayCopy.get(0));
					greyfish.getMouse().move(dest);
					return;
				}
			}
		}
	},
	
	ROTATE_SCREEN_YEW_HALF {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getCamera().moveYaw(MethodProvider.random(15, 160));
			
		}
	},
	
	ROTATE_SCREEN_YEW_RANDOM {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getCamera().moveYaw(MethodProvider.random(15, 320));
			
		}
	},
	
	ROTATE_SCREEN_YEW_LARGE {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getCamera().moveYaw(MethodProvider.random(120, 320));
			
		}
	},
	
	CHANGE_SCREEN_PITCH_HALF {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getCamera().movePitch(random(15, 36));
			
		}
	},
	
	CHANGE_SCREEN_PITCH_LARGE {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getCamera().movePitch(MethodProvider.random(30, 67));
			
		}
	},
	
	CHANGE_SCREEN_PITCH_RANDOM {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			greyfish.getCamera().movePitch(MethodProvider.random(5, 67));
			
		}
	},
	
	MOVE_SCREEN_RANDOMLY {
		@Override
		public void execute(Greyfish greyfish) throws InterruptedException {
			
			ROTATE_SCREEN_YEW_RANDOM.execute(greyfish);
			Greyfish.sleep(random(500, 1200));
			CHANGE_SCREEN_PITCH_RANDOM.execute(greyfish);
			
		}
	};
	
	/**
	 * Enumerated type constructor.
	 * 
	 * @param policyExecutor
	 * 		The {@code PolicyExecutor} instance.
	 */
	private AntibanFunction() { }
	
	/**
	 * Selects a random function based on the size of the enumeration.
	 * 
	 * @return
	 * 		{@code AntibanFunction}.
	 */
	public static AntibanFunction selectRandom() {
		
		return values()[random(values().length)];
	}
}
package org.osb.fishing.antiban;

import org.osb.fishing.Greyfish;

/**
 * Functional interface used for executing an anti-ban task.
 * 
 * @author Dustin Greyfield
 */
public interface PolicyExecutor {

	/**
	 * Executes the anti-ban function.
	 * @throws InterruptedException 
	 */
	public void execute(final Greyfish greyfish) throws InterruptedException;
	
}
package org.osb.fishing.antiban;

import org.osbot.rs07.script.MethodProvider;

/**
 * A generic enumeration type containing skills.
 * This will be added onto later.
 * 
 * @author Dustin Greyfield
 */
public enum SkillWidget {
	
	ATTACK,  
	
	DEFENCE,
	
	STRENGTH, 
	
	HITPOINTS,
	
	RANGE, 
	
	PRAYER,
	
	MAGIC,
	
	COOKING, 
	
	WOODCUTTING, 
	
	FLETCHING, 
	
	FISHING, 
	
	FIREMAKING, 
	
	CRAFTING,
	
	SMITHING,
	
	MINING, 
	
	HERBLORE, 
	
	AGILITY, 
	
	THIEVING, 
	
	SLAYER, 
	
	FARMING,
	
	RUNECRAFTING, 
	
	HUNTER, 
	
	CONSTRUCTION;
	
	public static int getRandomChildId() {
		
		return (values()[MethodProvider.random(values().length)].ordinal());
	}	
}

 

Then for example usage -

	/**
	 * Decouples the {@code #onLoop()} method by splitting antiban functions
	 * from the main script logic.
	 */
	private void cycleAntiban() throws InterruptedException {
		
		if (random(3) < 1)
			AntibanFunction.MOVE_MOUSE_RANDOMLY.execute(this);
		
		if (random(10) < 1)
			AntibanFunction.MOVE_SCREEN_RANDOMLY.execute(this);
		
		if (random(25) < 1 && sessionState == SessionState.FISHING) {
			AntibanFunction.selectRandom().execute(this);
			sleep(random(400, 700));
		}
	}

Ran this script and now all my items have disappeared from my bank? Is this a feature of your script? emote3.png

 

hi dis my 1st script ever so if anything is wrong let me know (you can change the rock id to copper/tin aswell)

credits to @Vilius and @Keven for helping

 

also this does not have antiban or gui , only paint

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.concurrent.TimeUnit;

import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "assnerd", info = "mines iron ore and drops em for you", name = "ironore powerminer for leechers", version = 69, logo = "")
public class PowerMiner extends Script {
	private long timeBegan;
	private long timeRan;

	String state = "IdleIdle"; // first state

	@Override
	public void onStart() {
		timeBegan = System.currentTimeMillis();
		getExperienceTracker().startAll();
		log("enjoy this you leecher");
	}

	private enum State {
		MINEMINE, DROPDROP, SLEEPSLEEP // the 3 states
	};

	private State getState() {
		RS2Object rock = getObjects().closest(13446); // gets nearest objects of the ID (change them if they get updated)
		if (inventory.isFull()) // checks if inventory is full
			return State.DROPDROP;
		if (rock != null && !myPlayer().isAnimating()) // checks if rock is visible and if character (your player) is not animating
			return State.MINEMINE;
		return State.SLEEPSLEEP;
	}

	@Override
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		case MINEMINE:
			state = "MineMine"; // changes state to MineMine
			log("mine mine motherfucker"); // rofl
			RS2Object rock = getObjects().closest(13446); // gets nearest objects of the ID (change them if they get updated)
			if (rock != null) { // checks if rock is visible
				rock.interact("Mine"); // mines the rock 
				sleep(random(1000, 3000));
			}
			break;
		case DROPDROP:
			state = "DropDrop"; // changes state to DropDrop
			log("drop drop motherfucker"); // rofl
			inventory.dropAllExcept(getInventory().filter(item -> item.getName().contains("pickaxe"))); // will drop everything in the inventory except pickaxes
			break;
		case SLEEPSLEEP:
			state = "SleepSleep"; // changes state to SleepSleep
			log("sleep sleep motherfucker"); // rofl
			sleep(random(500, 1500));

			break;
		}
		return random(400, 600);
	}

	@Override
	public void onExit() {
		log("perish you degenerate");
	}

	@Override
	public void onPaint(Graphics2D g) {
		timeRan = System.currentTimeMillis() - this.timeBegan;
		g.setColor(Color.GREEN); // this makes the paint text green
		g.drawString("RUNTIME: " + (ft(timeRan)), 15, 50); // this prints out runtime
		g.drawString("XP/HR(" + getExperienceTracker().getGainedXPPerHour(Skill.MINING) + ")", 15, 65); // this prints out xp/hr
		g.drawString("STATE: " + state, 15, 80); // this prints out state

	}

	private String ft(long duration) {
		String res = "";
		long days = TimeUnit.MILLISECONDS.toDays(duration);
		long hours = TimeUnit.MILLISECONDS.toHours(duration)
				- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
		long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
				- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration));
		long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
				- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration));
		if (days == 0) {
			res = (hours + ":" + minutes + ":" + seconds);
		} else {
			res = (days + ":" + hours + ":" + minutes + ":" + seconds);
		}
		return res;
	}
}

 

 

Awesome job on your first script!

Not issues or anything like that, just possible ways you could improve your code smile.pngsmile.png

 

1) That ft method hurts my fucking eyes doge.png  This is a bit cleaner:

public String formatTime(long ms){

    long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24;
    s %= 60; m %= 60; h %= 24;

    return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s)
                 : String.format("%02d:%02d:%02d", h, m, s);
}

2) You don't need to store timeRan in a global variable because it has no use anywhere else in the code, other than where it is calculated.

 

3) For the state you don't need to store a String value in a variable for output. You can simply override the toString() method in the enum, for example:

private enum State {
    
    MINE,
    DROP,
    SLEEP;

    @Override
    public String toString(){

        char[] nameArr = name().toLowerCase().toCharArray();
        nameArr[0] = Character.toUpperCase(nameArr[0]);
        return new String(nameArr);
    }
}

Then it can be used like:

g.drawString("STATE: " + getState().toString(), 15, 80); // this prints out state

4) You have done:

getExperienceTracker().startAll();

Considering you are only using one skill (Mining), you should call:

getExperienceTracker().start(Skill.MINING);

Edited by Explv

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.