Modding:Effects
Effect Types
All effects inherit a virtual method called GetEffectType()
. The result of GetEffectType()
is an integer, representing a bit vector in which each bit is a flag that designates whether or not the effect is of a given type.
The game supports the following effect types[1]:
Mechanisms | ||||
---|---|---|---|---|
# bit from right | Effect Type | Decimal | Binary | Notes |
1 | General | 1 | 0000000000000000000000000001 | |
2 | Mental | 2 | 0000000000000000000000000010 | cannot be applied to objects that lack a brain[2] |
3 | Metabolic | 4 | 0000000000000000000000000100 | cannot be applied to objects without stomachs[2], to gases[3], or to plasma[4] |
4 | Respiratory | 8 | 0000000000000000000000001000 | cannot be applied to objects without stomachs[2] |
5 | Circulatory | 16 | 0000000000000000000000010000 | cannot be applied to objects that cannot bleed[2] |
6 | Contact | 32 | 0000000000000000000000100000 | cannot be applied to liquid[2][5], gas[3], or plasma[4] |
7 | Field | 64 | 0000000000000000000001000000 | |
8 | Activity | 128 | 0000000000000000000010000000 | cannot be applied to objects without bodies |
9 | Dimensional | 256 | 0000000000000000000100000000 | |
10 | Chemical | 512 | 0000000000000000001000000000 | cannot be applied to plasma[4] |
11 | Structural | 1024 | 0000000000000000010000000000 | cannot be applied to liquid[5], gas[3], or plasma[4] |
12 | Sonic | 2048 | 0000000000000000100000000000 | cannot be applied to plasma[5] |
13 | Temporal | 4096 | 0000000000000001000000000000 | |
14 | Neurological | 8192 | 0000000000000010000000000000 | |
15 | Disease | 16384 | 0000000000000100000000000000 |
Class | |||
---|---|---|---|
# bit from right | Effect Type | Decimal | Binary |
25 | Minor | 16777216 | 0001000000000000000000000000 |
26 | Negative | 33554432 | 0010000000000000000000000000 |
27 | Removable | 67108864 | 0100000000000000000000000000 |
28 | Voluntary | 134217728 | 1000000000000000000000000000 |
There are other masks that check the classifications of bits instead:
Group of Bits | Decimal | Binary | Parts |
---|---|---|---|
Mechanism | 16777215 | 0000111111111111111111111111 | Bits # 1 - 24 |
Class | 251658240 | 1111000000000000000000000000 | Bits # 28 - 25 |
Duration Indefinite | 9999 | 10 011 100 001 111 | Bits # 1, 2, 3, 4, 9, 10, 11, 14 |
For example, the Shamed effect has types "mental", "minor", "negative", "removable", which can be represented with the following implementation of GetEffectType()
:
public override int GetEffectType()
{
return Effect.TYPE_MENTAL
| EFFECT.TYPE_MINOR
| EFFECT.TYPE_NEGATIVE
| EFFECT.TYPE_REMOVABLE;
}
There are also separate checks in Effect.cs which is checked every time Apply Event Effect is called. Objects that are considered solid will always return true.
Effect | Bits |
---|---|
Cannot be applied to liquids | 6, 11(Contact or Structural) |
Cannot be applied to gas | 3, 6, 11 (Metabolic, Contact, or Structural) |
Cannot be applied to Plasma | 3, 6, 7, 10, 11, 12 (Metabolic, Contact, Field, Chemical, Structural, or Sonic) |
Methods of masking
Effects have two methods of checking these masks:
- bool
IsOfType()
- returns true if ANY of the specified digits are true - bool
IsOfTypes()
- returns true if ALL of the specified digits are true
These checks are done by running a bitwise AND(&) operation on them.
Example
This is a simplified version of something already in GameObject.cs:
int mask = 9244;
GameObject GO = [...];
for (int count = GO.Effects.Count; index < count; ++index)
{
Effect effect = this.Effects[index];
if (effect.IsOfType(mask))
(Do something);
}
where mask
in binary is 10010000011100
, any effect of type 3, 4, 5, 11, 13.
References
- ↑
XRL.World.Effects
- ↑ 2.0 2.1 2.2 2.3 2.4
XRL.World.Effect
, methodCanEffectTypeBeAppliedTo
- ↑ 3.0 3.1 3.2
XRL.World.Effect
, methodCanEffectTypeBeAppliedToGas
- ↑ 4.0 4.1 4.2 4.3
XRL.World.Effect
, methodCanEffectTypeBeAppliedToPlasma
- ↑ 5.0 5.1 5.2
XRL.World.Effect
, methodCanEffectTypeBeAppliedToLiquid