Introduction
Every RPG game has its own system. Some are based on the famous D20 from Dungeons and Dragons and other have their own proprietary system. In order to give you the flexibility to use whatever system you want we’ve come up with the Formula objects, which all they do is output a number.
Formulas can be used for a wide variety of things. For example:
Define the value of a Stat
Calculate the damage output of an attack
Display new Dialogue options based on the output of a Formula
Basics
Let’s begin with the basics. A Formula object has a text field where you can type some words. Let’s begin with something very simple:
When we execute this formula, the output will always be 5. If we use this as the Formula for the strength stat, the player and all the enemies will always have a strength of 5 points.
This Formula always returns a fixed value; Not very exciting, huh? Let’s complicate things a bit.
Let’s say we’re creating a Formula that will define the value of our dexterity stat. In our game, the dexterity helps the player shoot with more accuracy. The base value (initial value) is 1 and is increased by 5 for each level. The Formula of the dexterity would then be:
Let’s break this down. Formulas have a set of pre-defined symbols that help you build your own mathematical expressions. One of them is the this[value] symbol, which basically means the base value of the Stat, in this case: 1
Another Formula symbol is the stat[NAME]. This allows you to access the final value of a stat identified by NAME from the same object. In this case, we’re accessing the level of the character and we multiply this value by 5.
The result of the previous formula is that if the player is at level 1, its dexterity stat will be 1 + (1 * 5) = 6, and if its at level 4 it will be 1 + (4 * 5) = 21.
Still reading? Great! You have just learned the hardest part!
Intermediate
Now that you know the basics of how a Formula works, let’s dig a bit deeper. We previously saw how to calculate a character’s stat using its own information. But we might also want to calculate a value taking into account two objects.
The most common scenario would be having a character attack an enemy. The damage of the attack could be the value of the strength stat of the player minus the armor stat of the enemy.
(Example of an Action using a Target and an Opponent field for the Formula)
In this case, the Formula would be:
The stat[NAME] symbol refers to the invoker of the calculation. In this case, the player wants to know the amount of damage it outputs. The stat:other[NAME] refers to the opponent of the Formula.
Advanced
You might be wondering what the heck is the graph at the bottom of the Formula object.
(Progression Table)
With the current Formula system you already know how to output a value depending on different inputs. But these values are not discreet, meaning that increasing one a bit will affect others.
Though this is the desired effect most of the times, there are others where you only want to increase a value once it reaches a threshold. The most common example is a character’s level.
To make things more difficult, each time a level is gained, the amount of experience points to reach the next one increase.
That’s why the Progression Tables com into play: You input a value (called Progress) and the table outputs a number (aka Tier). Notice that there can only be one per Formula.
Progression Tables have two parameters: Threshold and Max Tier.
Threshold is the amount increased by each new tier.
Max Tier is the maximum value a Progression Table can output.
We’ve put up an example of how to use a Progression Table to define the Level of a character based on the amount of experience points in the Common Cases section.
Formula Symbols
Symbol | Description |
---|---|
this[value] | The base value of the Formula |
table[input] | The tier of the Progression Table |
table:rise[input] | Returns the percentage complete to reach the next tier |
rand[X, Y] | Returns a random value between X and Y |
dice[R, S] | Returns the value of rolling R dices of S sides |
chance[X] | Returns 1 if a random percentage is less or equal to X, and 0 otherwise |
stat[name] | Returns the value of a stat identified by name |
attr[name] | Returns the value of an attribute identified by name |
stat:other[name] | Returns the value of the other stat identified by name |
attr:other[name] | Returns the value of the other attribute identified by name |
local[name] | Returns the value of a local variable (number or bool) identified by name |
local:other[name] | Returns the value of the other local variable identified by name |
global[name] | Returns the value of a global variable (number or bool) identified by name |
min[X, Y] | Returns the smallest value |
max[X, Y] | Returns the largest value |
round[X] | Rounds the value to the nearest integer |
floor[X] | Returns the largest integer smaller or equal to X |
ceil[X] | Returns the smallest integer greater or equal to X |