Implemeting Skills in RPG

There are a bunch of ways to handle skills but I like to use HTN Planners. Exploring HTN Planners through Example is a good reference. I think the main games that have use this are Killzone, Transformers: Fall of Cybertron, and Horizon Zero Dawn.

It’s very similar to a behavior tree but it creates a plan instead of running the actions directly. Normally this can be a bit complicated for action games but I like using it for turn based games since it doesn’t require refreshing the plan.

So I might make a compound task for a skill e.g. double slice. This task can reuse other existing tasks e.g. move to, dodge. You can also add more than just damage to the task e.g. first slash does x-y damage, has a x% chance to do poison, plays an animation, spawns particle effects if the attack hits, plays sounds etc.

There are a few things I like about planners.

  • Its easy to test e.g. given a set input it generates a list of actions which I can check without running the game.
  • I can combine skills with AI logic e.g. if an enemy has a team member that’s low on health then try using the heal skills first.
  • Planners are kind of like time travel which allows you to solve complex problems e.g. easy to win lotto with a time machine. For example, an enemy might have two skills: single physical attack, AOE fire attack and it can pick the best skill to use. This could be difficult to know beforehand e.g. does the player have fire resistance etc.

I feel like not many people use HTN planners so behavior trees are another alternative. I was tempted to try the new Behavior graphs for skills at some point. If you’re only starting then HTN planners are probably overkill but it might be worth looking at in the future.