• Register

Humanity has been invaded by otherworldly forces using magic. Can you lead the resistance against the oppressors in this fantasy turn-based strategy game to save humanity from becoming slaves of magic?

Post news Report RSS Devlog #13 The anatomy of skills in a turn-based game

This devlog is about how we created a modular skill system, which is easily editable and moddable using JSON files.

Posted by on

Devlog #13 The anatomy of skills in a turn-based game.

Hello everyone! This devlog will be a bit more technical than usual, so I will start with some general eye candy before going into today's main topic.

Character animation system:

anigifmace

idle animation

deathanigif

As promised in the previous devlog, the creation of character animations with arms is progressing nicely.

What do we want from our skill system?

Now, to the main topic, the skill system. Let's define our goals as usual first:

  • We need it to be modular, as we want to create a lot of skills as easily as possible.
  • We need them to be moddable outside the code, as we want to give the community the ability to tweak skills if they want to, or create new ones easily.

The naive solution:

When I first started working on this project I wanted to create a playable prototype as soon as possible so I went with a naive solution I think worth talking about before I rewrote the system. Basically, I created three types of skills. Attack skills, movement skills, and buff/debuff skills. It is a great simple system, quick to set up, intuitive, at first glance modular, so what is the problem?

The problem is when you want to create an attack skill with a buff/debuff effect if hit for example. Or a skill that involves movement as well. You can get around this by copy-pasting the relevant code into the main skill category, but it is a big no-no in the programming world. Mostly because if you want to change something in one place, you need to remember to change the copy of it too. More chance to make a mistake, which we want to reduce not increase! Not to mention it will create a messy code that is hard to read.

Identifying the core parts of a skill:

So, we need to go deeper than the type of skill to reach the real building blocks from which a skill can be created modularly. In our new system, a skill is created from 4 major parts.

  • Default parameters every skill has. These are things like skill name, sound/animation effect corresponding to the skill, etc.
  • Targeting module(s). This module defines which tiles are valid as input for a given skill.
  • Affecting module(s). This module defines which tiles will be affected, and its input is the chosen tile/tiles of the targeting module.
  • Execute module(s). This module defines what happens on the tiles. The input for this is the chosen tile/tiles of the affecting module.

These are the building blocks of how we define skills in our game. What modders (and us as well as we are developing) will be able to do is to use the modules I created, re-parameterize them, and link them together in any way they like to, as these are freely editable in JSON file format. Like building with lego, just the modules are the lego pieces, and the end result is a skill.

Example:

Here is the JSON file of the basic sword attack:

basic attack 1

Human readable and editable. Thankfully not even too long, because every parameter has a default value, and you only need to write it out if you want to change that value. It is using the melee_targeting module, so choosable tiles are the ones in melee range. Line_to_target affecting module basically means to draw a line from the character to the chosen tile. Every tile in that line is affected. The width parameter defines the width of the line in tiles. And the attack_execute module means it is going to do an attack against the unit in the affected tiles, using the weapon damage by default. The skill in the game:

basic attack

To demonstrate the power of this system, let's say I want the basic attack to be a sweeping attack, so to not only attack the tile that was chosen but the tiles next to it as well. All you need to do to edit the line_to_target affecting parameter width value to 2. That will make the line wider to the target so that we attack in a cone, like so:

basic attack wide

I think it is pretty neat that we can do this without touching the code! Of course, we should replace the animation with some sort of a sweeping animation as well for better visual feedback (just replace the self_effects in the JSON) but I think this gets the point across. In addition, I intentionally kept the example simple. I only used 1 module each, but you can add multiples as well. Want to create an attack that hit twice? Add another attack executes. Want to add a debuff to the skill? Just add the proper debuff execute module to the skill.

So, this is the backend rework I was working on while the animations are being done. It took a while to get this system working, but I believe it will speed up the process of adding skills into the game by a lot plus it is mod-friendly if the community wants to tinker with it. So that's it for today's devlog, and speaking of community, if you are interested in Slaves of Magic you can show us your support by wishlisting the game on Steam here!

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: