DEV Community 👩‍💻👨‍💻

Fabian Fabro
Fabian Fabro

Posted on

Final Fantasy XII's Gambit System was like programming for beginners

As someone who grew up with video games, especially with the Squaresoft, Square-Enix titles, I thought that Final Fantasy XII's approach to their battle system was fascinating compared to any other of the titles. If you have not played any of the Final Fantasy games, here is a rundown on how the gameplay mechanic works for each title.

In traditional RPGs, battles are engaged through 'Random Encounters.' This is generated by the amount of steps taken by the player before a battle is initialized.

//using c# to describe this

Random random = new Random();

int steps = 0;
int battleTrigger = random.Next(64, 255);
bool inBattle = false;

public void PlayerMove() {
   //Get player's controller input, if playerMove was a method a Player class
   playerMove = step + 1;
   battleTrigger -= 4;
}  

while(!inBattle){
   PlayerMove();
   if(battleTrigger < steps){
     inBattle = true; <-- Random Battle Engaged! *Cue Battle Music*
   }
}

Enter fullscreen mode Exit fullscreen mode

This was based on looking at the algorithm in the Random Encounter Wikipedia link I provided, where it states:

  1. Set X to a random integer between 64 and 255.
  2. For each step in plains, decrement X by 4. For each step in forest, swamp, or desert, decrement X by 8.
  3. When X < 0, a fight ensues. Go to step 1.

I felt this is more true to the Final Fantasy Random Encounters compared to the first algorithm given.

There are the exceptions of battle encounters in Final Fantasy I where battles are triggered when you step on a tile adjacent to a dungeon treasure box, (which was super annoying but you knew there was always a battle waiting for you even though you were low on health traversing in a dungeon with low MP!).

Final Fantasy I - III: Wait System

FFI Battle

The player has all of the time in the world to select a command in their array of actions:

Example:

  • Attack
  • (Magic) or (Skill) <- According to their class/job
  • Defend (or Guard which is the same thing just worded differently sometimes)
  • Item
  • Flee

Final Fantasy IV: Slight Active System (Wait System Choice Optional)

FFIV

  • Attack
  • Exclusive Skill to Character
  • Additional Exclusive Skill to Character
  • Item

with side commands Run, Defend, change Row (which affects all party members)

Final Fantasy V: Slight Active or Wait System

FFV
Job System

  • Attack
  • Current Job Skill or Customized Command from learnt Job skill if Freelancer
  • Customized Command from learnt Job skill
  • Item

with side commands Run and Defend, change Row (affects that member)

FFVI

Final Fantasy VI: Slight Active or Wait System

Magic System

  • Attack
  • Exclusive Skill to Character
  • Magic
  • Item

with side commands Run and Defend, change Row (affects that member)

I call these slight active systems because it is a small detail but whenever a command has been initiated and animation starts playing for that action, all of the character's battle gauges are not paused from filling up and the enemies are also waiting as well. Battle Gauges are the wait time for the party member. He or she cannot perform any actions until this gauge is filled, which then resets after their action is performed or an enemy disrupts it with certain attacks.

Final Fantasy VII: Full Active or Wait System

FFVII

Materia System

Yellow - Special Variations of Attack Command
Green - Magic Command
Red - Summon Command

  • Attack (Or custom skill using a Yellow Materia equipped)/Limit Break
  • Any custom command using Green or Red Materia
  • Item

with side commands Run and Defend, change Row (affects that member)

I would call this a Full Active System because of the battle gauges are continuously filling even though an action animation plays through. Although the next chosen action will not trigger until the current animation is playing, it still allows the player to wait and get to their character's command menu during the animation playing out.

Final Fantasy VIII: Slight Active or Wait System

FFVIII
Junction System

  • Attack (This can vary depending on Junction commands)/Limit Break
  • Draw/Cast
  • Custom Command
  • Custom Command

with side commands Run and Defend, change Row (affects that member)

Final Fantasy IX: Active or Wait System

FFIX
Crystal System

  • Attack/Trance
  • Exclusive Skill for Character
  • Exclusive Skill for Character
  • Item

with side commands Run and Defend, change Row (affects that member)

Final Fantasy X: Wait System

FFX
Sphere Grid System

  • Attack/Overdrive
  • Summon (Exclusive to Yuna)
  • Skills
  • Specials
  • Magics
  • Defend
  • Item

Side Command to switch party members in battle

From here on out, the random encounter becomes abandoned, only to adopt to the "On-map" battle encounter where you can visually see enemies you are about to engage with. Other titles such as Chrono Trigger, Persona series, Tales of Series, use this approach.

Final Fantasy XI: MMORPG

I'm actually unfamiliar as I have not experienced this game but from my understanding of watching some footage, you engage into enemies wandering across the map.

FFXI

  • Attack/Switch Target
  • Magic/Casting Time (Wait time when casting a spell)
  • Abilities
  • Items
  • Disengage/Call for Help
  • Check (Analyze Description in the log window)

And Now We reach to Final Fantasy XII

If you've stuck around till now, thanks for reading so far, I know this was a handful to read but I wanted to provide this information to understand the progression of evolution Square-Enix took in order to change up the battle mechanics for traditional RPGs.

Final Fantasy XII: Active but also Wait System And Introducing the Gambit System

So what is the Gambit System?

