Day #6
2024-07-05T04:00:00Z
Alright, feeling pumped let’s do this, SO EXCITED!
One thing I also have to make clear is that I need to have a strong focus on creating systems that are modular and expandable and can interact with other systems seamlessly and effortlessly, this way it’ll make the game development flow so much easier being that I’m making this solo and I need to prioritize everything equally, and I don’t wanna be let’s say modeling for a few days and come back and have no idea what my code does, so it’s very important that I keep my stuff very well organized and neat.
Okay, so for this project one of the very first mechanics that is most definitely going to be needed is a way for the player to talk to the characters within the story, in other words dialogue!
So I started working on the dialogue system about 5 days ago, and it’s actually pretty much complete.
What I needed to make sure of was that it was expandable and easily managable and what better way to do that then with OOP (Object Oriented Programming).
The structure of how I want scenes in the game to go are as follows
Cutscenes → Dialogue → Optional DIalogue Choices
In this game a cutscene basically encapsulates dialogue and then of course that dialogue can have dialogue choices within it which are opttional of course, think of it like a parent-child sort of thing, so each scene in the game is going to be triggered by me starting a cutscene and within those cutscenes are dialogue; cutscenes in this context are just holders for everything. Honestly just a super good way to just keep things organized under a familiar term.
I had to create 3 seperate classes, a Cutscene Class, a Dialogue Class and a Choice Class
Cutscene Class
This class basically takes in a part to start at which is just where the cutscene will place the player when it’s supposed to start, a dialogue object basically the class that holds all the dialogue and also optional dialogue choices, and then a BindableEvent called Completed that’ll be used to tell me when a Cutscene is over!
Dialogue Class
The dialogue class is pretty simple it literally just takes in a chain of nodes which store different thigns about that piece of dialogue!
Choice Class
Probably my FAVORITE one out of all of them, this class is what adds choices to an existing dialogue object, the choices which is just a table of strings, and then the bindableEvent
basically allows me to know when a choice has been selected, the UI function that handles populating the choices fires the bindable and let’s me know what choice was selected, then we have the most recent part of the system which is timeLeftToMakeChoice
this as it’s name suggests is how much time a player will have to make a choice, and then the choice
which is just a string of the selected choice, theres also a few more like responses
which holds the corresponding things the NPC will say back to a choice you’ve made, then of course we have the actions
which a table of functions, this is more useful when a choice explicitly needs something done like immediately and the results is basically the metrics that are influence depending on the choice you made!
Relationship Metrics
Alright so this part I don’t know, maybe might be subject to change but basically I’ve been doing research on choice mattering in story-driven games and just come across just a wide range of videos and I’ve come to a conclusion that every game has a certain narrative that it wants to tell and no matter what choice you pick it’s going to have to one way or another lead back to the path the creators of the game wanted you to take, I mean if this wasn’t the case scope for story driven games where you can make choices would be blown way out of proportion… so currently I have a mid-level system where the player has a relationship with every NPC in the game and these of course are stored somewhere I can easily access them when I need them but it’s a pretty simple module but it looks something like this
So it’s just a table with currently right now 2 metrics which are trust
and respect
, how it works is if you remember from before in the responses basically it’s a table of tables which have a string as the first index and then a dictionary called influence which is where the magic happens, what it doesnt do is randomly select responses oh no no, depending on the choice you pick there are obviously going to be corresponding responses, but within those responses are variants which have the different influences, an algorithm adds up compatibility score for all those responses that fall under the same index of the choice you selected, and then it sees which one is the most compatible with the relationship metrics you currently have with that NPC, it works pretty amazing and it’s probably all I’ll need really, sorry if it was a bit confusing but yeah feel free to ask questions though!
So that’s about it for all those things, they work super well and I’m really happy with how far I’ve come with all of it in the past few days!
My Current Code Setup
But let’s check out some code I have for the setup of one of the very first scenes in the game, (the car salesman getting fired by his boss)
So, uh this is pretty much the whole Client script which is in StarterCharacterScripts
, all im doing is requiring the carsalesman cutscene object and then setting up an event so I know when it’s done and then literally just playing it after, it’s so simple, clean and neat. This is why OOP is so awesome!
Video Showcases
Finally what you guys probably skipped to, although I do really like going into the code bits, most people are visual so you guys need some visual stuff which I completely understand!
Full Showcase (from 2 days ago)
This video shows me going through the back and forth dialogue with the boss, sum light sum light
Metrics & Weighted Variants(from 2 days ago)
This honestly doesn’t differ much from the last video but this version had what I talked about earlier implemented which is where the game finds the variant of a response which most closely matches the relationship metrics you have for the NPC you’re speaking too, also I havent added may variant responses as I think i’ll focus on just the top level ones and I’ll come back to the ones just below that when I have more things fleshed out
Actions & Cam Cutscene
So this one got me super excited and was fun to make, basically this is when I implemented choice actions which is choices that have functions tied directly to them, unlike just a regular choice which gives back a response this one just fires a function, so I used it too give the player a choice to either sit down
or stay standing
, and when you chose to sit down it would play a short and sweet camera cutscene and then continue the dialogue after that action is finished, this was really a chef’s kiss moment!
Choice Timer
Up until now I thought the dialogue and choice system was simply amazing, but there was just one thing I knew it was missing which was… A TIMER, I mean it didn’t make too much sense too just let players have unlimited time to make a decision so now if you read the code from up there you’d know that each choice class has it’s own number of seconds a player has to make a choice, so this makes it so robust and I can easily change the values too what I see fit in the context of the choice options the choices are attached too!
And that wraps up everything I’ve made up until today, thanks so much for reading and hope you have a wonderful day!