EFF file format

Applies to:
BG1: TotS, BG2, BG2: ToB, IWD, IWD:HoW, IWD:TotL, PST, BGEE

General Description
This file format describes an effect (opcode) and its parameters. The format is only ever found embedded in other files (e.g. ITM or SPL). The engine appears to roll a probability for each valid target type, rather than one probability per attack.

Overall structure:


Offset Size (datatype) Description
0x0000 2 (word)

Effect type

0x0002 1 (byte)

Target type

Note:
  • ITM global (equipped) effects: Target is always the wearer, this field isn’t relevant.
  • SPL global (casting) effects: Will not work with Projectile Target.
  • Everyone stands for “in current area”.
  • Excluding Target type 2, all other Target types apply the effect using projectile #1|None.
  • Target types 2 and 9 are applied in effect order, but always after the others, even when using projectile #1|None.
    • Target types (1, 3–8) are applied in effect order.
      • If a spell/item has effects listed in this order:
        • op(1), target = 2
        • op(2), target = 3
        • op(3), target = 1
        • op(4), target = 9
        • op(5), target = 2
        • op(6), target = 6
        They will be applied in this order: op(2), op(3), op(6), op(1), op(4), op(5).
  • Similar to Melee Weapon Attacks, when Target types other than 1, 2, 9 apply the effect, they are subjected to opcode #197 (parameter2=0) but not to opcode #83. (Excluding when they’re affecting the caster).
  • Be aware that opcode #146*p2=2, opcode #326, and opcode #333 might behave differently when it comes to Self/Projectile Target/Original Caster.
0x0003 1 (byte)

Power

0x0004 4 (dword)

Parameter 1

0x0008 4 (dword)

Parameter 2

0x000c 1 (char)

Timing mode

Note:
  • All effects except those with Timing mode 9 are removed by death.
  • Some effects use a measurement of gametime in seconds, and multiply it by 15, rather than taking the exact gametime in ticks.
    • This results in them lasting longer/shorter than they should (by up to 14 ticks).
      • One of such effects is Time Stop (this is in addition to lasting half its specified Duration).
0x000d 1 (byte)

Dispel / Resistance

The default behaviour is that effects cannot be dispelled and ignore magic resistance.

  • bit 0 ⟶ Can be dispelled, affected by magic resistance
  • bit 1 ⟶ Ignores magic resistance (when used in combination with bit 0)

This can also be presented in the more traditional way:

  • 0 ⟶ Natural/Nonmagical
  • 1 ⟶ Can be dispelled/Affected by resistance
  • 2 ⟶ Cannot be dispelled/Ignores resistance
  • 3 ⟶ Can be dispelled/Ignores resistance

The only difference between 0 and 2 is that 0 will automatically convert to 2 when targeting yourself.

0x000e 4 (dword)

Duration

  • This field is measured in seconds or ticks (115 second), depending on Timing mode.
0x0012 1 (byte)

Probability 1

0x0013 1 (byte)

Probability 2

Info:
  • The BG1 engine treats probability as a single word, effects are applied in the range 0–probability.
  • Other engines treat probability as two values. When an event fires, a random number (let us denote it by x) in the 0–99 range is generated. If x <= Probability1 && >= Probability2, the event fires.
    • Some counter-intuitive cases:
      • if you set both Probability1 and Probability2 to 0, you get an effect with a 1% chance of firing (it fires whenever the random number generator spits out zero).
      • if you set Probability1 to 1 and Probability2 to 0 (as, e.g., happens in BGT/BGEE’s implementation of the iron crisis), you don’t get an effect with a 1% chance of firing, but one with a 2% chance of firing.
0x0014 8 (resref)

Resref key

0x001c 4 (dword)

Dice Thrown / Maximum Level

Note: When this field is used as Maximum Level:
  • A 7 ➔ 1 dual-class character qualifies as HD 7, even though the level 7 class is still inactive.
  • A 1/7/1 multi-class character qualifies as HD 7, not level 3 (average).
  • The 2nd/3rd class levels are NOT included for single-classes.
    • A 1/30/1 single-class character qualifies as HD 1.
0x0020 4 (dword)

Dice Sides / Minimum Level

Note: When this field is used as Minimum Level:
  • A 7 ➔ 1 dual-class character qualifies as HD 7, even though the level 7 class is still inactive.
  • A 1/7/1 multi-class character qualifies as HD 7, not level 3 (average).
  • The 2nd/3rd class levels are NOT included for single-classes.
    • A 1/30/1 single-class qualifies as HD 1.
0x0024 4 (dword)

Saving throw type

Note: If more than 1 Saving Throw Type is specified (BIT0 – BIT4), the target rolls against their best save.
0x0028 4 (dword)

Saving throw bonus