Let’s create some enemies to fight, and their behaviour in battle, using Battle AIs.
Tell them what to do
The Battle AI will decide the battle actions of any combatant who’s not part of the player group (or an AI controlled member of the player group). You can learn more about battle AIs in this how-to.
We’ll create the following battle AIs:
- Fighter
For a fighter combatant using physical attacks. - Magician
For a magician combatant using magical attacks. - Supporter
For a supporting combatant using support abilities.
Open the ORK Framework editor and navigate to Battle System > Battle AI.
Battle AI 0: Fighter
This simple AI will have a 5 % chance to do nothing at all, and use Boost on the user if it’s not applied. Since a combatant always uses it’s base attack if no battle AI found an action, we don’t need to tell this AI to use the base attack (it would be different if you want to use the base attack on special conditionts, like on an enemy with less than 10 % HP).
This is how the AI will look like in the end – I’ll just assume that you know how to use the node editor by now and simply describe the settings of the different steps.
Battle AI Settings
- Name
Set to Fighter.
Check Chance
Add > Base > Check Chance
We want this step to check for a 5 % chance and executes the None action if the check is successful. Else, the Check Status step will be executed.
- Value Type
Select Value. - Value
Set to 5.
None
Add > Action > None
This step will result in the combatant doing nothing – the battle AI will end. No further settings.
Check Status
Add > Combatant > Check Status
This step should check if the status effect Strengthen isn’t applied to the user. If successful (i.e. Strengthen isn’t applied), Boost (ability action) should be used.
- Found Targets
Select Clear.
This setting decides what’ll be done with targets found by previous conditions.
Since we shouldn’t have any previous targets here, this setting doesn’t really matter, but let’s clear them anyway to be sure.
If we don’t clear the targets, all targets already found would also be used as possible targets by actions used after this step. - Target
Select Self.
This checks the user of the battle AI for the condition. - Needed
Select All.
We’ll only have one condition, so this setting doesn’t really matter now.
A status requirement should already be added – else click on Add Status Requirement.
- Status Needed
Select Status Effect. - Selection
Select Strengthen. - Is Applied
Disable this setting.
Ability
Add > Action > Ability
We want to perform Boost.
- Ability
Select Boost.
That’s it for this battle AI.
Battle AI 1: Magician
This battle AI is a little bit more complex. It will check enemies for weaknesses to Fire and Water attack attributes and use according abilities. If no weakness is found, the used ability will be selected randomly.
Battle AI Settings
- Name
Set to Magician.
Check Status
Add > Combatant > Check Status
This step should check enemies for a weakness to Fire (in our case, Fire > 100). If the check is successful, the ability Fire should be used, else another Check Status step.
- Found Targets
Select Clear. - Target
Select Enemy. - Needed
Select All.
A status requirement should already be added – else click on Add Status Requirement.
- Status Needed
Select Attack Attribute. - Selection
Select Element. - Attribute
Select Fire. - Check Type
Select Is Greater. - Value Type (Check Value)
Select Value. - Value (Check Value)
Set to 100.
Ability
Add > Action > Ability
Performs the ability Fire. If it can’t be used, continues the battle AI with the next Check Status step.
- Ability
Select Fire.
Check Status
Add > Combatant > Check Status
This step should check enemies for a weakness to Water (in our case, Water > 100). If the check is successful, the ability Water should be used, else a Random step.
- Found Targets
Select Clear. - Target
Select Enemy. - Needed
Select All.
A status requirement should already be added – else click on Add Status Requirement.
- Status Needed
Select Attack Attribute. - Selection
Select Element. - Attribute
Select Water. - Check Type
Select Is Greater. - Value Type (Check Value)
Select Value. - Value (Check Value)
Set to 100.
Ability
Add > Action Steps > Ability
Performs the ability Water. If it can’t be used, continues the battle AI with the next Random step.
- Ability
Select Water.
Random
Add > Base > Random
This step should randomly execute either Fire, Water or the combatant’s base attack (by having no next step). So we need three next steps – click on Add Step twice to add two new steps to the random step.
Copy the previously used Fire ability step and connect Random 0 to it. Copy the previously used Water ability step and connect Random 1 to it. Leave Random 2 unconnected. We can’t simply connect the random steps to the previous ability steps – this could create an eternal loop if the ability can’t be used.
That’s it for this battle AI.
Battle AI 2: Supporter
This battle AI will check allies and enemies for certain status conditions and uses abilities accordingly.
Battle AI Settings
- Name
Set to Supporter.
Check Status
Add > Combatant > Check Status
This step should check if the HP of any ally of the user is below 50 %. If successful, Small Heal should be used, else the next Check Status step.
- Found Targets
Select Clear. - Target
Select Ally. - Needed
Select All.
A status requirement should already be added – else click on Add Status Requirement.
- Status Needed
Select Status Value. - Selection
Select HP. - Check In
Select Percent. - Check Type
Select Is Less. - Value Type (Check Value)
Select Value. - Value (Check Value)
Set to 50.
Ability
Add > Action > Ability
We want to perform Small Heal. If it can’t be used, continue with the next Check Status step.
- Ability
Select Small Heal.
Check Status
Add > Combatant > Check Status
This step should check if the status effect Strengthen isn’t applied to any ally of the user. If successful, Boost should be used, else the next Check Status step.
- Found Targets
Select Clear. - Target
Select Ally. - Needed
Select All.
A status requirement should already be added – else click on Add Status Requirement.
- Status Needed
Select Status Effect. - Selection
Select Strengthen. - Is Applied
Disable this setting.
Ability
Add > Action > Ability
We want to perform Boost. If it can’t be used, continue with the next Check Status step.
- Ability
Select Boost.
Check Status
Add > Combatant > Check Status
This step should check if the status effect Weaken isn’t applied to any enemy of the user. If successful, Lessen should be used, else the next Check Status step.
- Found Targets
Select Clear. - Target
Select Enemy. - Needed
Select All.
A status requirement should already be added – else click on Add Status Requirement.
- Status Needed
Select Status Effect. - Selection
Select Weaken. - Is Applied
Disable this setting.
Ability
Add > Action > Ability
We want to perform Lessen. If it can’t be used, continue with the next Check Status step.
- Ability
Select Lessen.
Check Status
Add > Combatant > Check Status
This step should check if the status effect Poison isn’t applied to any enemy of the user. If successful, Poison should be used.
- Found Targets
Select Clear. - Target
Select Enemy. - Needed
Select All.
A status requirement should already be added – else click on Add Status Requirement.
- Status Needed
Select Status Effect. - Selection
Select Poison. - Is Applied
Disable this setting.
Ability
Add > Action > Ability
We want to perform Poison.
- Ability
Select Poison.
That’s it for the battle AIs.
Creating fearsome enemies
Enemies are plain old combatants, and we’ll create three:
- Evil Pants
A fighter using physical attacks. - Evil Caster
A magician using magical attacks. - Evil Supporter
A support combatant.
Navigate to Combatants > Combatants. We’ll first add a single new combatant and copy him later to create the others. Change the following settings.
Combatant 1: Evil Pants
- Name
Set to Evil Pants.
Base Settings > Prefab Settings
- Prefab
Select Evil Pants.
Can be found in Assets/Tutorial Resources/Prefabs/Combatants/. - Box Radius
Set to 1.
Status Settings
- Start Level
Set to 5. - Class
Select Player Class.
We don’t need a special class for our enemies, at least not yet.
Status Settings > Status Value Settings
The status values of a combatant can either be set to a fixed value in the combatant’s settings, or you can use status development like for the player’s combatant. For our simple game, we’ll create only static enemies with fixed values.
- No Status Development
Enable this setting.
With this setting enabled, you’ll be able to define the status values without going through more complex development settings and curve generation.
Now, you’ll be able to set the Normal and Experience type status values. The Experience type status values will define how much experience is earned when the player defeats the combatant.
- MaxHP
Set to 80. - MaxMP
Set to 5. - ATK
Set to 25. - DEF
Set to 22. - MATK
Set to 5. - MDEF
Set to 2. - AGI
Set to 17. - DEX
Set to 15. - LUK
Set to 3. - EXP
Set to 15.
Status Settings > Attribute Settings
- Race
Select Human. - Size
Select Medium.
Attacks & Abilities > Attack Settings
- Ability (Base Attack)
Select Attack. - Ability (Counter Attack)
Select Attack.
Attacks & Abilities > Ability Development
Add an ability to learn by clicking on Add Ability. The combatant will only be able to use abilities that he already learned at his level when in the game.
- Learn at Level
Set to 1. - Ability
Select Boost.
Inventory & Equipment > Start Inventory
The start inventory defines the items the combatant will have – and what items the player will get when he defeats this enemy.
- Gold
Set to 50.
Add an item by clicking on Add Item.
- Type
Select Item. - Item
Select Potion. - Value Type (Quantity)
Select Value. - Value (Quantity)
Set to 1. - Value Type (Chance (%))
Select Value. - Value (Chance (%))
Set to 75.
Add another item.
- Type
Select Item. - Item
Select Cure Potion. - Value Type (Quantity)
Select Value. - Value (Quantity)
Set to 1. - Value Type (Chance (%))
Select Value. - Value (Chance (%))
Set to 25.
Battle Settings > Steal Settings
This settings define what item(s) can be stolen from the combatant.
- Steal Item
Enable this setting. - Fix Item
Enable this setting. - Type
Select Item. - Item
Select Potion. - Steal Once
Enable this setting.
Battle Settings > AI Settings
You can ignore the AI Controlled setting – this is only used for members of the player group. Any non-player combatant will always be controlled by AI. If a combatant is member of the player group and AI Controlled, the player wont be able to select his battle actions (unless the combatant is the player combatant, i.e. the leader of the player group).
Click on Add Battle AI to add a battle AI.
- Battle AI
Select Fighter.
Animations & Movement > Animation Settings
We’ll take a closer look at animations when it comes to animating battles, for now we’ll only stick to the simple stuff.
- Use Auto Animation
Enable this setting.
That’s it for this combatant.
Combatant 2: Evil Caster
Copy Evil Pants and change the following settings.
- Name
Set to Evil Caster.
Base Settings > Prefab Settings
- Prefab
Select Evil Caster.
Status Settings > Status Value Settings
Let’s edit the enemies status values.
- MaxHP
Set to 60. - MaxMP
Set to 100. - ATK
Set to 1. - DEF
Set to 18. - MATK
Set to 20. - MDEF
Set to 22. - AGI
Set to 12. - DEX
Set to 15. - LUK
Set to 10. - EXP
Set to 17.
Attacks & Abilities > Ability Development
Change the first ability.
- Ability
Select Fire.
Add another ability by clicking on Add Ability.
- Learn at Level
Set to 1. - Ability
Select Water.
Inventory & Equipment > Start Inventory
- Gold
Set to 75.
Change the first item.
- Item
Select Magic Potion. - Value Type (Chance (%))
Select Value. - Value (Chance (%))
Set to 100.
Change the second item.
- Item
Select Fire Scroll. - Value Type (Chance (%))
Select Value. - Value (Chance (%))
Set to 5.
Battle Settings > Steal Settings
- Item
Select Magic Potion.
Battle Settings > AI Settings
- Battle AI
Select Magician.
That’s it for this combatant.
Combatant 3: Evil Supporter
Copy Evil Caster and change the following settings.
- Name
Set to Evil Supporter.
Base Settings > Prefab Settings
- Prefab
Select Evil Supporter.
Status Settings > Status Value Settings
- MaxHP
Set to 55. - MaxMP
Set to 80. - ATK
Set to 10. - DEF
Set to 25. - MATK
Set to 15. - MDEF
Set to 25. - AGI
Set to 9. - DEX
Set to 10. - LUK
Set to 1. - EXP
Set to 22.
Attacks & Abilities > Ability Development
Change the first ability.
- Ability
Select Poison.
Change the second ability.
- Ability
Select Small Heal.
Add a new ability.
- Learn at Level
Set to 1. - Ability
Select Boost.
Add another ability.
- Learn at Level
Set to 1. - Ability
Select Lessen.
Inventory & Equipment Start Inventory
- Gold
Set to 65.
Change the first item.
- Item
Select Cure Potion.
Change the second item.
- Item
Select Paralyse Scroll. - Value Type (Chance (%))
Select Value. - Value (Chance (%))
Set to 10.
Battle Settings > Steal Settings
- Item
Select Cure Potion.
Battle Settings > AI Settings
- Battle AI
Select Supporter.
That’s it for the combatants – click on Save Settings.
And that’s it for now – the next lesson will cover the first battle.