Page 1 of 1

How to (effectively) change a dialogue entry field at runtime?

Posted: Fri Feb 16, 2018 12:32 pm
by Abelius
Hi there,

I'm been unsuccessfully looking for this in the forum and the documentation, even though it must be something someone must have asked before, so sorry if that's already been explained.

I need to be able to change a dialogue entry field value at runtime. My use case is the following...

I have a node that has outgoing links to a lot of player response nodes, each of them checking a condition to be declared valid or invalid. I also have 'Show Invalid' field in each of them, that overrides the normal behavior of showing or not showing invalid responses (see this thread).

I also have these settings...:

Image

So every response, as long as it doesn't have 'Show Invalid' field to False, always is shown.

This is working fine, but now I'd want to further customize my dialogue responses...

Let's say I have six player responses. Each of them represents a full dialogue branch with that NPC and they're meant to be selected in order. When the second one is completed successfully (with a Quest Entry set to success) the third one is considered valid.

Until now, to avoid spoilers, I've set those responses 'Show Invalid' field to False, so they don't get shown until the player could actually click on them. But now I'd like that the next dialogue branch in the sequence is unhidden even being invalid at that moment, while the rest of them remain hidden.

In other words: I'd like the player to know about the next conversation choice with that player before they could actually select it, but only the next one in the sequence, not the rest.

So I guess I'd need to change those response nodes 'Show Invalid' field from False to True at some point at runtime, right? But I don't know any LUA or sequence command that can do that...

Is this possible? Would the dialogue database need to be "refreshed" or something?

Thank you!

Re: How to (effectively) change a dialogue entry field at runtime?

Posted: Fri Feb 16, 2018 3:23 pm
by Tony Li
Hi,

You can make changes to the database. Tick the Dialogue Manager's Instantiate Database checkbox. Otherwise runtime changes while playing in the editor will permanently change the database.

To change the field, you can use code similar to this:

Code: Select all

var entry = DialogueManager.MasterDatabase.GetDialogueEntry(conversationID, entryID);
Field.SetValue(entry.fields, "Show Invalid", true);
You'll probably want this data to stick around in saved games, so you may need to also save this data elsewhere, such as in Dialogue System/Lua variables. Then, when loading a game (i.e., in OnApplyPersistentData) read the values of those variables to update the "Show Invalid" fields.

Re: How to (effectively) change a dialogue entry field at runtime?

Posted: Fri Feb 16, 2018 5:05 pm
by Abelius
Ah, so those fields aren't included in normal savegames, okay.

Thank you so much for your detailed response. ;)

Re: How to (effectively) change a dialogue entry field at runtime?

Posted: Tue May 09, 2023 10:36 am
by petem
Just wanted to say thank you for this thread. It was exactly what I was looking for.

Basically: sorting out character speech (all done through Barks) for my FTUE. It's possible for the Player to do things that they're not supposed to during the FTUE, but rather than stop those actions, I wanted the characters to Bark that they were doing something they shouldn't as a nudge to the Player.

All my Bark lines were on ScriptableObjects – one associated with each FTUE Stage – as that makes it easy for me to add to or reorder the stages.

But – when I'd picked up that the Player had done something they shouldn't, the 'warning' Bark for that specific situation was immediately overwritten ('overdisplayed'?) by the standard Bark, as there's no way of controlling Bark Priorities with Barks that aren't in the database.

So, what I wanted to do was as I incremented the FTUE Stage, copy the Barks associated with that stage (as defined in the SOs) up to the Dialogue System database, where I could set relative priorities for things.

Took me a while, but it's working and it all works lovelyly.

Re: How to (effectively) change a dialogue entry field at runtime?

Posted: Tue May 09, 2023 10:44 am
by Tony Li
Thanks for the write-up. I'm glad that worked out for your needs!