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.

OSBot 2: isVisible?

Featured Replies

Hi, what is the method for checking if an RS2Object is on screen? I previously used isVisible() but it is no longer in the OSBot 2 API.

 

Thanks!

Purr purr, i've seen this thread many times.


GraphicUtilities.MAIN_SCREEN_CLIP.contains(Calculations.getBoundingBox(this, npc.getModel(), npc.getGridX(), npc.getGridY()).getBounds())

 /**
     * Gets bounding box of model.
     *
     * @param methodProvider - the ATMethodProvider instance.
     * @param model          - the model.
     * @param gridX          - the map grid 'x' position.
     * @param gridY          - the map grid 'y' position.
     * @return the bounding box of model.
     */
    public static Polygon getBoundingBox(ATMethodProvider methodProvider, Model model, int gridX, int gridY) {
        if (model == null) {
            return new Polygon();
        }
        short[][] screenCoordinates = GraphicUtilities.getScreenCoordinates(methodProvider.bot, gridX, gridY, methodProvider.client.accessor.getPlane(), model);
        Polygon temp = new Polygon();

        int minX = Integer.MAX_VALUE;
        int minY = Integer.MAX_VALUE;
        int maxX = 0;
        int maxY = 0;
        for (int triangleId = 0; triangleId < model.getTriangleCount(); triangleId++) {
            int triangleA = model.getVertexXIndices()[triangleId];
            int triangleB = model.getVertexYIndices()[triangleId];
            int triangleC = model.getVertexZIndices()[triangleId];

            short[] pointA = screenCoordinates[triangleA];
            short[] pointB = screenCoordinates[triangleB];
            short[] pointC = screenCoordinates[triangleC];
            if (pointA != null && pointB != null && pointC != null) {
                int aX = pointA[0];
                int aY = pointA[1];

                int bX = pointB[0];
                int bY = pointB[1];

                int cX = pointB[0];
                int cY = pointB[1];

                if (aX < minX) {
                    minX = aX;
                }
                if (bX < minX) {
                    minX = bX;
                }
                if (cX < minX) {
                    minX = cX;
                }

                if (aY < minY) {
                    minY = aY;
                }
                if (bY < minY) {
                    minY = bY;
                }
                if (cY < minY) {
                    minY = cY;
                }
                //maxes

                if (aX > maxX) {
                    maxX = aX;
                }
                if (bX > maxX) {
                    maxX = bX;
                }
                if (cX > maxX) {
                    maxX = cX;
                }

                if (aY > maxY) {
                    maxY = aY;
                }
                if (bY > maxY) {
                    maxY = bY;
                }
                if (cY > maxY) {
                    maxY = cY;
                }

            }
        }
        temp.addPoint(minX, minY);
        temp.addPoint(minX + (maxX - minX), minY);
        temp.addPoint(maxX, maxY);
        temp.addPoint(minX, maxY);
        return temp;
    }

I have only been scripting a few hours but here is what I used for my door.

 

Entity Door = objects.closest("Door");
if(Door != null && Door.exists()) {
camera.toEntity(Door);
}

Edited by Freak

I have only been scripting a few hours but here is what I used for my door.

Entity Door = objects.closest("Door");

if(Door != null && Door.exists()) {

camera.toEntity(Door);

}

this doesn't check if it is visible ^_^
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.