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.

Checking if certain Position or Area is clear

Featured Replies

Hey all, I am trying to figure something out and I really need to clear my head on this one probably lol.

 

How would I go around checking if a certain tile or area does NOT contain ANY NPC?

 

I've tried creating a Position list for the area, then looping through all these positions (I only use small area's, like 3x3), then grabbing a List of all local NPCs and checking for every Tile if none of those NPCs are on it.

    private boolean isAreaClear(Area area) {
        List<NPC> npcs = getNpcs();
        if (area == null) {
            return true;
        }
        List<Position> areaPos = area.getPositions(0);
        
        for (NPC npc : npcs) {
            for (Position pos : areaPos) {
                if (npc.getPosition().equals(pos)) {
                    return false;
                }
            }
        }
        return true;
    }
    
    private List<NPC> getNpcs() {
        List<NPC> list = new LinkedList<>();
        for (NPC npc : sC.npcs.getAll()) {
            if (npc.getDefinition() != null) {
                search:
                {
                    if(npc.getDefinition().getName() != null){
                    	String name = npc.getDefinition().getName();
                        if (name.equalsIgnoreCase("bandit")) {
                            list.add(npc);
                            break search;
                        }
                    }
                }
            }
        }
        return list;
    } 

I don't remember exact OSBot API, but something like this should work (this is one of several ways to do it):

//TODO add whatever null checks are needed...
public boolean NpcInArea(Area area) {
  for (NPC npc : npcs.getAll()) {
    if (area.contains(npc))
      return true;
  }

  return false;
}

Edited by Eliot

  • Author

 

I don't remember exact OSBot API, but something like this should work (this is one of several ways to do it):

//TODO add whatever null checks are needed...
public boolean NpcInArea(Area area) {
  for (NPC npc : npcs.getAll()) {
    if (area.contains(npc))
      return true;
  }

  return false;
}

 

Thank you, apparantly I was overcomplicating things again..

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.