How would I adapt dialogue system for conditional variables?

0 favourites
  • 8 posts
From the Asset Store
Create complex dialogues with ease with this tool/template!
  • I've noticed there are a lot of branching dialogue systems out there designed to allow you to use CSVs or JSON rather than doing Events for everything. However, in my game concept, a dialogue with any given NPC will branch at multiple points according to various variables (such as whether you've talked to the NPC before, whether you've done the NPC a favor, your character's personal qualities, etc.). I haven't found a dialogue system implementation that allows for this (the ones in the How Do I FAQ don't seem to); how would I go about it? Has one already been made that has that sort of flexibility? Happy to spend money in the Scirra store if that's what is called for.

  • I once implemented conditionnal branching using XML and a Dictionnary. The XML store the conditions and the actual dialogue, and the Dictionnary hold the game's variables that the conditions can use. I might add that to my dialogue system already in the store... Meanwhile, I guess you could ask me for some tips.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm surprised that a dialogue system hasn't been posted on the C2 store sooner! If yours were conditional, it would be near-perfect for my purposes.

    As for tips -- how did you format the XML/JSON to reference the dictionary variables?

  • I can't find that capx for the life of me but if I recall correctly, I used an XML syntax like this:

    <events>
        <event id="id1" x="50" y="50">
            <branches>
                <branch>
                    <cnds>
                        <cnd>
                             <lop>litteral or #keyInDictionnary</lop>
                             <cp>(something to identify what kind of comparison)</cp>
                             <rop>litteral or #keyInDictionnary</rop>
                             {add more <lop>,<cp> and <rop> nodes for more conditions using a logical OR}
                        </cnd>
                        {add more <cnd> nodes for more conditions using a logical AND}
                    </cnds>
                    {... multiples nodes for information on sprite animation, direction, path, speed, etc. can be added here}
                    <acts>
                        <act type="Dialogue">
                            <dialogueData>{dialogue data in whatever format}</dialogueData>
                        </act>
                        <act type="ChangeVar">
                             <varKey>key litteral</varKey>
                             <varOp>{kind of operation (add, substract, set)}</varOp>
                             <varValue>litteral or #keyInDictionnary</varValue>
                        </act>
                        {add more <act> nodes for more actions on this particular branch, with "type" values to anything you want, which will be interpreted to do whatever you see fit}
                    </acts>
                </branch>
                {add more <branch> nodes to allow for multiple possibilities of actions from the same "event", branching should occur only once per event activation, branching at the first branch with satisfied conditions}
            </branches>
        </event>
        {add more <event> nodes to place more events on the map}
    </events>[/code:1z5h1uju]
    
    You then need quite a lot of XPath magic and events acrobatics to interpret all of this correctly, but when done correctly you can do pretty much anything you want, à la RPG Maker. You could also limit yourself to dialogue only, but my system was meant to be quite versatile.
  • Excellent, thanks! I've used XPath at work, so I'm comfortable with that.

    Just wondering -- I've heard that JSON is better than XML for dialogue-heavy games. Do you agree? Or are there good reasons for doing this with XML rather than JSON?

  • JSON is definitely faster, but the data volume is most likely not heavy enough for it to make a difference. I find it easier to navigate with XPath than using JSON... maybe with a decent JSON plugin I would consider it over XML.

  • JSON is definitely faster, but the data volume is most likely not heavy enough for it to make a difference. I find it easier to navigate with XPath than using JSON... maybe with a decent JSON plugin I would consider it over XML.

    The goal is many thousands of lines of dialogue by the end, so speed might come into play eventually? Hmm.

  • In a single file ? Then I guess you should stick with JSON ! But I don't know what kind of data plugin would be best to load it in... I think this could work.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)