Announcement

Collapse
No announcement yet.

Blueprint Dialogue System

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    I have added a new entry in the documentation about new line characters in the CSV (this is NOT related to the new [br] tag mentioned).

    The section can be found here

    Unfortunately, this requires a C++ function, so Blueprint only projects can not use it. If anyone knows of a way to do this without C++, please let me know!

    Comment


      Hi there!

      Feel kinda silly for asking but I'm running against a wall right now. Recently started using the system and it's working beautifully except for the Conditions between conversations.

      My intent is to have a conversation start with the first entry on the table. Then, provided the player accepts a Quest, I set a variable to true. The first line is only displayed if that variable is false. If the variable is set to true, I'd like the NPC to start with a different line. Is that possible? If yes, I am not finding the correct way to do it. I set the variable to true during the last lines of the conversation when accepting the quest.

      Hope you can offer some help here.

      Comment


        Originally posted by NKGriever View Post
        Hi there!

        Feel kinda silly for asking but I'm running against a wall right now. Recently started using the system and it's working beautifully except for the Conditions between conversations.

        My intent is to have a conversation start with the first entry on the table. Then, provided the player accepts a Quest, I set a variable to true. The first line is only displayed if that variable is false. If the variable is set to true, I'd like the NPC to start with a different line. Is that possible? If yes, I am not finding the correct way to do it. I set the variable to true during the last lines of the conversation when accepting the quest.

        Hope you can offer some help here.
        Yep, that's how conditions are supposed to work. One gotcha though is that if the variable isn't set before the condition runs, the script will assume it is a string (and a string is not 0 or "false", making it evaluate to true), this might be what you're encountering.

        In the new version I've submitted to epic (I'll have update notes soon), there's a new intrinsic function called "IsValid" to test if a variable exists, so you could put in your condition: IsValid(my@variable) && my@variable == false
        Keep me posted if this worked or not

        PS: Sorry for the delay in responding btw, this thread doesn't update me anymore for some reason!

        Comment


          New Update (v1.3)

          New Update Available:
          This version supports UE4 4.9, 4.10, and 4.11
          v1.3 Changelog:

          General Changes:
          • Improved extendibility for UI Dialogue text and response items, as well as inline images
          • Speaker names will now process variables (BBCode-like option tags are not supported)
          • Added OnAllTextDisplayed events (UI and BPC)

          New Features:
          • Added function SetActive(true/False). This function will enable or disable the dialogue it is executed on
          • Added script functions SetBranch to set the current state, and SetInitialBranch to update the next branch to use on next interaction.
          • Added passive dialogue mode. Passive dialogues do not capture input and automatically flow to the next valid branch after a configurable delay.
          • SetBranch now supports cross component branching
          • ExecuteScript calls can now be nested. This is especially helpful if a custom script function executes a new set of scripts on external ResponseHandlers (usually BPC_Dialogues).
          • Script function to control passive dialogues added - SetPassive(bool enabled, [optional]number Delay)
          • Added Scriptable "Use Condition" functions to help control when a dialogue should be usable: SetUseCondition(Key, ConditionScript), GetUseCondition(Key), RemoveUseCondition(Key), ClearUseConditions().
            Note: ConditionString should be wrapped in quotation marks to be dynamic (eg. SetUseCondition("MyDynamicCon", "x == 42")). Otherwise, it will evaluate to true or false before storage (eg. SetUseCondition("MyStaticCon", x == 42) will result in SetUseCondition("MyStaticCon", "true"))
          • Added dialogue skipping. This will skip all following dialogue until a user response is expected or the dialogue is exited. To use, call SetSkipDialogue(true) in BPC_Dialogue.
            Note: Pre and Post actions are still executed
          • Added intrinsic functions IsValid and Delete.
            • IsValid(var) will test to see if a variable exists and is not empty (note: spaces are not considered empty)
            • Calling Delete(var) on a variable will destroy the variable (eg. IsValid(x) == true; Delete(x); IsValid(x); == false). (note: if a namespace is emptied, it will also be deleted). It can become important to delete variables if variables are used extensively: because of the linear nature of arrays, it can be costly to find or add when there are a large number of variables, reducing the number of unused variables can help this.
          • Added [br] line-break option to skip to a new line.
            IMPORTANT: BREAKING CHANGE: This is a breaking change. Inheriting UI's must expose a vertical box to the GetTextAreaVerticalBox function and replace the wrap box with a vertical box in the designer.


          Fixes:
          • Fixed Cooking Build Error with BPI_DialogueAwareNodes
          • Fixed script interpreter not returning the result of a custom function
          • Set Keyboard Focus call moved to Input event management. It will no longer be called if control scheme is unmanaged.
          • Fixed ternary operator scenario with nested functions that confused the operands (Details: "a = pow(2, 1 < 3 ? pow(2,2) : pow(3,3))" would falsely count the function arity as 3 instead of 2. This was caused by the ? operator being listed as a unary operator)


          Documentation:
          • Added information about using line breaks in CSV documents for easier reading (some C++ required) F.A.Q
          • Updated the built in functions list

          Last edited by Grogger; 04-06-2016, 12:34 PM. Reason: Update available

          Comment


            With this dialog system, would it be possible to do something like this - and if so, how exactly?
            1. player collects a certain item in the level
            2. player then talks to a certain NPC character for the very first time
            3. NPC immediately reacts to the player having found said item and uses the appropriate line of dialogue ("Hey, you found my key!")

            Or can this dialogue system not access variables from the game itself, but only those set during dialogue?
            Last edited by fookur; 04-02-2016, 07:52 AM.

            Comment


              Originally posted by fookur View Post
              With this dialog system, would it be possible to do something like this - and if so, how exactly?
              1. player collects a certain item in the level
              2. player then talks to a certain NPC character for the very first time
              3. NPC immediately reacts to the player having found said item and uses the appropriate line of dialogue ("Hey, you found my key!")

              Or can this dialogue system not access variables from the game itself, but only those set during dialogue?
              This is certainly do-able, we have a scenario like this in our game Dwarrows (seen in my sig), which uses the dialogue system. Our character collects tokens of sorts (those little yellow glowy things in the trailer), the system has access to the number of tokens and that number is used as a conditional to choose which dialogue certain characters will use.

              The dialogue can access variables from the "ScriptInterpreter" packaged with the system (not blueprint or c++ variables), so to do this you can either update the variable in the interpreter in blueprint: either using the myInterpreter.SetVariable through blueprint, or calling myInterpreter.ExecuteScript("varName = varName+1") from blueprint (this is probably more convenient because it has implicit conversions for the math portion), OR have a Custom Function that can be accessed through the script to get the amount.
              Last edited by Grogger; 04-02-2016, 10:39 AM.

              Comment


                So I went with the Execute Script variant, and I've been trying very hard to get it to work for the past 6 hours, but no luck so far.
                I put this in my Item Blueprint, because I couldn't think of a better place for it:
                Click image for larger version

