GetEffect

Category: Effects
Since engine version: 4.9.5.0 CE

Description

Retrieves effect data or determines whether a certain effect is present. The return value depend on the requested value. If an effect cannot be found the return value is always 0.

Syntax

any GetEffect (string szEffectName, object pTarget, int iIndex, int iQueryVal, int iMaxPriority);

Parameters

szEffectName:
[opt] Name of the effect without preceding 'Fx'. You can use '*' and '?' wildcards.
pTarget:
[opt] Target object in which to access effects. If 0, the global effects are accessed.
iIndex:
[opt] Effect index. With szEffectName specified and multiple matches for the search this will give you the indicated effect from the list of results. If szEffectName is not specified, this index is the effect number. Effect numbers do not necessarily run continuously from 0 to the number of effects. When using the index, this continuity is ensured.
iQueryVal:
[opt] Index of the value to be retrieved. See remarks.
iMaxPriority:
[opt] If not 0, only those effects are counted which have the specified priority or lower.

Remark

Using the parameter iQueryVal the following values can be retrieved:

iQueryVal Value
0 Effect number
1 Name
2 Priority
3 Timer interval
4 Command target
5 Command target id
6 Duration of the effect

Example

var obj, i, iEffect;
// Alle Objekte durchsuchen
while (obj=FindObject(0, 0,0,0,0, 0, 0,0, 0, obj))
  {
  // Von Effektzahl abwärts zählen, da Effekte entfernt werden
  i = GetEffectCount(0, obj);
  while (i--)
    if (iEffect = GetEffect("*Spell", obj, i))
      RemoveEffect(0, obj, iEffect);
  }
// Globale Effekte entfernen
i = GetEffectCount();
while (i--)
  if (iEffect = GetEffect("*Spell", 0, i))
    RemoveEffect(0, 0, iEffect);
Removes all magic effects from all objects and the global list.
See also: AddEffect, ChangeEffect, CheckEffect, EffectCall, EffectVar, Effects Documentation, GetEffectCount, RemoveEffect
Sven2, März 2004