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.

Rune Essence Portal Interaction (NPC and Object). SOLVED

Featured Replies

Previous thread: 

So it seems as if the portal in the rune essence mine changes types from object to NPC to whatever. I'm having trouble implementing a solution for this.

I've used some of the ideas explored in the previous thread, but my understanding is still weak.

I originally wanted to filter through both objects and NPCs but Chris told me this wasn't possible.

Instead he suggested for me to add both types to a list then filter through them.

// Is this the correct way of creating and adding to a list?

// Create
List <Object> portals = new ArrayList<>();

//Add
portals.add(getObjects().getAll().stream().filter(object -> object.getName().contains("Portal")).findAny());

//Add
portals.add(getNpcs().getAll().stream().filter(object -> object.getName().contains("Portal")).findAny());

I'm not sure how to interact with the list of type Object. I was thinking of  iterating through the list checking if the object was present, then interacting with it, but you can't interact unless the list is <Entity> not <Object>. If the list is <Entity> it's difficult to add to it...

Basically... I have no idea what I'm doing, and I need some more assistance :).

It should be common knowledge now, but in case it's forgotten, I take a while to learn, so pls be patient :).

EDIT

Read the 4th post for the solution.

Edited by Lexhanatin
Solved


		NPC portalNpc = null;
		RS2Object portalObj = null;
		int portalNpcDist = Integer.MAX_VALUE;
		int portalObjDist = Integer.MAX_VALUE;
		Entity portalEntity;
		
		// Find objects
		portalNpc = npcs.closest("Portal");
		portalObj = objects.closest("Portal");
		
		// Check if either NPC or OBJ is valid
		if (portalNpc != null || portalObj != null) {
			
			// Calculate distance to NPC
			if (portalNpc != null) {
				portalNpcDist = map.distance(portalNpc);
			}
			
			// Calculate distance to OBJ
			if (portalObj != null) {
				portalObjDist = map.distance(portalObj);
			}
			
			// Check distance
			// Note: NPC or OBJ may be null
			if (portalNpcDist < portalObjDist) {
				// NPC is closer
				portalEntity = portalNpc;
			} else {
				// OBJ is same distance/closer
				portalEntity = portalObj;
			}
			
			// Finally, check portal
			if (portalEntity != null) {
				// Interact
				if (portalEntity.interact("Exit")) {
					// TODO: Conditional sleep
				}
			}
		}

 

  • Author

@liverare

Not sure why nothing is being detected.

Screenshot_8.png

Edit:

It works sometimes, but when nothing is detected it just stalls.

Edited by Lexhanatin
Added extra info.

  • Author

I found the problem in @liverare solution.

Simply the portals name isn't "Portal". Extra tags are added to the name preventing the below code from working.

portalNpc = npcs.closest("Portal");
portalObj = objects.closest("Portal");

Instead partial matching should be used instead.

portalNpc = getNpcs().closestThatContains("Portal");
portalObj = getObjects().closestThatContains("Portal");

This will always find a portal.

 

The second problem in the solution was the implementation of distance.

The current instance of portal would be of type NPC or Object, but when comparing distances, another instance was deemed closer. This would prevent interaction.

A possible reason for this could be that the current portal instance was being compared to a previous instances distance. I'm not sure.

I fixed this by taking out the distance comparison. Below is the find product.

private void bank() throws InterruptedException { 
    log("Bank method");
    if (getObjects().closest("Rune Essence") != null) {
      log("Rune Essence Exists");
      portalNpc = getNpcs().closestThatContains("Portal");
      portalObj = getObjects().closestThatContains("Portal");

      if (portalNpc != null || portalObj != null) {
        log("Entity not null");
        if (portalNpc != null) {
          log("Portal is NPC");
          portalEntity = portalNpc;
        }

        if (portalObj != null) {
          log("Portal is Object");
          portalEntity = portalObj;
        }
        if (portalEntity != null) {
          log("Portal Interaction");
          if (portalEntity.interact("Exit", "Use")) {
            new ConditionalSleep(8000) {
              @Override
                public boolean condition() throws InterruptedException {
                return !myPlayer().isMoving();
              }
            }.sleep();
          }
        }
      }
      else {
        log ("Entity null");
      }
    }

 

I would like to thank everyone for helping me solve this problem over the week. Hopefully this thread will help people with similar problems in the future.

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.