Turn Based Combat(May take a moment to load)


The Makings of a TRPG


One of my favorite games growing up on PS2 was a tactical RPG game called Gladius. I loved the grid based combat and enthusiatically played along in this game's world of gladiator schools and arenas. You had to use the 3D environements in the arenas to gain the tactical advantage, and the hundreds of different skills and weapon types made the turn based combat system look and feel great.

My goal for this project was to begin creating something similar to Gladius. I soon realized that creating a full 3-D RPG game is an extraordinarily large task, and quickly had to reajust my goal to something more realistic. I decided on creating just one playable battle with simplified characters and minimal UI.This was still a huge task for me, but at least it was attainable.

This project has been months in the making, and there were many hurdles I had to overcome. Throughout the past few months I had a few problems that particularly stumped me for a while:

1. How to generate a grid and use A* pathfinding to find the shortest path on this grid
2. How to Visually illustrate the chosen A* path.
3. How to make my generated grid work with 3D terrain.
4. How to make turn based combat.
5. How to import 3D models of characters and rig them for animation.
6. How to make the arena.(I had no 3D level creation experience)

All of these challenges were difficult in their own way and took a lot of problem solving and research. But, by far, 1 and 4 stumped me for the most time. When I first approached the grid generation problem I was confident that I should create many squares or cubes side-by-side to create the grid. However, I came to find that it is much more simple to create a 2D array of points. Each point designates the center of a square in the grid. This way I am able to give each point an X,Y coordinate, and my A* pathfinding implementation simply returns a list of these points in order within the chosen path. I later went back to add a Z float value for the height of each point and a Quaternian rotation amount for each point in the grid to make my grid 3D.

To create turn based combat I implemented finite state machines for all of my characters. I then have a TurnManager class which takes in a Queue of these characters. Each character starts off in an Idle state and only goes into an active state when the TurnManager takes the top character in the Queue and makes it active. After a character finishes its turn, it goes idle and enters a finished turn state which triggers the Turn Manager to activate the next character.

This project taught me a lot about writing clean code and avoiding technical debt. It took me three attempts at this project to get every system to work together, and I found that striving to write cleaner code, adhering to naming conventions, and trying to stick to the SOLID principles helped a lot in keeping each system more modular and readable. There are still a few systems that are quite rough around the edges, but I am excited to expand on this project in the future by adding ability systems and stats to the characters.