Chain Contingency

Chain Contingency stores 3 spells of 8th level or lower, to be released later under conditions specified by the wizard.
==Description==
==Gameplay ==
This spell is applied to the caster only.
When the spell is finished casting a menu selection screen displays - the Menu is titled Chain Contingency, and an instruction reads, "Add spells to your contingency".
The player must make sections on the menu to "build" the contingency.
First select a condition that will trigger the chain contingency and ensure the choice is highlighted in red.
Second, select a target, to which the spells placed in the contingency will be directed at, and ensure the choice is highlighted in red..
Third, select up to three spells that are released by the contingency, choose from a spell book and level, and ensure the choice is highlighted in red, and the spell icons show in the three empty field boxes.
All spell levels from any applicable spellbook can be selected as long as they are currently memorized and are below Level 9.
Once this has been finished, select the "DONE" button, the contingency is saved and ready to be deployed when the conditions trigger the contingency event - this occurs automatically with no need for the caster to do anything. The player character will show an icon (No. 75) titled "Contingency Active".
===Acceptable contingency conditions===
* Wizard is hit (but not necessarily damaged)
* Wizard sees enemy
* Wizard's Hit Points are at 50%
* Wizard's Hit Points are at 25%
* Wizard's Hit Points are at 10%
* Wizard is helpless (i.e., stunned, held, paralyzed, asleep, webbed etc.)
* Wizard has been poisoned
===Acceptable spell targets===
* Self
* Last hit by
* Nearest enemy
===Cancelling a Contingency===
Contingencies can also be cancelled (i.e. harmlessly dissipated without casting the stored spells) by pressing the "Contingency" button on the wizard's spellbook, then pressing the small "hand" button next to the contingency.
===Some example Chain Contingency combinations===
Spells 	Target 	Condition 	Description/Uses
Abi-Dalzim's Horrid Wilting x 3 	Nearest Enemy	See Enemy/Hit	Arguably the most commonly used Chain Contingency combination. Open combat with a potential 60d8 party-friendly magic damage in a wide area, often ending a fight before it begins. 
Using condition "Hit" gives you some time before execution to reduce the enemy's defenses, e.g. launching a Spell Trigger (Lower Resistance x 3) to reduce an enemy's Magic Resistance.
Simulacrum, Mordenkainen's Sword x 2	Self 	See Enemy 	Start combat with an additional caster, as well as two (nearly) invulnerable "tanks".
Pierce Shield x 3 	Nearest Enemy	See Enemy 	Reduce the Magic Resistance of a Lower Resistance-immune boss while you are casting Improved Alacrity, reducing their MR before you unleash the rest of your spellbook (e.g. bottom of Watcher's Keep, Pocket Plane Challenge 5)
Cleric / Mage multiclass can also put Cleric spells into the Chain Contingency.
===Limitations ===
#There is often, but not always, a delay between when the condition is met and when the contingency actually fires. This delay can be anywhere from launching instantly to a full round delay, depending on how much processor script efficiency is used.
# When using offensive spells in a contingency, if an opponent has high Magic resistance or damage resistance buffs (e.g. Protection From Magic Energy) and the condition is "See Enemy", the contingency may fire before you are able to remove the opponent's protections and make it vulnerable to your magical attack.
# A wizard can only have one Chain Contingency at the same time. Trying to activate a second one will fail. However, one Chain Contingency and one "normal" Contingency can be active at once.
=== Resting and permanent duration ===
Since the duration is unlimited until triggered, you can memorize the Chain Contingency spell and the spells you want to put in it, cast it, then replace them in your memorized spells and rest. That way, you still have Chain Contingency active after rest, but also have more spell slots for the next encounter. Also this way you gain back the three spells which you put into Chain Contingency.
=== Time stop ===
Contingency and Chain Contingency will trigger even while you're immobile due to an enemy's Time Stop, but only spells that target yourself only or otherwise don't have projectiles actually take effect during the Time Stop, since all ranged spell projectiles are paused. This means that self-only spells, spells that work on melee touch range (e.g. Vampiric Touch), and ranged spells that take effect without projectiles (e.g. the Power Word spells like Power Word, Silence), do work. Moreover, keep in mind that, although immobilized, the Mage is not considered "helpless", so another trigger condition must be used.
* Example 1: With Wizard is hit -> Self -> Stoneskin, you can get your protections back up if an enemy attacks you during Time Stop
* Example 2: For Cleric / Mage, Hit Points at 25% -> Self -> Heal means you won't die (if it's triggered quickly enough, see the "trigger delays" section for details)
* Example 3: Wizard is hit -> Last hit by -> Power Word, Stun or Vampiric Touch means you can even retaliate against a melee attacker during Time Stop.
* What would not work during Time Stop is any Chain Contingency that targets ranged spell projectiles, e.g. See enemy -> Nearest enemy -> Horrid Wilting will trigger, but the spell will only hit once the time stop ends.
=== Dead magic zones ===
Much like Contingency, Chain Contingency can trigger successfully even in dead magic zones (e.g. the room in Watcher's Keep Teleport Maze where three Cornugons are fighting a Balor and the player can acquire the Purifier). However, it must be prepared before entering the area.
===Trigger delays===
Probably due to programming reasons, the different conditions offer different delays in terms of how quickly the contingency actually triggers once the condition is met. For example, the "see enemy" condition almost always has a very noticeable delay between the player actually spotting an enemy and the spells being released, whereas the "hit" condition always triggers the release of the spells immediately.
After extensive testing, this seems to be the amount of trigger delay that each condition offers (keep in mind, though, that the more trigger delay a condition has, the more variable said delay also becomes):
*"Wizard is hit" has no delay between the condition happening and the contingency triggering. It's the only condition that consistently triggers with no delay at all.
*"Wizard has been poisoned" tends to have the shortest trigger delay out of all conditions that have a delay.
*"Wizard is helpless" tends to have a medium amount of delay.
*"Wizard sees enemy" and "Wizard's Hit Points are at X%" often have a very noticeable, sometimes very long delay, but keep in mind that the amount of delay varies a lot (so, on rare occasions, it can be relatively short). The often-long delay is a particularly bad thing for the hit point-based condition, as that means something that might seem like a good idea at first (eg Heal cast when the wizard's hit points are at 10%) will very often prove fatal (the delay is too long, and the Mage simply dies before the contingency triggers).
===About the "wizard is helpless" condition===
Although the "wizard is helpless" condition might initially seem entirely devoted to defense (e.g. a mage is held and casts dispel magic on themselves to be cured or invisibility to avoid damage), the spell Otiluke's Resilient Sphere in the Enhanced Editions made it possible for this condition to be used offensively in a consistent manner.
In the Enhanced Editions, Otiluke's Resilient Sphere doesn't require a save when cast on friendly targets, so a Mage is able to use it on themselves to be protected from almost any attack in the game. However, since the spell technically "holds" the Mage, they're considered "helpless" for the purpose of contingencies (despite being very well protected), allowing contingencies to be triggered in a more controlled manner by the player compared to other conditions, while simultaneously providing the Mage immunity to almost anything in the game.
Moreover, another noteworthy "positive" spell (since Otiluke's is, essentially, a protection spell when cast on a party member) that also triggers the "wizard is helpless" condition is Project Image. So, despite what the condition's name might suggest, it's not just "negative" statuses (e.g. Mage is stunned, paralyzed, webbed and so on) that trigger it.
Finally, do note that a character negatively affected by Time Stop/Shadowstep is not considered "helpless" for the purpose of this trigger condition; even if, logically-speaking, they are so.
===What's considered a "hit" for the "wizard is hit" condition?===
This can be very counter-intuitive, since some attacks that do no damage are considered a hit and others aren't. And some attacks can be considered hits or not depending on the circumstances. So here are various examples of attacks that are considered hits and attacks that aren't:
*A spell blocked by Magic resistance: not a hit.
*A Fireball that causes damage: hit.
*A Fireball that causes no damage due to 100% fire resistance: hit.
*A Fireball blocked by Minor Globe of Invulnerability: not a hit.
*A Chromatic Orb blocked by Minor Spell Deflection: not a hit.
*A melee or ranged attack blocked by Protection From Magical Weapons: hit.
*A melee or ranged attack blocked by Stoneskin: hit.
*A melee or ranged attack blocked by Mirror Image: hit.
*A dragon's Wing Buffet blocked by Otiluke's Resilient Sphere: hit.
*A Fireball blocked by Otiluke's Resilient Sphere: not a hit.
*A Mage casting Power Word, Sleep on themselves: not a hit.
*Someone else casting Power Word, Sleep on the Mage: hit.
*A Stinking Cloud putting the Mage to sleep: not a hit.
*A Web spell webbing the Mage: not a hit.
*A Wail of the Banshee that instantly kills the Mage: hit and will still trigger the contingency after death.
===What's considered "being poisoned" for the "wizard has been poisoned" condition?===
Actual damage-over-time "poison effects" coded as such, like the one caused by Poison (spell) or the ones inflicted by various spiders, but also "bleeding", like the effect caused by Cornugons (cause they're coded as "poison effects").
On the other hand, merely suffering poison damage (eg from Cloudkill), does not count as "being poisoned".
==Where to obtain its scroll==
===Shadows of Amn===
*Ribald Barterman in his special items store
===Throne of Bhaal===
*Arcana Archives 
==Bugs== 
*Several spells that require the same type of saving throw roll with the same modifier within the same short time frame will share a single roll instead of each having their own. This might be intended rather than a bug. Either way, sharing the same roll, they will fail or succeed in sync. If the player is trying to inflict a status effect like Confusion for instance, three of the same spells placed into a Chain Contingency are therefore no more likely to succeed than one.
==Community insights==
There are some opinionated insights available at Chain Contingency/Gameplay, that read as a discussion and are best left as an exercise for the reader to obtain useful bits of information from it.
==See also == 
*Minor Sequencer
*Contingency
*Spell Sequencer
*Spell Trigger
===Gallery ===
OG CC 1.png|Gorion's Ward casts the Chain Contingency spell, and a menu screen displays to construct the parameters of the contingency.
OG CC 2.png|The Ward selects Spell Turning, Protection From Magical Weapons, and SI Abjuration, which will be applied to himself when his hit points are at 50%.
OG CC 3.png|The DONE button confirms the choices, and the spell animation finishes up. A "Contingency Active" icon is on his portrait. All finished!
==Mod content==
Regarding this type of spell, the Sword Coast Stratagems mod will do the following:
Allow players to use the individual versions of Spell Immunity in triggers
Spell Immunity is really eight sub-spells. This component allows a subspell to be placed into a Contingency or Spell Trigger.
On Enhanced-Edition installs, this is done crudely, by introducing scrolls of the eight different versions of Spell Immunity. ToBex allows it to be done more smoothly on original-game installs.
Make spell sequencers, spell triggers, and contingencies learnable by all mages
In the unmodded game, spell sequencers, contingencies etc. are in the Evocation school, making them unavailable to Enchanters; this is a serious weakness for the class. This component moves them to be in both the Conjuration and Evocation schools (like Wish), so that all mages may use them. The affected spells are Minor Sequencer, Spell Sequencer, Spell Trigger, Contingency, and Chain Contingency. This will not take effect if you have Spell Revisions installed (as SR takes care of this already by making them "Universal" School).
With Spell Revisions installed, this is the equivalent spell description:
Chain Contingency
Level: 9
School: Universal
Range: Personal
Duration: Special
Casting Time: 1 round
Area of Effect: Special
Saving Throw: None
Chain Contingency channels some of the magical energy of the mage and releases it only under certain circumstances. Basically, the mage chooses three spells, which will be released under certain conditions such as being hit by an enemy. When this condition occurs all three spells are cast immediately. Spells of up to 8th level may be used in the contingency.