How to make a simple dialog system ?

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
Mog
Posts: 7
Joined: Tue Jan 08, 2008 2:32 pm
Contact:

How to make a simple dialog system ?

Post by Mog »

hi everyone,

i am currently developping a little game who require a simple rpg dialog system.
I've already done this in the past but it wasn't so clean,and so handful.

For the moment i used irredit to place some characters in my scene,(every character has the name : NPC on irredit so i can get them using the GetSceneNodeByName fonction) and i make an NPC object (class i created) with every node who contains every information on each npc.

I am looking for some advice on how to handle a dialog system between the player and the npc

thanks
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Well you could have a 'speech bubble' above their heads that displays the necessary text at the necessary time. Check out my IrrAI RPG Example for a simple implementation of this.

Or you could use a chat box which is just like an IGUIListBox maybe in the bottom left of your screen which just displays the text in a list.

So once you've decided on how you want the chat to be displayed we might be able to offer more advice ;)
Image Image Image
mk.1
Posts: 76
Joined: Wed Oct 10, 2007 7:37 pm

Post by mk.1 »

A dialogue is a net of nodes so basically each node should contain the NPC's message, all possible answers and a link to the corresponding node (this can be an ID or a position in a file or whatever).

This is the basic stuff. Now there should be messages you can only use once (like "hey ya, here's the lamp you wanted me to find." => "Thank you. In return I give you the 'Ring of Destruction' <hands over ring>"). Now there're two things: one is an event that should be passed to your game (receiving the ring item) and you should make sure you can give the NPC the lamp only once. Assuming your event is just a unique number your struct could look something like this:

Code: Select all

class CDialogNode
{
private:
	int _nodeID;						// id of node
	std::string _npcMessage;			// message of NPC

	struct SDialogChoice
	{
		std::string _answer;			// answer message
		bool _isDisabled;				// you can't choose this message
		std::vector<int> _events;		// possible events you can send
	};

	std::vector<SDialogChoice> _choices;
public:
	CDialogNode();
	~CDialogNode();
	
	std::stringc getMessage();
	
	void addChoice(std::string answer, std::vector<int> events);
	int getNumChoices();
	std::stringc getAnswer(int num);
	bool isDisabled(int num);
	...
};
Mog
Posts: 7
Joined: Tue Jan 08, 2008 2:32 pm
Contact:

Post by Mog »

thank youf for your answer : i think i will make my own chatbox and display it a the top of the screen.

thanks for the example maybe i give it a try
Image
Post Reply