Effect Tutorial
From Gothongs Wiki
Effects (FX) are the backbone of the game. They are the buffs that you see on your HUD and also used by direct damage and things behind the scenes like cutscenes.
Relevant scripts:
| Script | Description |
|---|---|
| _lib_fx.lsl | Stores all the effect types and explains the effect types. Also stores a list of default values for passive effects (not to be confused with the passives system which is different). Also conditions and tags. |
| classes/got FX.lsl | Has the methods, macros, and building tools for making effects. |
| classes/got FXCompiler.lsl | Compiles effects into cached values and triggers LSL and RLV functions when effects are added or removed. |
The structure of an effect
The effect data is a JSON array with the following spect:
- (array) wrapper. An all or nothing container of multiple effect packages and stacks of packages.
- (int) wrapper_flags - WF_* flags. See below.
- (int) min_packages - Minimum packages to apply (all or nothing).
- (int) max_packages - Max packages to apply (applies the N first viable packages). Use 0 for ALL.
- (...strided) (int) package_stacks, (array) package_data - After max_packages the remaining elements are two-strided with nr stacks and the package to add said stacks of. Anything below 1 becomes 1.
- (float) Package duration - Duration to apply the package
- (int) Package flags - PF_* flags. See below.
- (str) Package name - Name of the package (unique). If the effect has a 0 duration you can use "" or 0 because it is only used in duration effects.
- (array) Effects - An array of FX arrays
- (int) Effect type - An effect integer from _lib_fx.lsl
- ...effect data - ...followed by data based on that effect.
- (array) Conditions - An array of condition arrays
- (int) Type of condition - Condition identifier from _lib_fx.lsl
- ...condition data - Data based on the condition identifier.
- (array) Events - An array of effect arrays.
- (int) event_type - An event type. You can use any relevant event from any of the header files in got/classes.lsl
- (str) event_script - The name of the script that raised the event. If the event was raised by got FX.lsl then use "" instead.
- (int) targ_flags - A TARG_* flag. See below.
- (int) max_targets - Max nr of targets to apply to. Not very useful. Leave at 0 for all viable.
- (array) wrapper (nested wrapper) - The wrapper to apply when the effect is raised. This is a nested wrapper.
- (array) event_params - An array of values that must match the event values. See below.
- (float) proc_chance - Adds a random chance that the event is raised. Between 0 (no chance) and 1 (100%).
- (int) event_flags - Event flags. See below.
- (float) max_range - Max range of event target from the victim of the package. In whole meters.
- (float) cooldown - Cooldown between procing the event.
- (array) tags - An array of fx$TAG_* constants from _lib_fx.lsl
- (int) min_conditions - Minimum conditions that must be met for the package to apply.
- (int) max_stacks - Max stacks that this package can have.
- (float) tick - When set to anything above 0 it will trigger all the effects this often. In whole seconds.
Here is a JSON encoded version of the above:
[ (int)wrapper_flags, (int)min_packages, (int)max_packages, (int)stacks_package0, [ (float)package_duration, (int)package_flags, (str)package_name, [ [ (int)effect_type, (var)effect_data0, ... ] ... ], [ [ (int)condition_type, (var)condition_data0, ... ] ... ], [ [ (int)event_type, (str)event_script, (int)targ_flags, (int)max_targets, (arr)wrapper, (arr)event_params, (float)proc_chance, (int)event_flags, (float)max_range, (float)cooldown ], ... ], [ (int)tag0, ... ], (int)min_conditions, (int)max_stacks, (float)tick ], (int)stacks_package1, (arr)package1 ... ]