tivo444 Posted March 22, 2016 Share Posted March 22, 2016 Hello. Is there a way to get an NPC's ID while in dialogue with them? Or at least their name? Thanks Quote Link to comment Share on other sites More sharing options...
Psvxe Posted March 22, 2016 Share Posted March 22, 2016 (edited) if(dialogue#inDialogue()) check id / name / index of npc Something like that Edited March 22, 2016 by Psvxe Quote Link to comment Share on other sites More sharing options...
tivo444 Posted March 22, 2016 Author Share Posted March 22, 2016 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. Quote Link to comment Share on other sites More sharing options...
Psvxe Posted March 22, 2016 Share Posted March 22, 2016 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. Quote Link to comment Share on other sites More sharing options...
iJodix Posted March 22, 2016 Share Posted March 22, 2016 (edited) 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 March 23, 2016 by iJodix Quote Link to comment Share on other sites More sharing options...
Psvxe Posted March 22, 2016 Share Posted March 22, 2016 (edited) 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! Edited March 22, 2016 by Psvxe Quote Link to comment Share on other sites More sharing options...
Goaks Posted March 23, 2016 Share Posted March 23, 2016 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! isinteracting returns true if you're interacting or false ff not Quote Link to comment Share on other sites More sharing options...
Psvxe Posted March 23, 2016 Share Posted March 23, 2016 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? Quote Link to comment Share on other sites More sharing options...
Token Posted March 23, 2016 Share Posted March 23, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...