Name:	ue4_overlap.jpg
Views:	1
Size:	175.3 KB
ID:	1103738
                So when the player collects the item, it adds a variable (or rather, it should) and is then destroyed. The handler is the BPC_Dialogue blueprint as described in the documentation.
                But what to do with the Execute Script node? What goes in the Script String field? It's pure guesswork, nothing makes any sense to me.
                And finally what needs to go in the Condition column in the data table?
                Neither in the documentation nor the sample scene did I find any useful information on that.

                I really hoped this would be easier. After all, it's one of the most basic things to do in a game.

                Comment


                  Originally posted by fookur View Post
                  So I went with the Execute Script variant, and I've been trying very hard to get it to work for the past 6 hours, but no luck so far.
                  I put this in my Item Blueprint, because I couldn't think of a better place for it:
                  [ATTACH=CONFIG]86690[/ATTACH]
                  So when the player collects the item, it adds a variable (or rather, it should) and is then destroyed. The handler is the BPC_Dialogue blueprint as described in the documentation.
                  But what to do with the Execute Script node? What goes in the Script String field? It's pure guesswork, nothing makes any sense to me.
                  And finally what needs to go in the Condition column in the data table?
                  Neither in the documentation nor the sample scene did I find any useful information on that.

                  I really hoped this would be easier. After all, it's one of the most basic things to do in a game.
                  The script is running code in the dialogue's script engine, so if you want to increment a variable you'd say "MyVariable = MyVariable + 1". In your case, make sure you declare the variable in the script interpreter before this script is run (eg. "itemCount = 0") and when you overlap, "itemCount = itemCount + 1".

                  Comment


                    I gave it another try, but the NPC just says whatever comes first in the data table and disregards all I've done. (I left the "initial branch" setting at "auto_select" in the bpc_dialogue component inside the NPC. I hope that's not wrong.)
                    The overlap event in the item's event graph:
                    Click image for larger version

