I designed an RPG game that has multiple story threads, meaning that, depending on the user's choice some things may or may not happen, you can achieve the same thing in several ways, the ending can be different and so on.
I implemented a simple decision engine, which works fine but has one huge flaw, in the moment you take a decision the story is influenced immediately by your decision, which means that you can't take a decision that will affect you in the far future. This is because the story unfolds like a branch in a tree structure, and it always needs to know which node is next. Under the hood, the decisions are implemented using a queue: each node knows about the previous node and the next node (or if it's a decision node it waits for user input to set the next node)
I saw lots of games that have complex decision engines, and I wonder, how are they made? Is there a special design that makes the things really easy? Did anyone did something similar and can give me a hint on how to tackle this?
UPDATE 1:
An important aspect is to manage to somehow keep the story code independent, so that it can be manipulated from an external file. I plan to use this as an engine so even the possible choices have to come from an external file. The code has to be totally abstract.
Also, I'm interested in a design solution, a nice way to do it, how others do it or did it.
if (isTree)
or keep anisTree
global var because the story may or may not have that choice in it. Know what I mean? It's more like a choice engine that will serve multiple stories. \$\endgroup\$isTree=true
however, later, he does something else, like, fighting a school mate, who in return goes and chops off his tree while the tree is still young because he got his ass kicked. Now, we have 2 variables that influence the existence of the treeisTree==true' and
didFightBrat==false`. Know what I mean? And the chain can go on forever, the existence of the tree can be influenced by an unknown number of factors. Know what I mean? \$\endgroup\$