Create a (Skill) Database Godot Tutorial | The Combat Series #6

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

When you add many skills and/or weapons to your game, keeping an overview, and balancing things like damage, range or RoF can be hard. A skill-database could be an optimal solution. Learn how to make one in just a couple of minutes!

👍︎︎ 2 👤︎︎ u/Stefan_GameDev 📅︎︎ Nov 01 2019 🗫︎ replies

It might be better to create pre-made scenes of every skill, could save some processing and is imo more readable, but anyway thank you it was a very nice guide!

👍︎︎ 1 👤︎︎ u/tofrank55 📅︎︎ Nov 01 2019 🗫︎ replies
Captions
one of the challenges that game developers face is how to handle all the different parameters for our skills and our weapons and our guns so therefore in this tutorial we'll be making and implementing a skill database that will handle all those parameters for us furthermore it will help us to write more concise code and give us an overview so that it will be easy for us to balance all the different skills and weapons in our game for a better player experience if you're new to the channel and you want to learn how to design and make games or maybe you just want to learn more about go dub then subscribe to this channel and don't forget to hit that little bell icon to make sure you don't miss out on anything also if you got any questions for me about about this tutorial about gold in general or maybe about the game development I'm doing myself I'm streaming every Tuesday and Thursday on Twitch you can find all the details links and my schedule down in the description box below now let's get started on that database so one of the first questions you might be asking yourself is should i implement the skill database and that's a very valid question because the answer isn't always yes let's have a look at our code and see what problems is going to fix for us and then you can see if you are facing similar problems within your game development and then you can answer the question whether you should or shouldn't implement that skill database that we're talking about so within our game so far within this tutorial series we have three scenes and attached scripts that are of interest to us we have the player arranged single target skill and the range area of effect skill on the player script we are matching the selected skill when we hit the bottom we hit fire to three different skill names that we have implemented so far now as we create more and more and more skills these match commands are going to be longer and longer and longer imagine we've got 50 single target skills that means that this line is not just going to be 500 a nice pair but 48 other skills same for our area of effect and same it would be for example when we implement auras or debuffs or buffs for our own party now once we have started this skill and one of the skill scenes is low we are again making a match command for in this case fire on ice beer but again if we have fifty in total we will have to be creating 48 more of these match commands making this total match function a very very long piece of code with a lot of lines is not going to be concise and soon will start missing having a sort of an overview furthermore all the parameters of the skills are in different locations they'll all be here for single target skills but what if you want to compare their damage values to for example the ranged area-of-effect skill like you would want to make sure that the damage values are balanced so that the one type of skill is not overpowered compared to the other and having all these parameters within different scripts is going to be a drawback when you're working on balancing your game so all of that is not really going to be a problem if you only got about 1215 skills or something similar like that but as soon as you go over that fixing all these parameters are fixing the problems of having an overview and writing concise code are going to be fixed by implementing a database and then I advise you to implement a database and that's not that difficult we're going to be doing this in only a couple of minutes so ask yourself how many skills do I have or when you're making the shooter how many different guns and ammunition ammunition do I have because for example armor-piercing incendiary hollow-point and normal bullets are in one ar-15 are basically four different skills so ask yourself how many of those variances do I have within the parameters of my skills or all weapons and then you can answer yourself the question should you or should you not implement a skill database now let's get working on implementation so I'll see you in the next part now for our database we're gonna be making use of a JSON dictionary right here you can see the compiled JSON file that I've already made for our fireball ice spear and lava bong now you might be wondering oh whoa whoa whoa whoa this doesn't really provide us with the overview that you're promising us and you're totally right but as I said I've not written this compile this and the way I compile this is making use of a spreadsheet that's right you can put all your skill data straight in an excel file strengthen it go Google sheet file and then simply compile it to Jason all you have to do is find the right atom so I have create a spreadsheet skill data and within that spreadsheet I've simply added my free skills and on the columns I put all the different skill parameters from the projectile speed to the delay time for our area of effect skills and by implementing or making use of a spreadsheet you have options for all the filter options saying I only want arranged area-of-effect skills for example you can sort by damaged values to see which one has the highest damage to the lowest damage you can make use of all those options that our spreadsheet provides that once you already have 50 skills and you want to implement skill number 51 it's very easy to determine what the parameter should be based on how you want that skill to function within the game is an early game skill or late game skill or a late game weapon for that matter or in your late game type of ammunition you can very quickly see where you want it to be within your game in terms of game design then you can see what the current parameter values are of the skills you've already implemented you can very quickly find those in the spreadsheet and then you'll be able to add that skill quite easily by simply adding another row to the spreadsheet then when that's all done we go to add-ons export sheet data and have a specific add-on that I'm using right now I'll link it down in the description below so you can get it for your Google sheets as well if you want to make use of your excel there's no problem you just have to find a JSON compiler add-on for Excel they exist but I don't have a link for them right now we open the sidebar and when they're over this all the settings are immediately correct for the add-on the if' link you simply have to change the export sheets to currency only by the full that will be on all we're gonna be exporting and that's we'll be compiling our JSON file and when that's done right now you see the right pop-up here with a new timestamp is the Jason that's being given to us so with this Jason thought just coming straight off out out of Excel we have all the overview in Eden Excel and every time we implement something new or we change one of the parameters we only have to compile a new jason and drag that to our game folder so what do you do is you right-click the skill data Jason found that we just compound you download it that will put it in your downloads folder and then from your downloaded folder you simply drag it to your go to project so we're in my other project folder structure I have a folder called data and that's where I put all this kind of jason database type of documents so i have them all neatly organized together and i can always access them so now that the JSON file is within our go to folder structure we can access it within our Godot project so let's start working on our importer function to import this data into Godot now to load this data of all the of the JSON file into Godot we're gonna be making news of a singleton a auto loaded script this is a script which is always loaded whenever the game is started so anything plays another already function of that script will be run as soon as the game starts and before any other note is put on to the game folder or in the game structure so to make that I'm gonna be making this script within the data folder as it will be handling the data within so we're gonna make a new script it's going to be a normal note it's gonna be an empty template and I'm gonna call this singleton this script data import the reason I call it data important upskill import is we're probably gonna have some more files some more database files to be loaded into the game when the game is started and the data import can perfectly handle more than one skill database it's no problem more than one database I should say so we create that and when we create we can immediately go to our project settings on the top here we can go to our autoload tab we can approach in data our data import that gold folder or our script and we can add it and here you can see that singleton is automatically enabled now what this does this Auto loading is that when I run the game and I have a look at the remote so here I can see all the nodes that are loaded currently within this place see is that it loads a giant map scene as we would expect but before anything else is loaded it loads that data import singleton is auto load of file is loaded before anything else is loaded onto the game and that's what we need to make sure this data is in the game before any node may require it now to actually load the data into it you of course have to be making a function so when we open the script data import GD we're gonna paste this little bit of code so I see have a small Intendant problem so let's pull this back a little bit and what we do is we're gonna be creating a new variable called skill data and the skill data variable is gonna have the entire database so this one's will be using within all the other scripts after this part so under the ready function so as soon as script is loaded we're going to be defining a new skill data foul which is a new film and then we open the file the skill data - sheet 1 jason that we have just downloaded from the Google Drive and put in our data folder structure our project folder structure we make it a read-only because we only need to read the data then we again create a new variable called skill data Jason that's gonna be using the Jason parse function and it's gonna get all the information within that skill data file that we have just opened up there and we gonna get that as text then we can close the foul because we know we don't need to have that thought open all the time it's only going to be taking resources so we can close the file and then we're gonna be defining the skill data the variable on the top here we're going to be defining it as that skill data and Jason that we have right here and the results of whatever this json.parse gave within this variable now if I would the skill data and we would run the game again you can see that it plays this call it runs this code right from the start of the script and we have all this data now rarely readily available we didn't go that we know needing I need to print this anymore but it's a demonstration of that it runs the code immediately when the game launches and it loads all that skill data that we have put into that Excel spreadsheet now let's start replacing some of the functions or updating some of the functions within those free scripts that we had at the start of this tutorial and let's upgrade them to make use of this new data skill database let's start with our player script in a player script we were matching the fireball and I spear here with the selected skill in the name of the selected skill to figure out whether we needed range single target skill scene or the ranged area-of-effect skill scene in our database however we have added a skill time range single target skill arranged AoE skill and if we would have 50 more they would all have a time so right now we are matching the name of the skill because we don't have that time or we did not had that time available would in Godot we didn't know that yet that was that information wasn't available but now with the database that information is available so instead of matching 50 different skill names here we expand on our skill system let's just match the type to do that you of course have to be accessing that database the way to do that is you first type the name of the script that it's in so that's the data import script we just made our singleton here off then we have to go to the the the parameter the variable within that script so that's going to be the skill data now the skill data is a dictionary and every dictionary makes use of keys a key holds a certain amount of information now you can see the keys that we have within a JSON file itself those keys are viable and fireball has all this information and then we have ice beer which has all this information the way you create this key is actually very easy because when you compile the Jason from the spreadsheet the first column is automatically the name of the key so if you want to have a skill ID on top of a skill name you would simply add a column in front of this and simply add that ID number for us however we decided on having the skill names as their IDs so that means that selected skill that we had from the prior code can be the dictionary key that we need now or to use now to retrieve the correct information and the information we want to retrieve out that cadaver key is of course our skill time now that skill type is very simply the column name of the of the column right here so skill type skill damage skill projectile speed those are being put into the JSON file as our different information parameters now with this done we no longer get a name here but we get a skill type so that also means that we have to be matching it to difference to every type of skill that there is so that's the range single target skill instead of lava bomb we can match this to ranged AoE skill now with this done we could be adding a thousand different skills and we would never have to change the code we would never have to expand on the match command because as long as we give them a existing skill time within this match command the magical command will be able to run without any adjustments in the code all you have to do is add the skill with the correct skill type in your database so this little script now has had an update this is now much more concise we don't have to upgrade for every skill we add and we get all the data out of our database now let's move on to the two different skills that we have for our arranged single target skill is currently matching the fireball and the eye sphere and setting all kinds of parameters but actually this entire match becomes unnecessary with the database that we have just said because we already know that we are having a single target skill and we know that the information is available within the database that we need so all we need to do is we go again into our script our data import we collect the skill data again we use the skill name this time it's not selected skill but within this script we name this skill names right there and we're gonna be retrieving the skill damage I believe I name it let's double verify that yeah we got skill damage and skill projectile speed let's copy-paste this so within Godot we can very easily build our database references so now we're collecting the data and of course we won't be damaged we set here we want this to be equal to that data we collect from the database same for projectile speed so now I'm already setting the damage and the projectile speed and this entire match command is no longer necessary so just like that we have upgraded this this piece of code we if we would add 50 a hundred thousand skills it wouldn't matter every single target skill is now going to have their correct damage values and their correct projectile speeds being taken straight out of the database and every time you add a new skill you will not have to expand the match command to accommodate for that skill because as long as in that database these variable database lookups are going to be taking the skill name that we already collect from our skill bar and it's going to be putting it straight in a lookup to the database to collect to collect the correct damage and reject those speed values or any other parameter or value that you might want to change but that based on the skill type that you're firing so let's have a look if this all still works then you can see that functionally we have not changed anything to our skills so we still have the firewall dealing a lot of damage being slow the ice spear being fast and low damage in the area of effect oh no that's not working right now well there you go it doesn't always go correct does it I make one small mistake and that the key hair or skill was capitalized and that needs to be a smoker if that would have been the case then that a wee skill would have work talking about a wee skills that goes straight into our ranged a wee skill script and update that as well and we will run that test again to make sure that it works after we finish this and you'll see that that was just that small minor mistake so right now we don't have a match command within our AoE skill to replace because we have not made a match command yet as we only have one AoE skill if we would have had several AoE skills it would have looked a little bit like this the magic commands in which of course after the first match we would have matched it with for example a meteor skill or grenade rocket or whatever yeah I know you need a comb in a pass so let's assume that we would have made the match command in the last episode when we created this a wee skill mechanic and then of course would have meant that we had deleted the parameters on the top here and we're currently sending the animation to lava bump we can remove this all together actually and instead of animation we can play the actual skill named master skill name is exactly the same as the animation name so now let's go with the parameters that we want to fill from the database let's the damage the damage delay time the remove delay time and we want to get the note collision shape 2d and we want to set its radius this little code is basically a look up to this coalition shape and in the inspector on their shape you have a radius in case you work with a circle shape 2d and that radius is determining how big the collision shape is so if I without this 250 I would be increasing the size in which the AoE skill is effective and of course different a wee skills can have different radiuses that's definitely something you want to be taking up into your database parameters so that you can set the values accordingly for every different skill that you have now we can define all these parameters from our database so that is our data import again our skill data then we're gonna input the skill name that's also available in this script on the top right there and then we have to be retrieving a value now this is exactly the same all of these and then we can add the names that is the skill damage the skill damage delay time the skill remove delay time and the skill radius now we're still that error is gone already so with that and these of course are all values of here skill damage skill radius skill damage delay time and skill remove delay time from the database column names so then we would have been able to remove this match command the last two lines of codes I've added here are of course to set the texture appropriately so that the correct animations and the correct visuals are playing and with that done we can play the game and I can demonstrate that the area of effect skill is actually working as we had intended I hope this was helpful guys and that you now know whether a you should or should not be implementing a database and if you should that you know how to make that database and how to make the correct lookups within your game code to make use of that database to its full functionality if you like this video then please give it your like smash that subscribe button if you haven't done so already and don't forget to hit that Bell icon if you want to make sure that you don't miss out on any video that I'll be creating furthermore in this combat series and the other series of that gonna come afterwards also if you got any questions as always you can put them down the comments box below or you can find me on my twitch stream where I stream my own game development you can find me that every Tuesday and Thursday or the links descriptions and schedule are right down in that description box below alright guys that's it for today keep on going keep on gaming I'll see you in the next episode
Info
Channel: Game Development Center
Views: 6,964
Rating: undefined out of 5
Keywords: Godot tutorial, Skill database godot, Database Godot, weapon database, Database for Godot, Build a database in Godot, Create a database in godot, Make a database in godot, Godot database, Godot skill database, Skill parameters in godot, Import Godot, JSON Godot, JSON parse Godot, Import data Godot, combat series, Tutorial Godot, Tutorial Godot 2d, Godot engine, Godot game engine, Godot 3.1 tutorial, Godot 2d, GDC, Godot, Tutorial, Game development
Id: Pc0mooBdhy8
Channel Id: undefined
Length: 22min 9sec (1329 seconds)
Published: Fri Nov 01 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.