r/howdidtheycodeit • u/iwaitinlines • Sep 05 '23
How point and click games are coded (state of game) or RPGs with branches
I was playing some old point and click games and was thinking on the the structure to keep the state was stored since there can be a lot of branches according to the user decision.
How is this implemented? I imagine a something like a decision tree, but it would be a gigantic tree to maintain and keep track of the right state.
Is it some kind of main state and some extra stored details that have the "outliers" ?
And if someone had a real example to take a look it would be great
13
Upvotes
14
u/abrightmoore Sep 05 '23
You might enjoy having a look at ScummVM which implements the Scumm system used in classic LucasArts point-and-click adventures.
https://en.m.wikipedia.org/wiki/ScummVM
Repo: https://github.com/scummvm/scummvm
Wiki: https://wiki.scummvm.org/index.php?title=Main_Page
5
u/nudemanonbike Sep 05 '23 edited Sep 05 '23
So there's not one correct answer to this problem.
I'd look into some frameworks that are designed to help with it:
Dialogue System for Unity (Used in disco elysium!): https://assetstore.unity.com/packages/tools/behavior-ai/dialogue-system-for-unity-11672
Ink, an all scripting based approach: https://www.inklestudios.com/ink/
Yarnspinner: https://yarnspinner.dev/
Ink and yarnspinner are both open-source and designed to be middleware, too.
There's paid tools, too (look at all the importers provided with the first tool), but you probably won't find great information on how those work on the back end
1
u/neonoodle Sep 06 '23
it's usually not a gigantic decision tree. There is often a limited set of variables that need to be stored. I wrote an adventure game system and the only thing that really needs to be stored is player position (and scene the player is in) and inventory states of everything that might have inventory, and then I added an inventory to every puzzle item. For instance the door has an inventory that can only take a certain key, and then when the player comes to the door they can use the key on the door and the door accepts it and it leaves the player's inventory. Now when the player tries to open the door, the door checks whether it's got the key and then opens or plays some dialog if the key isn't available. Then I just store all of the inventory states of the game and when I load the game state is just as I left it.
1
u/joonazan Sep 06 '23
If you have a graph of the game, just store a number indicating where in the graph the player is. Though games with that little state are often not very interesting.
Fallen London has an interesting approach where your character accumulates qualities. Each quality just has a name and icon and can be any number. It can be awkward to have to do everything with that system but the benefit is that it is very transparent and easy to understand by the player. It is also very easy to implement.
1
u/Rudy69 Sep 06 '23
flags, lots of flags