So for my game I am going to need a dialog system. I have a few ideas and I think the simplest one might be this but I am wondering if anyone else has any other ideas!
The best idea I can come up with is that all of the dialog is stored in a file, which will also use tags to "attach" the dialog to specific characters in the game. Each character will be based off of a UDT which will have variables that control the NPC's current mood, their name, and the dialog.
Depending on their mood, the dialog will will either be happy, sad, or angry. For quest characters they will just have "neutral".
So, for example I might be able to do this...
Bob as NPC
Bob.mood = happy
if Bob.mood = happy
Bob.dialog = "Greetings traveler! How may I assist you today?"
elseif Bob.mood = sad
Bob.dialog = "I was told I was ugly. So I'm depressed about that."
elseif Bob.mood = angry
Bob.dialog = "I REFUSE TO ASSIST YOU SINCE YOU SAID I WASN'T PRETTY"
endif
Instead of hard-coding the text though, I would definitely use a file system to store the dialog. I'm thinking something like this:
#happy Greetings traveler! How may I assist you today?
#sad "I was told I was ugly. So I'm depressed about that.
#angry I REFUSE TO ASSIST YOU SINCE YOU SAID I WASN'T PRETTY
Then I could parse through the file, and according to the mood set the dialog accordingly. I haven't really used parsing before though so I would have to research that but I'm sure it's not difficult.
The current dialog that would load as the player interacts with the NPC would get assigned to one text object that would reset itself once the player has finished talking to them. I would have a function that loads the dialog once the player presses the appropriate key to interact with the NPC.
I feel like parsing through a file on the fly may slow the game down a bit, however, so I'm wondering what I could do to better optimize it?
Slowly compiling code, one byte at a time.
Follow meh blague for more zany thoughts and possibly offensive programming!