What would be the best way to make an event-based game where one event triggers the next one?
For example, the player has to do something like pick up trash, and if they don’t pick up the trash then the story wont progress. This is probably a very simple thing to do but I can’t think of anything. I don’t want to use a bunch of if statments because if the story is long then you can see how it would get cluttered easily. If you’re familiar with the game “Fears to Fathom”, that’s basically what I’m going for
I used this approach once which worked wonderfully:
"Your game’s story should probably be in the form of a finite state automaton (or some kind of extended FSA). When certain events happen, you should move to a new state. This way you only ever have to store the current state and whatever information is needed to know where to move next in the FSA (along with player details like position, health, etc.).
For example, if we absolutely oversimplify the Pokemon games, the gym badges form the main branch of the FSA. You start in state 0 where you have no badges and as you beat the gym leaders you move through the states, to state 1, to state 2, etc. To get your game entities to update to the current state, you only need to get them to look at the current state. For example, an NPC outside the 3rd gym would check which state you are in, see you are in the state corresponding to having 3 badges, and respond accordingly (perhaps with a “Well done!”).
You don’t need to store the state of everything in the world; just the state of the story. The entities themselves know how to react depending on the current state."
c++ - game story event programming - Game Development Stack Exchange
I like this approach, I’ll definitely try it thanks!