So your characters learned to level up? Whoopty doo.
If you followed the previous tutorial then you now have a nice, basic, level up system for your game. Last time we learned how to eliminate the enemy and gain a little bit of experience in the process. That experience then accumulates and eventually causes our character to level up, which in turn alters our characters attributes slightly. If you haven't read the previous article yet, you can find it here.
Now that our characters level up from the experience that they collect, we need to develop a system for letting our increased strength and knowledge show. We need to create a math based system that allows our specs to reflect their increased value on their own. Today we are going to learn a very basic version of this just so that you can see how it works. I will probably post more on this at a later date showing a few more complicated ways to create a more in depth system. But for now, let's keep it basic.
Let's Get Started
To first get a firm understanding on what we are doing here, we are going to just focus on one part of the whole system. This will allow us to grasp what's happening and why, and then we can apply this same thing to all of the other aspects of the system with little twists if needed. The part we are going to focus on first is a very basic algorithm for calculating damage. When I say very basic, I do mean very basic.
The general concept of what we are going to do is take our characters attack, add it to our weapons attack strength, and then subtract our enemies defense (like I said, very basic). The output of this function will be the amount of HP that it takes from our enemy.
I kept it very simple with this example for the sake of understanding. Our attack is 5. Our weapon attack is 7.
5 + 7 = 12
Our enemies defense is 5.
12 - 5 = 7
The damage that we inflict is 7.
Again, this is a very basic way of doing things. For a lot of games, this would work. You wouldn't need to do much else. If your doing any kind of platform game or small scale rpg, this system would work well. If your creating a game that could compete with the Final Fantasy series, you would probably want a more complex and thorough system, which would involve incorporating several different factors into the calculation of the damage done. This usually involves things like strength, dexterity, agility and several others. I will cover all of these things and the math involved in the advanced mechanics part of this series. But for now, let's run with this.
Applying this to the Rest of our System
Once you've learned how to calculate damage done by an attack, all of the other specs of our characters will be easy to work with. To calculate the damage done to us, we would apply this same method, but opposite. We would add the enemies attack to his weapon attack if he's using one, and then subtract our defense. That would then take away from our HP.
You can calculate magic damage and things of that nature with the same method described previously. If you are looking to add elemental damage, status effects, and things like immunity and weaknesses, I will be posting another stencyl tutorial soon specifically about those topics.
What's Next?
Within the next two or three days I will be posting an in depth stencyl tutorial on skill trees. It will describe full implementation of skill trees, how to make them effect your characters stats, how to add new skills and magic to your character, and even how to apply a system of collecting points and how to spend them on your skill tree.