SPL file format

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

General Description
This file format describes a "spell". Spells include mage spells, priest spells, innate abilities, special abilities and effects used for game advancement (e.g. animation effects, custom spells). SPL files have a similar structure to ITM files.

Header:Size=114 Bytes Ext. Header: Size= 40 Bytes Feature Block: Size=48 Bytes

Detailed Description
SPL files consist of a main header, zero or more extended headers (each containing zero or more feature blocks) and zero or more casting feature blocks. All the feature blocks are stored as a continuous data segment, with each extended header containing an offset into this data, and the main header containing an offset into this data for the casting feature blocks.

Overall structure:


Offset Size (datatype) Description
0x0000 4 (char array) Signature ('SPL ')
0x0004 4 (char array) Version ('V1  ')
0x0008 4 (dword) Spell Name - Unidentified (strref)
0x000c 4 (dword) Spell Name - Identified (strref) (usu. -1)
0x0010 8 (resref) Completion Sound
0x0018 4 (dword) Flags
0x001c 2 (word) Spell type:
0=Special
1=Wizard
2=Cleric
3=Psionic
4=Innate
5=Bardsong
0x001e 4 (word) Exclusion Flags
0x0022 2 (word) Casting Graphics
0x0024 1 (char) Min Level (unused)
0x0025 1 (byte) Primary Type (Spell school) (IWD: school.2da, BG2:mschool.2da)
0x0026 1 (byte) Min Strength (unused)
0x0027 1 (char) Secondary Type (BG2:msectype.2da)
0x0028 1 (byte) Min Strength Bonus (unused)
0x0029 1 (byte) Usability 1 (unused)
0x002a 1 (byte) Min Int (unused)
0x002b 1 (byte) Usability 2 (unused)
0x002c 1 (byte) Min Dex (unused)
0x002d 1 (byte) Usability 3 (unused)
0x002e 1 (byte) Min Wis (unused)
0x002f 1 (byte) Usability 4 (unused)
0x0030 2 (word) Min Con (unused)
0x0032 2 (word) Min Cha (unused)
0x0034 4 (dword) Spell Level
0x0038 2 (word) Stack amount (unused)
0x003a 8 (resref) Spellbook icon (BAM). The engine replaces the last character of this filename with a C.
0x0042 2 (word) Lore to ID (unused)
0x0044 8 (resref) Ground icon (unused)
0x004c 4 (dword) Weight (unused)
0x0050 4 (dword) Spell Description - Unidentified (strref)
0x0054 4 (dword) Spell Description - Identified (strref) (usu. -1)
0x0058 8 (resref) Description icon (unused)
0x0060 4 (dword) Enchantment (unused)
0x0064 4 (dword) Extended Header offset
0x0068 2 (word) Extended Header count
0x006a 4 (dword) Feature Block Table offset
0x006e 2 (word) Casting Feature Block offset (these feature blocks may not use target type 2)
0x0070 2 (word) Casting Feature Block count


Extended headers represent the effects of a spell on the target. Multiple extended headers can be set in a spell, to allow the spell to use effects based on the level of the caster. Extended headers should be in the file in order of increasing level.

Offset Size (datatype) Description
0x0000 1 (char) Spell form
  • 1 - Standard
  • 2 - Projectile
0x0001 1 (char)
  • bit 2: 'Friendly' ability
