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.

Any way to get NPC ID while in dialogue?

Featured Replies

Hello.

 

Is there a way to get an NPC's ID while in dialogue with them? Or at least their name?

 

Thanks

if(dialogue#inDialogue())
check id / name / index of npc

Something like that

Edited by Psvxe

  • Author
if(dialogue#inDialogue())
check id / name / index of npc

Something like that

 

 

Yes, but that's the problem. I don't know how to check the NPC ID. Also, the API is down for me, so I can't look it up.

Yes, but that's the problem. I don't know how to check the NPC ID. Also, the API is down for me, so I can't look it up.

check your message.

Hello.

 

Is there a way to get an NPC's ID while in dialogue with them? Or at least their name?

 

Thanks

Well, thought about something like this, pretty sure there are better ways of doing this;

		if (getDialogues().inDialogue()) {
			for (NPC npc : getNpcs().getAll()) {
				if (npc != null && npc.getName().equals("NPC NAME HERE") && npc.getInteracting() != null && npc.isInteracting(myPlayer())) {
					return npc.getId();
				}
			}
		}

Edited by iJodix

  if(ctx.getDialogues.inDialogue()){
        NPC n = ctx.npcs.closest(new Filter<NPC>() {
             @Override
             public boolean match(NPC npc) {
                 return ctx.myPlayer().isInteracting(npc);
             }
         });
            //do whatever you want. (n.getName())
       }
ctx is my MethodProvider.

I didn't test the code nor do I exactly know what the isInteracting() method does. However you should be close. Of course there are better ways doing this but for now it will work.

Or what the guy above me used! biggrin.png

Edited by Psvxe

  if(ctx.getDialogues.inDialogue()){
        NPC n = ctx.npcs.closest(new Filter<NPC>() {
             @Override
             public boolean match(NPC npc) {
                 return ctx.myPlayer().isInteracting(npc);
             }
         });
            //do whatever you want. (n.getName())
       }
ctx is my MethodProvider.

I didn't test the code nor do I exactly know what the isInteracting() method does. However you should be close. Of course there are better ways doing this but for now it will work.

Or what the guy above me used! biggrin.png

 

isinteracting returns true if you're interacting or false ff not

isinteracting returns true if you're interacting or false ff not

Yeah i get that part but could you define what counts as interacting? like everything?

The API does not provide any method to obtain information about the npc you are in a dialogue with at any given moment. There are 3 methods you can use to determine the npc although all of them have exceptions.

 

1. Get the npc you are interacting with (easiest)

myPlayer().getInteracting().getId();

Works when you click on the npc and your player starts moving towards the npc as well as for 1 tick after each response from the npc. You could use this to determine the id before the actual dialogue.

 

2. Find the npc that is interacting with you (least reliable)

npcs.getAll().stream().filter(n -> n.getInteracting() == myPlayer()).findFirst().get().getId();

The npc should be interacting with you for 1 tick after each response from you. The main issue here is that other people might attempt to start dialogues with same npc leading to undefined behaviour.

 

3. Extract npc name from dialogue widget and then search for the npc (most reliable)

npcs.getAll().stream().filter(n -> n.getName().equals(widgets.get(WIDGET_COORDINATES).getMessage())).findFirst().get().getId();

Where WIDGET_COORDINATES represents the ids of the npc name widget on your dialogue interface. The only drawback of this method is that you can only obtain the id of the npc once they are the ones talking.

 

You can also filter the npcs using the API Filter class if you don't like lambda expressions:

npcs.closest(new Filter<NPC>() {
    @Override
    public boolean match(NPC n) {
        return n.getInteracting() == myPlayer();
    }
}).getId();

That's pretty much all you can do with the API right now, the main issue being that npc interaction is not a continuous thing, at least not for dialogues. It is continuous for instance if you are safespotting an npc and that npc keeps trying to reach your player but they can't. In this case, that npc will be interacting with your player. But anyway, there is absolutely no need for the npc id you are in dialogue with so we don't really have a method that provides that 100% accurate result.

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.