Action Based RPG

Posted on 10-06-2018

I’ve always been crazy about building RPG’s. Something about designing a core mechanic and going completely overboard with features has always intrigued me. Besides that, a solid base can be created on which can be expanded with clean code. Thus about a year ago I decided to start a project with an idea I had in mind for quite some time, and decided to slowly expand on it. Refactoring would be allowed whenever I felt like it, or the design changes asked for it.

The core mechanic revolves around Actions, which have a warmupTime and a duractionTime. As soon as an Action’s warmupTime is reached it invokes a list of Effects. The Action is then updated until its durationTime is reached, at which point the Action is discarded and the next Action will be updated. This means that instead of action points or mana, time is used as a resource. For example: An Attack inflicting lots of damage could have a long warumpTime, allowing the opponent to go for a shield. An Attack could also have a short warumpTime but a long durationTime, which in turn allows the opponent to retaliate and plan its Actions.

Entity waiting until the warmupTime has been reached before attacking

Entity waiting until the warmupTime has been reached before attacking

The game is played by lining up a queue of Actions, from which only the current Action is updated. The queue can by interacted with by adding, cancelling and moving Actions. The current Action can only be cancelled while the warmupTime is completing. If the current Action is discarded, the next Action in the queue will be updated. If there are no other Actions the current Action will loop.

The player interacting with the Action queue

The player interacting with the Action queue

As mentioned before, each Action has a number of Effects. Effects can range from inflicting damage, casting shields to stunning an opponent. I wrote a custom editor with a movable list, so that Effects can easily be added to an Action. Each Effect also has a target, which opens up more possibilities. For example: An Action that has recoil damage, or an Action that inflicts a great deal of damage on the target while inflicting poison on the caster.

Custom editor to edit Effects

Custom editor to edit Effects

An Entity is collection of current stats, like health and Actions, and a Character and Controller. A Character is a collection of data, namely animations, Actions and stats. A Controller interacts with its Entity. The Player is a type of Controller, but so is the AI. This design pattern allows every Character to be used by every kind of Controller, be it the player or a specific AI.

Entities battling using different Characters and Controllers

Entities battling using different Characters and Controllers

An ambition for this project is to create a playback system, which records player input in a normal battle and allows the battle to be replayed. I would like to do this by creating a type of Controller which copies the recorded input and seed. The only inputs which have to be saved are adding, moving and cancelling Actions. By calling these inputs at the correct time the battle should play out exactly the same.

The source code can be viewed on my Gitlab repository. The placeholder art is artwork from the game Dokapon Journey.