- Joined
- Aug 23, 2008
- Messages
- 2,319
This tutorial will guide you through making an easy turn-based battle system for a single player game. In this tutorial I will go for a system as used in Final Fantasy which uses an Active Time Battle gauge which fills over time and allows a unit to perform an action when full.
Tutorial:
Tutorial dificulty: 2/10
Requirements:
Variables used:
System:
Preperations:
Set aquisition range of all units to 0 in the Object Editor, so they can't attack by themselves. If you need units with a aquisition range, you need to create units that are only for battle and load their info at the Entering Battle Mode 2 trigger. Also set the units you want to use in battle to AllyBattleUnit[x]. Create as many arrays for this unit variable as you want to indicate the maximum size of a party.
Step 1: Entering battle
First of all, you need to make a trigger that activates the Battle Mode, which is the mode that activates when you enter a turn-based battle. For A Final Fantasy game, that will be a random moment while moving.
Battle Preparations is a trigger that contains all preparations before the actual battle starts. Like the ATB Gauge, battle camera's, etc. Whatever you want to have as preparations before battle can be made here. You do however need to set all units you're going in battle with in the BattleGroup Unit Group. Also change ownership of them to Neutral Passive, so you can't control them when it's not their turn. An example of a Battle Preparations trigger is:
Step 2: ATB Gauge
The Active Time Battle Gauge is a bar that indicates at what point a unit is ready to perform an action. The bar slowly fills and when it's full, you're able to command your unit. There are plenty of other ways to order units 1 by 1 to perform an action, but to give you a little idea of the situation, this is how you could make an ATB gauge trigger:
This is just an example and there are many other ways to do this. You can use anything you want as long as you keep those last 5 Actions in your trigger.
Step 3: Command
Now you have a unit selected when he's ready to perform a command. The most easy way is by selecting the unit and allowing it to perform only 1 actions.
Step 4: Victory & defeat
Ofcourse you need to set when you win and when you lose. You use a simple trigger for this.
In addition to the last 2 If/Then/Else commands, you need to add the triggers that do when you want when you won or lost a turn-based battle. This can be 'Game - Victory' or 'Game - Defeat', but you can also just go on and activate another party when you lose, or you continue with the game when you win.
Tutorial:
Tutorial dificulty: 2/10
Requirements:
- Basic triggering knowledge
- Basic variable knowledge
- Able to read
Variables used:
Boolean:
-BattleMode (Checks if the unit can enter a battle)
Integer:
-RANDOM (Random number from 1 to 100 to indicate a chance)
-AllyATB (The ATB points that are gained over time while in battle)
Point:
-BattleRoomPosition (The points in the battle room where the units will stand by default)
-BattleLocation (A variable which refers to the location of where the unit came from)
Unit:
-ActiveCharacter (The unit that will do a command)
-TempTarget (The targeted unit to attack-once when ordered to be attacked)
-AllyBattleUnit (The units that form AllyBattleGroup)
-EnemyBattleUnit (The units that form EnemyBattleGroup)
Unit Group:
-BattleGroup (Contains the units with which you fight in a battle)
-AllyBattleGroup (Contains units that can activate the Entering Battle Mode trigger)
-EnemyBattleGroup (Contains the units you fight)
-BattleMode (Checks if the unit can enter a battle)
Integer:
-RANDOM (Random number from 1 to 100 to indicate a chance)
-AllyATB (The ATB points that are gained over time while in battle)
Point:
-BattleRoomPosition (The points in the battle room where the units will stand by default)
-BattleLocation (A variable which refers to the location of where the unit came from)
Unit:
-ActiveCharacter (The unit that will do a command)
-TempTarget (The targeted unit to attack-once when ordered to be attacked)
-AllyBattleUnit (The units that form AllyBattleGroup)
-EnemyBattleUnit (The units that form EnemyBattleGroup)
Unit Group:
-BattleGroup (Contains the units with which you fight in a battle)
-AllyBattleGroup (Contains units that can activate the Entering Battle Mode trigger)
-EnemyBattleGroup (Contains the units you fight)
System:
Preperations:
Set aquisition range of all units to 0 in the Object Editor, so they can't attack by themselves. If you need units with a aquisition range, you need to create units that are only for battle and load their info at the Entering Battle Mode 2 trigger. Also set the units you want to use in battle to AllyBattleUnit[x]. Create as many arrays for this unit variable as you want to indicate the maximum size of a party.
Step 1: Entering battle
First of all, you need to make a trigger that activates the Battle Mode, which is the mode that activates when you enter a turn-based battle. For A Final Fantasy game, that will be a random moment while moving.
-
Entering Battle Mode 1
-
Events
- Unit - A unit is issued an order targeting a point
- Unit - A unit is issued an order targeting an object
-
Conditions
- (Triggering unit) is in AllyBattleGroup
-
Actions
- Set BattleMode = True
-
Events
-
Entering Battle Mode 2
-
Events
- Time - Every 1 second of the game time
-
Conditions
- BattleMode equal to True
-
Actions
- Set RANDOM = (Random number between 1 and 100)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- RANDOM Less than or equal to 10
-
Then - Actions
- Trigger - Turn on Battle Preperations <gen>
- Trigger - Turn off Entering Battle Mode 1 <gen>
- Trigger - Turn off (This trigger)
- Else - Actions
-
If - Conditions
-
Events
-
Battle Preparations
- Events
- Conditions
-
Actions
- Unit - Move AllyBattleUnit[1] instantly to BattleRoomPosition[1], facing (Center of Battle Room <gen>)
- Unit - Move AllyBattleUnit[2] <gen> instantly to BattleRoomPosition[2], facing (Center of Battle Room <gen>)
- Unit - Move AllyBattleUnit[3] instantly to BattleRoomPosition[3], facing (Center of Battle Room <gen>)
- Camera - Apply Battle Camera 1 <gen> for Player 1 (Red) over 2.00 seconds
- Camera - Apply Battle Camera 2 <gen> for Player 1 (Red) over 1.00 seconds
- Camera - Apply Battle Camera 3 <gen> for Player 1 (Red) over 3.00 seconds
- Camera - Apply Battle Camera 4 <gen> for Player 1 (Red) over 2.50 seconds
- Trigger - Turn on ATB Gauge <gen>
- Set AllyATB[1] = 0
- Set AllyATB[2] = 0
- Set AllyATB[3] = 0
Step 2: ATB Gauge
The Active Time Battle Gauge is a bar that indicates at what point a unit is ready to perform an action. The bar slowly fills and when it's full, you're able to command your unit. There are plenty of other ways to order units 1 by 1 to perform an action, but to give you a little idea of the situation, this is how you could make an ATB gauge trigger:
-
ATB Gauge
-
Events
- Time - Every 0.50 seconds of game time
- Conditions
-
Actions
-
For each (Integer A) from 1 to (Number of units in AllyBattleGroup), do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (AllyBattleUnit[(Integer A)] is alive) Equal to True
-
Then - Actions
- Set AllyATB[(Integer A)] = (AllyATB[(Integer A)] + 5)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- AllyATB[(Integer A)] Greater than or equal to 100
-
Then - Actions
- Trigger - Turn on Command 1 <gen>
- Trigger - Turn on Command 2 <gen>
- Trigger - Turn on Command 3 <gen>
- Trigger - Turn off (This trigger)
- Set ActiveCharacter = AllyBattleUnit[(Integer A)]
- Else - Actions
-
If - Conditions
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to (Number of units in AllyBattleGroup), do (Actions)
-
Events
Step 3: Command
Now you have a unit selected when he's ready to perform a command. The most easy way is by selecting the unit and allowing it to perform only 1 actions.
-
Command 1
- Events
- Conditions
-
Actions
- Unit - Change ownership of ActiveCharacter to Player 1 (Red), change color.
- Selection - Select ActivaCharacter for Player 1 (Red)
- Set BattleLocation = Position of ActiveCharacter
-
Command 2
-
Events
- Unit - A unit finished casting an ability
- Conditions
-
Actions
- Unit - Change owner of ActiveCharacter to Neutral Passive
- Unit - Order ActiveCharacter to move to BattleLocation
- Trigger - Turn off Command 1 <gen>
- Trigger - Turn off Command 2 <gen>
- Trigger - Turn off (This trigger)
-
Events
-
Command 3
-
Events
- Unit - A unit is issued an order targeting an object
-
Conditions
- (Issued order) equal to Attack
-
Actions
- Set TempTarget to (Attacked unit)
- Unit - Order ActiveCharacter to Attack-Once TempTarget
- Player - Change owner of ActiveCharacter to Neutral Passive
- Wait until (current order) of ActiveCharacter is order(stop), checking every 0.10 second
- Unit - Order ActiveCharacter to move to BattleLocation
- Trigger - Turn off Command 1 <gen>
- Trigger - Turn off Command 3 <gen>
- Trigger - Turn off (This trigger)
-
Events
Ofcourse you need to set when you win and when you lose. You use a simple trigger for this.
-
Victory and defeat
-
Events
- Unit - A unit dies
- Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Dying unit) is in EnemyBattleGroup
-
Then - Actions
- Unit Group - Remove (Dying unit) from EnemyBattleGroup
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Dying unit) is in AllyBattleGroup
-
Then - Actions
- Unit Group - Remove (Dying unit) from AllyBattleGroup
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- EnemyBattleGroup is empty
-
Then - Actions
- Trigger - Turn off ATB Gauge <gen>
- Trigger - Turn off (This trigger)
- Trigger - Turn on Entering Battle Mode 1 <gen>
- Trigger - Turn on Entering Battle Mode 2 <gen>
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- AllyBattleGroup is empty
-
Then - Actions
- Trigger - Turn off ATB Gauge <gen>
- Trigger - Turn off (This trigger)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
Last edited: