Skip 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.

[API Suggestion] PrincipalWind Positions of a Rectangular Area

Featured Replies

Not sure how many people are going to use this, but I found it useful in situations such as in NMZ where the Positions are dynamic and you may wanna go to the Northern position, etc

 

Also; probably a more efficient way to do this but w/e

 

Usage

DynamicArea da = new DynamicArea(myPlayer().getArea(2), bot.getMethods());
		
da.getPosition(PrincipalWind.NW);
da.getCenter();
da.getNorth();

 

 

Proof it works

https://puu.sh/uk5WF/e8db1ae028.png

https://puu.sh/uk5Ve/506102fa50.png

 

 

API (I named DynamicArea because of how i'm using it)

package com.polycoding.debugger;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.script.MethodProvider;

public class DynamicArea {

	private MethodProvider mp;

	private Area area;

	private int hiX, hiY, loX, loY, z;

	private int width, height;

	private LinkedList<Integer> allX = new LinkedList<Integer>(), allY = new LinkedList<Integer>();

	/**
	 * 
	 * @param area
	 *            A Rectangular org.osbot.rs07.api.map.Area to get PrincipalWind
	 *            positions from
	 * @param mp
	 *            MethodProvider
	 */
	public DynamicArea(Area area, MethodProvider mp) {
		this.mp = mp;
		this.area = area;
		this.z = area.getPlane();
		this.area.getPositions().stream().filter(p -> mp.map.canReach(p))
				.collect(Collectors.toList()).sort(((p1, p2) -> Integer
						.compare(mp.map.realDistance(p1), mp.map.realDistance(p2))));

		gatherAllXY();
	}

	public List<Position> getBoundingPositions() {
		return this.area.getPositions().stream().filter(
				p -> p.distance(getCenter()) == height / 2 || p.distance(getCenter()) == width / 2)
				.collect(Collectors.toList());

	}

	public Position getPosition(PrincipalWind pw) {
		switch (pw) {
		case E:
			return getEast();
		case N:
			return getNorth();
		case NE:
			return getNorthEast();
		case NW:
			return getNorthWest();
		case S:
			return getSouth();
		case SE:
			return getSouthEast();
		case SW:
			return getSouthWest();
		case W:
			return getWest();
		default:
			return null;
		}
	}

	public Position getCenter() {
		return new Position(hiX - (width / 2), hiY - (height / 2), z);
	}

	public Position getNorth() {
		return new Position(hiX - (width / 2), hiY, z);
	}

	public Position getSouth() {
		return new Position(hiX - (width / 2), loY, z);
	}

	public Position getWest() {
		return new Position(loX, hiY - (height / 2), z);
	}

	public Position getEast() {
		return new Position(hiX, hiY - (height / 2), z);
	}

	public Position getNorthEast() {
		return new Position(hiX, hiY, z);
	}

	public Position getNorthWest() {
		return new Position(loX, hiY, z);
	}

	public Position getSouthEast() {
		return new Position(hiX, loY, z);
	}

	public Position getSouthWest() {
		return new Position(loX, loY, z);
	}

	private void setHiLoX() {
		int size = allX.size();
		// The values should be sorted low->high, double checking
		if (allX.get(0) < allX.get(size - 1)) {
			loX = allX.get(0);
			hiX = allX.get(size - 1);
		}
	}

	private void setHiLoY() {
		int size = allY.size();
		// The values should be sorted low->high, double checking
		if (allY.get(0) < allY.get(size - 1)) {
			loY = allY.get(0);
			hiY = allY.get(size - 1);
		}
	}

	private void gatherAllXY() {
		this.area.getPositions().forEach(p -> {
			if (!allX.contains(p.getX())) {
				allX.add(p.getX());
			}
			if (!allY.contains(p.getY())) {
				allY.add(p.getY());
			}
		});
		setHiLoX();
		setHiLoY();
		width = hiX - loX;
		height = hiY - loY;
	}

	public enum PrincipalWind {
		N, NE, E, SE, S, SW, W, NW;
	}

}

 

If the areas aren't symmetrical, then something like getCenter() will be up to my personal preference of where I think it should be. 

  • Alek locked this topic
Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.