Example of FSM Building: Combat

A past side project included building Wizardry-style combat. That’s a very specific kind of turn-based combat, best displayed in Wizardry VI and Wizardry VII.

wizardry

I call this phased combat. The player enters orders for each of her party members in turn, shown in the screen shot. Each party member can make choices like Fight, Parry, cast a Spell, Run, and so on. Once she’s entered all the party choices, combat begins!

Notice that there are four sets of enemies–those are enemy groups. Attacks and spells target one of the groups, either going against the whole group (like a fireball) or choosing one of the group automatically. Group order matters, just like party organization (front to back) matters because only ranged weapons can attack from the back slots or enemy groups.

After player party orders are entered, both party and enemy orders execute, fastest first (as determined by a speed stat). This leads to an exciting “what will happen next?” effect you don’t always see in traditional turn-based combat. That’s an overview of what I’m building.

Here’s how my combat FSM started out–you can see the direct translation from system concept to flow of the FSM.

Screen Shot 2015-02-21 at 10.22.19 AM

It’s very basic at this point–it doesn’t handle death, for example, or the concept of enemy groups. It doesn’t have the combat order choices spelled out. The final state machine will be much, much more complex. Seeing it at this early stage, though, helps demonstrate how systems can translate very directly into FSMs. The FSM doesn’t just make it easier or faster to create the combat system: it helps me understand what I’m building.

Now that I have the skeleton, I dive right in at the start. I flesh out building the combat screen, which I won’t discuss in this post because the nuts and bolts of it aren’t important for this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.