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.

Polygon Area (not finished yet!)

Featured Replies

so i'm making a script with a combat location in an odd shapped room and a rectangle won't work so i deiced to make a little class to for a polygon area

 

 

-edit was rewritten by guy below me.

import java.awt.Polygon;
import org.osbot.script.rs2.map.Position;
import org.osbot.script.rs2.model.Entity;

public class PolygonArea 
{
    Polygon polygon;

PolygonArea(Position... positions)
{
polygon = new Polygon();
addPositions(positions);
}

    public boolean containsEntity(Entity e) 
{
        return polygon.contains(e.getX(), e.getY());
    }

    public static void addPositions(Position... positions) 
{
for (Position pos : positions)
{
polygon.addPoint(pos.getX(), pos.getY());
}
    }
}

How to use

PolygonArea polygonArea = new PolygonArea(positionsArray);
Check for entities in the area with this (NPC, Player, GroundItems, etc):
if (polygonArea.containsEntity(entity))
{
//do method
}

i still need to make a method to return the center of the polygon but i will touch on that later

 

Edited by TheScrub

This is very useful, great work! I think you could probably simplify it a bit, and remove some of the dependencies like this:

import java.awt.Polygon;
import org.osbot.script.rs2.map.Position;
import org.osbot.script.rs2.model.Entity;

public class PolygonArea 
{
    Polygon polygon;

    PolygonArea(Position... positions)
    {
        polygon = new Polygon();
        addPositions(positions);
    }

    public boolean containsEntity(Entity e) 
    {
        return polygon.contains(e.getX(), e.getY());
    }

    public void addPositions(Position... positions) 
    {
        for (Position pos : positions)
        {
            polygon.addPoint(pos.getX(), pos.getY());
        }
    }
}

How to use

PolygonArea polygonArea = new PolygonArea(positionsArray);

Check for entities in the area with this (NPC, Player, GroundItems, etc):

if (polygonArea.containsEntity(entity))
{
//do method
}

Edited by bfir3

  • Author

 

This is very useful, great work! I think you could probably simplify it a bit, and remove some of the dependencies like this:

import java.awt.Polygon;
import org.osbot.script.rs2.map.Position;
import org.osbot.script.rs2.model.Entity;

public class PolygonArea 
{
    Polygon polygon;

    PolygonArea(Position... positions)
    {
        polygon = new Polygon();
        addPositions(positions);
    }

    public boolean containsEntity(Entity e) 
    {
        return polygon.contains(e.getX(), e.getY());
    }

    public static void addPositions(Position... positions) 
    {
        for (Position pos : positions)
        {
            polygon.addPoint(pos.getX(), pos.getY());
        }
    }
}

How to use

PolygonArea polygonArea = new PolygonArea(positionsArray);

Check for entities in the area with this (NPC, Player, GroundItems, etc):

if (polygonArea.containsEntity(entity))
{
//do method
}

 

thanks i just wrote it for a single thing only used it once or twice thanks i will update the thread with ur revision of the code!

 

  • 5 months later...

You should inherit the Area class and override most/all of its methods to make it functional for a polygon-based region. This will ensure your PolygonArea instances can be applied to methods within the MethodProvider class that accept Area parameters.

  • Author

You should inherit the Area class and override most/all of its methods to make it functional for a polygon-based region. This will ensure your PolygonArea instances can be applied to methods within the MethodProvider class that accept Area parameters.

 

this snippet is pretty old and is only used by me in osbot 2 related stuff as the api doesn't contain an AREA class

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.