Page 1 of 2

Presenting Items During Conversations

Posted: Thu Mar 03, 2016 8:16 pm
by Arkias
Hey!

I was considering buying this from the Unity Store, and I figured I might as well ask here, before purchasing it and going to tinker on it on my own.

What would the way to modify the DM system to include something akin to 'question' and 'contradict'' during a conversation. What I mostly mean to say is that in certain conversations, during the speeches, there would be a way to create something akin to a sub conversation. Those familiar with games like Phoenix Wright or most Visual Novels would be correct.

A free example of such a game could be found here -- http://www.kongregate.com/games/chiefwa ... hilosopher .

In essence, I guess I'm asking is there a way in DM to create a branching conversation from a button on the UI -- or goes to a conversation end depending on what Item was presented.

I apologize for being confusing, but I was just wondering on how it'd be done.

Thanks,

Ark!

Re: Presenting Items During Conversations

Posted: Thu Mar 03, 2016 9:34 pm
by Tony Li
Hi Ark,

Sure, the Dialogue System is quite flexible. That would be fairly easy to do.

The Dialogue System has variables -- actually, under the hood it has a complete Lua scripting environment that you can tap into if you want. But in this case you could configure your button to set a Dialogue System variable. For example, let's say you define a Boolean (true/false) variable named "Contradict". If you assign this method to the UI button, it will set the variable's value to true and then update the player response menu accordingly:

Code: Select all

void OnClickContradict() {
    DialogueLua.SetVariable("Contradict", true);
    DialogueManager.UpdateResponses();
}
(If you don't want to write any code, you could use PlayMaker, Makinom, plyBlox, or one of the other visual scripting systems for which the Dialogue System has built-in integration.)

Every node in your conversation tree has a Conditions field. You could set the conditions on one or more responses so that it's only available if the "Contradict" variable is true. For example:
  • Mom: "Did you take out the trash?"
    • Brother: "Yes, mother."
      • Player: "Yup, I saw him take it out, Mom."
      • Player: "I wasn't paying attention."
      • Player: {Conditions: Variable["Contradict"]==true} "He's lying, Mom! He didn't take it out!"
This is just one way to do it. I assumed you intended for the "contradict" button, for example, to change the responses available in the player response menu. It could also do other things to change the course of the conversation. Speaking of sub-conversations, you can link nodes in any conversation to nodes in any other conversation, too. They're not limited to linking to nodes within the same conversation.

Please feel free to try out the evaluation version. The Dialogue System Extras page also a free visual novel framework add-on. If you're going to make something like a visual novel, it can be a good starting point.

Re: Presenting Items During Conversations

Posted: Thu Mar 03, 2016 10:02 pm
by Arkias
Thanks Li!

That was actually a huge help, I kind of realized I was in fact over thinking it.

This however does lead to another question; would there be a way to make.. branching buttons? For example, in this case, with the Mom/Brother thing --

  • Mom: "Did you take out the trash?"
    • Brother: "Yes, mother."
      • Mom: "Alright, that's good!"
Which would link back to the Mom asking about the trash -- Which I assume is just a simple node linking structure to create a loop, but is there a way for there to be a seperate button that would lead to the secondary conversation tree, without over-riding the current text?

Or In a more Node-Like Design -- is there a way to create more buttons that lead to a different conversational tree? So, while Enter would continue along the main tree (The actual conversation), contradiction and questioning would create a small sub path -- Akin to something like this?

Image

--The main idea here is that if you contradict, you need to bring an item a long that gets tested. Or, I think... a way to pull up your inventory as a conversational button to contradict (AKA like evidence that proves that the witness is lying, but other ones do nothing). I understand the basic idea is a node tree, with a check value that see's if Item.Contridict == [Whatever], but I mostly mean, is there a way to bring up the inventory for the player to bring up an item for evalution during the conversation as a contradiction of what's being said?

I do apologize if the question seems fairly basic, and could just be solved by enabling/disabling buttons depending on what type of conversation it is. I'm not the best programmer around, and wanted to know if my intuition on how it'd work is right.

Thanks,

Ark!

Re: Presenting Items During Conversations

Posted: Thu Mar 03, 2016 11:22 pm
by Tony Li
The way you drew it in your picture is almost exactly how you'd "draw" the conversation tree in the Dialogue Editor. It ends up looking a lot like a Mecanim state machine but for lines of dialogue instead of animation states.

I'll answer the inventory question first: It depends. (Don't you love those kinds of non-answers? ;)) But, really, it depends on how you're keeping track of inventory. Here are some examples:
  • If this is a visual novel and everything happens inside a conversation structure, you can just set Dialogue System variables (e.g., "Has_Incriminating_Photo") when the player comes across an item. Then you can check those variables in later conversations.
  • If you're using an inventory system plugin for which the Dialogue System has built-in support (e.g., S-Inventory or Inventory Pro), you can use special Lua functions in your conversations' Conditions. For example: HasItem("IncriminatingPhoto").
  • Otherwise if you're managing the inventory in your own scripts, you can register some of your script functions with Lua using these instructions which are fairly simple. In fact, that's exactly what the support packages for S-Inventory and Inventory Pro do. This allows Lua to act as a bridge between the Dialogue System and other plugins.
