ITM file format

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

General Description
This file format describes an "item". Items include weapons, armor, books, scrolls, rings and more. Items can have attached abilties, occuring either when a target creature it hit, or when the item is equipped. ITM files have a similar structure to SPL files.

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

Detailed Description
ITM 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.
NB. A creature must meet the minimum stat requirements to be able to converse with an item.

Overall structure:


Offset Size (datatype) Description
0x0000 4 (char array)

Signature (‘ITM ‘)

0x0004 4 (char array)

Version (‘V1 ‘)

0x0008 4 (strref)

Unidentified Name (strref)

0x000c 4 (strref)

Identified Name (strref)

0x0010 8 (resref)

BG1, BG2, BGEE:
Replacement item (ITM)

PSTEE:
Drop sound - played when the item is dropped in the inventory (WAV)

0x0018 4 (dword)

Flags

0x001c 2 (word)

Item type

0x001e 1*4 (byte)

Usability bitmask

0x0022 2 (char array)

Item animation

0x0024 2 (word)

Min Level

  • Treated as average of all active class levels, rounded up.
Info:
  • This field is basically the ITM counterpart of Level Required.
  • The only difference is that ITM abilities cannot have separate level requirements.
0x0026 2 (word)

Min Strength (unused in BG1)

0x0028 1 (byte)

Min Strength Bonus (unused in BG1)
Note: A strength of 19 or above is considered to have a Strength Bonus of 0, and would therefore not be able to equip any weapon with a Strength Bonus restriction.

0x0029 1 (byte)

Kit Usability 1

0x002a 1 (byte)

Min Intelligence (unused in BG1)

0x002b 1 (byte)

Kit Usability 2

0x002c 1 (byte)

Min Dexterity (unused in BG1)

0x002d 1 (byte)

Kit Usability 3

0x002e 1 (byte)

Min Wisdom (unused in BG1)

0x002f 1 (byte)

Kit Usability 4

0x0030 1 (byte)

Min Constitution (unused in BG1)

0x0031 1 (byte)

Weapon Proficiency

0x0032 2 (word)

Min Charisma

0x0034 4 (dword)

Price

0x0038 2 (word)

Stack amount

0x003a 8 (resref)

Inventory icon (BAM)

0x0042 2 (word)

Lore to ID

0x0044 8 (resref)

Ground icon (BAM)

0x004c 4 (dword)

Weight

0x0050 4 (strref)

Unidentified Description (strref)

0x0054 4 (strref)

Identified Description (strref)

0x0058 8 (resref)

Description icon (BAM)

0x0060 4 (dword)

Enchantment

0x0064 4 (dword)

Offset to extended headers

0x0068 2 (word)

Count of extended headers

0x006a 4 (dword)

Offset to feature blocks

0x006e 2 (word)

Index into equipping feature blocks

0x0070 2 (word)

Count of equipping feature blocks



Items can have several "abilities" that correspond to an action the item can do (e.g. melee attacks, projectile attacks, spell-casting etc.). Each of these abilities is specified through an extended header. Only the first three extended headers can have charges (extended headers further than this use the charges of the first extended header). Tooltips for item abilities are set through TOOLTIP.2DA.

NB. For items to be stackable, they must contain at least one extension header, even if it is empty.
NB. For an attack type of projectile, if the projectile type is set to 1,2 or 3, the weapon will use the attack speed of the ammunition.

Offset Size (datatype) Description
0x0000 1 (char)

Attack type

