Script change of conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
wax_lyrical
Posts: 6
Joined: Wed May 29, 2019 6:14 am

Script change of conversation

Post by wax_lyrical »

HI PixCrushers.

I have a BarkOnIdle script. The NPC barks random calls to barks like: "Get me out of this oven!!". The BarkOnIdle selects conversation nodes set to 'random'. Once out the NPC follows player, and cracks jokes.

I tried to keep the jokes in the same conversation, using a boolean to defeat access to them, but they are still being selected from the BarkOnIdle random anyway. Not sure if this is intended behaviour?

In any case. It would seem cleaner to switch the NPC conversation from within my scripts to new conversation (the one with jokes). I was trying to work out how to do this?

I've passed a reference to the BarkOnIdle in the code in question

[SerializeField] BarkOnIdle barkOnIdle;

I'm looking for something like

barkOnIdle.conversation = DialogueManager.getConversation("NPCJOKES");

Thanks!
....
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Script change of conversation

Post by Tony Li »

Hi,

BarkOnIdle will obey the Conditions you've set on dialogue entry nodes. It's possible that the "Get me out of the oven" nodes' Conditions are still evaluating as true for some reason. At runtime, you can use the Watches tab to check the values that would affect the Conditions.

If you temporarily set the Dialogue Manager's Debug Level to Info, then when the NPC decides what lines to bark it will report the result of evaluating each node's Conditions. For example, in the Dialogue System's DemoScene1, the Enemy NPCs bark randomly from 3 nodes. If Debug Level is set to Info, then the Console will log this:

Code: Select all

Dialogue System: Add Link (Enemy): ID=6:1 'Die!' (True)
Dialogue System: Add Link (Enemy): ID=6:2 'You're going down!' (True)
Dialogue System: Add Link (Enemy): ID=6:3 'He's mine!' (True)
The "(True)" at the end means that the Conditions evaluated to true, so it's adding the node as a possible random choice. If the Conditions evaluate to false, the log will look something like this:

Code: Select all

Dialogue System: Block On False Link (Enemy): ID=6:3 'He's mine!' (False)
I recommend using variables (or actor fields) and Conditions if possible because the data is included in saved games. Otherwise, if you manually change the BarkOnIdle component's conversation field, you'll need to remember to change it again when the player saves the game and loads that saved game.

However, if you want to get BarkOnIdle's conversation field, it's just a string that specifies the conversation title. Set it like this:

Code: Select all

barkOnIdle.conversation = "NPCJOKES";
wax_lyrical
Posts: 6
Joined: Wed May 29, 2019 6:14 am

Re: Script change of conversation

Post by wax_lyrical »

Thanks, Tony
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Script change of conversation

Post by Tony Li »

You're welcome! If still gives you trouble after the suggestions above, just let me know.
Post Reply