How would I adapt dialogue system for conditional variables?

Get help using Construct 2

Post » Thu Feb 19, 2015 10:19 pm

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.
B
6
S
1
G
1
Posts: 91
Reputation: 900

Post » Thu Feb 19, 2015 10:28 pm

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. ;)
B
62
S
26
G
24
Posts: 954
Reputation: 18,318

Post » Thu Feb 19, 2015 10:36 pm

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?
B
6
S
1
G
1
Posts: 91
Reputation: 900

Post » Thu Feb 19, 2015 11:52 pm

I can't find that capx for the life of me but if I recall correctly, I used an XML syntax like this:
Code: Select all
<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>


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. ;)
B
62
S
26
G
24
Posts: 954
Reputation: 18,318

Post » Fri Feb 20, 2015 3:19 am

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?
B
6
S
1
G
1
Posts: 91
Reputation: 900

Post » Fri Feb 20, 2015 3:30 am

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.
B
62
S
26
G
24
Posts: 954
Reputation: 18,318

Post » Fri Feb 20, 2015 3:36 am

Magistross wrote: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.
B
6
S
1
G
1
Posts: 91
Reputation: 900

Post » Fri Feb 20, 2015 12:20 pm

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.
B
62
S
26
G
24
Posts: 954
Reputation: 18,318


Return to How do I....?

Who is online

Users browsing this forum: mekonbekon and 9 guests