Most effiecent way to store tons of functions and things to check for

Intro
Hallo I am making an rpg and so far it seems like only skill system is left. We will end up with a lot of skills. The way you train them isn’t by the traditonal ap/sp system, we use something like the game “Mabinogi”.
If you don’t know how it works you can read the section below else you can just skip to the problem.

The system
To train a skill you’ll have to do a certain task x amount of times to gain experince. When experince of that skill is on 100% it levels up. When you level up the number of task incresses and new ones may be added, they varies from skills to skills. Some examples to this is:

Sword master lowest rank:

Attack an enemy with Sword. exp 10 amount of times you can do this 10
Defeat an enemy with Sword. exp 20 amount of times you can do this 5

Sword master highest rank:
Defeat Strong enemy with Sword 0.01 2500
Defeat an Awful enemy with Sword 0.1 300
Defeat a Boss enemy with Sword 1.0 80

Cooking:
Make any dish by mixing cooking ingredients.exp 6 repeatible 100

cooking highest rank:

Steam a Dish 20 1
Make a Pie 20 0.5
Eat a Pie 50 0.2
Make Jam 50 0.2
Learn More from Friends or a Book 1 50

The Problem
I’m relatively new to coding and I can only think of one way to program this, however it’s going to take tons of space and a lot of resources on the computer its running on. So my question is how would you program this?
The way I was going to do this is making a script pr class and save all the currently values for all the different skills but we are talking about a game that have a mastery for all kinds of weapons, one skill for each magic and so on. So any ideas are welcome. If you’re unsure what my problem is or how the system works please don’t hassitate to ask…My last 3 questions was ignored :,c

I’m not asking for you to provide the finished code just more the theory behind it.

Anybody?

If they were as hard to answer as this one, you might have scared people away. :wink:

It’s not necessarily hard to implement, but it’s hard to answer because there are so many possible approaches.

You could write a bunch of scripts – perhaps an abstract base Skill class, and a subclass for each skill. Like you said, it’s a lot of scripting. But if it works for you, go for it.

The trend, however, has been toward data-driven development, for these reasons:

  • When the details are in data rather than code, there’s less code, so there’s less opportunity for code bugs.
  • Non-programmers can add new skills and tweak settings.
  • If you make a change to a skill, you don’t need to recompile code.
  • You can usually reuse code better.

To do this, you need a way to define a skill entirely in data – its effects, its animations, its requirements, etc. You could define them in ScriptableObjects. Jacob Pennock write a good tutorial on ScriptableObjects.

A ScriptableObject is an object like any other, but it’s serializable and easy to work with in Unity. Say you create a “class Skill : ScriptableObject”. In this class, you might define an array of abilities, where each ability is itself a serializable class with variables such as:

  • Name of ability
  • Exp.
  • Amount of times you can do this
  • What happens when you use the skill (animations, sounds, damage, create object, etc.)

You can even save ScriptableObjects as asset files in your project. Then you can give each character an array that you can edit in the Inspector to add skill assets to.

You might also look into how other systems, such as plyGame, handle skills: documentation, creating a sword skill.

2 Likes