Functions
Description
The functions
directory contains all functions used by formulas. Every function is defined in a separate file and has a unique identifier (e.g. 10).
Each function does one specific task and is usually unique.
For example, one function could check if the target is immune to fire while the other calculates the amount of health the target should lose. Now these functions can of course be summed up in one, but it's best to split as many tasks of a formula into several functions so they can be reused in others.
All functions are processed in a predetermined order. At any point within a function, can the processing of the upcoming functions be cancelled.
So when a caster uses the action Fire on a target, the first function would check whether the target is immune to it and if that's the case, not even process the second function which would calculate the damage.
If you want an action to not have an effect on a target that is immune to fire, you can just add the first function to the start of the formula.
Layout
Arguments
Every formula function is called with 6 arguments by default.
Formula
A metatable with all formula processing relevant information. This includes all properties of the Formula Processing Work structure (e.g. current action, caster / target stats, ...)
Caster
A metatable of the Battle Unit Keep structure of the caster.
Target
A metatable of the Battle Unit Keep structure of the target.
Functions
A table with all predefined formula functions from the functions
directory.
Classes
A table with all predefined functions from the classes
directory that build metatables to simulate object oriented programming.
Helpers
A table with all predefined functions from the helpers
directory that help reuse a block of code after defining it once.
These arguments are described in detail in the following pages.
Notes
Last updated