How To Make A Turn Based Combat System
What is a turn based combat system?
A turn based combat system is a game mechanic common in RPGs. RPG stands for Role Playing Game, and further more if you don’t know what that is than think the core Pokémon games, those are RPGs. In a turn based combat system, the player chooses what they are going to do and most oftenly an AI chooses the opposing move of a character, however there can be instances were a characters move order is consistent. Once the player and AI have both chosen what they will do (however the AI is generally instantaneous, I am just trying to sound more traditional) everything plays out, which can be based on multiple factors. For this tutorial we will be using Pokémon as our example.
Making Turns Using Variables
Making turns work in your combat system is actually quite easy to do.
Create A Variable, and Name It “Turn”.
The Turn Variable Determines Who’s Turn It Is, So Turn 0 is your Turn and Turn 1 is the AI’s.
Always make sure the Turn variable starts at 0 at the beginning of a battle, this requires simply, Set Variable (Turn) To 0.
Keep this in mind for later but remeber that after Player 1 choses their moves to change the Variable to 1, which using a check block will prevent the player from taking action when it’s not their turn.
Attacking and Speed
The player shall only be able to attack on their turn, so make sure that once an enemy turn finishes to switch the Turn Variable back to 0. If you are going to want to make an RPG type style game your character is going to need a move set, but I am not here to determine that for your game, so I’m just going to use Pokémon as example.
Let’s say for example you own a Charmander, and the only two moves it can learn are Ember and Growl. When you want to use Growl, make sure to run through a Variable check to make sure it’s your turn. Then and only then can Growl take effect on the enemy.
Now if you wanted to damage your enemy and use Ember, remeber to always run it through the Variable check. You also want to make a new Variable, call it something like Enemy HP or so,etching like that, and set it to whatever amount you want. After the move passes through the Variable to (Enemy HP) or however much damage you want.
This is all I can type right now, I am getting tired.
Hope you at least enjoyed what I finished