We’ll take a look at turn based battles, factions and add the first battle to the game.

Turn based battles are a classic battle system in RPGs – in a turn based battle, each combatant can perform an action per turn. The order in which the combatants can perform their actions is based on a turn calculation (usually through a formula, using status values of the combatants, e.g. AGI).

Battle system settings

First, we’ll take a look at the battle system settings for turn based battles. Open the ORK Framework editor and navigate to Battle System > Turn Based Battles. Change the following settings.

Turn Based Settings

This settings only affect turn based battles – active time and real time battles have their own settings.

  • Turn Based Mode
    Select Classic.
    For now, we’ll go with strictly turn based battles.
    All battle actions of a turn will be selected at the start of the turn and performed after all actions have been chosen.
  • Use Dynamic Combat
    Disable this setting.
    If enabled, the turn based battles would allow multiple actions at the same time, breaking down the strict turn based battle order.
  • Turn Calculation
    Select Turn Calculation.
    This is our formula which will calculate the order of the turns.

Control Block Settings

Player Control Block

These settings define how the player control will be handled during turn based battles – i.e. when the player can be moved around.

  • Block Player Control
    Select Battle.
    The player control will be blocked during the whole battle.
  • Block in Battle Menu
    Enable this setting.
    The player control will be blocked while displaying battle menus.

Camera Control Block

These settings define how the camera control will be handled during turn based battles.

  • Block Camera Control
    Select Battle.
    The camera control will be blocked during the whole battle.
    This will allow us to use camera steps in battle events.
  • Block in Battle Menu
    Enable this setting.

Move AI Settings

This setting determines if Move AIs can be used during turn based battles.

  • Allow Move AI
    Disable this setting.
    We’re not using Move AI yet, and we don’t want to use it in turn based battles.

That’s it for the turn based battle settings.

Factions

Factions define if a combatant is an enemy or ally of the player. You can learn more about factions in this how-to.

The default faction settings are good enough for our little game – just to make sure they’re correct, let’s look them over. Navigate to Combatants > Factions. You should have three factions:

  • Player
  • Allies
  • Enemies

Now, let’s check the start sympathy between the factions (this determines if they’re allies or enemies to one another). A value below 0 will make factions to enemies, while a value above or equal to 0 will make them allies. Navigate to Combatants > Faction Sympathy and check the sympathy matrix:

  • Player to Allies: 1000
  • Player to Enemies: -1000
  • Allies to Enemies: -1000

That’s it for the factions, but we will check if the player faction is set correctly. Navigate to Game > Game Settings. Make sure that the Player faction is selected as Default Faction (found in Player/Group Settings).

Our work in the editor is done for now – click on Save Settings and close the ORK Framework editor.

Adding a battle to the scene

Now it’s finally time to add our first battle to the game – we’ll add it to the field scene, so open 2 Field (found in Assets/Tutorial Resources/Scenes).

In the scene, navigate the view to the town entrance (where we placed our scene changer) and use the ORK Scene Wizard to add a battle to the scene: Create Object > Battle > Turn Based Battle. Move the battle’s game object a little bit down the road, so that the player will have to walk a bit before starting the battle.

gametutorial_18_the_first_battle1

The state of the battle (if already fought or not) is automatically handled by ORK Framework – the battle receives a Scene ID when added to your Unity® scene, when the player finishes the battle, the scene ID is stored and saved with a save game. As long as the battle isn’t bound to any special occurrence (like the player has to accept a quest first) there is no need for you to use game variables to remember fought battles.

We want the battle to start when the player walks into it’s trigger (collider). Since we used the scene wizard to create our battle, most of the settings are already correct. In the Battle Component‘s inspector, change the following settings.

Start Settings

  • Use Scene ID
    Enable this setting (it should already be enabled).
    When you don’t want ORK to remember the battle’s state, simply disable this setting and the battle will reappear each time you enter the scene.
  • Scene ID
    Set to 0 (it should automatically receive this ID).
  • Battle Type
    Select Turn Based.
    This should already be selected, since we used the scene wizard to add a turn based battle.
  • Can Escape
    Disable this setting.
    We wont run from our first fight! This can be enabled or disabled for each individual battle.
  • Look At Enemies
    Enable this setting.
    This will make the combatants look at their opponents at the start of the battle.
  • Start Type
    Select Trigger Enter.
    The battle will start when the player enter’s the trigger of the object.

Combatants Settings

This setting determines who the player will fight in this battle. For our first battle, we’ll fight a single Evil Pants.

A combatant/group is already added to the battle by default, so let’s change it’s settings.

  • Faction
    Select Enemies.
    If the selected faction is an ally of the player, there will be no fight.
  • Use Group
    Disable this setting.
    We want to fight a single combatant, and haven’t set up combatant groups yet.
  • Combatant
    Select Evil Pants.
  • Set Level
    Select Default.
    We want to use the combatant’s default class level from his settings.
  • Set Class Level
    Select Default.

And that’s it. The rest of the settings would allow us to override the default battle spots, start/end events and other things that we don’t need for now.

Save the scene.

Testing

Open the main menu scene (0 Main Menu) and hit Play. Walk outside of the town and into the battle. You’ll notice a few things now:

  • The enemy is hovering in the air.
  • The enemy just pops up.
  • There is no feedback on damage or things like that.
  • Nothing is animated.

That’s because we didn’t set those things up yet. We’ll fix the hovering enemy for now – the rest will be covered in the next tutorials.

Placing on ground

Let’s place the battle spots on the ground – open the ORK Framework editor and navigate to Battle System > Battle Spots. Change the following settings.

  • Place on Ground
    Enable this setting.
  • Distance
    Set to 100.
  • Layer Mask
    Select Default.
    This determines the layer(s) that will be checked when doing a raycast to find the ground below a battle spot.
    The scene’s terrain should be placed in the Default layer. Keep in mind that other things (like colliders/triggers) should be placed on a different layer, e.g. Ignore Raycast.

Now the battle spots will be placed on the ground, and your combatants with them.

And that’s it for now – the next lesson will cover damage/refresh flying texts.