Now if you want to actually open your inventory window during a conversation, that's possible, too. It's just a little more complicated to describe in a post how they would interact with each other. But it's entirely do-able.


For the Question and Contradict buttons, now that I have a clearer idea, I don't think you need to write any code at all. You could structure the conversation like this in the Dialogue Editor:
  • Mom: Did you take out the trash?
    • Brother: Yes, Mom, I did.
      • Player: (say nothing)
        • Mom: That's good, honey.
      • Player: Question --> "When did you do that?"
        • Brother: About an hour ago. --> (back to Brother: Yes, Mom, I did.)
      • Player: Contradict --> "That's not true. I've been outside this whole time."
        • (To a different branch)
When the conversation gets to the brother's "Yes, Mom, I did." line, it will show a player response menu with three responses buttons: (say nothing), Question, or Contradict.

You could optionally set the (say nothing) "response" on a timer so if the player doesn't click a response button after n seconds it automatically proceeds to the mom's "That's good, honey." line. You could also make it an invisible button, but I think most games usually show this as a button with the button text set to something like "..." so players might expect that.

If you only want to offer the Question button once, you could set an additional condition on it for that.

(Side note: When I say "Dialogue Editor" you could also use one of the supported third party editors if you prefer, such as Chat Mapper, articy:draft, or the Neverwinter Nights 1 or 2 Toolsets.)

Re: Presenting Items During Conversations

Posted: Thu Mar 03, 2016 11:52 pm
by Arkias
And of course, I guess I wanted it to do it the difficult way. Everything else had been answered, but the way I did want to implement Item's into the conversation was the more complicated way of bringing up the inventory, and letting the player choose. If they got the wrong one, tell its wrong, and loop back to main conversation. Otherwise, it's correct, and the incriminating photo is what you wanted to show at that part. Would this be doable with integration, or would I need to code it in somehow?

And really, thanks for all your help and answering my Questions!

Ark

Re: Presenting Items During Conversations

Posted: Fri Mar 04, 2016 9:27 am
by Tony Li
Hi,

Sorry for the delayed response. I had finished up for the day just before you replied.

You'll have to do a little customization to do what you describe, but one of the Dialogue System's design principles is easy customization. You can hook into Dialogue System processes without having to directly modify any Dialogue System code.

Every dialogue entry node can run a short cutscene sequence. Designers often use this sequence to play lipsync animation, change camera angles, etc. You define sequences using simple text-based commands -- for example, "Camera(Closeup)" -- making them easy to add while writing dialogue without breaking flow.

Some of these sequencer commands "outsource" certain tasks. For example, the TextInput() sequencer command displays a text input field and waits for the player's input. Then it stores the input in a Dialogue System variable.

It's easy to add custom sequencer commands. The Dialogue System includes a template. Just copy it and put your code in the stubs where indicated.

I recommend adding a custom sequencer command, similar to TextInput(), that displays your inventory box and waits for the player to select an item. Then it would store the name of the item in a Dialogue System variable, at which point your conversation could check the variable's value.

Re: Presenting Items During Conversations

Posted: Sun Mar 06, 2016 11:33 am
by Arkias
I wasn't sure if I was meant to ask here or there, but I figured since I had already been asking you, it would do well enough. I also couldn't figure out if this was more of a Dialogue System question or the inventory Pro type... So admittedly, I did ask in two places.


I've been trying to use The Dialogue System and Inventory Pro together for different purposes. I'm.. Kind of lost at this one point, and while it integrates fine in most cases, would there be a way for the Dialogue System to force Open the Player Inventory, wait till a selection is made, hand the name of the item over, and then close?

I'm under the impression I'm going to need to create a custom Sequencer and a Custom Item Type, but I've no idea how the two interact as it is to find the scope.

I think the only main issue I'm having is figuring out how the Dialogue System would call Inventory Pro's Inventory UIWindow to open up, OR how it'd actually pass the name as a Dialogue System Variable.

Would you be able to give me some tips on this?

Thanks,

Ark!

Re: Presenting Items During Conversations

Posted: Sun Mar 06, 2016 4:42 pm
by Tony Li
Hi,

I'll see if I can put together a simple example scene today and post it here.

Re: Presenting Items During Conversations

Posted: Sun Mar 06, 2016 9:25 pm
by Tony Li
I just posted this on the DevDog forum too:

Here's an example: InvPro_SelectItemInConversation_2016-03-06.unitypackage

It adds a custom sequencer command "OpenItemSelectionUI(variableName)" that opens an Inventory Pro window and waits for the player to select an item. Selection uses the 'use' interaction, which is mapped to the right mouse button. The conversation then branches based which item the player selected.

The package includes a README file with instructions. You can also download the package from the Dialogue System Extras page. It's kind of far down in the Misc section.

Re: Presenting Items During Conversations

Posted: Mon Mar 07, 2016 1:36 am
by Arkias
Thank you so much for doing this Li!

Edit: Realized that a proper workaround was just making the inventory that items were added to the new one that was made.


Thanks,

Ark