Quote: "I think AIML bots would be awesome. Someone made an AIML interpreter plugin before for DBPro. Can't remember who or what it was called, though."
Never heard of those before, but I just looked them up, and they actually look a lot like what I did
.
I completed the dialogue system today, and it seems to work very well so far
. I may post a video of it tomorrow (it's really not very interesting to watch) since it's getting late now, but here is an explanation of how it works...
If the player wants to talk to a character, they type 'talk [npc name]', which brings up a list of the first parts of options. For example, if the dialogues of a npc are:
Who are you?
Who are the Death Eaters?
Who are the professors at Hogwarts?
What are you doing?
What do you need done?
What do you like to do?
Then the options:
1) Who
2) What
would show up. If the player enters 1, then the options:
1) are you?
2) are the
would show up, and then if he enters 2, then:
1) Death Eaters?
2) professors at Hogwarts?
And then if he entered 1, it would show, "You say, 'Who are the Death Eaters?' to [npc name]", and they would respond with a scripted response. So basically, you are constructing a sentence part by part (with up to 5 parts, though most dialogues won't need more than 2 or 3). This in itself I think is pretty cool, but the best part is that it's all scripted to allow for responses and dialogue options based on certain conditions. Here's an example of code:
<d=What`is your`name?>
<name=What is your name?>
player.familiar=0
<r=My name is Professor McGonagall>
player.age.start=0
player.age.end=19
</r>
<r=My name is Minerva McGonagall.>
player.age.start = 20
</r>
</d>
<d=What`is your`job?>
<name=What is your job?>
<r=I'm a professor at Hogwarts.>
dialogue.hasNotFired=this
</r>
<r=I've already answered this.>
dialogue.hasFired=this
</r>
</d>
<s=Greeting>
<say=McGonagall says, 'Hello there.'>
player.familiar=1
</s>
Where <d indicates a dialogue the player can select. The ` is the dialogue definition indicates where the dialogue is "broken up" into the separate parts. So in this case, the player would have the option:
1) What
Then, if they selected that,
1) is your
Then if they select that,
1) name?
2) job?
The cool part is that an option will only show up if the conditions are met, for example, in this part:
<d=What`is your`name?>
<name=What is your name?>
player.familiar=0
<r=My name is Professor McGonagall>
player.age.start=0
player.age.end=19
</r>
<r=My name is Minerva McGonagall.>
player.age.start = 20
</r>
</d>
the player.familiar=0 means that the player must not know the npc (there is an introduce command now, which allows you to see NPC names rather than descriptions) to be able to ask that question.
Then there is allowed to be up to 10 responses for each dialogue, in this case there are only 2:
<r=My name is Professor McGonagall>
player.age.start=0
player.age.end=19
</r>
<r=My name is Minerva McGonagall.>
player.age.start = 20
</r>
Which have conditions of their own. If the player is between the age of 0 and 19, she will answer that her name is Professor McGonagall, but if the player is 20 or older, she will answer with her first name as well, Minerva. In the second dialogue:
<d=What`is your`job?>
<name=What is your job?>
<r=I'm a professor at Hogwarts.>
dialogue.hasNotFired=this
</r>
<r=I've already answered this.>
dialogue.hasFired=this
</r>
</d>
The option will always be available to ask, but the response will differ based on whether the question has already been asked or not, so that adds some appearance of intelligence to the npc. If you ask someone what their job is twice in real life, they would likely not answer the same way the second time you ask as the first. It's also possible to add actions to each response, for example:
<r=I've already answered this.>
dialogue.hasFired=this
<a=Change Age>
player.setAge=10
</a>
</r>
Would set the players age (I know that one's not very useful, but just an example) to 10 if she responded in that way.
Lastly (nope not done yet, for all 3 of you that are still with me
), there are things called "scripts", which allow NPCs to perform actions or talk to you first without you having to initiate contact. That's this part of the script:
<s=Greeting>
<say=McGonagall says, 'Hello there.', to you.>
player.familiar=1
player.room=this.room
</s>
Scripts will be initiated automatically if all conditions are met in it, in this case, if the player is in the same room as the npc and knows the player. These can also have actions attached to them, for example adding this between <s and </s>:
<a=McGonagall bounds you.>
player.setBound=1
player.setBoundPrompt=McGonagall holds you until you greet her back!
</a>
Would bound the player (make him unable to move) with the prompt "McGonagall holds you until you greet her back!".
Next I'm planning to add dynamic variables within responses so instead of:
<say=McGonagall says, 'Hello there.', to you.>
you could so something like:
<say=McGonagall says, 'Hello, <player.name>', to you.>
And it would automatically insert the players name into the text.
So, to the both of you that are still reading this, you probably don't really care, but I just had to explain it to someone because I'm so proud of it
. It's probably the most difficult thing to program I've had to do in a while (and almost nothing is difficult for me now, a lot of things are just tedious), but I'm very happy with the outcome, and I think it will allow for some great player-npc dialogue within the game.
Video might come tomorrow if I decide to make one, but it's really not that interesting to watch, just fun to play and script.