ID:153436
 
In my current project (Which will probably never be released, but it's fun to work on anyway.), I'm looking for a way to construct a 'dialogue tree' of sorts. The thing is, I need this tree to be able to execute actions, not just say something special to certain responses;
Hello. How are you today?
"Fine, thanks."
Good to hear!
[smile]
"Not very good."
[frown]
What is wrong?
"Don't worry about it."
"Non of your concern. Back off, moron!"
No need for hostilities.
[walk away]
[add person to ignore list]
"None of your business, bug-face."
I'll show you who's a bug face..
[equip a weapon]
[target person]


Something like that is what I'm looking for. The thing is, I'm not sure how I'd do something without extremely messy procedures and lists. I'm looking for a nice and neat way to execute this idea. Any thoughts welcome (relating to this topic, that is!).

~>Volte
You could use XML (and Deadron's XML library) to set up the system. Each "dialogue node" tag would enclose a possible response by the player, and would in turn enclose tags which would hold data such as:

- What the player says when choosing this node
- What the NPC says in response
- A player proc to run (with tags nested inside this, specifying further options such as stuff to pass to the proc)
- An NPC proc to run (ditto)
- Further dialogue node tags

Obviously some of those would be optional, like the proc running.

It'd be best if you allowed multiple types of each of those tags to be placed directly inside one dialogue node tag; for example, you might want the NPC to say multiple lines of dialogue at once, or run multiple procs.
In response to Crispy
Crispy wrote:
You could use XML (and Deadron's XML library) to set up the system. Each "dialogue node" tag would enclose a possible response by the player, and would in turn enclose tags which would hold data such as:

- What the player says when choosing this node
- What the NPC says in response
- A player proc to run (with tags nested inside this, specifying further options such as stuff to pass to the proc)
- An NPC proc to run (ditto)
- Further dialogue node tags

Obviously some of those would be optional, like the proc running.

It'd be best if you allowed multiple types of each of those tags to be placed directly inside one dialogue node tag; for example, you might want the NPC to say multiple lines of dialogue at once, or run multiple procs.

I know absolutely nothing about XML, but I guess I could try diving in. I've taken a peek at Deadron.XML, and it looks confusing to say the least. This idea does sound interesting, though. Thanks, Cripsy! :)

~>Volte
In response to Volte
Volte wrote:
I know absolutely nothing about XML

Then now is an excellent time to learn! =)

I've taken a peek at Deadron.XML, and it looks confusing to say the least.

It's pretty easy once you get the hang of it. It's the easiest XML library I've seen, in any language (although I haven't actually used it seriously, I'm just going by the documentation).
In response to Crispy
What does XML stand for, what is the definition of and idea behind it?
In response to Loduwijk
Loduwijk wrote:
What does XML stand for, what is the definition of and idea behind it?

eXtended Markup Language. It was supposed to be the next iteration of HTML, where people could invent their own HTML tags and use them to encompass text, thereby making all the text inside those tags take on the properties that were defined. In that regard it was a spectacular failure.

Programmers decided they liked the way the language could be used for other purposes, however, so they adopted it for databases and stuff.

I admit that I like how easy it makes data to manipulate. However, I absolutely hate the format.
Just to elaborate briefly on what everyone else was saying... here's one way you could mark this up in XML, by nesting child nodes.
<npc>Hello. How are you today?
<choice>Fine, thanks.
<npc action="Smile">Good to hear!</npc>
</choice>

<choice action="Groan">Lousy!
<npc action="BattleCry">Then I shall put you out of your misery!</npc>
<npc action="SmitePlayer" />
</choice>
</npc>

(If you do create code to handle this, please consider submitting it to BYONDscape...)
In response to Gughunter
Gughunter wrote:
(If you do create code to handle this, please consider submitting it to BYONDscape...)

/me puts it on his ToDo list along with his Bits of Binary tutorial and Housing Lib (using swapmaps).
In response to Loduwijk
Loduwijk wrote:
What does XML stand for, what is the definition of and idea behind it?

Here is an article that attempts to tell you everything you need to know:

http://www.byondscape.com/ascape.dmb/Deadron.2003-0517

Guy, any chance the article could be made free, since the library itself is subscription?
If you want an example of its use in a BYOND game, go and download the source for Beta Quest by Salarn, he used it for savefiles in the game. :)
In response to Deadron
Guy, any chance the article could be made free, since the library itself is subscription?

Done!