Kingmaker is a 2D tactical strategy where the player controls an army of animals fighting to help the lion cub gain domination! While the game is laid out like a chessboard, in many ways it is more similar to an SRPG.
All pieces have a health bar. A piece, even if attacked, does not die until this hits 0.
All pieces have attack and defence values. These numbers determine the damage dealt to and taken by other pieces.
All pieces have an energy counter. When a counter hits the max level, the piece can act. Performing actions lowers this bar.

The goal of this project was to make a small game while learning a simple, open source C++ games library.

There are multiple units in the game, each with statistics that affect them and an ability that defines them:

  • The Cub represents the king, and it will cause the player to win the game if it lands on the opposing side's back row. It can also resurrect dead allies.
  • The deadly Lioness protects her cub by dashing throwing herself into the enemy frontline.
  • The turtle protects its allies by summoning green shells.
  • Elephants heal weakened allies by spraying water over them.
  • Giraffes can hit enemies from a distance by bashing their heads on them.
  • Owls reduce enemy energy and health by recklessly charging into them.
  • Hippos bash their targets with enough force to push them back.
  • Monkeys throw tiny pebbles which stagger enemies, reducing their energy.
  • Zebras are basic soldiers with no special properties save numbers.

I built this game as a sort of side-project long before I made my Artificial Intelligence game so I had little to no knowledge of Pathfinding or using State Machines for AI. This meant that since the units couldn't decide on a path and follow it across multiple turns, they had to do things like determine their target and check if the tiles they wish to enter were empty every single turn.

So instead of creating a pathfinding system that was currently beyond my abilities, I decided to make the AI of each unit type as unique as possible, with specific goals that they will try to achieve during their turns.
The best example is the elephant, who heals weakened allies. Ideally, it would always heal the weakest ally, but it also wants to find one it can reach as quickly as possible. This is done by running a for loop through the army. The script first picks out the unit in the army with the lowest health remaining, and uses it as the target against which everything else is decided on. From there, the loop checks every other animal in the allied array, using a combined value of their health and distance to determine if they're a higher priority target.
Once the target has been decided, the elephant then uses its heal ability, or spends the rest of their turn moving until they're in range to do so.