The effect type represents a modifier that can be applied to a game object.
There is no literal for an effect.
There is no explicit or implicit conversion to or from an effect.
The following functions allow an effect to exist outside of the scope of the current script by storing it on an object:
The following functions allow an effect which exists outside of the scope of the current script to be used in the current script by retrieving it from an object:
Every effect has a type set on it that determines how it affects the object it is applied to. They also have a number of parameters on them, which vary based on the type, that change the specific behaviour.
When the effect is removed (usually because the duration on the effect expires) the modifier is removed. These modifiers can be rule or stat based or more complicated visual and game effects.
They can be assigned different duration types which affect how they're applied and removed:
- Temporary: Applied for a short duration (measured in seconds)
- Permanent: Applied until manually removed through scripting
- Instant: These are one-shot modifiers that are not stored on the object (the death effect is an instant modifier for example)
- Equipped: Associated with an equipped item. The effect is removed when the item is unequipped.
Some effect types can only be applied as instant effects. These effects will delete themselves after they've been applied no matter what duration type was set for them. All other duration types will be stored in a list on the object they're applied to.
Effects are usually created and applied through the scripting language. The list of effects applied to an object can also be examined and modified through scripting. The game engine itself will apply some instant effects when appropriate (like death or damage during combat).
When an effect is applied through scripting, the designer has the option of specifying a sub-type on it. The subtype, which can be either "normal" or "magical", affects whether a "Dispel Magic" spell should clear the effect or not (Dispel Magic is an instant effect type). Magical effects are usually tagged with the spell id that created it so that more rules checking can be done when they're cleared.
Some effects trigger events to the object that they're applied to. This is especially important for hostile effects like damage or death. Each effect is tagged with the object id of the creator so that the target can react appropriately.
All stat modifiers stack with each other. If an object has two bonuses of the same type applied, they will get the full bonus from each.
When a game is reloaded, all the effects on an object are re-applied but with a special "loading" flag turned on. Most effects will see this and do nothing, since the object they're applying themselves to has already had the modifiers applied. A few effects will need to re-apply themselves if their effect is not easily saved.
Packages of effects can be constructed by "linking" them in the scripting language before they're applied. Any effects that are linked together will be given the same unique id when they're applied. If any effect in this group is then removed, either through expiry or scripting, then the entire group will go with them. This is most often used to tie a visual effect to a stat modifier. When the modifier expires the visual effect will disappear.
Effects are applied internally by signalling an "apply effect" event with pointer to the effect attached. They are usually removed in the same way because you don't know what else is linked to that effect and what dispelling them will do to the object.
The check to see if an effect has expired is done as part of an object's AI Update. Some effect types also have timers that are checked here to see if they need to be given an update (used for regeneration type effects).
Party members will have a series of "effect icons" that appear on their character sheets so that the player can see what effects are on them. These icons will be controlled by a special "Effect Icon" effect that will be linked to the spell's effects and managed by the scripter.
Behaviour for effects can be defined in either the engine or in scripting. When an effect is applied or removed, the game will check for a defined handler for that effect type. If none exists, then the object will receive an event to their script with the effect attached.
To access the effect in an onApply or onRemove event, use the
effect GetCurrentEffect() scripting command. The properties on this effect can be examined to determine type, duration and other parameters. If your script handles the effect properly and you want it to be stored (so that you get the onRemove event later) you need to call the special
void SetIsCurrentEffectValid(int nValid) function. This will add it to the effect list on that object.
Effects will usually be handled by the core scripts rather than by an object's AI script.