Hello guys I'm try to make some games that have more to it than just simple high score scrolling shooters etc.
I'm trying to design my own systm of handling narrative. I want to be able to place NPC's in the game world, with scripts attached to them. Some of the NPC's would just have n random greetings. Others will be mission givers and will offer you a quest of sorts. (The quest could be go speak to Bob in the pub, or it might be bring me the Holy Grail and Crown Jewels, or something in between).
I've wracked my brain for a long while over this but sadly keep slipping back to the only way I know how, which is to manually code all the strings that people can say and have a horrible web of if statements and other such insanity to give me a rudimental dialogue system. Its not good enough even with just a few characters, but if I had dozens/hundreds of characters it would be even worse.
I've read lots about it already but I'm still very confused when I start trying on my own project. I've read that Json/XML might be the way to go and that I can add custom markups in the Json text to call methods in my code, but I dont even know if this is right and if so how I can do it.
The back of my brain is screaming at me that there is a simpler way to do it, but I've sat here for a very long time without managing to think of ideas.
Here is a diagram I drew which pretty much shows the flow of how I want my NPC to behave. If anyone can see this and then tell me how they might do something like this that would be fantastic!! (note: if Json is the correct advise, please give me a exact example of how exactly to format the Json in order to check the bools I mention in my flowchart - thanks!):
note: The circles denote an output from the data as Text for the dialogue system. The bools will need to be checked against by the data file to see which output to give (hope that makes sense and is possible)
Answer
It looks like you're trying to describe behaviour, and "tool for describing behaviour" is basically the definition of a programming language.
Data formats like XML and JSON suck for describing behaviour, because you can't have e.g. conditionals or mutable state. If you make your parser clever (such that it turns certain XML/JSON constructs into conditionals etc.), you'll soon realise you've implemented the world's worst programming language.
Use a programming language.
More specifically, perhaps you want a finite-state machine as an object for each mission, to track the player's progress in it? It could listen to appropriate events (like inventory changes), and change state accordingly. Then every NPC related to the mission could refer to that common data when deciding what they will say.
No comments:
Post a Comment