After building our status system, it’s time to use it in formulas to calculate things like attack damage or hit chance.
In this game tutorial we’ll focus on creating the formulas we need, to learn more about formulas in general read this how-to.
Keeping order with formula types
To keep things organized we will separate our formulas into different formula types:
- Physical
For everything related to physical attacks (using ATK and DEF). - Magical
For everything related to magical attacks (using MATK and MDEF). - Chance
For the different chance calculations (like hit or counter chance). - Other
For other things (like the turn order calculation).
Formula types are created in – you should already know – the ORK Framework editor. So open the editor and navigate to Game > Formula Types. We need four formula types, so add the needed number and change the following settings.
Formula Type 0
- Name
Change to Physical.
Formula Type 1
- Name
Change to Magical.
Formula Type 2
- Name
Change to Chance.
Formula Type 3
- Name
Change to Other.
That’s it for the formula types.
Formulas … mathematical!
Now let’s create our formulas. Keep in mind that the formulas are a crucial part of how your system works and how balanced it will be. Since you can simply use another formula within a formula as a calculation step, we will break down some of the formulas to basic blocks, so that we later only have to tweak and balance a small number of formulas.
We will create the following formulas:
- Turn Calculation
To calculate the turn order in battles (turn based, active time). - Level Factor
Calculates a factor based on user and target level (same level > factor 1). - Hit Chance
Calculates a chance if an attack will hit the target. - LUK Chance
A LUK based chance, used for counter, critical and block chance. - Physical Damage
The base physical damage calculation. - Physical Damage 5
5 times the base physical damage. - Magical Damage
The base magical damage calculation. - Magical Damage 5
5 times the base magical damage. - Magical Damage 10
10 times the base magical damage. - Small Heal
Calculates the HP refresh of a light heal ability.
That’s 10 formulas in total, so navigate to Game > Formulas and add the needed number of formulas. Formulas are created using a node editor – you can learn more about the node editor in this how-to.
Formula 0: Turn Calculation
We start with a simple formula to calculate the order of turns in battle. The minimum value of the formula should be 1.
We will use this simple formula: ((user LUK + user DEX) / 10) + user AGI
In Turn Based battles, the formula is calculated at the start of a turn for each combatant – the combatant with the highest result will have the first move, followed be the next highest combatant, and so forth.
In Active Time battles, the formula is used to fill each combatants timebar over time (i.e. the timebar will be increased by the formula’s result).
To create the formula, we need four additional steps (nodes) beside the start node.
Formula Settings (Start Node)
- Name
Change to Turn Calculation. - Type
Select Other. - Use Minimum Value
Enable this setting. - Minimum Value
Set to 1.
Now, right click on the start node’s Next slot and add a status value step: Add > Combatant > Status Value
Step 0: Status Value
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select LUK.
Add another status value step on this node’s Next slot.
Step 1: Status Value
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select DEX.
Now, add value step on this node’s Next slot: Add > Value > Value
Step 2: Value
- Operator
Select Divide. - Value Type
Select Value. - Value
Set to 10.
Now, add another status value step on this node’s Next slot.
Step 3: Status Value
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select AGI.
That’s it for this formula.
Formula 1: Level Factor
The level factor will later be used in other formulas to influence their outcome. Basically it’s used to give higher level combatants an advantage when fighting lower level combatants. If the combatant’s have the same level, the factor will be 1. The minimum value of the formula should be 0.
We will use this formula: ((user Level – target Level) / 50) + 1
The value 50 in the formula is related to level 99 being the highest level in our game – it’s not really half of it, but it gives us a nice increase of 10 % every 5 level difference (i.e. if the attacker is 5 levels above it’s target, he will do 10 % more damage).
To create the formula, we need four additional steps (nodes) beside the start node.
Formula Settings (Start Node)
- Name
Change to Level Factor. - Type
Select Other. - Use Minimum Value
Enable this setting. - Minimum Value
Set to 0.
Now, right click on the start node’s Next slot and add a level step: Add > Combatant > Level
Step 0: Level
- Operator
Select Add. - Status Origin
Select User.
Add another level step on this step’s Next slot.
Step 1: Level
- Operator
Select Sub. - Status Origin
Select Target.
Now, add value step on this node’s Next slot: Add > Value > Value
Step 2: Value
- Operator
Select Divide. - Value Type
Select Value. - Value
Set to 50.
Add another value step on this node’s Next slot.
Step 3: Value
- Operator
Select Add. - Value Type
Select Value. - Value
Set to 1.
That’s it for this formula.
Formula 2: Hit Chance
Our hit chance is based on the relation between the user’s DEX and the target’s AGI – if they’re equal, the hit chance should be 75 %, but we also use the level factor we just created to give higher level combatants an advantage. This formula’s minimum value is also 0.
We’ll use this formula: (user DEX / target AGI) * 75 * Level Factor
To create the formula, we need four additional steps (nodes) beside the start node.
Formula Settings (Start Node)
- Name
Change to Hit Chance. - Type
Select Chance. - Use Minimum Value
Enable this setting. - Minimum Value
Set to 0.
Now, right click on the start node’s Next slot and add a status value step: Add > Combatant > Status Value
Step 0: Status Value
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select DEX.
Add another status value step on this step’s Next slot.
Step 1: Status Value
- Operator
Select Divide. - Status Origin
Select Target. - Status Value
Select AGI.
Now, add value step on this node’s Next slot: Add > Value > Value
Step 2: Value
- Operator
Select Multiply. - Value Type
Select Value. - Value
Set to 75.
Add another value step on this node’s Next slot.
Step 3: Value
- Operator
Select Multiply. - Value Type
Select Formula. - Formula
Select Level Factor (the formula we just created).
That’s it for this formula.
Formula 3: LUK Chance
This formula is similar to the hit chance, but is used for all LUK based chances (counter attacks, critical hit, blocking attacks). The chance is based on the relation between user and target LUK, the chance is 5 % if both are equal. This formula’s minimum value is also 0.
We’ll use this formula: (user LUK / target LUK) * 5 * Level Factor
Again, we need four additional steps (nodes).
Formula Settings (Start Node)
- Name
Change to LUK Chance. - Type
Select Chance. - Use Minimum Value
Enable this setting. - Minimum Value
Set to 0.
Now, right click on the start node’s Next slot and add a status value step: Add > Combatant > Status Value
Step 0: Status Value
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select LUK.
Add another status value step on this step’s Next slot.
Step 1: Status Value
- Operator
Select Divide. - Status Origin
Select Target. - Status Value
Select LUK.
Now, add value step on this node’s Next slot: Add > Value > Value
Step 2: Value
- Operator
Select Multiply. - Value Type
Select Value. - Value
Set to 5.
Add another value step on this node’s Next slot.
Step 3: Value
- Operator
Select Multiply. - Value Type
Select Formula. - Formula
Select Level Factor (the formula we just created).
That’s it for this formula.
Formula 4: Physical Damage
Now we’ll create the base physical damage calculation. The physical damage is based on the user’s ATK and the target’s DEF – and we’ll also use the level factor formula. To get thing’s a little bit more complex, we’ll use a power of calculation to increase the attack with higher ATK values. The minimum result should be 0.
We’ll use this formula: (user ATK ^ 2) / target DEF * Level Factor
And again – four additional nodes needed.
Formula Settings (Start Node)
- Name
Change to Physical Damage. - Type
Select Physical. - Use Minimum Value
Enable this setting. - Minimum Value
Set to 0.
Now, right click on the start node’s Next slot and add a status value step: Add > Combatant > Status Value
Step 0: Status Value
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select ATK.
Now, add value step on this node’s Next slot: Add > Value > Value
Step 1: Value
- Operator
Select Power Of. - Value Type
Select Value. - Value
Set to 2.
Add another status value step on this step’s Next slot.
Step 2: Status Value
- Operator
Select Divide. - Status Origin
Select Target. - Status Value
Select DEF.
Add another value step on this node’s Next slot.
Step 3: Value
- Operator
Select Multiply. - Value Type
Select Formula. - Formula
Select Level Factor.
That’s it for this formula.
Formula 5: Physical Damage 5
This will be easy, simply use the physical damage formula and multiply it by 5. A minimum value isn’t needed, since we only multiply another formula with a minimum value of 0.
We’ll use this formula: Physical Damage * 5
We only need one additional step this time, because we can use the other formula as start value in the formula settings.
Formula Settings (Start Node)
- Name
Change to Physical Damage 5. - Type
Select Physical. - Value Type (Start Value)
Select Formula. - Value (Start Value)
Select Physical Damage.
Now, right click on the start node’s Next slot and add a value step: Add > Value > Value
Step 0: Value
- Operator
Select Multiply. - Value Type
Select Value. - Value
Set to 5.
That’s it for this formula.
Formula 6: Magical Damage
The base magical damage calculation is similar to the base physical damage – only we’ll be using the user’s MATK and the target’s MDEF. The minimum result should be 0.
We’ll use this formula: (user MATK ^ 2) / target MDEF * Level Factor
And again – four additional nodes needed.
Formula Settings (Start Node)
- Name
Change to Magical Damage. - Type
Select Magical. - Use Minimum Value
Enable this setting. - Minimum Value
Set to 0.
Now, right click on the start node’s Next slot and add a status value step: Add > Combatant > Status Value
Step 0: Status Value
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select MATK.
Now, add value step on this node’s Next slot: Add > Value > Value
Step 1: Value
- Operator
Select Power Of. - Value Type
Select Value. - Value
Set to 2.
Add another status value step on this step’s Next slot.
Step 2: Status Value
- Operator
Select Divide. - Status Origin
Select Target. - Status Value
Select MDEF.
Add another value step on this node’s Next slot.
Step 3: Value
- Operator
Select Multiply. - Value Type
Select Formula. - Formula
Select Level Factor.
That’s it for this formula.
Formula 7: Magical Damage 5
Like Physical Damage 5, this formula multiplies the magical damage by 5.
We’ll use this formula: Magical Damage * 5
We only need one additional step this time, because we can use the other formula as start value in the formula settings.
Formula Settings (Start Node)
- Name
Change to Magical Damage 5. - Type
Select Magical. - Value Type (Start Value)
Select Formula. - Value (Start Value)
Select Magical Damage.
Now, right click on the start node’s Next slot and add a value step: Add > Value > Value
Step 0: Value
- Operator
Select Multiply. - Value Type
Select Value. - Value
Set to 5.
That’s it for this formula.
Formula 8: Magical Damage 10
Same thing, only times 10.
We’ll use this formula: Magical Damage * 10
We only need one additional step this time, because we can use the other formula as start value in the formula settings.
Formula Settings (Start Node)
- Name
Change to Magical Damage 10. - Type
Select Magical. - Value Type (Start Value)
Select Formula. - Value (Start Value)
Select Magical Damage.
Now, right click on the start node’s Next slot and add a value step: Add > Value > Value
Step 0: Value
- Operator
Select Multiply. - Value Type
Select Value. - Value
Set to 10.
That’s it for this formula.
Formula 9: Small Heal
Our final formula will calculate the amount of HP a small heal ability will refresh. It’s based on the user’s MATK and ignore’s the target’s status. Again, minimum value of 0.
We’ll use this formula: user MATK * 5
We need two steps this time.
Formula Settings (Start Node)
- Name
Change to Small Heal. - Type
Select Magical. - Use Minimum Value
Enable this setting. - Minimum Value
Set to 0.
Now, right click on the start node’s Next slot and add a status value step: Add > Combatant > Status Value
Step 0: Status Value
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select MATK.
Now, add value step on this node’s Next slot: Add > Value > Value
Step 1: Value
- Operator
Select Multiply. - Value Type
Select Value. - Value
Set to 5.
That’s it for the formulas – click on Save Settings.
Now that all our formulas are completed, you can try filtering the formula list using the Search/Filter box above the list.
It’s a lot easier to find a certain formula this way, since we separated the formulas into the different types.
And that’s it for now – the next lesson will cover Abilities.