In this tutorial we’ll set up some simple battle AIs and two enemy combatants.
Before diving into the battle system, we set up two enemies for the player to fight – a wasp and a snake.
The enemies will attack with the base attack (Attack ability) and randomly with a Poison Attack – we’ll set up battle AIs to handle this.
Battle AIs #
AI controlled combatants use battle AIs to select their actions in battle. Learn more about battle AIs in this documentation.
A combatant’s default action in battle is using their base attack, when no battle AI is used or no useable action was found, they’ll use their base attack.
We’ll make a very simple setup where the enemies use a random ability that’s available to the combatant (for our wasp and snake it’s the Poison Attack) with a chance of 25, 50 or 75% – otherwise they’ll use their base attack.
Open the Makinom editor and navigate to Battles > Battle AI, we’ll change the Default battle AI and add additional battle AIs.
0: Random Ability 25% #
Has a 25% chance to use a random ability (available to the combatant).
In case the chance fails, this battle AI ends, continuing with the next battle AI fo the combatant (or using the base attack if no other battle AI is available).
Battle AI Settings #
- Name
Set to: Random Ability 25%
Chance #
Add Node > Base > Chance
Does chance checks and performs a next node based on it.
The a default chance check is already set up for us (Range 0), so let’s change.
- Minimum Range
Select Value > Value.
Set the value to 0. - Maximum Range
Select Value > Value.
Set the value to 25.
Ability #
Add Node > Action > Ability
Uses an ability of the combatant – we’ll use a random ability.
The node is connected to the 0 – 25 next slot of the Chance node.
- Use Random Ability
Enable this setting
This’ll use a random ability available to the combatant. - Use Highest Level
Enable this setting.
This’ll use the highest available (and usable) level that’s available to the combatant.
We don’t really use abilities with multiple levels in this tutorial series, but it’s still a good practice.
1: Random Ability 50% #
Has a 50% chance to use a random ability (available to the combatant).
Copy the Random Ability 25% battle AI and change the following settings.
Battle AI Settings #
- Name
Set to: Random Ability 50%
Chance #
- Maximum Range
Select Value > Value.
Set the value to 50.
2: Random Ability 75% #
Has a 75% chance to use a random ability (available to the combatant).
Copy the Random Ability 50% battle AI and change the following settings.
Battle AI Settings #
- Name
Set to: Random Ability 75%
Chance #
- Maximum Range
Select Value > Value.
Set the value to 75.
Combatants General Settings #
Next, we’ll set up the default battle AI for all combatants – we’ll use the Random Ability 25% battle AI.
Navigate to Combatants > Combatants > General Settings.
Battle Settings > Default Battle AI #
Click on Add Battle AI.
- Battle AI
Select Random Ability 25%.
Wasp #
Navigate to Combatants > Combatants and add a new combatant.
Content Information #
- Name
Set to: Wasp
Base Settings > Prefab Settings #
- Prefab
Select the Wasp prefab.
You can find it in Assets/Tutorial Assets/Prefabs/Combatants/Enemies/.
Status Settings #
Our enemies don’t use a status development, i.e. they’ll have fixed status values. We’ll also set a level for them.
- Start Level
Set to 2.
Status Value Settings > Status Values #
Click on Set Default to add all Normal type status values with a default start value.
I’ll just list the status values and their start value here – i.e. you need to change the Start Value setting for each of the Initial Status Value settings.
- Max HP
Set to 16. - Max MP
Set to 10. - ATK
Set to 6. - DEF
Set to 5. - MATK
Set to 1. - MDEF
Set to 5.
Status Value Settings > Experience Reward #
We’ll define the EXP the player receives when defeating this enemy here.
Click on Add Experience Reward.
- Status Value
Select EXP. - Reward Value
Select Value > Value.
Set the value to 3.
Attacks & Abilities > Ability Development #
We’ll add the Poison Attack to the combatant’s abilities.
Click on Add Ability.
- Learn At Level
Set to 1.
This is the level at which the ability will become available. - Ability
Select Poison Attack.
Animations & Movement > Animations #
We’ll use different movement animations, since our wasp is flying.
Click on Add Animations.
- Animations
Select Flying Movement.
That’s it for our first enemy!
Snake #
The snake is similar to the wasp, just a bit stronger, using the ability more often and using different movement animations.
Copy the Wasp combatant and change the following settings.
Content Information #
- Name
Set to: Snake
Base Settings > Prefab Settings #
- Prefab
Select the Snake prefab.
Status Settings #
- Start Level
Set to 3.
Status Value Settings > Status Values #
I’ll just list the status values and their start value here – i.e. you need to change the Start Value setting for each of the Initial Status Value settings.
- Max HP
Set to 35. - Max MP
Set to 10. - ATK
Set to 8. - DEF
Set to 6. - MATK
Set to 1. - MDEF
Set to 8.
Status Value Settings > Experience Reward #
- Reward Value
Select Value > Value.
Set the value to 4.
Battle Settings > Battle AI #
We’ll override the default battle AI to use the 50% chance for using an ability.
- Replace Default
Enable this setting.
This’ll replace the default battle AI of the general settings.
Otherwise, the battle AI of the combatant will be used first, followed by the default battle AI (if no action was found or the battle AI is used in queue mode).
Click on Add Battle AI.
- Battle AI
Select Random Ability 50%.
Animations & Movement > Animations > Animation 0 #
- Animations
Select Simple Movement.
Combatant Groups #
Combatant groups can be used by battles, combatant spawners, etc. to create predefined groups. Learn more about combatant groups in this documentation.
We’ll set up a group with our two enemies – the group will have 2 of them, but each is randomly selected, so the group could be 2 wasps or 2 snakes, or 1 wasp and 1 snake.
Navigate to Combatants > Combatant Groups, we’ll change the Default group.
- Name
Set to: Forest x2
Combatants > Combatant 0 #
This is the first combatant of the group.
- Use Random Combatant
Enable this setting.
This’ll let us add multiple combatants for this group position, using 1 randomly.
Change the combatant of the already added Random Combatant 0.
- Combatant
Select Wasp.
Copy the random combatant and change the following setting.
- Combatant
Select Snake.
Combatants > Combatant 1 #
We’ll just copy Combatant 0, since we want to use the same setup for the 2nd combatant of the group.
No changes needed to the setup.
Save Changes #
And that’s it for now!
Save the changes using the Save Settings button at the bottom of the editor.
Next, we’ll set up our battle system.