Sunday 30 September 2018

September Struggles

Since starting development on my game prototype I've encountered several problems that I've had to solve. Most of the problems I've ran in to so far have been caused by having to get used to Unity, but having experience in several similar studios has helped with that.

One problem that had me stumped for a good week this month that I want to talk about is creating the dialogue tree for use in the game's events. Basically the way I needed it to be is so that the player can choose an option in an event and get a relevant response with new options. 




To add this in initially I started with having 4 options and then when you choose one, it goes to the next 4 options. Obviously this was just for basic testing and would not cover the large events I have planned. Scaling wise it would be ridiculous as well, with the initial 4 options linking to 16 more stored in the class and then those 16 linking to 64... Not really too efficient.

I already had a class to hold event information from this placeholder system, Event title, options, sprite... But the way it worked wasn't useful. It stored all the event's data  in this one class.

What I eventually decided on after some research is to have the initial event class that is called, and then an additional class that it links to which I called an event module.


I started out visualizing how it would work in some diagrams to get my head around how it would be implemented. The event would contain the same variables as the module but with additional variables that wouldn't change during the event (title, sprite).

Events connect to the modules through destination variables attached to the different options that can be changed in the editor. A function in this event class is played when a choice is pressed that takes the destination node and goes to that event module.

In my case I also had to have a few additional features to the event system, effects that can be afflicted on the player (good or bad) and stat checks that can give the player a varying chance of succeeding at the event depending on their stats in comparison to the stat needed for that specific module.

For the effects on the player, I introduced a reward module that works and activates similarly to the event modules and produces a different effect depending on the option. These give me the ability to apply an effect, for example -5 health or +1 luck, in every module.


The stat checks I made work by adding variables for each option that hold the stat type (strength, health, luck etc.) and stat requirement for that option. A formula is then played on choice press that gives the player a percentage of succeeding depending on the difference between the player's stat and the required stat. This is also workable with no stat requirement e.g if an option has simply a 50% chance of succeeding. These link to different event modules depending on success or failure.



From here, the event modules can also link to additional event modules using their destination node, only terminating the chain when a module with no options is the destination.

Eventually this came together and gives me the event system I have right now, with a fully branching dialogue tree with enhanced features that I need for the game. It took stumped me a few times making this system for the simple fact of not planning it out in it's entirety first and also trying to build off my existing system. In the end I mostly rebuilt everything that I currently had for the event system.

Here's a recent showcase of the game with the event system in! Thanks for reading.

P.S we have a new Logo!