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.

HHumanSimulator | Simple task delay manager

Featured Replies

What is this? A class which manages timers for delayed actions in a script with a fancy name including SIMULATOR!

Why is it useful? Ease of implementation.

Flaws? It can only be treated as one timer at a time and can not track multiple delays at a time unless the code is expanded.

 

This is pretty meh but its useful and maybe someone will find it useful when they start out scripting.

 

In tasks such as smithing or other highly afk tasks i think that reaction time to notice inventory completion is important to simulate human like behavior to reduce bans. This sort of "anti-ban" if they even do anything helps break patterns that could be detectable, then again if you have a shitty method to interact with things in the world then it won't save you.

Also note that humans are not as random as you think they are and everyone has habits!

 

[updated using suggestions by @PolishCivil]

public class HHumanSimulator {

	//Default time in seconds to wait.
	private static final int default_min_reaction_time = 5;
	private static final int default_max_reaction_time = 15;
	//While active the script will be idle.
	private static boolean active = false;
	//Time is saved in milliseconds in here every time a new simulation start.
	private static long start_time;
	//The randomly generated wait time in milliseconds in stored here.
	private static long current_reaction_time;

	//Check if you can do the task.
	public static boolean check() {
		if (!active) {
			start_time = System.currentTimeMillis();
			current_reaction_time = randomReactionTime(default_min_reaction_time, default_max_reaction_time);
			active = true;
		}
		if (System.currentTimeMillis() - start_time > current_reaction_time)
			active = false;
		return !active;
	}
	
	//Same as above however this method lets you add your own custom times rather than default.
	public static boolean check(int new_min_reaction_time, int new_max_reaction_time) {
		if (!active) {
			start_time = System.currentTimeMillis();
			current_reaction_time = randomReactionTime(new_min_reaction_time, new_max_reaction_time);
			active = true;
		}
		if (System.currentTimeMillis() - start_time > current_reaction_time)
			active = false;
		return !active;
	}
	
	//Same as above however lets you set a % chance for it to trigger or not.
	public static boolean check(int new_min_reaction_time, int new_max_reaction_time, int trigger_chance) {
		if (!active && trigger(trigger_chance)) {
			start_time = System.currentTimeMillis();
			current_reaction_time = randomReactionTime(new_min_reaction_time, new_max_reaction_time);
			active = true;
		}
		if (System.currentTimeMillis() - start_time > current_reaction_time)
			active = false;
		return !active;
	}
	
	//Returns a boolean based on a % chance.
	private static boolean trigger(int chance) {
		int rand = ThreadLocalRandom.current().nextInt(101);
		return rand <= chance;
	}

	//Returns the time left till simulation is done.
	public static long debugTimeLeft() {
		return current_reaction_time - (System.currentTimeMillis() - start_time);
	}

	//Generates a random long between two values.
	private static long randomReactionTime(int min, int max) {
		int random_reaction_time = ThreadLocalRandom.current().nextInt((max - min) + 1) + min;
		return random_reaction_time * 1000L;
	}

}

Example Usage:

		if (!inventory.contains(gold_bar_id)) {
			if (HHumanSimulator.check(5, 15, 50))
				GoldSmither.setState(State.BANK);
			return;
		}

Edited by House

Seeing that you have to place poll(5, 15); inside of a loop for it to properly work, it seems like a lot of code per action just to execute a random wait.

 

 

Edited by Abuse

  • Author

Seeing that you have to place poll(5, 15); inside of a loop for it to properly work, it seems like a lot of code per action just to execute a random wait.

 

The point is its straight forward.

The point is its straight forward.

Change this:

			HHumanSimulator.poll(5, 15);
			HHumanSimulator.reactionSimulationDone();

To this

			HHumanSimulator.check(5, 15);

And it will be 3x better.

Create an account or sign in to comment

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.