Hi,
I've fixed all of my previous issues and am continuing to convert my code over to the Dialogue System. I'm now looking at implementing a shopkeeper functionality that can call an existing OpenShop() method from the NPC game object after a certain dialogue node is spoken (e.g. my previous system would call a function after the NPC spoke something like ''Take a look at my shop!'). I've been browsing through the manual and am having a bit of trouble finding what I'm looking for.
Can you point me to which articles or features might be relevant to implementing this feature?
Thanks!
Running Custom Method after Certain Dialogue Node
-
- Posts: 111
- Joined: Mon Apr 08, 2019 8:01 am
Re: Running Custom Method after Certain Dialogue Node
Hi,
You could write a custom sequencer command (more info: Cutscene Sequences)
But in this case it's easier to use the built-in SendMessage() sequencer command. The player response dialogue entry node could look something like this:
If you want to open the shop on the NPC's line, it would be something like:
You could write a custom sequencer command (more info: Cutscene Sequences)
But in this case it's easier to use the built-in SendMessage() sequencer command. The player response dialogue entry node could look something like this:
- Dialogue Text: "What do you have for sale?"
- Sequence: SendMessage(OpenShop,,listener)
If you want to open the shop on the NPC's line, it would be something like:
- Dialogue Text: "Take a look at my shop!"
- Sequence: SendMessage(OpenShop)
-
- Posts: 111
- Joined: Mon Apr 08, 2019 8:01 am
Re: Running Custom Method after Certain Dialogue Node
Hey Tony,
Thanks for the reply. That's kind of what I was looking for, except the sequence is triggered during the dialogue. Is there a way to fire it after the conversation ends?
Off the top of my head I can think of a work around, being that the sequence will 'ready' the shop to be triggered and I can do something with OnConversationEnd() maybe to check whether or not I should open the shop, but it seems a bit clunky and I'm not completely sure if it will work. Not sure if you could have anything better than that in mind.
Thanks!
Thanks for the reply. That's kind of what I was looking for, except the sequence is triggered during the dialogue. Is there a way to fire it after the conversation ends?
Off the top of my head I can think of a work around, being that the sequence will 'ready' the shop to be triggered and I can do something with OnConversationEnd() maybe to check whether or not I should open the shop, but it seems a bit clunky and I'm not completely sure if it will work. Not sure if you could have anything better than that in mind.
Thanks!
Re: Running Custom Method after Certain Dialogue Node
Here are two options:
1a. If you use continue buttons, use a sequencer command like this:
The "@Message(WaitForever)" part tells the command to wait until it receives a sequencer message "WaitForever". (This is an arbitrary string. There's nothing special about "WaitForever". I just chose something that will never actually be sent.) However, the "required" part guarantees that the command will run when the node ends, even if it's still waiting for the message.
1b. If you're not using continue buttons, use a sequencer command like this:
This tells the command to wait for a duration based on the length of the dialogue text and the timing settings in the Dialogue Manager's Subtitle Settings.
2. Or set a dialogue database variable in the node's Script field:
If you've defined openShop in the Dialogue Editor's Variables section, you can use the "..." button to set up the Script field without having to do any typing.
Then add a Dialogue System Trigger to the shopkeeper or Dialogue Manager. Set its trigger to OnConversationEnd. Set the Condition > Lua Conditions to:
And add 2 actions:
1a. If you use continue buttons, use a sequencer command like this:
Code: Select all
required SendMessage(OpenShop)@Message(WaitForever)
1b. If you're not using continue buttons, use a sequencer command like this:
Code: Select all
SendMessage(OpenShop)@{{end}}
2. Or set a dialogue database variable in the node's Script field:
Code: Select all
Variable["openShop"] = true
Then add a Dialogue System Trigger to the shopkeeper or Dialogue Manager. Set its trigger to OnConversationEnd. Set the Condition > Lua Conditions to:
Code: Select all
Variable["openShop"] == true
- Run Lua Code:
Code: Select all
Variable["openShop"] = false
- OnExecute() Event: Activate the shop. (Alternatively, use a Play Sequence action with SendMessage(OpenShop).)
-
- Posts: 111
- Joined: Mon Apr 08, 2019 8:01 am
Re: Running Custom Method after Certain Dialogue Node
Thanks, the first solution worked like a charm. Sequences seem extremely powerful- I'll definitely do some more research down the line about them.
Re: Running Custom Method after Certain Dialogue Node
Sounds good. Glad to help!