Name:	ue4_keyitem_eventgraph.jpg
Views:	1
Size:	158.8 KB
ID:	1103744
                    Trying to declare the variable in the script interpreter's event graph:
                    Click image for larger version

Name:	ue4_scriptinterpreter.jpg
Views:	1
Size:	64.0 KB
ID:	1103745
                    And the data table:
                    Click image for larger version

Name:	ue4_keyitem_data.jpg
Views:	1
Size:	36.7 KB
ID:	1103746

                    And another thing: What would I write inside the Execute Script node if I wanted to set a variable to true or false instead of adding numbers? I couldn't find an answer in the documentation. The Execute Script node is never mentioned anywhere. I had no idea it existed until today.

                    Comment


                      Originally posted by fookur View Post
                      I gave it another try, but the NPC just says whatever comes first in the data table and disregards all I've done. (I left the "initial branch" setting at "auto_select" in the bpc_dialogue component inside the NPC. I hope that's not wrong.)
                      The overlap event in the item's event graph:
                      [ATTACH=CONFIG]86707[/ATTACH]
                      Trying to declare the variable in the script interpreter's event graph:
                      [ATTACH=CONFIG]86708[/ATTACH]
                      And the data table:
                      [ATTACH=CONFIG]86709[/ATTACH]

                      And another thing: What would I write inside the Execute Script node if I wanted to set a variable to true or false instead of adding numbers? I couldn't find an answer in the documentation. The Execute Script node is never mentioned anywhere. I had no idea it existed until today.
                      auto_select will use the first valid dialogue entry, so that's fine.
                      What you did should work, so far as I can think. You can try outputing the resolved string of execute script to see what it turns out (or use GetVariable and print out the value), to make sure it's properly set before the dialogue comes in.
                      Something else to try, I usually have a blank 'hub' entry in my data tables that have the possible branches in the 'Branches' column and has the 'silent' trait. (eg. row 0 would have blank text, 'KeyFound' in the branches column, and 'silent trait) - I can't test right now, but I'm wondering if there's maybe an issue with conditions running on the initial dialogue.


                      PS: I don't recommend changing the base files of the system, in case of updates (a new one is coming soon - waiting Epic's approval).

                      Comment


                        Originally posted by fookur View Post
                        And another thing: What would I write inside the Execute Script node if I wanted to set a variable to true or false instead of adding numbers? I couldn't find an answer in the documentation. The Execute Script node is never mentioned anywhere. I had no idea it existed until today.
                        Missed that part. Booleans are like in c++, anything not 0 or false evaluates to true. To set a variable to false, "myVar = false" or "myVar = 0" and to test for false "!myVar" or "myVar != true" or "myVar == false"

                        Comment


                          I forgot to mention that the Get Script Interpreter node is apparently causing errors for me. Maybe that's a hint at why it's still not working.
                          When I try to get the the keycount variable via Event Tick inside my Player BP in order to print it out non-stop:
                          > Error Accessed None 'CallFunc_GetScriptInterpreter_Interpreter' from node Get Variable in graph 'EventGraph' in blueprint PlayerBP
                          And as soon as I overlap and "collect" the item (using the node setup from my last post):
                          > Error Accessed None 'CallFunc_GetScriptInterpreter_Interpreter' from node Execute Script in graph 'EventGraph' in blueprint KeyItem

                          Not sure what could be the problem. Maybe the Handler? I simply created a new variable and made it a reference to BPC Dialogue. That seems to be what is shown in the documentation.

                          (BTW when I put a silenced blank hub in row0 of my data table, the dialogue interface won't open at all anymore. Maybe I just made some beginner's mistake because I haven't studied the sample level enough.)
                          Last edited by fookur; 04-02-2016, 07:57 PM.

                          Comment


                            Originally posted by fookur View Post
                            I forgot to mention that the Get Script Interpreter node is apparently causing errors for me. Maybe that's a hint at why it's still not working.
                            When I try to get the the keycount variable via Event Tick inside my Player BP in order to print it out non-stop:
                            > Error Accessed None 'CallFunc_GetScriptInterpreter_Interpreter' from node Get Variable in graph 'EventGraph' in blueprint PlayerBP
                            And as soon as I overlap and "collect" the item (using the node setup from my last post):
                            > Error Accessed None 'CallFunc_GetScriptInterpreter_Interpreter' from node Execute Script in graph 'EventGraph' in blueprint KeyItem

                            Not sure what could be the problem. Maybe the Handler? I simply created a new variable and made it a reference to BPC Dialogue. That seems to be what is shown in the documentation.

                            (BTW when I put a silenced blank hub in row0 of my data table, the dialogue interface won't open at all anymore. Maybe I just made some beginner's mistake because I haven't studied the sample level enough.)
                            Sounds like the script interpreter wasn't set up. Have a look at the video tutorials, the documentation and the sample content on how to get that setup, that should work out nicely

                            Comment


                              So, there goes my weekend, tinkering with the dialogue system and not getting anywhere. *sigh*
                              I started from scratch and migrated the entire dialogue system to my game once more, following the Youtube video, the documentation, and the examples in the demo level very closely. However, I didn't notice anything different from the way I had set it up the first time. And I am still getting the same error when trying to print out the variable from inside my PlayerBP or when collecting the item. (Printing it from inside the BP ScriptInterpreter right after declaring it works fine of course.)
                              My PlayerBP:
                              Click image for larger version

Name:	ue4_playerbp.jpg
Views:	1
Size:	236.8 KB
ID:	1103768
                              The script interpreter is spawned in my custom gamemode as is recommended in the video / the demo level:
                              Click image for larger version

Name:	ue4_gamemode.jpg
Views:	1
Size:	176.2 KB
ID:	1103767

                              And here's something interesting I noticed just now: I'm getting the same errors in your demo level.
                              1. Add an ExecuteScript node (Script String: keycount = 0) to the demo's BP Script Interpreter right behind its Event BeginPlay (This part doesn't seem to be the problem.)
                              2. In the Third Person demo character try to get the keycount variable like I did in the picture above
                              The Result:
                              Error Accessed None 'CallFunc_GetScriptInterpreter_Interpreter' from node Get Variable in graph 'EventGraph' in blueprint ThirdPersonCharacter

                              Something is fundamentally wrong here. Perhaps the declaration of variables has to happen somewhere else?
                              Or perhaps the Handler variable used with the GetScriptInterpreter node has to be created in a special way?
                              Last edited by fookur; 04-03-2016, 12:30 PM.

                              Comment


                                Originally posted by fookur View Post
                                So, there goes my weekend, tinkering with the dialogue system and not getting anywhere. *sigh*
                                I started from scratch and migrated the entire dialogue system to my game once more, following the Youtube video, the documentation, and the examples in the demo level very closely. However, I didn't notice anything different from the way I had set it up the first time. And I am still getting the same error when trying to print out the variable from inside my PlayerBP or when collecting the item. (Printing it from inside the BP ScriptInterpreter right after declaring it works fine of course.)
                                My PlayerBP:
                                [ATTACH=CONFIG]86751[/ATTACH]
                                The script interpreter is spawned in my custom gamemode as is recommended in the video / the demo level:
                                [ATTACH=CONFIG]86750[/ATTACH]

                                And here's something interesting I noticed just now: I'm getting the same errors in your demo level.
                                1. Add an ExecuteScript node (Script String: keycount = 0) to the demo's BP Script Interpreter right behind its Event BeginPlay (This part doesn't seem to be the problem.)
                                2. In the Third Person demo character try to get the keycount variable like I did in the picture above
                                The Result:
                                Error Accessed None 'CallFunc_GetScriptInterpreter_Interpreter' from node Get Variable in graph 'EventGraph' in blueprint ThirdPersonCharacter

                                Something is fundamentally wrong here. Perhaps the declaration of variables has to happen somewhere else?
                                Or perhaps the Handler variable used with the GetScriptInterpreter node has to be created in a special way?
                                Hey fookur, I did have a go at testing this in the sample and it was a successful use case, so I'm thinking something in the setup is up, I'm guessing the GetScriptInterpreter function in your BPC_Dialogue is the route problem.

                                The GetScriptInterpreter node is an interface function, so the custom BPC_Dialogue should override the GetScriptInterpreter function and return the one you've spawned form game mode. It should look like this:

                                Click image for larger version

Name:	GetscriptInterpreter.JPG
Views:	1
Size:	51.4 KB
ID:	1103783

                                Comment

                                Working...
                                X