Function in a Function
There are several cases where you might want to call a formula function within another one.
Let's say you wanted to create a formula function which requires additional conditions depending on if the target is undead. These additional conditions could be defined in other formula functions.
For example, formula function 0 could be checking whether the target has the safety augment, and if it does, set the formula skip state and miss state to 1 like this:
while formula function 1 could do the same but with the stability augment instead like this:
Now instead of duplicating that code in your new formula function, you can just call them like this:
So if the target is undead, they must also not have the safety augment. If they are not undead, they must also not have the stability augment.
Make sure to pass the arguments of the current formula function along the one you are calling so it has the same capabilities as this one.
Since these formula functions were manually called and therefore not part of the formula's functions list, you must manually check whether the formula skip state was modified and if so, return preemptively.
If this was the case here, then all the following formula functions and the code that doubles the formula's power would be skipped.
Now you could technically do all of this via helper functions instead. However, this was only a very simple example. There are formula functions which call 3 or more other formula functions with dozen lines of code one after another.
So while helpers are usually used to do one specific task, functions do more complex ones.
Last updated