For Item abilities:

  • Do NOT use 0|None, will crash the game.
  • Only Magical abilities can be drained (along with opcode #243’s other restrictions).
  • Type 4 cannot be used except from scripts (icon won’t show up in actionbar).

For Weapon abilities:

  • Do NOT use 0|None, will crash the game.
  • Melee: Ignores the projectile field (always uses #1|None). Valid for Weapon Styles.
  • Ranged:
  • Magical: Identical to Melee, except that it can be drained.
  • Launcher:
    • In the mainhand slots:
      • Ability cannot actually be selected, nor is the item considered “equipped” by script triggers or opcode #183.
      • Equipped effects, stats and on-hit effects are added to the currently selected weapon ability IF that ability requires a launcher of this type.
    • In the off-hand slot:
      • Item cannot be equipped in off-hand, unless its itemtype can only be equipped in the off-hand slot, from ITEMTYPE.2DA.
      • Attack cycle will stop when this weapon would have attacked (must be re-initiated manually or by script).
        • The creature will stop attacking when the off-hand attack would have occurred. Similar to pressing the group “Stop” button (F3).
0x0001 1 (char)

ID Req.

  • bit 0 ⟶ ID Required
  • bit 1 ⟶ Non-ID Required
0x0002 1 (char)

Location

  • 0 ⟶ None
    • Ability will not be selectable through the UI (but still available to scripts and spell-casting opcodes).
  • 1 ⟶ Weapon
  • 2 ⟶ Spell
  • 3 ⟶ Equipment / Item
    • Ability can be selected from Quick-item slots, when equipped in one of those slots, or from the “Use Item (F8)” button if equipped elsewhere (except the Magical Weapon Slot).
  • 4 ⟶ Innate
  • 5+ ⟶ As 0.
Note: The first ability header of an item equipped in a weapon/off-hand slot will always be treated as a weapon abillty, even if it lacks the correct location to be selected as such, unless that item is a shield in the off-hand.
0x0003 1 (char)

Alternative dice sides

0x0004 8 (resref)

Use icon

0x000c 1 (char)

Target type

Note:
  • This field doesn’t matter when the ability is activated/cast by script, when cast by another opcode, or for weapon attacks.
  • Weapon attacks always use a more restricted form of Living actor, as they cannot target containers or doors unless they are locked.
0x000d 1 (char)

Target count

  • Only usable by Item abilities, and only with Ability Targets 1, 3, or 4.
  • Targeting reticle will display amount remaining while selecting targets.
  • Double-clicking a target/location will target it for the remaining amount.
  • Regardless of the number of targets, only a single “Charge” will be expended.
  • This feature cannot be utilized by scripts.
    • Scripts will treat this field as if it’s always 1.
0x000e 2 (word)

Range

0x0010 1 (byte)

Launcher required

In particular:

  • It ONLY checks items for BOW / XBOW / SLING and will always use that item’s first ability header – it doesn’t matter what that ability’s Type is (Melee/Ranged/Magical/Launcher).
    • This also means that you can’t make an Arrow that requires being shot out of a Sword.
  • ITEMCAT is offset 0x1C of the ITM file (which is also linked to ITEMTYPE.2DA).
  • Only the Mainhand, Ammo, and Magical Weapon slots can utilize launchers. The off-hand ignores this field, while the fist slot uses it (only to crash).
  • Weapons of any ITEMCAT can use this field, as long as it is equipped in one of the proper slots.
    • This also means that you can make a Sword that requires being shot out of a Bow.
  • Bows, Crossbows, and Slings with multiple abilities can even use themselves as their required launcher.
0x0011 1 (byte)

Alternative dice thrown

0x0012 1 (byte)

Speed Factor

0x0013 1 (byte)

Alternative damage bonus

0x0014 2 (word)

THAC0 bonus

A successful hit will always occur if any of the conditions below is true

  • This field is set to 32767.
  • The target creature(s) is STATE_HELPLESS.
  • The target is affected by Time Stop.
0x0016 1 (byte)

Dice sides

0x0017 1 (byte)

Primary Type (School)

0x0018 1 (byte)

Dice thrown

0x0019 1 (byte)

Secondary Type

0x001a 2 (word)

Damage bonus

0x001c 2 (word)

Damage type

  • 0 ⟶ None
    • Deals Crushing damage, uses base AC (ignores all 4 specific AC).
      • If #dice = 0: Deals damage as normal, just no dice amount.
      • If #dice > 0: Sets target’s HP to Damage Dealt, ignores crushing resistance.
  • 1 ⟶ Piercing
  • 2 ⟶ Crushing
  • 3 ⟶ Slashing
  • 4 ⟶ Missile
  • 5 ⟶ Fist
    • Deals non-lethal damage, but uses Crushing AC.
  • 6 ⟶ Piercing/Crushing (Better)
    • Uses whichever damage type and AC the creature has the worst damage resistance against (regardless if its AC is better or worse). Uses Piercing if equal resistance.
  • 7 ⟶ Piercing/Slashing (Better)
    • Uses whichever damage type and AC the creature has the worst damage resistance against (regardless if its AC is better or worse). Uses Piercing if equal resistance.
  • 8 ⟶ Crushing/Slashing (Worse)
    • Uses whichever damage type and AC the creature has the better damage resistance against (regardless if its AC is better or worse). Uses Slashing if equal resistance.
  • 9 ⟶ Blunt Missile
    • Same as None
      • Either it’s bugged or Blunt Missile has always been an IWD2-only feature.
      • It’s probably meant to deal crushing damage while using Missile AC.
  • 10+ ⟶ Same as None
Note:
0x001e 2 (word)

Count of feature blocks

0x0020 2 (word)

Index into feature blocks

0x0022 2 (word)

Max Charges

0x0024 2 (word)

Charge depletion behaviour

Note:
  • This field is irrelevant when the Max Charges field is zero. Item can be used infinitely.
  • If the item has a Max Stack Size > 1, this behavior will instead occur when the stack is depleted, not the charges (but still requires a non-zero Max Charges).
0x0026 4 (dword)

Flags

0x002a 2 (word)

Projectile Animation (projectl.ids/missile.ids)

0x002c 2*3 (word)

Melee animation

  • It should total 100, but not mandatory on EE games.
  • Not needed if Arrow/Bolt/Bullet is used.
  • It should work as such:
    Engine rolls 0 – 99.
    • overhand range = 0 to (overhand - 1)
    • backhand range = overhand to (overhand + backhand - 1)
    • thrust range = (overhand + backhand) to (overhand + backhand + thrust - 1)

    A couple of examples:

    • With values 34, 33, and 33:
      • 0 – 33: Overhand
      • 34 – 66: Backhand
      • 67 – 99: Thrust
    • With values 100, 100, 100:
      • 0 – 99: Overhand
      • 100 – 199: Backhand (never used)
      • 200 – 299: Thrust (never used)
  • Along with Is arrow?/Is bolt?/Is bullet?, it is only used for attack animations. If all are zero, no animation will be used for attacking. Activated Item abilities can leave them all 0, as they are not used.
0x0032 2 (word)

Arrow qualifier / Is arrow?

  • 0 ⟶ No
  • 1 ⟶ Yes

It controls which firing animation the ability will use. It needs to be set on any launcher and/or ammo, but the launcher will override the ammo.

0x0034 2 (word)

Bolt qualifier / Is bolt?

  • 0 ⟶ No
  • 1 ⟶ Yes

It controls which firing animation the ability will use. It needs to be set on any launcher and/or ammo, but the launcher will override the ammo.

0x0036 2 (word)

Bullet qualifier / Is bullet?

  • 0 ⟶ No
  • 1 ⟶ Yes

It controls which firing animation the ability will use. It needs to be set on any launcher and/or ammo, but the launcher will override the ammo.



Any action carried out by an item 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

Info: See here for further details.
0x0003 1 (char)

Power

0x0004 4 (dword)

Parameter 1

0x0008 4 (dword)

Parameter 2

0x000c 1 (char)

Timing mode

Info: See here for further details.
0x000d 1 (char)

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

0x0012 1 (char)

Probability 1

0x0013 1 (char)

Probability 2

Info: See here for further details.
0x0014 8 (resref)

Resource

0x001c 4 (dword)

Dice Thrown / Maximum Level

Info: See here for further details.
0x0020 4 (dword)

Dice Sides / Minimum Level

Info: See here for further details.
0x0024 4 (dword)

Saving throw type

Info: See here for further details.
0x0028 4 (dword)

Saving Throw Bonus

0x002c 4 (dword)

TobEx: Stacking ID. Checked when bit 25 of the Saving Throw Type is set.

If two effects of the same opcode are applied, both have Limit Effect Stacking bit set, and both have the same stacking ID, then the latter applied effect is suspended in application until the former effect expires. Regardless of whether it is applied, the latter effect will expire at the same time that it would expire if it was applied. In other words, the total duration of some non-stacking effect opcode is not extended because more than one copy of the effect was applied.

Stacking IDs are unique to the opcode being applied. To maintain uniqueness of stacking IDs between different mods, one recommendation is to use the higher word of Special as the modder’s Infinity Engine Community Prefix, then use the lower word as an identifying ID. For example, 0x41360001 (‘A6’ 0x0001).




Header Flags

Bit Byte 1 Byte 2 Byte 3 Byte 4
0 Unsellable (critical item)
  • In BG1 and IWD, this flag does not affect whether the item can be sold or disintegrated. See BIT11 instead.
  • On EE games, Stores can buy critical items if they are flagged as Can buy Critical, provided they can buy its itemtype.
  • Will also cause the item to be moved into Player1's Inventory if the character who has it leaves the party on their own.
Silver
  • Determines how the weapon interacts with opcode #120.
Unused Undispellable
1 Two-handed
  • Forces Two-handed weapon style and attack animation.
  • Disables off-hand: attacks and equipped effects.
Cold iron
  • Determines how the weapon interacts with opcode #120.
Unused Toggle critical hit aversion (BGEE, TobEx)
  • Keep in mind that if you set this bit to 1 for an ITM whose Item type is Headgear, then you'll toggle off the Critical hit aversion.
2 Movable / Droppable Stolen (unsellable) / Off-handed
  • Set offhand animations for 0x5###-0x6### animId series (excluding 0x64##) when weapon placed in offhand.
  • Forces Dual-Wield animation (overrides BIT1).
Unused Unused
3 Displayable
  • Item will show up on the ground (when dropped). Setting the Ground Icon to "" (empty) still uses a default icon, this gets around that. It can still be clicked on and picked up.
  • The default icon if the Ground Icon is "" (empty) is a small bag "GSACK01.BAM", the icon without the Displayable flag is a 1x1 invisible pixel.
Conversable / unsellable
  • In BG1 and IWD, this flag prevents the item from being sold and is not about dialogs. This includes placement into a bag of holding.
  • Dialog can be initiated with the weapon through right-clicking in the Inventory.
  • Item needs to be listed in ITEMDIAL.2DA as: (Item ResRef) (Label StrRef) (Dialog ResRef).
    • Label StrRef is the label that will be on the button when right-clicking.
Unused Unused
4 Cursed
  • Determines how the item interacts with opcode #26.
  • The item cannot be unequipped.
  • Cursed weapons override the Magical Weapon slot.
Fake two-handed (BGEE)
  • Forces Two-handed animation.
Unused Unused
5 Cannot scribe to spellbook (scrolls)
  • Whether a scroll can be "Copy Note" to journal or "Write Magic" to spell book is determined by its ability headers. Setting this bit doesn't alter it either way.
  • It doesn't prevent a "clone" from getting a duplicate (opcode #236*p2=2).
  • It doesn't prevent the CopyGroundPilesTo() action from moving them.
  • In original BG1, it was set on every item except for the Identify Scroll.
  • In BGEE/SoD, only a few (16) random items added by Beamdog don't have it set, as well as the Identify and Chromatic Orb scrolls.
Forbid off-hand weapon (BGEE)
  • Disables Two-Weapon Style.
  • Does not disable off-hand equipped effects.
  • In Magical Weapon Slot: Disables off-hand (Attacks only).
Unused Unused
6 Magical
  • Determines how the weapon interacts with opcode #120.
  • Has no relation to the Enchantment field. Both function independently.
Usable in inventory (PSTEE) Unused Unused
7 Left-handed
  • Disables off-hand: attacks and equipped effects.
  • Disables Two-Weapon Style (Inventory display is incorrect though).
Adamantine (BGEE) Unused Unused


These codes are used in store files to indicate which types of items they will buy. They are also used to determine which inventory slots the item is allowed to go into on the inventory screen and the sound the item makes when moved in the inventory.

Code Item type
0x00 Books/misc
0x01 Amulets and necklaces
0x02 Armor
0x03 Belts and girdles
0x04 Boots
0x05 Arrows
0x06 Bracers and gauntlets
0x07 Headgear (Helms, hats, and other head-wear)
0x08 Keys (not in Icewind Dale?)
0x09 Potions
0x0a Rings
0x0b Scrolls
0x0c Shields (not in IWD)
0x0d Food
0x0e Bullets (for a sling)
0x0f Bows
0x10 Daggers
0x11 Maces (in BG, this includes clubs)
0x12 Slings
0x13 Small swords
0x14 Large swords
0x15 Hammers
0x16 Morning stars
0x17 Flails
0x18 Darts
0x19 Axes (specifically, 1-handed axes -- halberds and 2-handed polearms not included)
0x1a Quarterstaff
0x1b Crossbow
0x1c Hand-to-hand weapons (fist, fist irons, punch daggers, etc)
0x1d Spears
0x1e Halberds (2-handed polearms)
0x1f Crossbow bolts
0x20 Cloaks and robes
0x21 Gold pieces (not an inventory item, but can appear as "monster dropped" treasure)
0x22 Gems
0x23 Wands
0x24 Containers/eye/broken armor
0x25 Books/Broken shields/bracelets
0x26 Familiars/Broken swords/earrings
0x27 Tattoos (PST)
0x28 Lenses (PST)
0x29 Bucklers/teeth
0x2a Candles
0x2b
Unknown
0x2c Clubs (IWD)
0x2d
Unknown
0x2e
Unknown
0x2f Large Shields (IWD)
0x30
Unknown
0x31 Medium Shields (IWD)
0x32 Notes
0x33
Unknown
0x34
Unknown
0x35 Small Shields (IWD)
0x36
Unknown
0x37 Telescopes (IWD)
0x38 Drinks (IWD)
0x39 Great Swords (IWD)
0x3a Container
0x3b Fur/pelt
0x3c Leather Armor
0x3d Studded Leather Armor
0x3e Chain Mail
0x3f Splint Mail
0x40 Half Plate
0x41 Full Plate
0x42 Hide Armor
0x43 Robe
0x44
Unknown
0x45 Bastard Sword
0x46 Scarf
0x47 Food (IWD2)
0x48 Hat
0x49 Gauntlet

Header Usability

Bit Byte 1 Byte 2 Byte 3 Byte 4
0 Chaotic... Cleric/Mage Fighter/Mage/Thief Dwarf
1 ...Evil Cleric/Thief Fighter/Thief Half-Elf
2 ...Good Cleric/Ranger Mage Halfling
3 ...Neutral Fighter Mage/Thief Human
4 Lawful... Fighter/Druid Paladin Gnome
5 Neutral... Fighter/Mage Ranger Monk
6 Bard Fighter/Cleric Thief Druid
7 Cleric Fighter/Mage/Cleric Elf Half-Orc

Note: PSTEE uses ITM V1.1 usability flags.

Header Animation

Value(ASCII) Value(Hex) Description
" " 2020h <none>
"2A" 3241h Leather Armor
"3A" 3341h Chainmail
"4A" 3441h Plate Mail
"2W" 3257h Robe
"3W" 3357h Robe
"4W" 3457h Robe
"AX" 4158h Axe
"BW" 4257h Bow
"CB" 4342h Crossbow
"CL" 434Ch Club
"D1" 4431h Buckler
"D2" 4432h Shield (Small)
"D3" 4433h Shield (Medium)
"D4" 4434h Shield (Large)
"DD" 4444h Dagger
"FL" 464Ch Flail
"FS" 4653h Flame Sword
"H0" 4830h Small Vertical Horns
"H1" 4831h Large Horizontal Horns
"H2" 4832h Feather Wings
"H3" 4833h Top Plume
"H4" 4834h Dragon Wings
"H5" 4835h Feather Sideburns
"H6" 4836h Large Curved Horns (incorrect paperdoll image)
"HB" 4842h Halberd
"MC" 4D43h Mace
"MS" 4D53h Morning Star
"QS" 5153h Quarter Staff (Metal)
"S1" 5331h Sword 1-Handed
"S2" 5332h Sword 2-Handed
"SL" 534Ch Sling
"SP" 5350h Spear
"SS" 5353h Short Sword
"WH" 5748h War Hammer
"S3" 5333h Katana #
"SC" 5343h Scimitar #

Header Kit Usability

Bit Byte 1 Byte 2 Byte 3 Byte 4
0 Cleric of Talos Stalker Ranger Diviner Beserker Fighter
1 Cleric of Helm Beastmaster Ranger Enchanter Wizardslayer Fighter
2 Cleric of Lathlander Assassin Thief Illusionist Kensai Fighter
3 Totemic Druid Bounty Hunter Thief Invoker Cavalier Paladin
4 Shapeshifter Druid Swashbuckler Thief Necromancer Inquisiter Paladin
5 Avenger Druid Blade Bard Transmuter Undead Hunter Paladin
6 Barbarian Jester Bard All (no kit) Abjurer
7 Wildmage Skald Bard Ferlain Conjurer

Header Proficiency

Value (hex) Description
00h None
59h Bastard Sword
5Ah Long Sword
5Bh Short Sword
5Ch Axe
5Dh Two-Handed Sword
5Eh Katana
5Fh Scimitar/Wakizashi/Ninja-To
60h Dagger
61h War Hammer
62h Spear
63h Halberd
64h Flail/Morningstar
65h Mace
66h Quarterstaff
67h Crossbow
68h Long Bow
69h Short Bow
6Ah Darts
6Bh Sling
6Ch Blackjack
6Dh Gun
6Eh Martial Arts
6Fh Two-Handed Weapon Skill
70h Sword and Shield Skill
71h Single Weapon Skill
72h Two Weapon skill
73h Club
74h Extra Proficiency 2
75h Extra Proficiency 3
76h Extra Proficiency 4
77h Extra Proficiency 5
78h Extra Proficiency 6
79h Extra Proficiency 7
7Ah Extra Proficiency 8
7Bh Extra Proficiency 9
7Ch Extra Proficiency 10
7Dh Extra Proficiency 11
7Eh Extra Proficiency 12
7Fh Extra Proficiency 13
80h Extra Proficiency 14
81h Extra Proficiency 15
82h Extra Proficiency 16
83h Extra Proficiency 17
84h Extra Proficiency 18
85h Extra Proficiency 19
86h Extra Proficiency 20

Extended Header MeleeAnimation

Value Word 1 Value Word 2 Value Word 3 Data
00h 14h 50h Dagger
0Ah 19h 41h Short Sword
32h 32h 00h Long Sword, Bastard Sword, Scimitar, Battle Axe, Warhammer, Club, Mace, Flail, Morning Star
3Ch 28h 00h Two-Handed Sword
00h 23h 41h Halberd
00h 00h 64h Spear
0Ah 46h 14h Staff
00h 00h 00h Any Missile Weapon (Bow, Arrow, CrossBow, Bolt, Sling, Bullet, Throwing Axe, Dart, Throwing Dagger, etc.)
22h 21h 21h Any Non-Weapon Item (Amulets, Rings, Wands, etc.)

Extension Header Flags

Bit Byte 1 Byte 2 Byte 3 Byte 4
0 Add strength bonus Unknown Unknown Unknown
1 Breakable Breaks Sanctuary / Invisibility (EE games) Unknown ToBEx: Toggle backstab
2 Damage strength bonus (BGEE split bit 0) Hostile Unknown EE/ToBEx: Cannot target invisible
3 THAC0 strength bonus (BGEE split bit 0) Recharge after resting Unknown Unknown
4 Unknown Unknown Unknown Unknown
5 Unknown Unknown Unknown Unknown
6 Unknown Unknown Unknown Unknown
7 Unknown Unknown Unknown Unknown