I'm trying to figure out a good way to implement dialogs (that is, talks, not UI's). My thoughts so far:
- I see a dialog as a tree of sentences (or better, a forest), so I think that XML is a good choice.
- There would be a XML file for each NPC. And more files for generic NPC's. Example: Peter.xml, Linda.xml, Citizen.xml, Soldier.xml, etc.
- These files would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<dialog npcName="skeleton">
<ops>
<q>Hi, how are you?</q>
<a>Oh, thank you! It's been so long since I was last asked about that...</a>
<a>Well, so and so. And you?</a>
<ops>
<q>Oh, I'm fine. But you look starving. I'll fetch some food for you.</q>
<a questActivate="eggToSkeleton">Don't worry. In fact, I have no stomach,
so the groceries would fall to the ground if I tried to eat. For example:
if I ate an egg, it would break for sure.</a>
<q>I was wandering how a skeleton can talk. And how can be 'so and so'.</q>
<a>What? Haven't you ever heard about undead?</a>
<q objectCondition="egg, inInventory" objectAction="egg, destroy"
questComplete="eggToSkeleton">I have an egg just here. Let's try to
see what happens.</q>
<a>*The skeleton eats... well, it puts the egg into its mouth. When its
bony fingers release the egg, it begins to roll down and finally
crashes to the ground, leaving an orange splash among the green
blades of grass.*</a>
<a>Just as I told you. But... thanks.</a>
<farewell mode="polite"/>
<ops>
<q>Begone, monster! You are an unnatural being!</q>
<a>Yes, I know. But it is not my fault, and I can do nothing about that. I
can't even commit suicide!</a>
<farewell mode="rude"/>
</ops>
</dialog>
I have no experience with XML and I haven't found sample codes for this purpose. Am I on the right path?