A character can gain immunity against certain effects, including poison, disease, damage, sneak attacks, critical hits, spells, and more. Some immunities only grant partial protection where others are complete.
A damage immunity effect protects against one of the 12 damage types: Slashing, piercing, bludgeoning, fire, cold, electrical, acid, sonic, divine, negative energy, positive energy, or magical damage. Damage immunities range from 5% to 100%, indicating the amount of damage that is prevented. For example, fire elementals have 100% fire immunity, so they take no fire damage.
Decreased damage immunity is called damage vulnerability. Damage vulnerability increases the damage taken by the percentage specified. For example, since fire elementals have 50% cold vulnerability, Cone of cold will deal 50% more damage to them.
There are in game items that will give 100% immunity to one elemental type but damage vulnerability to another elemental type. For example, an item with give 100% fire immunity with 50% cold vulnerability.
When not the direct target of a spell, immunity against the spell will not counter it, but only protect the immune character from the effects. So being immune to the Fireball spell will not prevent a fireball's explosion from harming anyone else. Being immune to Web will not prevent a web from appearing nearby, but the immune character will not be entangled or slowed down by it.
Certain effects implicitly give immunity. For example, items with the Freedom of movement property grants immunity to Web.
There is a severe bug involving spell immunity checks: The check is always performed based on the last spell cast by a particular spellcaster. So if a spellcaster casts Cloudkill on a target protected by Shadow Shield (spell school immunity: Necromancy), the target will ignore the spell, but if the same spellcaster casts Incediary Cloud afterwards on the same target and the target is not immune to the Evocation school or lvl 8 spells, the target will lose its immunity to Cloudkill, because the hard-coded resistance check against Cloudkill erroneously checks the target's immunity to Incediary Cloud instead of Cloudkill from now on.
Same is also true if the target is protected by Globe of Invulnerability and a spellcaster casts Spike Growth followed by Sunbeam on the target - initially, the target will ignore Spike Growth (level 3 spell), but after Sunbeam is cast, immunity for Spike Growth will be ignored, since the engine runs immunity checks between Globe of Invulnerability and Sunbeam from now on for all AOE spells previously cast by this particular spellcaster and obviously returns FALSE (no immunity), since Sunbeam's spell level is too high.
Same is also true if immunity is granted by equipped items, for example, if a target wears Imaedril's Respite ring (Spell school immunity: Transmutation), it will ignore Spike Growth (same spell school), but if the same spellcaster casts a spell from a different school (Sunbeam or whatever) on the same target, the target will lose its immunity to transmutation spells cast by this spellcaster, because all immunity checks including checks against the initial Spike Growth are now performed between target<->last spell cast by the spellcaster and since the last spell is from a different school, immunity check returns FALSE. This will continue until the spellcaster casts another spell from the Transmutation school, at which point Transmutation immunity for the initial Spike Growth AOE will kick in again.
Ability and level drain always counts as a single immunity, and can not be separated. Immunity to Instant death effects is the same as immunity to Death magic. Immunity to mind-affecting spells makes a character immune to fear, stun, dominate, charm, daze, and sleep effects, even if not caused by a spell.
Spell descriptors may serve as reminders to what effects are caused by a spell, but the spell itself is not countered by such immunity. For example, a creature immune to mind-affecting spells may still be blinded by Color spray, but not stunned or sent to sleep.
Undead and constructs are immune to all of the negative effects above, and elementals are immune to them all except for death magic. All elves are immune to sleep. Most Vermin (Spiders and the like) are immune to mind effects. Red dragon disciples become immune to paralysis and sleep at 10th level, and monks gain immunity to disease and poison at 5th and 11th level, respectively.