How to check if player is in dialogue?

Post » Mon Nov 19, 2012 4:42 pm

Since isinmenumode doesn't work for dialogue. I'm trying to figure out how to check this.
  • player.istalking() doesn't compile (says its not a function)
  • player.getdialoguetarget() always returns none for the player (according to the wiki)
  • To make isindialougewithplayer work I would have to know who is talking to the player.
  • All the is__ControlEnabled() functions don't work
  • Even tried some animation variable checks out of desperation.
This has to be possible right? Any help with this would be appreciated.
User avatar
Laura Shipley
 
Posts: 3564
Joined: Thu Oct 26, 2006 4:47 am

Post » Mon Nov 19, 2012 9:30 pm

I'm not sure it is possible, on the player.

The player is hardly ever in Dialogue as there are no speeches for the player, it's just clicking an item in a menu.

... NPCs go into Dialogue mode (when they speak to the player) but I am not at all sure the player goes into the same mode?
User avatar
Casey
 
Posts: 3376
Joined: Mon Nov 12, 2007 8:38 am

Post » Mon Nov 19, 2012 5:20 pm

IsMovementControlsEnabled should at least work.

Very frustrating...

Thanks for the reply.
User avatar
Jonny
 
Posts: 3508
Joined: Wed Jul 18, 2007 9:04 am

Post » Mon Nov 19, 2012 11:27 am

There is no "elegant" way of doing it, but it can be done.

You need a seperate quest (Say MonitoringQuest) with a single optional alias assigned using "Find Matching Reference [X] In Loaded Area" withMatch condition set to "IsInDialogueWithPlayer". Add a Stage 0 marked as Start up [X] and add a script fragment that checks the alias

If you just need an immediate check, you could add a Quest Script with a Bool or even use a GlobalVariable:


Spoiler

(self As Quest) As SomeQuestScript).IsInDialogue = (SomeAlias && SomeAlias.GetActorRef()

Mark the Stage 0 as [X] Completes Quest.

Then from you main quest, inject the Monitoring Quest like so:


Spoiler

MonitoringQuest.Start()if (MonitoringQuest As SomeQuestScript).IsInDialogue;;;Do StuffendifMonitoringQuest.Stop()

Notice how I start and stop the quest before and after the check. Aliases are only filled when quests begin.

If you also need a reference to the Person the player is talking to:

MonitoringQuest.GetAlias(0).GetActorRef()

Should work until you call Stop()

If you want to know any time the player enters dialogue in general (and with whome), your second quest will have to continually poll the monitoring quest.

You could do it all from the Main Quest:

Spoiler

Event OnUpdate()  MonitoringQuest.Start()  ReferenceAlias NPCRef = MonitoringQuest.GetAlias(0) As ReferenceAlias  if (NPCRef && NPCRef.GetActorRef())	OnPlayerDialogue(NPCRef.GetActorRef())  endif  MonitoringQuest.Stop()endEventFunction OnPlayerDialogue(ObjectReference ActorRef)  ;; Do Stuff..EndFunction


Hopefully that is not your desire because polling isn't elegant. Looping scripts remain resident in save games even after a mod is disabled. Basically this technique makes your mod harder to uninstall. You will probably need to provide a mechanism for users to disable your monitoring loop before uninstalling (Say a break-out boolean check in the loop).

It is a shame that the SM Event Node "Player Activate Actor" doesn't work as it would be so much nicer to not use continuous polling.

If general notification is your goal, another method I am aware of is to edit the RACES. Most races have a magic effect associated with them. Add a custom magic effect or edit the existing magic effect(s) with a script attached. THe script would allow you to receive the OnActivate() event (which is necessary to start dialogue). Just add a tiny delay before doing the check. This second method doesn't require polling and would give you a more immediate notification, but is going to be much less compatible with mods or even DLC. For example, Dawnguard introduces new custom (DLC specific) races.

And finally, you may be able to do something with a Cloak Spell. Basically add an ability/spell to the player with an area effect. An alternative to polling with a quest that searches the currently loaded area. However a cloak spell approach may not work if the person you are speaking to is too far away (Like up on a balcony like in Dawnguard). You also have to be carefull as Spell Reistance may prevent it from working and you dont want it turning people hostile. I have heard of Cloak Spells breaking Brawls and making people attack the Player because any spell effect is considered cheating in a Brawl.
User avatar
Lily
 
Posts: 3357
Joined: Mon Aug 28, 2006 10:32 am

Post » Mon Nov 19, 2012 5:24 pm

Wow amazing information Dheu!
This is for my hotkey mod. I want hotkeys to deactivate while you are talking to people. Deactivating during dialogue is mainly for gamepad users but would be nice for keyboard users too as a safe guard (so you don't shoot a fireball in someones face). Controller users can configure their controlmap to get more use out the mod and have tons of hotkeys. But it is best to revert back during menus for easy navigation. This doesn't work during conversations like other menus, and hotkeys will fire when you choose dialogue options. So I needed to check for dialogue to deactivate them.

This check must happen quite often and be very responsive. I need to look into what you have done with the quests when I get a little more time. I am unfamiliar with some of it. Editing the races sounds very promising and easy to do. Except for the issue with other mods and Dawnguard as you noted. I try to make the mod not change anything just be additive. Cloak spells are worth looking into but I think it may be to demanding and troublesome for this application.

Thanks again for the help! This is all very useful for this and future problems. I'll get back to you after I have time to try some of this out tomorrow.
User avatar
Strawberry
 
Posts: 3446
Joined: Thu Jul 05, 2007 11:08 am

Post » Mon Nov 19, 2012 2:52 pm

UI.IsMenuOpen("DialogueMenu")
...since you already rely on SKSE.
User avatar
Nathan Hunter
 
Posts: 3464
Joined: Sun Apr 29, 2007 9:58 am

Post » Mon Nov 19, 2012 10:14 am

Don't forget to check if player is in a scene, depending on what you want to achieve.
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Mon Nov 19, 2012 2:38 pm

Ah perfect JustinOther. That's one of the new SKSE functions isn't it. Thank you very much.

I'm not sure if that is necessary nurgln, but I'l have to check it out. Thanks for pointing it out.
User avatar
evelina c
 
Posts: 3377
Joined: Tue Dec 19, 2006 4:28 pm

Post » Mon Nov 19, 2012 7:54 pm

UI.IsMenuOpen("Dialogue Menu") works brilliantly. Just a note you have to put a space between dialogue and menu.

Still thanks to everyone for there help and suggestions.
User avatar
Liv Brown
 
Posts: 3358
Joined: Wed Jan 31, 2007 11:44 pm


Return to V - Skyrim