Effect Tutorial

From Gothongs Wiki
Revision as of 16:41, 28 July 2023 by Panda (talk | contribs)
Jump to navigationJump to search

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 - 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
	...
]

Package

A package is a collection of effects, conditions and events. Packages can be instant or happen over time. A package that happens over time typically has an icon that shows on your HUD below the resource bars.

A wrapper can apply multiple packages, and a package can contain multiple effects.

Package flags:

Flag Value Description
PF_DETRIMENTAL 0x1 Sets package as detrimental. Receiving a detrimental package activates the combat timer. Sending a detrimental package to an NPC will make it attack you. Invulnerability block receiving detrimental packages.
PF_CANNIBALIZE 0x2 If a package with the same name already exists, replace it with this one and add its stacks. Default behavior is to keep the original wrapper and add the incoming package's stacks because it is faster.
PF_EVENT_ON_OVERWRITE 0x4 Raises the INTEVENT_ON_REMOVE event when PF_CANNIBALIZE is set and a spell is overwritten.
PF_ALLOW_WHEN_DEAD 0x8 By default a player is not allowed to receive ANY packages when defeated. This flag overrides that. Useful for resurrect.
PF_ALLOW_WHEN_QUICKRAPE 0x10 By default when caught on a trap or grapple, NPCs cannot apply packages to you. This overrides that.
PF_NO_STACK_MULTIPLY 0x20 Many effect values are multiplied by nr of stacks of a package a player has. This prevents that multiplication.
PF_FULL_UNIQUE 0x40 By default, packages are unique by name and by sender. This makes them only unique by name. When set you may only have one package active with this name no matter how many senders.
PF_TRIGGER_IMMEDIATE 0x80 By default the non-passive effects (like damage) are only triggered when a package with a duration "ticks". Setting this will make it tick instantly when the package is added also. This flag is used a lot.
PF_NO_DISPEL 0x100 Prevents the package from being dispelled.
PF_STACK_TIME 0x200 When a package with the same name is received, it adds that package's duration instead of its stacks. Tank mitigation abilities usually use this.
PF_FULL_VIS 0x400 By default you may only see your own spells on the target bar. This forces the spell icon to show up no matter who cast it.

Effects

Conditions

Events