Features
Dialogue
Option 1:
The player is able to actively choose the dialogue that the protagonist says. After initiating a conversation with a suspect, or just an A.I. controlled NPC, the player can choose responses to questions or statements to say. There is a problem about how to keep track of all of the decisions. There are a few ways to handle this. An easy way to accomplish this is a tree; the following drawing illustrates an example conversation:
This simple tree demonstrates two possible answers to the question "How are you?" The player can then choose either "Good" or "Bad." This can easily be coded; a class has private members "left" and "right" which represent abstract branches of the tree. The "left" would point to "Good" and the "right" would point to "Bad" (in the picture, boxes are classes, while arrows represent pointers). However, what if the storyline called for three options -- like adding "Okay" to the list of answers? Likewise, what if, instead of "That's great!", the storyline required the suspect to ask "How come?" no matter the response? Certain dialogues have multiple responses, so how is this handled? The tree can of course, branch off as many times as possible and can convert to the same outcome:
/*
* Use a tree
*/
class tree {
private:
class node {
public:
string data;
private:
node *right;
node *left;
friend class tree;
};
public:
node *root;
tree() {
root = NULL;
}
//etc
};
The script then needs to be translated into code. We can label each split as a node. Once we have a set of nodes, we can link them, and pass a string into the data that will be printed.
The tree starts with the node "How are you?" and links to "Good" and "Bad." "Bad" then links to two other nodes. Therefor, nodes are initialized for each decision (with the start being initialized as the tree) and then the entire tree in constructed. "Good" becomes the left pointer node of "How are you" and "Bad" becomes the right pointer node. "Good" then will most likely call a function to print the next piece of dialogue ("That's great") and then will point to NULL for both its left and right pointer nodes; thus, the 'search' down the tree ends and "Good" becomes what is known as a leaf. The leafs are then stored in some type of structure for the program to know what decisions the player has made. If a node points to NULL, then it becomes a leaf.
/*
* Basic tree class that points to a starter node
*/
class tree {
public:
tree() {start = NULL}
//overload constructor
tree(node * node_ptr) { start = node_ptr; }
private:
node * start;
};
/*
* Simple node class that points to two other nodes.
*/
class node {
public:
node() {
left = NULL;
right = NULL;
node * left;
node * right;
};
Option 2:
Another option is to write out all the dialog in an xml file and have a dialog class that when initialized would parse the xml file and store the data in a hash table.
Option 3:
Use an .ini file:
[q0001]
question = How are you?
answer1 = Good
target1 = q0002
answer2 = Bad
target2 = q0003
[q0002]
question = O, great!
[q0003]
question = How come?
answer1 = blah
target1 = blah
answer2 = blah
target2 = blah
Option 4:
An ambitious idea: allow the player to construct their own responses and questions using something similar to A.L.I.C.E. I suppose we should (if we go this route) write our own AI chat system since after searching I (Ivan) have found very little. The AI bot would have to be able to be recoded for each character, it would have to have 'states', it would have to change with time, etc.
Option 5:
Combine a quick response feature with a chatbot feature. The player is given the ability to either ask precreated questions or answer with precreated statements, but also has the ability to type in questions and statements for greater depth and investigation.