The limitations are determined by your GM
The entire text referring to the circumstance in the Contingency spell is
it takes Effect when a certain circumstance occurs. You describe that circumstance when you cast the two Spells. For example, a contingency cast with Water Breathing might stipulate that Water Breathing comes into Effect when you are engulfed in water or a similar liquid.
The contingent spell takes Effect immediately after the circumstance is met for the first time
There are few limitations placed by the text itself, leaving the interpretation to the GM.
When a player wants to learn Contingency, it is helpful to define how the circumstances will be limited in advance so they can make a conscious choice to take the spell or not, as the power of the spell can vary very widely based on these limitations.
user-024673's answer supports a very permissive perspective. I want to make the case for a more restrictive perspective to help the GM consider both views and arguments for both. In Summary
- Can you chain multiple conditions? Likely no.
- Does it have to be about the caster? Likely yes.
- Does it have to be close-by? Possibly no.
- Do you need to be conscious about it? Consensus no.
- Can it be about the near future? Likely no.
- Can it detect like divination spells? Likely no.
- Can it detect beyond divination spells' capabilities? Very likely no.
- Can it reference game mechanics? Likely no.
Here are the sub-questions of the very general overall question that are worth to break down in more detail:
Can the caster chain multiple conditions?
For example, "When someone targets me with an attack in melee OR when I rapidly blink my eyes three times.".
These are two common uses of contingency,
- as an emergency response to something that happened
- as a way to store an extra spell that can then be triggerd at will by the caster (maybe using a reaction if not on the casters turn)
The wording of "a certain circumstance" seems to express clear intention of a single circumstance. The example however provides the use of alternatives
engulfed in water or a similar liquid
(emphasis added). I think the alternatives here are still closely related, and would argue against chaining unrelated conditions by OR. But there is room for GM interpretation.
Does the circumstance have to relate to the caster?
comes into Effect when you are engulfed
(emphasis added), the need of a material component in the form of the caster, the requirement that the component must be on the caster at all times all seem to suggest this.
If you make this a requirement, then you also need to clarify what is counts as relating to the caster.
The mere fact that a circumstance is made trigger condition and thus is of interest to the caster would not be sufficiently strong connection in my view. It would need to be something done by the caster, experienced by the caster, happening in the caster's close vicinity, directly affecting the caster, or at least affecting the caster's immediate family, close friends or property. The use of Contingency as a long-distance alarm for your tower could qualify.
I would rule the conditions have to relate closely to the caster, but again, this is up to the GM.
Does the circumstance have to be nearby?
The circumstance in the example cited is nearby, the water directly engulfing the caster.
Contingency has been discussed as a way to set up a long-distance alarm for your tower by sending yourself a message (if you allow cantrips to be stored), or some other perceivable, benefical spell like mirror image (if you don't).
If you restrict it to nearby effects, you will have to come up with a defintion of what is nearby. Is it a certain distance from the caster? The same room, if indoors? Line of sight? As the caster may not even have to be conscious for the circumstance to take effect, these seem arbitrary calls.
I personally would not restrict the circumstance by distance. Our GM does limiting it vaguely to the "immediate area". Again, this is entirely the GM's call.
Does the caster need to be conscious of the circumstance?
Using Revivify in a Contingency, to save you from death appears to be a widely accepted use of Contingency, and when you are dead you clearly are not concious of anything any more.
I would say the caster does not need to be conscious of the circumstance.
Can the circumstance refer to something in the near future?
For example, can you state "When I am about to be hit by an attack", or "When a dragon is going to breathe on me", or even "when I am about to take damage"?
The contingent spell takes effect immediately after the circumstance is met for the first time
(emphasis added), you cannot by RAW use Contingency to cast Resilient Sphere to block an attack, or to cast Dimension Door to evade a Meteor Swarm, as it only takes effect after those happened. RAW there is no time between the casting of the spell or the making of an attack, and its effect.
You can circumvent this for attacks by setting a Shield spell being cast by the caster as a trigger, as the rules for reactions allow Shield to interrupt the trigger. This seems to me quite technical and convoluted.
If the circumstance can be described as something that is about to happen in the near future, then the thing itself will not have happened yet, and this would provide a general way to avoid the restiction.
In the example the water has already engulfed the caster. The absence of any language talking about pre-empting circumstances and the text talking explicitly about the effect occuring after the circumstance occured both signal that the intent is not preemption.
In my view, it should not be possible to refer to near-future circumstances. Again, this is the DMs call.
What can the circumstance detect?
Glyph of Warding can detect alignment. Mordenkainens Faithful Hound can detect invisible and ethereal creatures, Detect Magic can detect magic, Zone of Truth can detect lies (with a saving throw), True Seeing can see a shapechanged doppleganger for what it is.
- "when I meet someone of chaotic evil alignment",
- "when I am touching a magic item with my left hand's little finger", - "when someone etheral is within 30 feet of me",
- "when someone invisible is within 60 feet of me",
- "when a doppelganger talks to me",
- "when someone is scrying on me",
- "when someone is lying to me after I say 'Tell the truth now!'",
- "when a trap or secret door is in the room",
- "when a legendary treasure or magic item is within 30 feet of me",
and so on, would allow you to mimic the detection properties of a host of other spells, without having to know those spells.
Granted, many of those are much lower level, and using the single Contingency on them seems like an expensive way to duplicate them. But you can formulate circumstances affording things like lie detection without saving throw or alignment detection that are difficult to achieve otherwise.
The example seems to indicate that divination is not the intent of the spell.
In my view, allowing such uses would turn Contingency into an overtly powerful divination spell, that, in not being an actual divination spell, would also circumvent anti-divination measures. I would possibly allow it to mimic low level divination spells, but not spells of level 6 or higher or other kinds of detection.
Can I use an unknowable circumstance?
For example "when I meet someone planning to assassinate me".
Or, if you allow the circumstance to be about people other than the caster, a court wizard could have "when I meet someone planning to assassinate or betray the king" (like in the question). The creature in question could be protected by mind blank and other anti-divination magics, as Contingency is not even a diviniation spell.
Or, if you allow circumstances not about the caster, you even could formulate circumstances that ascertain fundametal truths about the game world, like "if the lich Vecna really ascended to godhood", or, "if the Aboleths are the oldest species in existence".
Like in the previous case, allowing this would turn Contingency into an uber-powerful divination spell that could determine things that even higher level, specialized divination spells cannot, and that would penetrate any anti-divination measures.
Based on the logic of comparing to other spells, and the guidance in the DMG on spell design (p. 283):
If a spell is so good that a caster would want to use it all the time, it might be too powerful for its level.
I believe, that is surely not the intended use of the spell, and would not allow this. But the individual DM may decide otherwise.
Can the circumstance refer to game mechanics?
For example, can you trigger a cure wounds upcast to level 5 "when I am down to under 5 hit points"?
The player characters do not know anything about game mechanics. They experience a situation where they only have a few hp left as being badly hurt, and could not word conditions in that way. But for play purposes, having a clear number or condition is less ambiguous.
I'd limit reference to terms that the characters could use, like "bloodied" or "dying", or "badly hurt" and that and leave the DM to set the actual cutoff. Again this is up to each DM.