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.

isCharacterFacing(Character<?> character, RS2Object object)

Featured Replies

Quickly wrote this, feel free to improve!

Precision: 45°

You could probably calculate the angle much more precisely, I'll maybe give that a shot another time ^^

public static boolean isCharacterFacing(Character<?> character, Position position) {
		
		int rotation = character.getRotation();
		Position charPos = character.getPosition();
		int xDiff = charPos.getX() - position.getX();
		int yDiff = charPos.getY() - position.getY();
		
		// Character position equals position.
		if (xDiff == 0 && yDiff == 0) {
			return false; 
		}
		
		// Position is east of character.
		if (xDiff < 0) {
			if (rotation < 1024) {
				return false;
			}
		}
		// Position is west of character.	
		else if (xDiff > 0) {
			if (rotation > 1024) {
				return false;
			}
		}
		// Position is on the same vertical axis.
		else {
			// Position is exactly south of character.
			if (yDiff > 0) {
				return rotation < 256 || rotation > 1792;
			}
			// Position is exactly north of character.
			else {
				return rotation > 762 && rotation < 1286;
			}
		}
		
		// Position is south of character.
		if (yDiff > 0) {
			if (rotation > 512 && rotation < 1536) {
				return false;
			}
		}
		// Position is north of character.
		else if (yDiff < 0) {
			if (rotation < 512 || rotation > 1536) {
				return false;
			}
		}
		// Position is on the same horizontal axis.
		else {
			// Position is exactly east of character.
			if (xDiff < 0) {
				return rotation > 1286 && rotation < 1792;
			}
			// Position is exactly west of character.
			else {
				return rotation > 256 && rotation < 762;
			}
		}
		
		return true;
	}
	
	public static boolean isCharacterFacing(Character<?> character, RS2Object object) {
		return isCharacterFacing(character, object.getPosition());
	}

Edited by Botre

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.