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
How to make a simple dialog system ?
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
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
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:
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);
...
};