0x0002 2 (word) Location
0x0004 8 (resref) Memorised icon (BAM). The engine replaces the last character of this filename with a B.
0x000c 1 (char) Target:
0 = Invalid (target cannot be selected)
1 = Creature
2 = Crash
3 = Character potrait (ignores range, uses projectile #1)
4 = Area
5 = Self
6 = Crash
7 = None (Self, ignores game pause)
0x000d 1 (char) Target Number
0x000e 2 (word) Range
0x0010 2 (word) Level Required
0x0012 2 (word) Casting Time
0x0014 2 (word) Times per day
0x0016 2 (word) Dice Sides (unused)
0x0018 2 (word) Dice Thrown (unused)
0x001a 2 (word) Enchanted (unused)
0x001c 2 (word) Damage Type (unused)
0x001e 2 (word) Count of feature blocks
0x0020 2 (word) Offset to feature blocks
0x0022 2 (word) Charges (unused)
0x0024 2 (word) Charge depletion behvaiour (unused)
0x0026 2 (word) Projectile (BG2:projectl.ids)


Any action carried out by a spell is done by feature blocks, each of which holds an effect number as well as targetting and timing information. The engine appears to roll a probability for each valid target type, rather than one probability per attack.

Offset Size (datatype) Description
0x0000 2 (word) Opcode Number
0x0002 1 (char) Target type
  • 0=None
  • 1=Self (pre-projectile)
  • 2=Pre-target
  • 3=Party
  • 4=Everyone (inc. party)
  • 5=Everyone (excl. party)
  • 6=Everyone matching specific value of caster (or Party if cast by party member)
  • 7=Everyone matching specific value of target
  • 8=Everyone (excl. caster)
  • 9=Self (post-projectile)
0x0003 1 (char) Power
0x0004 4 (dword) Parameter 1
0x0008 4 (dword) Parameter 2
0x000c 1 (char) Timing Mode
  • 0=Duration
  • 1=Permanent
  • 2=While equipped
  • 3=Delayed Duration
  • 4=Delayed
  • 5=Delayed?
  • 6=Duration?
  • 7=Permanent?
  • 8=Permanent?
  • 9=Permanent (after Death)
  • 10=Trigger
  • 4096=Absolute duration
0x000d 1 (char) Resistance

The default behaviour is that effects cannot be dispelled and ignore resistance.
  • bit 0: Can be dispelled, affected by resistance
  • bit 1: Ignores resistance (when used in combination with bit 0)

This can also be presented in the more traditional way:
  • 0=Nonmagical
  • 1=Can be dispelled/Affected by resistance
  • 2=Cannot be dispelled/Ignores resistance
  • 3=Can be dispelled/Ignores resistance
0x000e 4 (dword) Duration
0x0012 1 (char) Probability 1
0x0013 1 (char) Probability 2

Note: The BG1 engine treats probability as a single word, effects are applied in the range 0-probability.
Note: Other engines treat probability as two values, effects are applied in the range probability <= x <= probability.
Probability range is 0-99
0x0014 8 (resref) Resource
0x001c 4 (dword) Dice Thrown
0x0020 4 (dword) Dice Sides
0x0024 4 (dword) Saving Throw Type
  • bit 0: Spells
  • bit 1: Breathe
  • bit 2: Death
  • bit 3: Wands
  • bit 4: Polymorph
NB. If more than 1 saving throw type is specified, the target rolls against their best save.
0x0028 4 (dword) Saving Throw Bonus
0x002c 4 (dword) Unknown




Bit Byte 1 Byte 2 Byte 3 Byte 4
0 Unknown Unknown Not in combat Unknown
1 Unknown Unknown Unknown Unknown
2 Unknown Hostile/Breaks Invisibility Unknown Unknown
3 Unknown No LOS required Unknown Unknown
4 Unknown Allow spotting Unknown Unknown
5 Unknown Outdoors only Unknown Unknown
6 Unknown Ignore dead-magic and wild surge effect Unknown Unknown
7 Unknown Ignore wild surge effect (i.e. trigger/contingency) Unknown Unknown


bit 0: Exclude Chaotic priests. (BG2 & HoW)
bit 1: Exclude Evil priests. (BG2 & HoW)
bit 2: Exclude Good priests. (BG2 & HoW)
bit 3: Exclude GENeutral priests. (BG2 & HoW)
bit 4: Exclude Lawful priests. (BG2 & HoW)
bit 5: Exclude LCNeutral priests. (BG2 & HoW)
bit 6: Exclude Abjurers
bit 7: Exclude Conjurers
bit 8: Exclude Diviners
bit 9: Exclude Enchanters
bit 10: Exclude Illusionists
bit 11: Exclude Invokers
bit 12: Exclude Necromancers
bit 13: Exclude Transmuters
bit 14: Wild Magic (exclude Generalists) (BG2)
bit 15 - 29: Unused
bit 30: Exclude Cleric/Paladin
bit 31: Exclude Druid/Ranger

NB.Alignment and School exclusion bits cannot be combined.


BG1,BG2,IWD
00
    ...No animation
08
09 Necromancy
10 Alteration
11 Enchantment
12 Abjuration
13 Illusion
14 Conjuration
15 Invocation
16 Divination
17 White sparks
18 Black sparks
19 White sparks
20 White sparks
21 White sparks
22 White -> red sparks
23 White -> purple/red sparks
24 White -> red sparks
26 White sparks
32 White sparks
34 White sparks
56461 No animation
65535 No animation

NB. The 'spark' entries are related to sprklclr.2da (and probably opcode #41)

PST
35: Abjuration
36: Alteration
37: Conjuration
38: Enchantment
39: Divination
40: Illusion
41: Invocation
42: Necromancy
44: Special (Innate) Skill