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.

Mouse Handler

Featured Replies

 
 
import java.util.Random;

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.input.mouse.EntityDestination;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.Condition;
import org.osbot.rs07.utility.ConditionalSleep;

public class MouseHandler {
	/**
	 * I tried to keep hovering and delaying away form each other. 
	 */	
	public static final int SECOND = 1000;	
	public static final int MINUTE = 60 * SECOND;
	
	private Script sI;
	private Random random = new Random();
	
	private boolean multiclicking; 
	private boolean hovering; 
	private boolean delay;		
	
	private long lastUpdated = System.currentTimeMillis();
	private long lastChecked = System.currentTimeMillis();
	private long shouldUpdate = -1;
	
	//add in the string name (OSBot username) boolean so our character has a little profile.
	public MouseHandler(Script sI)	{
		this.sI = sI;
		this.delay = random.nextBoolean(); //shouldAllow(name);
		this.hovering = delay ? false: random.nextBoolean();
		this.multiclicking = random.nextBoolean();
		this.shouldUpdate = this.randomUpdate();
	}
	
	public boolean shouldAllow(String name)	{
		return name.length() % 2 == 0;
	}
	
	public int randomDelay()	{
		return MethodProvider.gRandom(8, 7) * SECOND;
	}
	
	public int randomUpdate()	{
		return MethodProvider.gRandom(40, 20) * MINUTE;
	}
	
	public boolean useDelay()	{
		if (!this.delay)	{	return true;	}
		else{
			new ConditionalSleep(randomDelay())	{
				@Override
				public boolean condition() throws InterruptedException {
					return false;
				}
			}.sleep();
			return true;
		}
	}
	
	public boolean hoverEntity(Entity entity)	{
		if (!hovering)	{
			return true;
		}else{
			if (entity != null)	{
				return entity.hover();
			}else{
				return true;
			}
		}
	}
	
	public boolean multiclicking(Entity entity, final boolean condition)	{
		if (!multiclicking)	{	return true;	}
		else{
			if (entity != null)	{
				return sI.mouse.continualClick(new EntityDestination(sI.bot, entity), 
					new Condition()	{
						@Override
						public boolean evaluate() {
							return condition;
					}});
			}else{
				return true;
			}
		}		
	}
	
	public long getTimeLeft()	{
		long time = this.shouldUpdate - (System.currentTimeMillis() - this.lastUpdated);
		return time > 0 ? time: -1;
	}
	
	public void update()	{
		if (System.currentTimeMillis() - this.lastChecked > MINUTE)	{
			this.lastChecked = System.currentTimeMillis();
			if (getTimeLeft() < 0)	{
				this.hovering = random.nextBoolean();
				this.delay = hovering ? false: random.nextBoolean();
				this.multiclicking = random.nextBoolean();
				this.lastUpdated = System.currentTimeMillis();
				this.shouldUpdate = this.randomUpdate();				
			}
		}
	}
	
	public boolean allowHovering()	{
		return this.hovering;
	}
	
	public boolean allowDelay()	{
		return this.delay;
	}
	
	public boolean allowMulticlicking()	{
		return this.multiclicking;
	}
}

 

Edited by josedpay

Guest
This topic is now closed to further replies.

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.