In this tutorial we’ll set up the main formulas for our status system.
Formulas #
We’ll set up the following formulas:
- physical damage
- magical damage
- hit chance
- critical chance
- critical damage multiplier
- level based reward
Formulas work as a steb-by-step calculation, calculating each node at a time to the current formula result. We’ll use sub-calculations (via Begin Sub Calculation and End Sub Calculation nodes) to make sure the math is still correct.
Navigate to Game > Formulas, we’ll change the already added Default formula and add additional formulas. You can optionally use formula types for organizing them in the editor, but it’s not required (and isn’t part of this tutorial series).
Calculating Physical Damage #
The physical damage is calculated like this:
Value * User.WPN * User.ATK / ((100+Target.DEF) / 100)
It uses the following values:
- Value
The initial value forwarded to the formula, e.g. 1 for a base attack or 2 for a critical hit. - User.WPN
The user’s Weapon Damage status value. - User.ATK
The user’s Attack status value. - Target.DEF
The target’s Defence status value.
Due to how formulas work, we’ll pack the 2nd half of the formula ((100+Target.DEF) / 100) into a sub-calculation.
Calculating Magical Damage #
The magical damage is calculated like this:
Value * 2 * User.MATK * User.MATK / (User.MATK + Target.MDEF)
It uses the following values:
- Value
The initial value forwarded to the formula, e.g. 15 for a low level magic spell. - User.MATK
The user’s Magic Attack status value. - Target.MDEF
The target’s Magic Defence status value.
Due to how formulas work, we’ll pack the 2nd half of the formula (User.MATK + Target.MDEF) into a sub-calculation.
Calculating Hit Chance #
The hit chance is calculated like this:
(User.DEX / Target.AGI) * 100
It uses the following values:
- User.DEX
The user’s Dexterity status value. - Target.AGI
The target’s Agility status value.
The result will be limited to values between 0 and 100. We only need one formula for this.
Calculating Critical Chance #
The critical chance is calculated like this:
(User.LUK + (User.DEX / 4)) – (Target.LUK + (Target.DEX / 4))
It uses the following values:
- User.LUK
The user’s Luck status value. - User.DEX
The user’s Dexterity status value. - Target.LUK
The target’s Luck status value. - Target.DEX
The target’s Dexterity status value.
Since user and target calculations are basically the same, we’ll split the formula into 2:
- LUK Base
The formula used to calculate user and target sides of the formula (by passing on different users): (LUK + (DEX / 4)) / 3 - Critical Chance
The formula used to calculate the critical chance: LUK Base(User) – LUK Base(Target).
The result will be limited to values between 0 and 100.
Calculating Critical Damage Multiplier #
We’ll use this formula as a multiplication factor for critical hit damages. We’ll simply use a value of 1.5 as the critical damage multiplier.
While we can also just define that value wherever a critical hit is used (e.g. in an attack ability), using a formula allows us to later change this for all abilities or items that use the formula. This makes it easier to test different setups and change it for all using critical hits.
Calculating Level Based Reward #
Combatants will give experience and quantity (e.g. gold) rewards scaled by their level. The level based reward is calculated like this:
Value * User.Level
It uses the following values:
- Value
The initial value forwarded to the formula, e.g. 1 for 1x level experience/quantity, 2 for 2x level experience/quantity. - User.Level
The user’s level.
0: Physical Damage #
This formula calculates the physical damage, using a sub calculation for the defence part of the formula. Using the formula requires to pass on an initial value that is greater than 0 to achieve actual damage.
Formula Settings #
- Name
Set to Physical Damage.
Status Value #
Add Node > Combatant > Status Value
Multiply by the user’s weapon damage. This’ll multiply the passed on initial value (coming from an ability) by the weapon damage.
- Operator
Select Multiply. - Status Origin
Select User. - Status Value
Select Weapon Damage. - Value Origin
Select Current.
Status Value #
Add Node > Combatant > Status Value
Multiply by the user’s attack.
- Operator
Select Multiply. - Status Origin
Select User. - Status Value
Select Attack. - Value Origin
Select Current.
Begin Sub Calculation #
Add Node > Base > Begin Sub Calculation
This node starts a sub calculation.
The result of the sub calculation (ending using an End Sub Calculation node) is added to the current formula result using this node’s operator.
We’ll divide the current formula result by the sub calculation’s result. We’ll also immediately set the sub calculation’s current value to 100.
- Operator
Select Divide. - Initial Value
Select Value > Value.
Set the value to 100.
Tip! You can also have sub calculations within your sub calculations!
Status Value #
Add Node > Combatant > Status Value
Uses a combatant’s status value – we’ll use the target’s defence.
- Operator
Select Add. - Status Origin
Select Target. - Status Value
Select Defence. - Value Origin
Select Current.
We’ll use the current value of the status value.
Value #
Add Node > Value > Value
Divide by 100.
- Operator
Select Divide. - Value
Select Value > Value.
Set the value to 100.
End Sub Calculation #
Add Node > Base > End Sub Calculation
This ends our sub calculation, using it’s Begin Sub Calculation node’s operator to change the formulas value.
Any open sub calculation is closed at the end of a formula, i.e. we don’t really need to add this node, but it’s better to keep things clean and organized – every Begin Sub Calculation node should have an End Sub Calculation node.
No further settings needed.
1: Magical Damage #
This formula calculates the magical damage, using a sub calculation for the defence part of the formula. Using the formula requires to pass on an initial value that is greater than 0 to achieve actual damage.
Formula Settings #
- Name
Set to Magical Damage.
Value #
Add Node > Value > Value
Multiply by 2. This’ll multiply the passed on initial value (coming from an ability) by 2.
- Operator
Select Multiply. - Value
Select Value > Value.
Set the value to 2.
Status Value #
Add Node > Combatant > Status Value
Multiply by the user’s magic attack.
- Operator
Select Multiply. - Status Origin
Select User. - Status Value
Select Magic Attack. - Value Origin
Select Current.
Status Value #
Add Node > Combatant > Status Value
Once more multiply by the user’s magic attack. You can just copy the previous node.
- Operator
Select Multiply. - Status Origin
Select User. - Status Value
Select Magic Attack. - Value Origin
Select Current.
Begin Sub Calculation #
Add Node > Base > Begin Sub Calculation
This node starts a sub calculation.
We’ll divide the current formula result by the sub calculation’s result. This time we don’t set an initial value (i.e. keep it at 0).
- Operator
Select Divide.
Status Value #
Add Node > Combatant > Status Value
Add the user’s magic attack.
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select Magic Attack. - Value Origin
Select Current.
Status Value #
Add Node > Combatant > Status Value
Add the target’s magic defence.
- Operator
Select Add. - Status Origin
Select Target. - Status Value
Select Magic Defence. - Value Origin
Select Current.
End Sub Calculation #
Add Node > Base > End Sub Calculation
This ends our sub calculation, using it’s Begin Sub Calculation node’s operator to change the formulas value.
No further settings needed.
2: Hit Chance #
This formula calculates the hit chance.
Formula Settings #
- Name
Set to Hit Chance. - Use Minimum Value
Enable this setting. - Minimum Value
Select Value > Value.
Set the value to 0. - Use Maximum Value
Enable this setting. - Maximum Value
Select Value > Value.
Set the value to 100.
Status Value #
Add Node > Combatant > Status Value
Add the user’s dexterity.
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select Dexterity. - Value Origin
Select Current.
Status Value #
Add Node > Combatant > Status Value
Divide by the target’s agility.
- Operator
Select Divide. - Status Origin
Select Target. - Status Value
Select Agility. - Value Origin
Select Current.
Value #
Add Node > Value > Value
Multiply by 100.
- Operator
Select Multiply. - Value
Select Value > Value.
Set the value to 100.
3: LUK Base #
This formula is part of the critical chance calculation and calculates the user’s and target’s side of the calculation by passing on the user or target.
Formula Settings #
- Name
Set to LUK Base.
Status Value #
Add Node > Combatant > Status Value
Add the user’s dexterity.
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select Dexterity. - Value Origin
Select Current.
Value #
Add Node > Value > Value
Divide by 4.
- Operator
Select Divide. - Value
Select Value > Value.
Set the value to 4.
Status Value #
Add Node > Combatant > Status Value
Add the user’s luck.
- Operator
Select Add. - Status Origin
Select User. - Status Value
Select Luck. - Value Origin
Select Current.
4: Critical Chance #
This formula calculates the critical chance using the LUK Base formula for user and target.
Formula Settings #
- Name
Set to Critical Chance. - Use Minimum Value
Enable this setting. - Minimum Value
Select Value > Value.
Set the value to 0. - Use Maximum Value
Enable this setting. - Maximum Value
Select Value > Value.
Set the value to 100.
Value #
Add Node > Value > Value
Add the LUK Base formula for the user.
- Operator
Select Add. - Value
Select Value > Formula.
Select LUK Base.
The setup should automatically use the User as the user and the Target as the target of the other formula.
- Game Object (User)
Select User. - Game Object (Target)
Select Target.
Value #
Add Node > Value > Value
Subtract the LUK Base formula for the target.
- Operator
Select Sub. - Value
Select Value > Formula.
Select LUK Base.
This time we need to change the user of the formula.
- Game Object (User)
Select Target. - Game Object (Target)
Select Target.
5: Critical Damage Multiplier #
This formula calculates the multiplier for critical damages and will be used by critical target changes of abilities.
Formula Settings #
- Name
Set to Critical Damage Multiplier.
Value #
Add Node > Value > Value
Add 1.5.
- Operator
Select Add. - Value
Select Value > Value.
Set the value to 1.5.
6: Level Based Reward #
This formula calculates the level based reward, e.g. used by experience rewards of defeated combatants or loot tables dropping level based gold quantities.
Using the formula requires to pass on an initial value that is greater than 0 to get an actual reward.
Formula Settings #
- Name
Set to Level Based Reward.
Level #
Add Node > Combatant > Level
Uses a combatant’s level as value. We’ll multiply the initial formula value by the user’s level.
- Operator
Select Multiply. - Status Origin
Select User.
Save Changes #
And that’s it for the formula setup.
Don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.
Next, we’ll set up ability types and item types.