Gambits are the functionality used to control the action commands for your party members in battle. The control of Active or Wait System is interesting for this game. Since there are no random encounters but on-map encounters, the player can engage battle if they want, unless there are monsters who are aggressive and will engage you instead. When inputting commands, 'Active' let's time to keep running while selecting from the command menu. 'Wait' pauses the game in motion as you are selecting your next action. After the action has been selected, that character will always perform that action whenever the gauge fills up, until you give another command. This would be the case when Gambit is selected Off because you have to micro manage every action for each character.

This is the main command list for Character Actions.

  • Attack
  • Magick & Technicks
  • Mist
  • Gambit [On or Off Toggle]
  • Items

FFXII License Board

This is the License Grid where the Player can choose the skills, equipment, status increases, in order to improve their characters.

I did not play Zodiac Age but I saw that the big change was dividing up all the licenses to learn by the Job System.

FFXII Job System

Here is video footage of the battle system in play.

FFXII Battle

So now, turning on Gambits, we are turning on custom functionality for our party members in order to determine actions they will take according to certain conditions. Let's take a look at how these Gambit Commands look:

Baltier's Gambit Actions
Picture from: https://news.xbox.com/en-us/wp-content/uploads/sites/2/3-FFXII-The-Zodiac-Age-Xbox-One-Gambit-Detail.jpg?resize=1020%2C574

Alright Baltier, you awesome sky pirate, let's see what you got!

We see that each action is indexed from 1 - 12 on the left. This is the priority level with 1 being the highest priority and 12 being the lowest priority.

  1. Foe: HP = 100% -> Steal

This is saying that once a battle is engaged, With a foe at full health, Baltier will use the steal command at that foe. Then if an ally deals damage to that foe, Baltier will check if that foe's health is 100%, which is not so it moves on to the next command. Next,

  1. Ally: any -> *Phoenix Down

*Phoenix Down is a revival item when a party member is dead.

This says that Baltier will use a Phoenix Down on any member, although the item only works if the member is dead.

Red Commands = Offensive Actions
Blue Commands = Defensive Actions

Let's take a look at one more:

  1. Foe: 5+ foes present -> Flare

When there are 5 or more foes alive and nearby, Baltier will cast Flare (A non-elemental magic attack).

Let's look at this in a code


if(FoeHP.CurrentHP == FoeHP.MaxHP)
{
   BaltierAction.Steal(Foe);
} 
else if(Ally)
{
   BaltierAction.useItem("Phoenix Down", Ally);
} 
else if(Ally.CurrentMP < ((30 / Ally.MaxMP) * 100))
{
   BaltierAction.useItem("Hi-Ether", Ally);//Ether recovers magic points
}
else if(Ally.CurrentHP < ((30 / Ally.MaxHP) * 100))
{
   BaltierAction.castSpell("Curaga", Ally);
}
else if(Ally)
{
   BaltierAction.castSpell("Esuna", Ally);
}
else if(Foe.Status == "Reflect")
{
   BaltierAction.castSpell("Dispel Mote", Foe);
}
else if(Foe.Weakness == "Fire")
{
   BaltierAction.castSpell("Firaga", Foe);
}
else if(Foe.Weakness == "Lightning")
{
   BaltierAction.castSpell("Thundaga", Foe);
}
else if(Foe.Weakness == "Ice")
{
   BaltierAction.castSpell("Blizzaga", Foe);
}
else if(FoeCount >= 5)
{
   BaltierAction.castSpell("Flare", FoesArray);
}
else if(FoeArray >= 1)
{
   //This is an interesting situation
}
else if(Ally == "Ashe")
{
   BaltierAction.castSpell("Bubble", "Ashe");
}

Enter fullscreen mode Exit fullscreen mode

Seeing 11. Foe: Highest HP -> Attack

This is more like a while loop because what if there is more than 1 foe? Baltier would take into consideration of attack a foe who's HP will always be the highest out of the other foes. If it was just one foe, they it would be an easy action call with

BaltierAction.Attack(Foe);
Enter fullscreen mode Exit fullscreen mode

But account for multiple foes, I would think it would be an array of foes, and checking the foe in that array whoever has the highest CurrentHP, which Baltier will target that Foe.

I feel like there would be a method call for the FoeArray in order to check this condition like:

//There is probably a better way to do this since this is an O(n)
pubic Foe FoeWithHighestHP(FoeArray){
   Foe HighestHPFoe = FoeArray[0];

   foreach(Foe foe in FoeArray)
   {
      if(foe.CurrentHP > HighestHPFoe.CurrentHP)
      {
          HighestHPFoe = foe;
      }
   }
   return HighestHPFoe
}

BaltierAction.Attack(FoeWithHighestHP(FoeArray));
Enter fullscreen mode Exit fullscreen mode

But you get the idea, seeing how much control and customization you have with characters actions in order to fight through the battles. I feel like this is a nice introduction of programming without actually knowing code and Square-Enix did such an interesting take behind the scenes to give this freedom to the player. It's like we are scripting our own AI allies in the way we want them to act.

I thought this was just a nice fun blog to write because I was always fascinated by connection of Final Fantasy XII's battle system with programming.

Top comments (3)

Collapse
 
lucysuddenly profile image
Lucy Suddenly

The gambit system was so revolutionary and fun! Thanks for covering it!

Collapse
 
fihra profile image
Fabian Fabro Author

Thanks for checking this out!

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.